const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PostcardManager-tVdA-szj.js","assets/usePostcardZones-BbYD8RoC.js","assets/DirectMail-D8tSLTRJ.js"])))=>i.map(i=>d[i]); var ont=Object.defineProperty;var FSe=t=>{throw TypeError(t)};var lnt=(t,s,r)=>s in t?ont(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var _n=(t,s,r)=>lnt(t,typeof s!="symbol"?s+"":s,r),Eue=(t,s,r)=>s.has(t)||FSe("Cannot "+r);var us=(t,s,r)=>(Eue(t,s,"read from private field"),r?r.call(t):s.get(t)),qa=(t,s,r)=>s.has(t)?FSe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),$n=(t,s,r,n)=>(Eue(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),qi=(t,s,r)=>(Eue(t,s,"access private method"),r);var YO=(t,s,r,n)=>({set _(a){$n(t,s,a,r)},get _(){return us(t,s,n)}});function cnt(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 f0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function SDe(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 CDe={exports:{}},Lie={},MDe={exports:{}},lo={};/** * @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 nL=Symbol.for("react.element"),dnt=Symbol.for("react.portal"),unt=Symbol.for("react.fragment"),hnt=Symbol.for("react.strict_mode"),mnt=Symbol.for("react.profiler"),pnt=Symbol.for("react.provider"),fnt=Symbol.for("react.context"),gnt=Symbol.for("react.forward_ref"),xnt=Symbol.for("react.suspense"),ynt=Symbol.for("react.memo"),vnt=Symbol.for("react.lazy"),zSe=Symbol.iterator;function _nt(t){return t===null||typeof t!="object"?null:(t=zSe&&t[zSe]||t["@@iterator"],typeof t=="function"?t:null)}var TDe={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ADe=Object.assign,EDe={};function eM(t,s,r){this.props=t,this.context=s,this.refs=EDe,this.updater=r||TDe}eM.prototype.isReactComponent={};eM.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")};eM.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function PDe(){}PDe.prototype=eM.prototype;function Y0e(t,s,r){this.props=t,this.context=s,this.refs=EDe,this.updater=r||TDe}var X0e=Y0e.prototype=new PDe;X0e.constructor=Y0e;ADe(X0e,eM.prototype);X0e.isPureReactComponent=!0;var BSe=Array.isArray,IDe=Object.prototype.hasOwnProperty,Q0e={current:null},LDe={key:!0,ref:!0,__self:!0,__source:!0};function DDe(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)IDe.call(s,n)&&!LDe.hasOwnProperty(n)&&(a[n]=s[n]);var i=arguments.length-2;if(i===1)a.children=r;else if(1>>1,we=le[ye];if(0>>1;yea(_e,be))Cea(Te,_e)?(le[ye]=Te,le[Ce]=be,ye=Ce):(le[ye]=_e,le[Ze]=be,ye=Ze);else if(Cea(Te,be))le[ye]=Te,le[Ce]=be,ye=Ce;else break e}}return pe}function a(le,pe){var be=le.sortIndex-pe.sortIndex;return be!==0?be:le.id-pe.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var l=Date,i=l.now();t.unstable_now=function(){return l.now()-i}}var d=[],u=[],p=1,f=null,v=3,_=!1,b=!1,j=!1,w=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function A(le){for(var pe=r(u);pe!==null;){if(pe.callback===null)n(u);else if(pe.startTime<=le)n(u),pe.sortIndex=pe.expirationTime,s(d,pe);else break;pe=r(u)}}function I(le){if(j=!1,A(le),!b)if(r(d)!==null)b=!0,ie(L);else{var pe=r(u);pe!==null&&ae(I,pe.startTime-le)}}function L(le,pe){b=!1,j&&(j=!1,N(q),q=-1),_=!0;var be=v;try{for(A(pe),f=r(d);f!==null&&(!(f.expirationTime>pe)||le&&!X());){var ye=f.callback;if(typeof ye=="function"){f.callback=null,v=f.priorityLevel;var we=ye(f.expirationTime<=pe);pe=t.unstable_now(),typeof we=="function"?f.callback=we:f===r(d)&&n(d),A(pe)}else n(d);f=r(d)}if(f!==null)var ke=!0;else{var Ze=r(u);Ze!==null&&ae(I,Ze.startTime-pe),ke=!1}return ke}finally{f=null,v=be,_=!1}}var R=!1,$=null,q=-1,U=5,V=-1;function X(){return!(t.unstable_now()-Vle||125ye?(le.sortIndex=be,s(u,le),r(d)===null&&le===r(u)&&(j?(N(q),q=-1):j=!0,ae(I,be-ye))):(le.sortIndex=we,s(d,le),b||_||(b=!0,ie(L))),le},t.unstable_shouldYield=X,t.unstable_wrapCallback=function(le){var pe=v;return function(){var be=v;v=pe;try{return le.apply(this,arguments)}finally{v=be}}}})(BDe);zDe.exports=BDe;var Ent=zDe.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 Pnt=S,_p=Ent;function Gr(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"),Ope=Object.prototype.hasOwnProperty,Int=/^[: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]*$/,qSe={},USe={};function Lnt(t){return Ope.call(USe,t)?!0:Ope.call(qSe,t)?!1:Int.test(t)?USe[t]=!0:(qSe[t]=!0,!1)}function Dnt(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 Ont(t,s,r,n){if(s===null||typeof s>"u"||Dnt(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 Xh(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 $u={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){$u[t]=new Xh(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];$u[s]=new Xh(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){$u[t]=new Xh(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){$u[t]=new Xh(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){$u[t]=new Xh(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){$u[t]=new Xh(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){$u[t]=new Xh(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){$u[t]=new Xh(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){$u[t]=new Xh(t,5,!1,t.toLowerCase(),null,!1,!1)});var tve=/[\-:]([a-z])/g;function sve(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(tve,sve);$u[s]=new Xh(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(tve,sve);$u[s]=new Xh(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(tve,sve);$u[s]=new Xh(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){$u[t]=new Xh(t,1,!1,t.toLowerCase(),null,!1,!1)});$u.xlinkHref=new Xh("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){$u[t]=new Xh(t,1,!1,t.toLowerCase(),null,!0,!0)});function rve(t,s,r,n){var a=$u.hasOwnProperty(s)?$u[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{Lue=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?_E(t):""}function Rnt(t){switch(t.tag){case 5:return _E(t.type);case 16:return _E("Lazy");case 13:return _E("Suspense");case 19:return _E("SuspenseList");case 0:case 2:case 15:return t=Due(t.type,!1),t;case 11:return t=Due(t.type.render,!1),t;case 1:return t=Due(t.type,!0),t;default:return""}}function Bpe(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 S4:return"Fragment";case N4:return"Portal";case Rpe:return"Profiler";case nve:return"StrictMode";case Fpe:return"Suspense";case zpe:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case UDe:return(t.displayName||"Context")+".Consumer";case qDe:return(t._context.displayName||"Context")+".Provider";case ave:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ive:return s=t.displayName||null,s!==null?s:Bpe(t.type)||"Memo";case a1:s=t._payload,t=t._init;try{return Bpe(t(s))}catch{}}return null}function Fnt(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 Bpe(s);case 8:return s===nve?"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 b_(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function HDe(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function znt(t){var s=HDe(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 JO(t){t._valueTracker||(t._valueTracker=znt(t))}function WDe(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return t&&(n=HDe(t)?t.checked?"true":"false":t.value),t=n,t!==r?(s.setValue(t),!0):!1}function kre(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 $pe(t,s){var r=s.checked;return Mc({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function HSe(t,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.checked!=null?s.checked:s.defaultChecked;r=b_(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 GDe(t,s){s=s.checked,s!=null&&rve(t,"checked",s,!1)}function qpe(t,s){GDe(t,s);var r=b_(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")?Upe(t,s.type,r):s.hasOwnProperty("defaultValue")&&Upe(t,s.type,b_(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function WSe(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 Upe(t,s,r){(s!=="number"||kre(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var bE=Array.isArray;function Z4(t,s,r,n){if(t=t.options,s){s={};for(var a=0;a"+s.valueOf().toString()+"",s=e8.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function bI(t,s){if(s){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=s;return}}t.textContent=s}var RE={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},Bnt=["Webkit","ms","Moz","O"];Object.keys(RE).forEach(function(t){Bnt.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),RE[s]=RE[t]})});function XDe(t,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||RE.hasOwnProperty(t)&&RE[t]?(""+s).trim():s+"px"}function QDe(t,s){t=t.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=XDe(r,s[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,a):t[r]=a}}var $nt=Mc({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 Wpe(t,s){if(s){if($nt[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Gr(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Gr(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Gr(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Gr(62))}}function Gpe(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 Kpe=null;function ove(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Zpe=null,Y4=null,X4=null;function ZSe(t){if(t=oL(t)){if(typeof Zpe!="function")throw Error(Gr(280));var s=t.stateNode;s&&(s=zie(s),Zpe(t.stateNode,t.type,s))}}function JDe(t){Y4?X4?X4.push(t):X4=[t]:Y4=t}function eOe(){if(Y4){var t=Y4,s=X4;if(X4=Y4=null,ZSe(t),s)for(t=0;t>>=0,t===0?32:31-(Qnt(t)/Jnt|0)|0}var t8=64,s8=4194304;function wE(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 Mre(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=wE(i):(o&=l,o!==0&&(n=wE(o)))}else l=r&~a,l!==0?n=wE(l):o!==0&&(n=wE(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 aL(t,s,r){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-Ig(s),t[s]=r}function rat(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=zE),nCe=" ",aCe=!1;function _Oe(t,s){switch(t){case"keyup":return Eat.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function bOe(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var C4=!1;function Iat(t,s){switch(t){case"compositionend":return bOe(s);case"keypress":return s.which!==32?null:(aCe=!0,nCe);case"textInput":return t=s.data,t===nCe&&aCe?null:t;default:return null}}function Lat(t,s){if(C4)return t==="compositionend"||!fve&&_Oe(t,s)?(t=yOe(),DR=hve=I1=null,C4=!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=cCe(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 SOe(){for(var t=window,s=kre();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=kre(t.document)}return s}function gve(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 Uat(t){var s=SOe(),r=t.focusedElem,n=t.selectionRange;if(s!==r&&r&&r.ownerDocument&&NOe(r.ownerDocument.documentElement,r)){if(n!==null&&gve(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=dCe(r,o);var l=dCe(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,M4=null,tfe=null,$E=null,sfe=!1;function uCe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;sfe||M4==null||M4!==kre(n)||(n=M4,"selectionStart"in n&&gve(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}),$E&&CI($E,n)||($E=n,n=Ere(tfe,"onSelect"),0E4||(t.current=lfe[E4],lfe[E4]=null,E4--)}function Al(t,s){E4++,lfe[E4]=t.current,t.current=s}var w_={},nh=D_(w_),Cm=D_(!1),bN=w_;function t3(t,s){var r=t.type.contextTypes;if(!r)return w_;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 Mm(t){return t=t.childContextTypes,t!=null}function Ire(){sc(Cm),sc(nh)}function yCe(t,s,r){if(nh.current!==w_)throw Error(Gr(168));Al(nh,s),Al(Cm,r)}function DOe(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(Gr(108,Fnt(t)||"Unknown",a));return Mc({},r,n)}function Lre(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||w_,bN=nh.current,Al(nh,t),Al(Cm,Cm.current),!0}function vCe(t,s,r){var n=t.stateNode;if(!n)throw Error(Gr(169));r?(t=DOe(t,s,bN),n.__reactInternalMemoizedMergedChildContext=t,sc(Cm),sc(nh),Al(nh,t)):sc(Cm),Al(Cm,r)}var a0=null,Bie=!1,Zue=!1;function OOe(t){a0===null?a0=[t]:a0.push(t)}function tit(t){Bie=!0,OOe(t)}function O_(){if(!Zue&&a0!==null){Zue=!0;var t=0,s=sl;try{var r=a0;for(sl=1;t>=l,a-=l,g0=1<<32-Ig(s)+a|r<q?(U=$,$=null):U=$.sibling;var V=v(N,$,A[q],I);if(V===null){$===null&&($=U);break}t&&$&&V.alternate===null&&s(N,$),C=o(V,C,q),R===null?L=V:R.sibling=V,R=V,$=U}if(q===A.length)return r(N,$),pc&&ew(N,q),L;if($===null){for(;qq?(U=$,$=null):U=$.sibling;var X=v(N,$,V.value,I);if(X===null){$===null&&($=U);break}t&&$&&X.alternate===null&&s(N,$),C=o(X,C,q),R===null?L=X:R.sibling=X,R=X,$=U}if(V.done)return r(N,$),pc&&ew(N,q),L;if($===null){for(;!V.done;q++,V=A.next())V=f(N,V.value,I),V!==null&&(C=o(V,C,q),R===null?L=V:R.sibling=V,R=V);return pc&&ew(N,q),L}for($=n(N,$);!V.done;q++,V=A.next())V=_($,N,q,V.value,I),V!==null&&(t&&V.alternate!==null&&$.delete(V.key===null?q:V.key),C=o(V,C,q),R===null?L=V:R.sibling=V,R=V);return t&&$.forEach(function(se){return s(N,se)}),pc&&ew(N,q),L}function w(N,C,A,I){if(typeof A=="object"&&A!==null&&A.type===S4&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case QO:e:{for(var L=A.key,R=C;R!==null;){if(R.key===L){if(L=A.type,L===S4){if(R.tag===7){r(N,R.sibling),C=a(R,A.props.children),C.return=N,N=C;break e}}else if(R.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===a1&&wCe(L)===R.type){r(N,R.sibling),C=a(R,A.props),C.ref=qA(N,R,A),C.return=N,N=C;break e}r(N,R);break}else s(N,R);R=R.sibling}A.type===S4?(C=Xk(A.props.children,N.mode,I,A.key),C.return=N,N=C):(I=UR(A.type,A.key,A.props,null,N.mode,I),I.ref=qA(N,C,A),I.return=N,N=I)}return l(N);case N4:e:{for(R=A.key;C!==null;){if(C.key===R)if(C.tag===4&&C.stateNode.containerInfo===A.containerInfo&&C.stateNode.implementation===A.implementation){r(N,C.sibling),C=a(C,A.children||[]),C.return=N,N=C;break e}else{r(N,C);break}else s(N,C);C=C.sibling}C=rhe(A,N.mode,I),C.return=N,N=C}return l(N);case a1:return R=A._init,w(N,C,R(A._payload),I)}if(bE(A))return b(N,C,A,I);if(RA(A))return j(N,C,A,I);c8(N,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,C!==null&&C.tag===6?(r(N,C.sibling),C=a(C,A),C.return=N,N=C):(r(N,C),C=she(A,N.mode,I),C.return=N,N=C),l(N)):r(N,C)}return w}var r3=BOe(!0),$Oe=BOe(!1),Rre=D_(null),Fre=null,L4=null,_ve=null;function bve(){_ve=L4=Fre=null}function wve(t){var s=Rre.current;sc(Rre),t._currentValue=s}function ufe(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 J4(t,s){Fre=t,_ve=L4=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(bm=!0),t.firstContext=null)}function _f(t){var s=t._currentValue;if(_ve!==t)if(t={context:t,memoizedValue:s,next:null},L4===null){if(Fre===null)throw Error(Gr(308));L4=t,Fre.dependencies={lanes:0,firstContext:t}}else L4=L4.next=t;return s}var kk=null;function jve(t){kk===null?kk=[t]:kk.push(t)}function qOe(t,s,r,n){var a=s.interleaved;return a===null?(r.next=r,jve(s)):(r.next=a.next,a.next=r),s.interleaved=r,H0(t,n)}function H0(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 i1=!1;function kve(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function UOe(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 j0(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function G1(t,s,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,No&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,H0(t,r)}return a=n.interleaved,a===null?(s.next=s,jve(n)):(s.next=a.next,a.next=s),n.interleaved=s,H0(t,r)}function RR(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,cve(t,r)}}function jCe(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 zre(t,s,r,n){var a=t.updateQueue;i1=!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 p=t.alternate;p!==null&&(p=p.updateQueue,i=p.lastBaseUpdate,i!==l&&(i===null?p.firstBaseUpdate=u:i.next=u,p.lastBaseUpdate=d))}if(o!==null){var f=a.baseState;l=0,p=u=d=null,i=o;do{var v=i.lane,_=i.eventTime;if((n&v)===v){p!==null&&(p=p.next={eventTime:_,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var b=t,j=i;switch(v=s,_=r,j.tag){case 1:if(b=j.payload,typeof b=="function"){f=b.call(_,f,v);break e}f=b;break e;case 3:b.flags=b.flags&-65537|128;case 0:if(b=j.payload,v=typeof b=="function"?b.call(_,f,v):b,v==null)break e;f=Mc({},f,v);break e;case 2:i1=!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},p===null?(u=p=_,d=f):p=p.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(p===null&&(d=f),a.baseState=d,a.firstBaseUpdate=u,a.lastBaseUpdate=p,s=a.shared.interleaved,s!==null){a=s;do l|=a.lane,a=a.next;while(a!==s)}else o===null&&(a.shared.lanes=0);kN|=l,t.lanes=l,t.memoizedState=f}}function kCe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=Xue.transition;Xue.transition={};try{t(!1),s()}finally{sl=r,Xue.transition=n}}function i8e(){return bf().memoizedState}function ait(t,s,r){var n=Z1(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},o8e(t))l8e(s,r);else if(r=qOe(t,s,r,n),r!==null){var a=zh();Lg(r,t,n,a),c8e(r,s,n)}}function iit(t,s,r){var n=Z1(t),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(o8e(t))l8e(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,Vg(i,l)){var d=s.interleaved;d===null?(a.next=a,jve(s)):(a.next=d.next,d.next=a),s.interleaved=a;return}}catch{}finally{}r=qOe(t,s,a,n),r!==null&&(a=zh(),Lg(r,t,n,a),c8e(r,s,n))}}function o8e(t){var s=t.alternate;return t===Sc||s!==null&&s===Sc}function l8e(t,s){qE=$re=!0;var r=t.pending;r===null?s.next=s:(s.next=r.next,r.next=s),t.pending=s}function c8e(t,s,r){if(r&4194240){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,cve(t,r)}}var qre={readContext:_f,useCallback:Wu,useContext:Wu,useEffect:Wu,useImperativeHandle:Wu,useInsertionEffect:Wu,useLayoutEffect:Wu,useMemo:Wu,useReducer:Wu,useRef:Wu,useState:Wu,useDebugValue:Wu,useDeferredValue:Wu,useTransition:Wu,useMutableSource:Wu,useSyncExternalStore:Wu,useId:Wu,unstable_isNewReconciler:!1},oit={readContext:_f,useCallback:function(t,s){return kx().memoizedState=[t,s===void 0?null:s],t},useContext:_f,useEffect:SCe,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,zR(4194308,4,t8e.bind(null,s,t),r)},useLayoutEffect:function(t,s){return zR(4194308,4,t,s)},useInsertionEffect:function(t,s){return zR(4,2,t,s)},useMemo:function(t,s){var r=kx();return s=s===void 0?null:s,t=t(),r.memoizedState=[t,s],t},useReducer:function(t,s,r){var n=kx();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=ait.bind(null,Sc,t),[n.memoizedState,t]},useRef:function(t){var s=kx();return t={current:t},s.memoizedState=t},useState:NCe,useDebugValue:Pve,useDeferredValue:function(t){return kx().memoizedState=t},useTransition:function(){var t=NCe(!1),s=t[0];return t=nit.bind(null,t[1]),kx().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,r){var n=Sc,a=kx();if(pc){if(r===void 0)throw Error(Gr(407));r=r()}else{if(r=s(),mu===null)throw Error(Gr(349));jN&30||GOe(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,SCe(ZOe.bind(null,n,o,t),[t]),n.flags|=2048,DI(9,KOe.bind(null,n,o,r,s),void 0,null),r},useId:function(){var t=kx(),s=mu.identifierPrefix;if(pc){var r=x0,n=g0;r=(n&~(1<<32-Ig(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=II++,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[Dx]=s,t[AI]=n,v8e(t,s,!1,!1),s.stateNode=t;e:{switch(l=Gpe(r,n),r){case"dialog":Yl("cancel",t),Yl("close",t),a=n;break;case"iframe":case"object":case"embed":Yl("load",t),a=n;break;case"video":case"audio":for(a=0;ai3&&(s.flags|=128,n=!0,UA(o,!1),s.lanes=4194304)}else{if(!n)if(t=Bre(l),t!==null){if(s.flags|=128,n=!0,r=t.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),UA(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!pc)return Gu(s),null}else 2*rd()-o.renderingStartTime>i3&&r!==1073741824&&(s.flags|=128,n=!0,UA(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=rd(),s.sibling=null,r=jc.current,Al(jc,n?r&1|2:r&1),s):(Gu(s),null);case 22:case 23:return Fve(),n=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?tp&1073741824&&(Gu(s),s.subtreeFlags&6&&(s.flags|=8192)):Gu(s),null;case 24:return null;case 25:return null}throw Error(Gr(156,s.tag))}function fit(t,s){switch(yve(s),s.tag){case 1:return Mm(s.type)&&Ire(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return n3(),sc(Cm),sc(nh),Cve(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return Sve(s),null;case 13:if(sc(jc),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Gr(340));s3()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return sc(jc),null;case 4:return n3(),null;case 10:return wve(s.type._context),null;case 22:case 23:return Fve(),null;case 24:return null;default:return null}}var u8=!1,Xu=!1,git=typeof WeakSet=="function"?WeakSet:Set,Yn=null;function D4(t,s){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){Fc(t,s,n)}else r.current=null}function _fe(t,s,r){try{r()}catch(n){Fc(t,s,n)}}var RCe=!1;function xit(t,s){if(rfe=Tre,t=SOe(),gve(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,p=0,f=t,v=null;t:for(;;){for(var _;f!==r||a!==0&&f.nodeType!==3||(i=l+a),f!==o||n!==0&&f.nodeType!==3||(d=l+n),f.nodeType===3&&(l+=f.nodeValue.length),(_=f.firstChild)!==null;)v=f,f=_;for(;;){if(f===t)break t;if(v===r&&++u===a&&(i=l),v===o&&++p===n&&(d=l),(_=f.nextSibling)!==null)break;f=v,v=f.parentNode}f=_}r=i===-1||d===-1?null:{start:i,end:d}}else r=null}r=r||{start:0,end:0}}else r=null;for(nfe={focusedElem:t,selectionRange:r},Tre=!1,Yn=s;Yn!==null;)if(s=Yn,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,Yn=t;else for(;Yn!==null;){s=Yn;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 j=b.memoizedProps,w=b.memoizedState,N=s.stateNode,C=N.getSnapshotBeforeUpdate(s.elementType===s.type?j:gg(s.type,j),w);N.__reactInternalSnapshotBeforeUpdate=C}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(Gr(163))}}catch(I){Fc(s,s.return,I)}if(t=s.sibling,t!==null){t.return=s.return,Yn=t;break}Yn=s.return}return b=RCe,RCe=!1,b}function UE(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&&_fe(s,r,o)}a=a.next}while(a!==n)}}function Uie(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 bfe(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 w8e(t){var s=t.alternate;s!==null&&(t.alternate=null,w8e(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[Dx],delete s[AI],delete s[ofe],delete s[Jat],delete s[eit])),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 j8e(t){return t.tag===5||t.tag===3||t.tag===4}function FCe(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||j8e(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 wfe(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=Pre));else if(n!==4&&(t=t.child,t!==null))for(wfe(t,s,r),t=t.sibling;t!==null;)wfe(t,s,r),t=t.sibling}function jfe(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(jfe(t,s,r),t=t.sibling;t!==null;)jfe(t,s,r),t=t.sibling}var Tu=null,_g=!1;function Hv(t,s,r){for(r=r.child;r!==null;)k8e(t,s,r),r=r.sibling}function k8e(t,s,r){if(qx&&typeof qx.onCommitFiberUnmount=="function")try{qx.onCommitFiberUnmount(Die,r)}catch{}switch(r.tag){case 5:Xu||D4(r,s);case 6:var n=Tu,a=_g;Tu=null,Hv(t,s,r),Tu=n,_g=a,Tu!==null&&(_g?(t=Tu,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):Tu.removeChild(r.stateNode));break;case 18:Tu!==null&&(_g?(t=Tu,r=r.stateNode,t.nodeType===8?Kue(t.parentNode,r):t.nodeType===1&&Kue(t,r),NI(t)):Kue(Tu,r.stateNode));break;case 4:n=Tu,a=_g,Tu=r.stateNode.containerInfo,_g=!0,Hv(t,s,r),Tu=n,_g=a;break;case 0:case 11:case 14:case 15:if(!Xu&&(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)&&_fe(r,s,l),a=a.next}while(a!==n)}Hv(t,s,r);break;case 1:if(!Xu&&(D4(r,s),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(i){Fc(r,s,i)}Hv(t,s,r);break;case 21:Hv(t,s,r);break;case 22:r.mode&1?(Xu=(n=Xu)||r.memoizedState!==null,Hv(t,s,r),Xu=n):Hv(t,s,r);break;default:Hv(t,s,r)}}function zCe(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new git),s.forEach(function(n){var a=Sit.bind(null,t,n);r.has(n)||(r.add(n),n.then(a,a))})}}function og(t,s){var r=s.deletions;if(r!==null)for(var n=0;na&&(a=l),n&=~o}if(n=a,n=rd()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*vit(n/1960))-n,10t?16:t,L1===null)var n=!1;else{if(t=L1,L1=null,Hre=0,No&6)throw Error(Gr(331));var a=No;for(No|=4,Yn=t.current;Yn!==null;){var o=Yn,l=o.child;if(Yn.flags&16){var i=o.deletions;if(i!==null){for(var d=0;drd()-Ove?Yk(t,0):Dve|=r),Tm(t,s)}function P8e(t,s){s===0&&(t.mode&1?(s=s8,s8<<=1,!(s8&130023424)&&(s8=4194304)):s=1);var r=zh();t=H0(t,s),t!==null&&(aL(t,s,r),Tm(t,r))}function Nit(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),P8e(t,r)}function Sit(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(Gr(314))}n!==null&&n.delete(s),P8e(t,r)}var I8e;I8e=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||Cm.current)bm=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return bm=!1,mit(t,s,r);bm=!!(t.flags&131072)}else bm=!1,pc&&s.flags&1048576&&ROe(s,Ore,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;BR(t,s),t=s.pendingProps;var a=t3(s,nh.current);J4(s,r),a=Tve(null,s,n,t,a,r);var o=Ave();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,Mm(n)?(o=!0,Lre(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,kve(s),a.updater=qie,s.stateNode=a,a._reactInternals=s,mfe(s,n,t,r),s=gfe(null,s,n,!0,o,r)):(s.tag=0,pc&&o&&xve(s),Sh(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(BR(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=Mit(n),t=gg(n,t),a){case 0:s=ffe(null,s,n,t,r);break e;case 1:s=LCe(null,s,n,t,r);break e;case 11:s=PCe(null,s,n,t,r);break e;case 14:s=ICe(null,s,n,gg(n.type,t),r);break e}throw Error(Gr(306,n,""))}return s;case 0:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:gg(n,a),ffe(t,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:gg(n,a),LCe(t,s,n,a,r);case 3:e:{if(g8e(s),t===null)throw Error(Gr(387));n=s.pendingProps,o=s.memoizedState,a=o.element,UOe(t,s),zre(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=a3(Error(Gr(423)),s),s=DCe(t,s,n,r,a);break e}else if(n!==a){a=a3(Error(Gr(424)),s),s=DCe(t,s,n,r,a);break e}else for(dp=W1(s.stateNode.containerInfo.firstChild),hp=s,pc=!0,Ng=null,r=$Oe(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(s3(),n===a){s=W0(t,s,r);break e}Sh(t,s,n,r)}s=s.child}return s;case 5:return VOe(s),t===null&&dfe(s),n=s.type,a=s.pendingProps,o=t!==null?t.memoizedProps:null,l=a.children,afe(n,a)?l=null:o!==null&&afe(n,o)&&(s.flags|=32),f8e(t,s),Sh(t,s,l,r),s.child;case 6:return t===null&&dfe(s),null;case 13:return x8e(t,s,r);case 4:return Nve(s,s.stateNode.containerInfo),n=s.pendingProps,t===null?s.child=r3(s,null,n,r):Sh(t,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:gg(n,a),PCe(t,s,n,a,r);case 7:return Sh(t,s,s.pendingProps,r),s.child;case 8:return Sh(t,s,s.pendingProps.children,r),s.child;case 12:return Sh(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,Al(Rre,n._currentValue),n._currentValue=l,o!==null)if(Vg(o.value,l)){if(o.children===a.children&&!Cm.current){s=W0(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=j0(-1,r&-r),d.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?d.next=d:(d.next=p.next,p.next=d),u.pending=d}}o.lanes|=r,d=o.alternate,d!==null&&(d.lanes|=r),ufe(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(Gr(341));l.lanes|=r,i=l.alternate,i!==null&&(i.lanes|=r),ufe(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}Sh(t,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,J4(s,r),a=_f(a),n=n(a),s.flags|=1,Sh(t,s,n,r),s.child;case 14:return n=s.type,a=gg(n,s.pendingProps),a=gg(n.type,a),ICe(t,s,n,a,r);case 15:return m8e(t,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:gg(n,a),BR(t,s),s.tag=1,Mm(n)?(t=!0,Lre(s)):t=!1,J4(s,r),d8e(s,n,a),mfe(s,n,a,r),gfe(null,s,n,!0,t,r);case 19:return y8e(t,s,r);case 22:return p8e(t,s,r)}throw Error(Gr(156,s.tag))};function L8e(t,s){return oOe(t,s)}function Cit(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 nf(t,s,r,n){return new Cit(t,s,r,n)}function Bve(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Mit(t){if(typeof t=="function")return Bve(t)?1:0;if(t!=null){if(t=t.$$typeof,t===ave)return 11;if(t===ive)return 14}return 2}function Y1(t,s){var r=t.alternate;return r===null?(r=nf(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 UR(t,s,r,n,a,o){var l=2;if(n=t,typeof t=="function")Bve(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case S4:return Xk(r.children,a,o,s);case nve:l=8,a|=8;break;case Rpe:return t=nf(12,r,s,a|2),t.elementType=Rpe,t.lanes=o,t;case Fpe:return t=nf(13,r,s,a),t.elementType=Fpe,t.lanes=o,t;case zpe:return t=nf(19,r,s,a),t.elementType=zpe,t.lanes=o,t;case VDe:return Hie(r,a,o,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case qDe:l=10;break e;case UDe:l=9;break e;case ave:l=11;break e;case ive:l=14;break e;case a1:l=16,n=null;break e}throw Error(Gr(130,t==null?t:typeof t,""))}return s=nf(l,r,s,a),s.elementType=t,s.type=n,s.lanes=o,s}function Xk(t,s,r,n){return t=nf(7,t,n,s),t.lanes=r,t}function Hie(t,s,r,n){return t=nf(22,t,n,s),t.elementType=VDe,t.lanes=r,t.stateNode={isHidden:!1},t}function she(t,s,r){return t=nf(6,t,null,s),t.lanes=r,t}function rhe(t,s,r){return s=nf(4,t.children!==null?t.children:[],t.key,s),s.lanes=r,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function Tit(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=Rue(0),this.expirationTimes=Rue(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Rue(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function $ve(t,s,r,n,a,o,l,i,d){return t=new Tit(t,s,r,i,d),s===1?(s=1,o===!0&&(s|=8)):s=0,o=nf(3,null,null,s),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},kve(o),t}function Ait(t,s,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(F8e)}catch(t){console.error(t)}}F8e(),FDe.exports=wp;var wm=FDe.exports;const Hve=_o(wm);var z8e,GCe=wm;z8e=GCe.createRoot,GCe.hydrateRoot;const Dit="modulepreload",Oit=function(t){return"/"+t},KCe={},dy=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=Oit(d),d in KCe)return;KCe[d]=!0;const u=d.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":Dit,u||(f.as="script"),f.crossOrigin="",f.href=d,i&&f.setAttribute("nonce",i),document.head.appendChild(f),u)return new Promise((v,_)=>{f.addEventListener("load",v),f.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)})},Rit=1,Fit=1e6;let nhe=0;function zit(){return nhe=(nhe+1)%Number.MAX_SAFE_INTEGER,nhe.toString()}const ahe=new Map,ZCe=t=>{if(ahe.has(t))return;const s=setTimeout(()=>{ahe.delete(t),WE({type:"REMOVE_TOAST",toastId:t})},Fit);ahe.set(t,s)},Bit=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,Rit)};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?ZCe(r):t.toasts.forEach(n=>{ZCe(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)}}},VR=[];let HR={toasts:[]};function WE(t){HR=Bit(HR,t),VR.forEach(s=>{s(HR)})}function an({...t}){const s=zit(),r=a=>WE({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>WE({type:"DISMISS_TOAST",toastId:s});return WE({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function Ia(){const[t,s]=S.useState(HR);return S.useEffect(()=>(VR.push(s),()=>{const r=VR.indexOf(s);r>-1&&VR.splice(r,1)}),[t]),{...t,toast:an,dismiss:r=>WE({type:"DISMISS_TOAST",toastId:r})}}function Cr(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 YCe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function G0(...t){return s=>{let r=!1;const n=t.map(a=>{const o=YCe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{children:l,...i}=o,d=S.useMemo(()=>i,Object.values(i));return e.jsx(r.Provider,{value:d,children:l})};n.displayName=t+"Provider";function a(o){const l=S.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 Ac(t,s=[]){let r=[];function n(o,l){const i=S.createContext(l),d=r.length;r=[...r,l];const u=f=>{var N;const{scope:v,children:_,...b}=f,j=((N=v==null?void 0:v[t])==null?void 0:N[d])||i,w=S.useMemo(()=>b,Object.values(b));return e.jsx(j.Provider,{value:w,children:_})};u.displayName=o+"Provider";function p(f,v){var j;const _=((j=v==null?void 0:v[t])==null?void 0:j[d])||i,b=S.useContext(_);if(b)return b;if(l!==void 0)return l;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[u,p]}const a=()=>{const o=r.map(l=>S.createContext(l));return function(i){const d=(i==null?void 0:i[t])||o;return S.useMemo(()=>({[`__scope${t}`]:{...i,[t]:d}}),[i,d])}};return a.scopeName=t,[n,qit(a,...s)]}function qit(...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 f=d(o)[`__scope${u}`];return{...i,...f}},{});return S.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}function j_(t){const s=Uit(t),r=S.forwardRef((n,a)=>{const{children:o,...l}=n,i=S.Children.toArray(o),d=i.find(Vit);if(d){const u=d.props.children,p=i.map(f=>f===d?S.Children.count(u)>1?S.Children.only(null):S.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:S.isValidElement(u)?S.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}var Wve=j_("Slot");function Uit(t){const s=S.forwardRef((r,n)=>{const{children:a,...o}=r;if(S.isValidElement(a)){const l=Wit(a),i=Hit(o,a.props);return a.type!==S.Fragment&&(i.ref=n?G0(n,l):l),S.cloneElement(a,i)}return S.Children.count(a)>1?S.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var B8e=Symbol("radix.slottable");function $8e(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=B8e,s}function Vit(t){return S.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===B8e}function Hit(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 Wit(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 cL(t){const s=t+"CollectionProvider",[r,n]=Ac(s),[a,o]=r(s,{collectionRef:{current:null},itemMap:new Map}),l=j=>{const{scope:w,children:N}=j,C=mt.useRef(null),A=mt.useRef(new Map).current;return e.jsx(a,{scope:w,itemMap:A,collectionRef:C,children:N})};l.displayName=s;const i=t+"CollectionSlot",d=j_(i),u=mt.forwardRef((j,w)=>{const{scope:N,children:C}=j,A=o(i,N),I=Pa(w,A.collectionRef);return e.jsx(d,{ref:I,children:C})});u.displayName=i;const p=t+"CollectionItemSlot",f="data-radix-collection-item",v=j_(p),_=mt.forwardRef((j,w)=>{const{scope:N,children:C,...A}=j,I=mt.useRef(null),L=Pa(w,I),R=o(p,N);return mt.useEffect(()=>(R.itemMap.set(I,{ref:I,...A}),()=>void R.itemMap.delete(I))),e.jsx(v,{[f]:"",ref:L,children:C})});_.displayName=p;function b(j){const w=o(t+"CollectionConsumer",j);return mt.useCallback(()=>{const C=w.collectionRef.current;if(!C)return[];const A=Array.from(C.querySelectorAll(`[${f}]`));return Array.from(w.itemMap.values()).sort((R,$)=>A.indexOf(R.ref.current)-A.indexOf($.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:l,Slot:u,ItemSlot:_},b,n]}var Git=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Qr=Git.reduce((t,s)=>{const r=j_(`Primitive.${s}`),n=S.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 Gve(t,s){t&&wm.flushSync(()=>t.dispatchEvent(s))}function Vc(t){const s=S.useRef(t);return S.useEffect(()=>{s.current=t}),S.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}function Kit(t,s=globalThis==null?void 0:globalThis.document){const r=Vc(t);S.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 Zit="DismissableLayer",Mfe="dismissableLayer.update",Yit="dismissableLayer.pointerDownOutside",Xit="dismissableLayer.focusOutside",XCe,q8e=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),R_=S.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...d}=t,u=S.useContext(q8e),[p,f]=S.useState(null),v=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,_]=S.useState({}),b=Pa(s,$=>f($)),j=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),N=j.indexOf(w),C=p?j.indexOf(p):-1,A=u.layersWithOutsidePointerEventsDisabled.size>0,I=C>=N,L=Jit($=>{const q=$.target,U=[...u.branches].some(V=>V.contains(q));!I||U||(a==null||a($),l==null||l($),$.defaultPrevented||i==null||i())},v),R=eot($=>{const q=$.target;[...u.branches].some(V=>V.contains(q))||(o==null||o($),l==null||l($),$.defaultPrevented||i==null||i())},v);return Kit($=>{C===u.layers.size-1&&(n==null||n($),!$.defaultPrevented&&i&&($.preventDefault(),i()))},v),S.useEffect(()=>{if(p)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(XCe=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),QCe(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=XCe)}},[p,v,r,u]),S.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),QCe())},[p,u]),S.useEffect(()=>{const $=()=>_({});return document.addEventListener(Mfe,$),()=>document.removeEventListener(Mfe,$)},[]),e.jsx(Qr.div,{...d,ref:b,style:{pointerEvents:A?I?"auto":"none":void 0,...t.style},onFocusCapture:Cr(t.onFocusCapture,R.onFocusCapture),onBlurCapture:Cr(t.onBlurCapture,R.onBlurCapture),onPointerDownCapture:Cr(t.onPointerDownCapture,L.onPointerDownCapture)})});R_.displayName=Zit;var Qit="DismissableLayerBranch",U8e=S.forwardRef((t,s)=>{const r=S.useContext(q8e),n=S.useRef(null),a=Pa(s,n);return S.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})});U8e.displayName=Qit;function Jit(t,s=globalThis==null?void 0:globalThis.document){const r=Vc(t),n=S.useRef(!1),a=S.useRef(()=>{});return S.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let d=function(){V8e(Yit,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 eot(t,s=globalThis==null?void 0:globalThis.document){const r=Vc(t),n=S.useRef(!1);return S.useEffect(()=>{const a=o=>{o.target&&!n.current&&V8e(Xit,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 QCe(){const t=new CustomEvent(Mfe);document.dispatchEvent(t)}function V8e(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?Gve(a,o):a.dispatchEvent(o)}var tot=R_,sot=U8e,Zc=globalThis!=null&&globalThis.document?S.useLayoutEffect:()=>{},rot="Portal",rM=S.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=S.useState(!1);Zc(()=>o(!0),[]);const l=r||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?Hve.createPortal(e.jsx(Qr.div,{...n,ref:s}),l):null});rM.displayName=rot;function not(t,s){return S.useReducer((r,n)=>s[r][n]??r,t)}var hd=t=>{const{present:s,children:r}=t,n=aot(s),a=typeof r=="function"?r({present:n.isPresent}):S.Children.only(r),o=Pa(n.ref,iot(a));return typeof r=="function"||n.isPresent?S.cloneElement(a,{ref:o}):null};hd.displayName="Presence";function aot(t){const[s,r]=S.useState(),n=S.useRef(null),a=S.useRef(t),o=S.useRef("none"),l=t?"mounted":"unmounted",[i,d]=not(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return S.useEffect(()=>{const u=p8(n.current);o.current=i==="mounted"?u:"none"},[i]),Zc(()=>{const u=n.current,p=a.current;if(p!==t){const v=o.current,_=p8(u);t?d("MOUNT"):_==="none"||(u==null?void 0:u.display)==="none"?d("UNMOUNT"):d(p&&v!==_?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,d]),Zc(()=>{if(s){let u;const p=s.ownerDocument.defaultView??window,f=_=>{const j=p8(n.current).includes(_.animationName);if(_.target===s&&j&&(d("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",u=p.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},v=_=>{_.target===s&&(o.current=p8(n.current))};return s.addEventListener("animationstart",v),s.addEventListener("animationcancel",f),s.addEventListener("animationend",f),()=>{p.clearTimeout(u),s.removeEventListener("animationstart",v),s.removeEventListener("animationcancel",f),s.removeEventListener("animationend",f)}}else d("ANIMATION_END")},[s,d]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:S.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function p8(t){return(t==null?void 0:t.animationName)||"none"}function iot(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 oot=eve[" useInsertionEffect ".trim().toString()]||Zc;function xu({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=lot({defaultProp:s,onChange:r}),i=t!==void 0,d=i?t:a;{const p=S.useRef(t!==void 0);S.useEffect(()=>{const f=p.current;f!==i&&console.warn(`${n} is changing from ${f?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=i},[i,n])}const u=S.useCallback(p=>{var f;if(i){const v=cot(p)?p(t):p;v!==t&&((f=l.current)==null||f.call(l,v))}else o(p)},[i,t,o,l]);return[d,u]}function lot({defaultProp:t,onChange:s}){const[r,n]=S.useState(t),a=S.useRef(r),o=S.useRef(s);return oot(()=>{o.current=s},[s]),S.useEffect(()=>{var l;a.current!==r&&((l=o.current)==null||l.call(o,r),a.current=r)},[r,a]),[r,n,o]}function cot(t){return typeof t=="function"}var H8e=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"}),dot="VisuallyHidden",Yie=S.forwardRef((t,s)=>e.jsx(Qr.span,{...t,ref:s,style:{...H8e,...t.style}}));Yie.displayName=dot;var uot=Yie,Kve="ToastProvider",[Zve,hot,mot]=cL("Toast"),[W8e]=Ac("Toast",[mot]),[pot,Xie]=W8e(Kve),G8e=t=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=t,[i,d]=S.useState(null),[u,p]=S.useState(0),f=S.useRef(!1),v=S.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${Kve}\`. Expected non-empty \`string\`.`),e.jsx(Zve.Provider,{scope:s,children:e.jsx(pot,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:i,onViewportChange:d,onToastAdd:S.useCallback(()=>p(_=>_+1),[]),onToastRemove:S.useCallback(()=>p(_=>_-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:v,children:l})})};G8e.displayName=Kve;var K8e="ToastViewport",fot=["F8"],Tfe="toast.viewportPause",Afe="toast.viewportResume",Z8e=S.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=fot,label:a="Notifications ({hotkey})",...o}=t,l=Xie(K8e,r),i=hot(r),d=S.useRef(null),u=S.useRef(null),p=S.useRef(null),f=S.useRef(null),v=Pa(s,f,l.onViewportChange),_=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),b=l.toastCount>0;S.useEffect(()=>{const w=N=>{var A;n.length!==0&&n.every(I=>N[I]||N.code===I)&&((A=f.current)==null||A.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[n]),S.useEffect(()=>{const w=d.current,N=f.current;if(b&&w&&N){const C=()=>{if(!l.isClosePausedRef.current){const R=new CustomEvent(Tfe);N.dispatchEvent(R),l.isClosePausedRef.current=!0}},A=()=>{if(l.isClosePausedRef.current){const R=new CustomEvent(Afe);N.dispatchEvent(R),l.isClosePausedRef.current=!1}},I=R=>{!w.contains(R.relatedTarget)&&A()},L=()=>{w.contains(document.activeElement)||A()};return w.addEventListener("focusin",C),w.addEventListener("focusout",I),w.addEventListener("pointermove",C),w.addEventListener("pointerleave",L),window.addEventListener("blur",C),window.addEventListener("focus",A),()=>{w.removeEventListener("focusin",C),w.removeEventListener("focusout",I),w.removeEventListener("pointermove",C),w.removeEventListener("pointerleave",L),window.removeEventListener("blur",C),window.removeEventListener("focus",A)}}},[b,l.isClosePausedRef]);const j=S.useCallback(({tabbingDirection:w})=>{const C=i().map(A=>{const I=A.ref.current,L=[I,...Mot(I)];return w==="forwards"?L:L.reverse()});return(w==="forwards"?C.reverse():C).flat()},[i]);return S.useEffect(()=>{const w=f.current;if(w){const N=C=>{var L,R,$;const A=C.altKey||C.ctrlKey||C.metaKey;if(C.key==="Tab"&&!A){const q=document.activeElement,U=C.shiftKey;if(C.target===w&&U){(L=u.current)==null||L.focus();return}const se=j({tabbingDirection:U?"backwards":"forwards"}),te=se.findIndex(Y=>Y===q);ihe(se.slice(te+1))?C.preventDefault():U?(R=u.current)==null||R.focus():($=p.current)==null||$.focus()}};return w.addEventListener("keydown",N),()=>w.removeEventListener("keydown",N)}},[i,j]),e.jsxs(sot,{ref:d,role:"region","aria-label":a.replace("{hotkey}",_),tabIndex:-1,style:{pointerEvents:b?void 0:"none"},children:[b&&e.jsx(Efe,{ref:u,onFocusFromOutsideViewport:()=>{const w=j({tabbingDirection:"forwards"});ihe(w)}}),e.jsx(Zve.Slot,{scope:r,children:e.jsx(Qr.ol,{tabIndex:-1,...o,ref:v})}),b&&e.jsx(Efe,{ref:p,onFocusFromOutsideViewport:()=>{const w=j({tabbingDirection:"backwards"});ihe(w)}})]})});Z8e.displayName=K8e;var Y8e="ToastFocusProxy",Efe=S.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=Xie(Y8e,r);return e.jsx(Yie,{"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()}})});Efe.displayName=Y8e;var dL="Toast",got="toast.swipeStart",xot="toast.swipeMove",yot="toast.swipeCancel",vot="toast.swipeEnd",X8e=S.forwardRef((t,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...l}=t,[i,d]=xu({prop:n,defaultProp:a??!0,onChange:o,caller:dL});return e.jsx(hd,{present:r||i,children:e.jsx(wot,{open:i,...l,ref:s,onClose:()=>d(!1),onPause:Vc(t.onPause),onResume:Vc(t.onResume),onSwipeStart:Cr(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Cr(t.onSwipeMove,u=>{const{x:p,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${p}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:Cr(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:Cr(t.onSwipeEnd,u=>{const{x:p,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${p}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),d(!1)})})})});X8e.displayName=dL;var[_ot,bot]=W8e(dL,{onClose(){}}),wot=S.forwardRef((t,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:o,onClose:l,onEscapeKeyDown:i,onPause:d,onResume:u,onSwipeStart:p,onSwipeMove:f,onSwipeCancel:v,onSwipeEnd:_,...b}=t,j=Xie(dL,r),[w,N]=S.useState(null),C=Pa(s,Y=>N(Y)),A=S.useRef(null),I=S.useRef(null),L=a||j.duration,R=S.useRef(0),$=S.useRef(L),q=S.useRef(0),{onToastAdd:U,onToastRemove:V}=j,X=Vc(()=>{var de;(w==null?void 0:w.contains(document.activeElement))&&((de=j.viewport)==null||de.focus()),l()}),se=S.useCallback(Y=>{!Y||Y===1/0||(window.clearTimeout(q.current),R.current=new Date().getTime(),q.current=window.setTimeout(X,Y))},[X]);S.useEffect(()=>{const Y=j.viewport;if(Y){const de=()=>{se($.current),u==null||u()},ie=()=>{const ae=new Date().getTime()-R.current;$.current=$.current-ae,window.clearTimeout(q.current),d==null||d()};return Y.addEventListener(Tfe,ie),Y.addEventListener(Afe,de),()=>{Y.removeEventListener(Tfe,ie),Y.removeEventListener(Afe,de)}}},[j.viewport,L,d,u,se]),S.useEffect(()=>{o&&!j.isClosePausedRef.current&&se(L)},[o,L,j.isClosePausedRef,se]),S.useEffect(()=>(U(),()=>V()),[U,V]);const te=S.useMemo(()=>w?nRe(w):null,[w]);return j.viewport?e.jsxs(e.Fragment,{children:[te&&e.jsx(jot,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:te}),e.jsx(_ot,{scope:r,onClose:X,children:wm.createPortal(e.jsx(Zve.ItemSlot,{scope:r,children:e.jsx(tot,{asChild:!0,onEscapeKeyDown:Cr(i,()=>{j.isFocusedToastEscapeKeyDownRef.current||X(),j.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":j.swipeDirection,...b,ref:C,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Cr(t.onKeyDown,Y=>{Y.key==="Escape"&&(i==null||i(Y.nativeEvent),Y.nativeEvent.defaultPrevented||(j.isFocusedToastEscapeKeyDownRef.current=!0,X()))}),onPointerDown:Cr(t.onPointerDown,Y=>{Y.button===0&&(A.current={x:Y.clientX,y:Y.clientY})}),onPointerMove:Cr(t.onPointerMove,Y=>{if(!A.current)return;const de=Y.clientX-A.current.x,ie=Y.clientY-A.current.y,ae=!!I.current,le=["left","right"].includes(j.swipeDirection),pe=["left","up"].includes(j.swipeDirection)?Math.min:Math.max,be=le?pe(0,de):0,ye=le?0:pe(0,ie),we=Y.pointerType==="touch"?10:2,ke={x:be,y:ye},Ze={originalEvent:Y,delta:ke};ae?(I.current=ke,f8(xot,f,Ze,{discrete:!1})):JCe(ke,j.swipeDirection,we)?(I.current=ke,f8(got,p,Ze,{discrete:!1}),Y.target.setPointerCapture(Y.pointerId)):(Math.abs(de)>we||Math.abs(ie)>we)&&(A.current=null)}),onPointerUp:Cr(t.onPointerUp,Y=>{const de=I.current,ie=Y.target;if(ie.hasPointerCapture(Y.pointerId)&&ie.releasePointerCapture(Y.pointerId),I.current=null,A.current=null,de){const ae=Y.currentTarget,le={originalEvent:Y,delta:de};JCe(de,j.swipeDirection,j.swipeThreshold)?f8(vot,_,le,{discrete:!0}):f8(yot,v,le,{discrete:!0}),ae.addEventListener("click",pe=>pe.preventDefault(),{once:!0})}})})})}),j.viewport)})]}):null}),jot=t=>{const{__scopeToast:s,children:r,...n}=t,a=Xie(dL,s),[o,l]=S.useState(!1),[i,d]=S.useState(!1);return Sot(()=>l(!0)),S.useEffect(()=>{const u=window.setTimeout(()=>d(!0),1e3);return()=>window.clearTimeout(u)},[]),i?null:e.jsx(rM,{asChild:!0,children:e.jsx(Yie,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},kot="ToastTitle",Q8e=S.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});Q8e.displayName=kot;var Not="ToastDescription",J8e=S.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});J8e.displayName=Not;var eRe="ToastAction",tRe=S.forwardRef((t,s)=>{const{altText:r,...n}=t;return r.trim()?e.jsx(rRe,{altText:r,asChild:!0,children:e.jsx(Yve,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${eRe}\`. Expected non-empty \`string\`.`),null)});tRe.displayName=eRe;var sRe="ToastClose",Yve=S.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=bot(sRe,r);return e.jsx(rRe,{asChild:!0,children:e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:Cr(t.onClick,a.onClose)})})});Yve.displayName=sRe;var rRe=S.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 nRe(t){const s=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),Cot(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(...nRe(n))}}),s}function f8(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?Gve(a,o):a.dispatchEvent(o)}var JCe=(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 Sot(t=()=>{}){const s=Vc(t);Zc(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function Cot(t){return t.nodeType===t.ELEMENT_NODE}function Mot(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 ihe(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var Tot=G8e,aRe=Z8e,iRe=X8e,oRe=Q8e,lRe=J8e,cRe=tRe,dRe=Yve;function uRe(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,t4e=zi,XN=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return t4e(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:a,defaultVariants:o}=s,l=Object.keys(a).map(u=>{const p=r==null?void 0:r[u],f=o==null?void 0:o[u];if(p===null)return null;const v=e4e(p)||e4e(f);return a[u][v]}),i=r&&Object.entries(r).reduce((u,p)=>{let[f,v]=p;return v===void 0||(u[f]=v),u},{}),d=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((u,p)=>{let{class:f,className:v,..._}=p;return Object.entries(_).every(b=>{let[j,w]=b;return Array.isArray(w)?w.includes({...o,...i}[j]):{...o,...i}[j]===w})?[...u,f,v]:u},[]);return t4e(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 Aot=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),hRe=(...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 Eot={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 mRe=S.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},d)=>S.createElement("svg",{ref:d,...Eot,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:hRe("lucide",a),...i},[...l.map(([u,p])=>S.createElement(u,p)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z=(t,s)=>{const r=S.forwardRef(({className:n,...a},o)=>S.createElement(mRe,{ref:o,iconNode:s,className:hRe(`lucide-${Aot(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 WR=Z("AArrowDown",[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 7v9",key:"pknjwm"}],["path",{d:"m14 12 4 4 4-4",key:"buelq4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GR=Z("AArrowUp",[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 16V7",key:"ty0viw"}],["path",{d:"m14 11 4-4 4 4",key:"1pu57t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KR=Z("ALargeSmall",[["path",{d:"M21 14h-5",key:"1vh23k"}],["path",{d:"M16 16v-3.5a2.5 2.5 0 0 1 5 0V16",key:"1wh10o"}],["path",{d:"M4.5 13h6",key:"dfilno"}],["path",{d:"m3 16 4.5-9 4.5 9",key:"2dxa0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZR=Z("Accessibility",[["circle",{cx:"16",cy:"4",r:"1",key:"1grugj"}],["path",{d:"m18 19 1-7-6 1",key:"r0i19z"}],["path",{d:"m5 8 3-3 5.5 3-2.36 3.5",key:"9ptxx2"}],["path",{d:"M4.24 14.5a5 5 0 0 0 6.88 6",key:"10kmtu"}],["path",{d:"M13.76 17.5a5 5 0 0 0-6.88-6",key:"2qq6rc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Am=Z("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YR=Z("AirVent",[["path",{d:"M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"larmp2"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"M18.3 17.7a2.5 2.5 0 0 1-3.16 3.83 2.53 2.53 0 0 1-1.14-2V12",key:"1bo8pg"}],["path",{d:"M6.6 15.6A2 2 0 1 0 10 17v-5",key:"t9h90c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XR=Z("Airplay",[["path",{d:"M5 17H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-1",key:"ns4c3b"}],["path",{d:"m12 15 5 6H7Z",key:"14qnn2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sw=Z("AlarmClockCheck",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rw=Z("AlarmClockMinus",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"M9 13h6",key:"1uhe8q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QR=Z("AlarmClockOff",[["path",{d:"M6.87 6.87a8 8 0 1 0 11.26 11.26",key:"3on8tj"}],["path",{d:"M19.9 14.25a8 8 0 0 0-9.15-9.15",key:"15ghsc"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.26 18.67 4 21",key:"yzmioq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M4 4 2 6",key:"1ycko6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nw=Z("AlarmClockPlus",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JR=Z("AlarmClock",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M12 9v4l2 2",key:"1c63tq"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eF=Z("AlarmSmoke",[["path",{d:"M11 21c0-2.5 2-2.5 2-5",key:"1sicvv"}],["path",{d:"M16 21c0-2.5 2-2.5 2-5",key:"1o3eny"}],["path",{d:"m19 8-.8 3a1.25 1.25 0 0 1-1.2 1H7a1.25 1.25 0 0 1-1.2-1L5 8",key:"1bvca4"}],["path",{d:"M21 3a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a1 1 0 0 1 1-1z",key:"x3qr1j"}],["path",{d:"M6 21c0-2.5 2-2.5 2-5",key:"i3w1gp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tF=Z("Album",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["polyline",{points:"11 3 11 11 14 8 17 11 17 3",key:"1wcwz3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sF=Z("AlignCenterHorizontal",[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4",key:"11f1s0"}],["path",{d:"M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4",key:"t14dx9"}],["path",{d:"M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1",key:"1w07xs"}],["path",{d:"M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1",key:"1apec2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rF=Z("AlignCenterVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4",key:"14d6g8"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4",key:"1e2lrw"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1",key:"1fkdwx"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1",key:"1euafb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t5=Z("AlignCenter",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nF=Z("AlignEndHorizontal",[["rect",{width:"6",height:"16",x:"4",y:"2",rx:"2",key:"z5wdxg"}],["rect",{width:"6",height:"9",x:"14",y:"9",rx:"2",key:"um7a8w"}],["path",{d:"M22 22H2",key:"19qnx5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aF=Z("AlignEndVertical",[["rect",{width:"16",height:"6",x:"2",y:"4",rx:"2",key:"10wcwx"}],["rect",{width:"9",height:"6",x:"9",y:"14",rx:"2",key:"4p5bwg"}],["path",{d:"M22 22V2",key:"12ipfv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iF=Z("AlignHorizontalDistributeCenter",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oF=Z("AlignHorizontalDistributeEnd",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M10 2v20",key:"uyc634"}],["path",{d:"M20 2v20",key:"1tx262"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lF=Z("AlignHorizontalDistributeStart",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M4 2v20",key:"gtpd5x"}],["path",{d:"M14 2v20",key:"tg6bpw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cF=Z("AlignHorizontalJustifyCenter",[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M12 2v20",key:"t6zp3m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dF=Z("AlignHorizontalJustifyEnd",[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"12",y:"7",rx:"2",key:"1ht384"}],["path",{d:"M22 2v20",key:"40qfg1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uF=Z("AlignHorizontalJustifyStart",[["rect",{width:"6",height:"14",x:"6",y:"5",rx:"2",key:"hsirpf"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M2 2v20",key:"1ivd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hF=Z("AlignHorizontalSpaceAround",[["rect",{width:"6",height:"10",x:"9",y:"7",rx:"2",key:"yn7j0q"}],["path",{d:"M4 22V2",key:"tsjzd3"}],["path",{d:"M20 22V2",key:"1bnhr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mF=Z("AlignHorizontalSpaceBetween",[["rect",{width:"6",height:"14",x:"3",y:"5",rx:"2",key:"j77dae"}],["rect",{width:"6",height:"10",x:"15",y:"7",rx:"2",key:"bq30hj"}],["path",{d:"M3 2v20",key:"1d2pfg"}],["path",{d:"M21 2v20",key:"p059bm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pF=Z("AlignJustify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s5=Z("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r5=Z("AlignRight",[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fF=Z("AlignStartHorizontal",[["rect",{width:"6",height:"16",x:"4",y:"6",rx:"2",key:"1n4dg1"}],["rect",{width:"6",height:"9",x:"14",y:"6",rx:"2",key:"17khns"}],["path",{d:"M22 2H2",key:"fhrpnj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gF=Z("AlignStartVertical",[["rect",{width:"9",height:"6",x:"6",y:"14",rx:"2",key:"lpm2y7"}],["rect",{width:"16",height:"6",x:"6",y:"4",rx:"2",key:"rdj6ps"}],["path",{d:"M2 2v20",key:"1ivd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xF=Z("AlignVerticalDistributeCenter",[["path",{d:"M22 17h-3",key:"1lwga1"}],["path",{d:"M22 7h-5",key:"o2endc"}],["path",{d:"M5 17H2",key:"1gx9xc"}],["path",{d:"M7 7H2",key:"6bq26l"}],["rect",{x:"5",y:"14",width:"14",height:"6",rx:"2",key:"1qrzuf"}],["rect",{x:"7",y:"4",width:"10",height:"6",rx:"2",key:"we8e9z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yF=Z("AlignVerticalDistributeEnd",[["rect",{width:"14",height:"6",x:"5",y:"14",rx:"2",key:"jmoj9s"}],["rect",{width:"10",height:"6",x:"7",y:"4",rx:"2",key:"aza5on"}],["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"M2 10h20",key:"1ir3d8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vF=Z("AlignVerticalDistributeStart",[["rect",{width:"14",height:"6",x:"5",y:"14",rx:"2",key:"jmoj9s"}],["rect",{width:"10",height:"6",x:"7",y:"4",rx:"2",key:"aza5on"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M2 4h20",key:"mda7wb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _F=Z("AlignVerticalJustifyCenter",[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bF=Z("AlignVerticalJustifyEnd",[["rect",{width:"14",height:"6",x:"5",y:"12",rx:"2",key:"4l4tp2"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 22h20",key:"272qi7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wF=Z("AlignVerticalJustifyStart",[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"6",rx:"2",key:"13squh"}],["path",{d:"M2 2h20",key:"1ennik"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jF=Z("AlignVerticalSpaceAround",[["rect",{width:"10",height:"6",x:"7",y:"9",rx:"2",key:"b1zbii"}],["path",{d:"M22 20H2",key:"1p1f7z"}],["path",{d:"M22 4H2",key:"1b7qnq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kF=Z("AlignVerticalSpaceBetween",[["rect",{width:"14",height:"6",x:"5",y:"15",rx:"2",key:"1w91an"}],["rect",{width:"10",height:"6",x:"7",y:"3",rx:"2",key:"17wqzy"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M2 3h20",key:"91anmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NF=Z("Ambulance",[["path",{d:"M10 10H6",key:"1bsnug"}],["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.28a1 1 0 0 0-.684-.948l-1.923-.641a1 1 0 0 1-.578-.502l-1.539-3.076A1 1 0 0 0 16.382 8H14",key:"lrkjwd"}],["path",{d:"M8 8v4",key:"1fwk8c"}],["path",{d:"M9 18h6",key:"x1upvd"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SF=Z("Ampersand",[["path",{d:"M17.5 12c0 4.4-3.6 8-8 8A4.5 4.5 0 0 1 5 15.5c0-6 8-4 8-8.5a3 3 0 1 0-6 0c0 3 2.5 8.5 12 13",key:"1o9ehi"}],["path",{d:"M16 12h3",key:"4uvgyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CF=Z("Ampersands",[["path",{d:"M10 17c-5-3-7-7-7-9a2 2 0 0 1 4 0c0 2.5-5 2.5-5 6 0 1.7 1.3 3 3 3 2.8 0 5-2.2 5-5",key:"12lh1k"}],["path",{d:"M22 17c-5-3-7-7-7-9a2 2 0 0 1 4 0c0 2.5-5 2.5-5 6 0 1.7 1.3 3 3 3 2.8 0 5-2.2 5-5",key:"173c68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MF=Z("Amphora",[["path",{d:"M10 2v5.632c0 .424-.272.795-.653.982A6 6 0 0 0 6 14c.006 4 3 7 5 8",key:"1h8rid"}],["path",{d:"M10 5H8a2 2 0 0 0 0 4h.68",key:"3ezsi6"}],["path",{d:"M14 2v5.632c0 .424.272.795.652.982A6 6 0 0 1 18 14c0 4-3 7-5 8",key:"yt6q09"}],["path",{d:"M14 5h2a2 2 0 0 1 0 4h-.68",key:"8f95yk"}],["path",{d:"M18 22H6",key:"mg6kv4"}],["path",{d:"M9 2h6",key:"1jrp98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TF=Z("Anchor",[["path",{d:"M12 22V8",key:"qkxhtm"}],["path",{d:"M5 12H2a10 10 0 0 0 20 0h-3",key:"1hv3nh"}],["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AF=Z("Angry",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["path",{d:"M7.5 8 10 9",key:"olxxln"}],["path",{d:"m14 9 2.5-1",key:"1j6cij"}],["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EF=Z("Annoyed",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 15h8",key:"45n4r"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M14 9h2",key:"116p9w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PF=Z("Antenna",[["path",{d:"M2 12 7 2",key:"117k30"}],["path",{d:"m7 12 5-10",key:"1tvx22"}],["path",{d:"m12 12 5-10",key:"ev1o1a"}],["path",{d:"m17 12 5-10",key:"1e4ti3"}],["path",{d:"M4.5 7h15",key:"vlsxkz"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IF=Z("Anvil",[["path",{d:"M7 10H6a4 4 0 0 1-4-4 1 1 0 0 1 1-1h4",key:"1hjpb6"}],["path",{d:"M7 5a1 1 0 0 1 1-1h13a1 1 0 0 1 1 1 7 7 0 0 1-7 7H8a1 1 0 0 1-1-1z",key:"1qn45f"}],["path",{d:"M9 12v5",key:"3anwtq"}],["path",{d:"M15 12v5",key:"5xh3zn"}],["path",{d:"M5 20a3 3 0 0 1 3-3h8a3 3 0 0 1 3 3 1 1 0 0 1-1 1H6a1 1 0 0 1-1-1",key:"1fi4x8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LF=Z("Aperture",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14.31 8 5.74 9.94",key:"1y6ab4"}],["path",{d:"M9.69 8h11.48",key:"1wxppr"}],["path",{d:"m7.38 12 5.74-9.94",key:"1grp0k"}],["path",{d:"M9.69 16 3.95 6.06",key:"libnyf"}],["path",{d:"M14.31 16H2.83",key:"x5fava"}],["path",{d:"m16.62 12-5.74 9.94",key:"1vwawt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DF=Z("AppWindowMac",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M14 8h.01",key:"1primd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GE=Z("AppWindow",[["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}],["path",{d:"M10 4v4",key:"pp8u80"}],["path",{d:"M2 8h20",key:"d11cs7"}],["path",{d:"M6 4v4",key:"1svtjw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OF=Z("Apple",[["path",{d:"M12 20.94c1.5 0 2.75 1.06 4 1.06 3 0 6-8 6-12.22A4.91 4.91 0 0 0 17 5c-2.22 0-4 1.44-5 2-1-.56-2.78-2-5-2a4.9 4.9 0 0 0-5 4.78C2 14 5 22 8 22c1.25 0 2.5-1.06 4-1.06Z",key:"3s7exb"}],["path",{d:"M10 2c1 .5 2 2 2 5",key:"fcco2y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KE=Z("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RF=Z("ArchiveX",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"m9.5 17 5-5",key:"nakeu6"}],["path",{d:"m9.5 12 5 5",key:"1hccrj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n5=Z("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FF=Z("Armchair",[["path",{d:"M19 9V6a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v3",key:"irtipd"}],["path",{d:"M3 16a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"1qyhux"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zF=Z("ArrowBigDownDash",[["path",{d:"M15 5H9",key:"1tp3ed"}],["path",{d:"M15 9v3h4l-7 7-7-7h4V9z",key:"ncdc4b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BF=Z("ArrowBigDown",[["path",{d:"M15 6v6h4l-7 7-7-7h4V6h6z",key:"1thax2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $F=Z("ArrowBigLeftDash",[["path",{d:"M19 15V9",key:"1hci5f"}],["path",{d:"M15 15h-3v4l-7-7 7-7v4h3v6z",key:"16tjna"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qF=Z("ArrowBigLeft",[["path",{d:"M18 15h-6v4l-7-7 7-7v4h6v6z",key:"lbrdak"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UF=Z("ArrowBigRightDash",[["path",{d:"M5 9v6",key:"158jrl"}],["path",{d:"M9 9h3V5l7 7-7 7v-4H9V9z",key:"1sg2xn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VF=Z("ArrowBigRight",[["path",{d:"M6 9h6V5l7 7-7 7v-4H6V9z",key:"7fvt9c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HF=Z("ArrowBigUpDash",[["path",{d:"M9 19h6",key:"456am0"}],["path",{d:"M9 15v-3H5l7-7 7 7h-4v3H9z",key:"1r2uve"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WF=Z("ArrowBigUp",[["path",{d:"M9 18v-6H5l7-7 7 7h-4v6H9z",key:"1x06kx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GF=Z("ArrowDown01",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["rect",{x:"15",y:"4",width:"4",height:"6",ry:"2",key:"1bwicg"}],["path",{d:"M17 20v-6h-2",key:"1qp1so"}],["path",{d:"M15 20h4",key:"1j968p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KF=Z("ArrowDown10",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aw=Z("ArrowDownAZ",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZF=Z("ArrowDownFromLine",[["path",{d:"M19 3H5",key:"1236rx"}],["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m6 15 6 6 6-6",key:"h15q88"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YF=Z("ArrowDownLeft",[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XF=Z("ArrowDownNarrowWide",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h4",key:"6d7r33"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h10",key:"1438ji"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZE=Z("ArrowDownRight",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QF=Z("ArrowDownToDot",[["path",{d:"M12 2v14",key:"jyx4ut"}],["path",{d:"m19 9-7 7-7-7",key:"1oe3oy"}],["circle",{cx:"12",cy:"21",r:"1",key:"o0uj5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JF=Z("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ez=Z("ArrowDownUp",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iw=Z("ArrowDownWideNarrow",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ow=Z("ArrowDownZA",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eh=Z("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tz=Z("ArrowLeftFromLine",[["path",{d:"m9 6-6 6 6 6",key:"7v63n9"}],["path",{d:"M3 12h14",key:"13k4hi"}],["path",{d:"M21 19V5",key:"b4bplr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sz=Z("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rz=Z("ArrowLeftToLine",[["path",{d:"M3 19V5",key:"rwsyhb"}],["path",{d:"m13 6-6 6 6 6",key:"1yhaz7"}],["path",{d:"M7 12h14",key:"uoisry"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ua=Z("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nz=Z("ArrowRightFromLine",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M21 12H7",key:"13ipq5"}],["path",{d:"m15 18 6-6-6-6",key:"6tx3qv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k0=Z("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const az=Z("ArrowRightToLine",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fi=Z("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iz=Z("ArrowUp01",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["rect",{x:"15",y:"4",width:"4",height:"6",ry:"2",key:"1bwicg"}],["path",{d:"M17 20v-6h-2",key:"1qp1so"}],["path",{d:"M15 20h4",key:"1j968p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oz=Z("ArrowUp10",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lw=Z("ArrowUpAZ",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hc=Z("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lz=Z("ArrowUpFromDot",[["path",{d:"m5 9 7-7 7 7",key:"1hw5ic"}],["path",{d:"M12 16V2",key:"ywoabb"}],["circle",{cx:"12",cy:"21",r:"1",key:"o0uj5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cz=Z("ArrowUpFromLine",[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dz=Z("ArrowUpLeft",[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cw=Z("ArrowUpNarrowWide",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YE=Z("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uz=Z("ArrowUpToLine",[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hz=Z("ArrowUpWideNarrow",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h4",key:"1krc32"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dw=Z("ArrowUpZA",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vd=Z("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mz=Z("ArrowsUpFromLine",[["path",{d:"m4 6 3-3 3 3",key:"9aidw8"}],["path",{d:"M7 17V3",key:"19qxw1"}],["path",{d:"m14 6 3-3 3 3",key:"6iy689"}],["path",{d:"M17 17V3",key:"o0fmgi"}],["path",{d:"M4 21h16",key:"1h09gz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pz=Z("Asterisk",[["path",{d:"M12 6v12",key:"1vza4d"}],["path",{d:"M17.196 9 6.804 15",key:"1ah31z"}],["path",{d:"m6.804 9 10.392 6",key:"1b6pxd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fz=Z("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gz=Z("Atom",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z",key:"1l2ple"}],["path",{d:"M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z",key:"1wam0m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xz=Z("AudioLines",[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yz=Z("AudioWaveform",[["path",{d:"M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2",key:"57tc96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rc=Z("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vz=Z("Axe",[["path",{d:"m14 12-8.5 8.5a2.12 2.12 0 1 1-3-3L11 9",key:"csbz4o"}],["path",{d:"M15 13 9 7l4-4 6 6h3a8 8 0 0 1-7 7z",key:"113wfo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uw=Z("Axis3d",[["path",{d:"M4 4v16h16",key:"1s015l"}],["path",{d:"m4 20 7-7",key:"17qe9y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _z=Z("Baby",[["path",{d:"M9 12h.01",key:"157uk2"}],["path",{d:"M15 12h.01",key:"1k8ypt"}],["path",{d:"M10 16c.5.3 1.2.5 2 .5s1.5-.2 2-.5",key:"1u7htd"}],["path",{d:"M19 6.3a9 9 0 0 1 1.8 3.9 2 2 0 0 1 0 3.6 9 9 0 0 1-17.6 0 2 2 0 0 1 0-3.6A9 9 0 0 1 12 3c2 0 3.5 1.1 3.5 2.5s-.9 2.5-2 2.5c-.8 0-1.5-.4-1.5-1",key:"5yv0yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bz=Z("Backpack",[["path",{d:"M4 10a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z",key:"1ol0lm"}],["path",{d:"M8 10h8",key:"c7uz4u"}],["path",{d:"M8 18h8",key:"1no2b1"}],["path",{d:"M8 22v-6a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v6",key:"1fr6do"}],["path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2",key:"donm21"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wz=Z("BadgeAlert",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jz=Z("BadgeCent",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M15.4 10a4 4 0 1 0 0 4",key:"2eqtx8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hw=Z("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kz=Z("BadgeDollarSign",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nz=Z("BadgeEuro",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M7 12h5",key:"gblrwe"}],["path",{d:"M15 9.4a4 4 0 1 0 0 5.2",key:"1makmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sz=Z("BadgeHelp",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["line",{x1:"12",x2:"12.01",y1:"17",y2:"17",key:"io3f8k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cz=Z("BadgeIndianRupee",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M8 8h8",key:"1bis0t"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m13 17-5-1h1a4 4 0 0 0 0-8",key:"nu2bwa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mz=Z("BadgeInfo",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"16",y2:"12",key:"1y1yb1"}],["line",{x1:"12",x2:"12.01",y1:"8",y2:"8",key:"110wyk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tz=Z("BadgeJapaneseYen",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 8 3 3v7",key:"17yadx"}],["path",{d:"m12 11 3-3",key:"p4cfq1"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M9 16h6",key:"8wimt3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Az=Z("BadgeMinus",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ez=Z("BadgePercent",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pz=Z("BadgePlus",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"16",key:"10p56q"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iz=Z("BadgePoundSterling",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M8 12h4",key:"qz6y1c"}],["path",{d:"M10 16V9.5a2.5 2.5 0 0 1 5 0",key:"3mlbjk"}],["path",{d:"M8 16h7",key:"sbedsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lz=Z("BadgeRussianRuble",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9 16h5",key:"1syiyw"}],["path",{d:"M9 12h5a2 2 0 1 0 0-4h-3v9",key:"1ge9c1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dz=Z("BadgeSwissFranc",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M11 17V8h4",key:"1bfq6y"}],["path",{d:"M11 12h3",key:"2eqnfz"}],["path",{d:"M9 16h4",key:"1skf3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oz=Z("BadgeX",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rz=Z("Badge",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fz=Z("BaggageClaim",[["path",{d:"M22 18H6a2 2 0 0 1-2-2V7a2 2 0 0 0-2-2",key:"4irg2o"}],["path",{d:"M17 14V4a2 2 0 0 0-2-2h-1a2 2 0 0 0-2 2v10",key:"14fcyx"}],["rect",{width:"13",height:"8",x:"8",y:"6",rx:"1",key:"o6oiis"}],["circle",{cx:"18",cy:"20",r:"2",key:"t9985n"}],["circle",{cx:"9",cy:"20",r:"2",key:"e5v82j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zz=Z("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bz=Z("Banana",[["path",{d:"M4 13c3.5-2 8-2 10 2a5.5 5.5 0 0 1 8 5",key:"1cscit"}],["path",{d:"M5.15 17.89c5.52-1.52 8.65-6.89 7-12C11.55 4 11.5 2 13 2c3.22 0 5 5.5 5 8 0 6.5-4.2 12-10.49 12C5.11 22 2 22 2 20c0-1.5 1.14-1.55 3.15-2.11Z",key:"1y1nbv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $z=Z("Bandage",[["path",{d:"M10 10.01h.01",key:"1e9xi7"}],["path",{d:"M10 14.01h.01",key:"ac23bv"}],["path",{d:"M14 10.01h.01",key:"2wfrvf"}],["path",{d:"M14 14.01h.01",key:"8tw8yn"}],["path",{d:"M18 6v11.5",key:"dkbidh"}],["path",{d:"M6 6v12",key:"vkc79e"}],["rect",{x:"2",y:"6",width:"20",height:"12",rx:"2",key:"1wpnh2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qz=Z("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uz=Z("Barcode",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M8 5v14",key:"1ybrkv"}],["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"M17 5v14",key:"ycjyhj"}],["path",{d:"M21 5v14",key:"nzette"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vz=Z("Baseline",[["path",{d:"M4 20h16",key:"14thso"}],["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vx=Z("Bath",[["path",{d:"M10 4 8 6",key:"1rru8s"}],["path",{d:"M17 19v2",key:"ts1sot"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M7 19v2",key:"12npes"}],["path",{d:"M9 5 7.621 3.621A2.121 2.121 0 0 0 4 5v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5",key:"14ym8i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hz=Z("BatteryCharging",[["path",{d:"M15 7h1a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-2",key:"1sdynx"}],["path",{d:"M6 7H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h1",key:"1gkd3k"}],["path",{d:"m11 7-3 5h4l-3 5",key:"b4a64w"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wz=Z("BatteryFull",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"13",key:"c6fn6x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gz=Z("BatteryLow",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kz=Z("BatteryMedium",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zz=Z("BatteryWarning",[["path",{d:"M10 17h.01",key:"nbq80n"}],["path",{d:"M10 7v6",key:"nne03l"}],["path",{d:"M14 7h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-2",key:"1x5o8m"}],["path",{d:"M22 11v2",key:"1wo06k"}],["path",{d:"M6 7H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"1mdjgh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yz=Z("Battery",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xz=Z("Beaker",[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qz=Z("BeanOff",[["path",{d:"M9 9c-.64.64-1.521.954-2.402 1.165A6 6 0 0 0 8 22a13.96 13.96 0 0 0 9.9-4.1",key:"bq3udt"}],["path",{d:"M10.75 5.093A6 6 0 0 1 22 8c0 2.411-.61 4.68-1.683 6.66",key:"17ccse"}],["path",{d:"M5.341 10.62a4 4 0 0 0 6.487 1.208M10.62 5.341a4.015 4.015 0 0 1 2.039 2.04",key:"18zqgq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jz=Z("Bean",[["path",{d:"M10.165 6.598C9.954 7.478 9.64 8.36 9 9c-.64.64-1.521.954-2.402 1.165A6 6 0 0 0 8 22c7.732 0 14-6.268 14-14a6 6 0 0 0-11.835-1.402Z",key:"1tvzk7"}],["path",{d:"M5.341 10.62a4 4 0 1 0 5.279-5.28",key:"2cyri2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XE=Z("BedDouble",[["path",{d:"M2 20v-8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v8",key:"1k78r4"}],["path",{d:"M4 10V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"fb3tl2"}],["path",{d:"M12 4v6",key:"1dcgq2"}],["path",{d:"M2 18h20",key:"ajqnye"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e7=Z("BedSingle",[["path",{d:"M3 20v-8a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v8",key:"1wm6mi"}],["path",{d:"M5 10V6a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v4",key:"4k93s5"}],["path",{d:"M3 18h18",key:"1h113x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N0=Z("Bed",[["path",{d:"M2 4v16",key:"vw9hq8"}],["path",{d:"M2 8h18a2 2 0 0 1 2 2v10",key:"1dgv2r"}],["path",{d:"M2 17h20",key:"18nfp3"}],["path",{d:"M6 8v9",key:"1yriud"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t7=Z("Beef",[["circle",{cx:"12.5",cy:"8.5",r:"2.5",key:"9738u8"}],["path",{d:"M12.5 2a6.5 6.5 0 0 0-6.22 4.6c-1.1 3.13-.78 3.9-3.18 6.08A3 3 0 0 0 5 18c4 0 8.4-1.8 11.4-4.3A6.5 6.5 0 0 0 12.5 2Z",key:"o0f6za"}],["path",{d:"m18.5 6 2.19 4.5a6.48 6.48 0 0 1 .31 2 6.49 6.49 0 0 1-2.6 5.2C15.4 20.2 11 22 7 22a3 3 0 0 1-2.68-1.66L2.4 16.5",key:"k7p6i0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s7=Z("BeerOff",[["path",{d:"M13 13v5",key:"igwfh0"}],["path",{d:"M17 11.47V8",key:"16yw0g"}],["path",{d:"M17 11h1a3 3 0 0 1 2.745 4.211",key:"1xbt65"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 8v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-3",key:"c55o3e"}],["path",{d:"M7.536 7.535C6.766 7.649 6.154 8 5.5 8a2.5 2.5 0 0 1-1.768-4.268",key:"1ydug7"}],["path",{d:"M8.727 3.204C9.306 2.767 9.885 2 11 2c1.56 0 2 1.5 3 1.5s1.72-.5 2.5-.5a1 1 0 1 1 0 5c-.78 0-1.5-.5-2.5-.5a3.149 3.149 0 0 0-.842.12",key:"q81o7q"}],["path",{d:"M9 14.6V18",key:"20ek98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r7=Z("Beer",[["path",{d:"M17 11h1a3 3 0 0 1 0 6h-1",key:"1yp76v"}],["path",{d:"M9 12v6",key:"1u1cab"}],["path",{d:"M13 12v6",key:"1sugkk"}],["path",{d:"M14 7.5c-1 0-1.44.5-3 .5s-2-.5-3-.5-1.72.5-2.5.5a2.5 2.5 0 0 1 0-5c.78 0 1.57.5 2.5.5S9.44 2 11 2s2 1.5 3 1.5 1.72-.5 2.5-.5a2.5 2.5 0 0 1 0 5c-.78 0-1.5-.5-2.5-.5Z",key:"1510fo"}],["path",{d:"M5 8v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"19jb7n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n7=Z("BellDot",[["path",{d:"M19.4 14.9C20.2 16.4 21 17 21 17H3s3-2 3-9c0-3.3 2.7-6 6-6 .7 0 1.3.1 1.9.3",key:"xcehk"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["circle",{cx:"18",cy:"8",r:"3",key:"1g0gzu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a7=Z("BellElectric",[["path",{d:"M18.8 4A6.3 8.7 0 0 1 20 9",key:"xve1fh"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["circle",{cx:"9",cy:"9",r:"7",key:"p2h5vp"}],["rect",{width:"10",height:"6",x:"4",y:"16",rx:"2",key:"17f3te"}],["path",{d:"M14 19c3 0 4.6-1.6 4.6-1.6",key:"n7odp6"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i7=Z("BellMinus",[["path",{d:"M18.4 12c.8 3.8 2.6 5 2.6 5H3s3-2 3-9c0-3.3 2.7-6 6-6 1.8 0 3.4.8 4.5 2",key:"eck70s"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M15 8h6",key:"8ybuxh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X1=Z("BellOff",[["path",{d:"M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5",key:"o7mx20"}],["path",{d:"M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7",key:"16f1lm"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o7=Z("BellPlus",[["path",{d:"M19.3 14.8C20.1 16.4 21 17 21 17H3s3-2 3-9c0-3.3 2.7-6 6-6 1 0 1.9.2 2.8.7",key:"guizqy"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M15 8h6",key:"8ybuxh"}],["path",{d:"M18 5v6",key:"g5ayrv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l7=Z("BellRing",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cf=Z("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mw=Z("BetweenHorizontalEnd",[["rect",{width:"13",height:"7",x:"3",y:"3",rx:"1",key:"11xb64"}],["path",{d:"m22 15-3-3 3-3",key:"26chmm"}],["rect",{width:"13",height:"7",x:"3",y:"14",rx:"1",key:"k6ky7n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pw=Z("BetweenHorizontalStart",[["rect",{width:"13",height:"7",x:"8",y:"3",rx:"1",key:"pkso9a"}],["path",{d:"m2 9 3 3-3 3",key:"1agib5"}],["rect",{width:"13",height:"7",x:"8",y:"14",rx:"1",key:"1q5fc1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c7=Z("BetweenVerticalEnd",[["rect",{width:"7",height:"13",x:"3",y:"3",rx:"1",key:"1fdu0f"}],["path",{d:"m9 22 3-3 3 3",key:"17z65a"}],["rect",{width:"7",height:"13",x:"14",y:"3",rx:"1",key:"1squn4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d7=Z("BetweenVerticalStart",[["rect",{width:"7",height:"13",x:"3",y:"8",rx:"1",key:"1fjrkv"}],["path",{d:"m15 2-3 3-3-3",key:"1uh6eb"}],["rect",{width:"7",height:"13",x:"14",y:"8",rx:"1",key:"w3fjg8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u7=Z("BicepsFlexed",[["path",{d:"M12.409 13.017A5 5 0 0 1 22 15c0 3.866-4 7-9 7-4.077 0-8.153-.82-10.371-2.462-.426-.316-.631-.832-.62-1.362C2.118 12.723 2.627 2 10 2a3 3 0 0 1 3 3 2 2 0 0 1-2 2c-1.105 0-1.64-.444-2-1",key:"1pmlyh"}],["path",{d:"M15 14a5 5 0 0 0-7.584 2",key:"5rb254"}],["path",{d:"M9.964 6.825C8.019 7.977 9.5 13 8 15",key:"kbvsx9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h7=Z("Bike",[["circle",{cx:"18.5",cy:"17.5",r:"3.5",key:"15x4ox"}],["circle",{cx:"5.5",cy:"17.5",r:"3.5",key:"1noe27"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["path",{d:"M12 17.5V14l-3-3 4-3 2 3h2",key:"1npguv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m7=Z("Binary",[["rect",{x:"14",y:"14",width:"4",height:"6",rx:"2",key:"p02svl"}],["rect",{x:"6",y:"4",width:"4",height:"6",rx:"2",key:"xm4xkj"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 10h4",key:"ru81e7"}],["path",{d:"M6 14h2v6",key:"16z9wg"}],["path",{d:"M14 4h2v6",key:"1idq9u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p7=Z("Binoculars",[["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M19 7V4a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3",key:"3apit1"}],["path",{d:"M20 21a2 2 0 0 0 2-2v-3.851c0-1.39-2-2.962-2-4.829V8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v11a2 2 0 0 0 2 2z",key:"rhpgnw"}],["path",{d:"M 22 16 L 2 16",key:"14lkq7"}],["path",{d:"M4 21a2 2 0 0 1-2-2v-3.851c0-1.39 2-2.962 2-4.829V8a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v11a2 2 0 0 1-2 2z",key:"104b3k"}],["path",{d:"M9 7V4a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v3",key:"14fczp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f7=Z("Biohazard",[["circle",{cx:"12",cy:"11.9",r:"2",key:"e8h31w"}],["path",{d:"M6.7 3.4c-.9 2.5 0 5.2 2.2 6.7C6.5 9 3.7 9.6 2 11.6",key:"17bolr"}],["path",{d:"m8.9 10.1 1.4.8",key:"15ezny"}],["path",{d:"M17.3 3.4c.9 2.5 0 5.2-2.2 6.7 2.4-1.2 5.2-.6 6.9 1.5",key:"wtwa5u"}],["path",{d:"m15.1 10.1-1.4.8",key:"1r0b28"}],["path",{d:"M16.7 20.8c-2.6-.4-4.6-2.6-4.7-5.3-.2 2.6-2.1 4.8-4.7 5.2",key:"m7qszh"}],["path",{d:"M12 13.9v1.6",key:"zfyyim"}],["path",{d:"M13.5 5.4c-1-.2-2-.2-3 0",key:"1bi9q0"}],["path",{d:"M17 16.4c.7-.7 1.2-1.6 1.5-2.5",key:"1rhjqw"}],["path",{d:"M5.5 13.9c.3.9.8 1.8 1.5 2.5",key:"8gsud3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g7=Z("Bird",[["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M3.4 18H12a8 8 0 0 0 8-8V7a4 4 0 0 0-7.28-2.3L2 20",key:"oj1oa8"}],["path",{d:"m20 7 2 .5-2 .5",key:"12nv4d"}],["path",{d:"M10 18v3",key:"1yea0a"}],["path",{d:"M14 17.75V21",key:"1pymcb"}],["path",{d:"M7 18a6 6 0 0 0 3.84-10.61",key:"1npnn0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x7=Z("Bitcoin",[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y7=Z("Blend",[["circle",{cx:"9",cy:"9",r:"7",key:"p2h5vp"}],["circle",{cx:"15",cy:"15",r:"7",key:"19ennj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v7=Z("Blinds",[["path",{d:"M3 3h18",key:"o7r712"}],["path",{d:"M20 7H8",key:"gd2fo2"}],["path",{d:"M20 11H8",key:"1ynp89"}],["path",{d:"M10 19h10",key:"19hjk5"}],["path",{d:"M8 15h12",key:"1yqzne"}],["path",{d:"M4 3v14",key:"fggqzn"}],["circle",{cx:"4",cy:"19",r:"2",key:"p3m9r0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _7=Z("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b7=Z("BluetoothConnected",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}],["line",{x1:"18",x2:"21",y1:"12",y2:"12",key:"1rsjjs"}],["line",{x1:"3",x2:"6",y1:"12",y2:"12",key:"11yl8c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w7=Z("BluetoothOff",[["path",{d:"m17 17-5 5V12l-5 5",key:"v5aci6"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M14.5 9.5 17 7l-5-5v4.5",key:"1kddfz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j7=Z("BluetoothSearching",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}],["path",{d:"M20.83 14.83a4 4 0 0 0 0-5.66",key:"k8tn1j"}],["path",{d:"M18 12h.01",key:"yjnet6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k7=Z("Bluetooth",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a5=Z("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N7=Z("Bolt",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S7=Z("Bomb",[["circle",{cx:"11",cy:"13",r:"9",key:"hd149"}],["path",{d:"M14.35 4.65 16.3 2.7a2.41 2.41 0 0 1 3.4 0l1.6 1.6a2.4 2.4 0 0 1 0 3.4l-1.95 1.95",key:"jp4j1b"}],["path",{d:"m22 2-1.5 1.5",key:"ay92ug"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C7=Z("Bone",[["path",{d:"M17 10c.7-.7 1.69 0 2.5 0a2.5 2.5 0 1 0 0-5 .5.5 0 0 1-.5-.5 2.5 2.5 0 1 0-5 0c0 .81.7 1.8 0 2.5l-7 7c-.7.7-1.69 0-2.5 0a2.5 2.5 0 0 0 0 5c.28 0 .5.22.5.5a2.5 2.5 0 1 0 5 0c0-.81-.7-1.8 0-2.5Z",key:"w610uw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M7=Z("BookA",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m8 13 4-7 4 7",key:"4rari8"}],["path",{d:"M9.1 11h5.7",key:"1gkovt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T7=Z("BookAudio",[["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8v3",key:"gejaml"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 8v3",key:"1qzp49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A7=Z("BookCheck",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 9.5 2 2 4-4",key:"1dth82"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E7=Z("BookCopy",[["path",{d:"M2 16V4a2 2 0 0 1 2-2h11",key:"spzkk5"}],["path",{d:"M22 18H11a2 2 0 1 0 0 4h10.5a.5.5 0 0 0 .5-.5v-15a.5.5 0 0 0-.5-.5H11a2 2 0 0 0-2 2v12",key:"1wz07i"}],["path",{d:"M5 14H4a2 2 0 1 0 0 4h1",key:"16gqf9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fw=Z("BookDashed",[["path",{d:"M12 17h2",key:"13u4lk"}],["path",{d:"M12 22h2",key:"kn7ki6"}],["path",{d:"M12 2h2",key:"cvn524"}],["path",{d:"M18 22h1a1 1 0 0 0 1-1",key:"w6gbqz"}],["path",{d:"M18 2h1a1 1 0 0 1 1 1v1",key:"1vpra5"}],["path",{d:"M20 15v2h-2",key:"fph276"}],["path",{d:"M20 8v3",key:"deu0bs"}],["path",{d:"M4 11V9",key:"v3xsx8"}],["path",{d:"M4 19.5V15",key:"6gr39e"}],["path",{d:"M4 5v-.5A2.5 2.5 0 0 1 6.5 2H8",key:"wywhs9"}],["path",{d:"M8 22H6.5a1 1 0 0 1 0-5H8",key:"1cu73q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P7=Z("BookDown",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 10 3 3 3-3",key:"zt5b4y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I7=Z("BookHeadphones",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 12v-2a4 4 0 0 1 8 0v2",key:"1vsqkj"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L7=Z("BookHeart",[["path",{d:"M16 8.2A2.22 2.22 0 0 0 13.8 6c-.8 0-1.4.3-1.8.9-.4-.6-1-.9-1.8-.9A2.22 2.22 0 0 0 8 8.2c0 .6.3 1.2.7 1.6A226.652 226.652 0 0 0 12 13a404 404 0 0 0 3.3-3.1 2.413 2.413 0 0 0 .7-1.7",key:"1t75a8"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D7=Z("BookImage",[["path",{d:"m20 13.7-2.1-2.1a2 2 0 0 0-2.8 0L9.7 17",key:"q6ojf0"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["circle",{cx:"10",cy:"8",r:"2",key:"2qkj4p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O7=Z("BookKey",[["path",{d:"m19 3 1 1",key:"ze14oc"}],["path",{d:"m20 2-4.5 4.5",key:"1sppr8"}],["path",{d:"M20 8v13a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"1ocbpn"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H14",key:"1gfsgw"}],["circle",{cx:"14",cy:"8",r:"2",key:"u49eql"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R7=Z("BookLock",[["path",{d:"M18 6V4a2 2 0 1 0-4 0v2",key:"1aquzs"}],["path",{d:"M20 15v6a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"1rkj32"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H10",key:"18wgow"}],["rect",{x:"12",y:"6",width:"8",height:"5",rx:"1",key:"73l30o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F7=Z("BookMarked",[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z7=Z("BookMinus",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B7=Z("BookOpenCheck",[["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m16 12 2 2 4-4",key:"mdajum"}],["path",{d:"M22 6V4a1 1 0 0 0-1-1h-5a4 4 0 0 0-4 4 4 4 0 0 0-4-4H3a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h6a3 3 0 0 1 3 3 3 3 0 0 1 3-3h6a1 1 0 0 0 1-1v-1.3",key:"8arnkb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $7=Z("BookOpenText",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ou=Z("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q7=Z("BookPlus",[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U7=Z("BookText",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 11h8",key:"vwpz6n"}],["path",{d:"M8 7h6",key:"1f0q6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V7=Z("BookType",[["path",{d:"M10 13h4",key:"ytezjc"}],["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8V6H8v2",key:"x8j6u4"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H7=Z("BookUp2",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M18 2h1a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"161d7n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2",key:"1lorq7"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W7=Z("BookUp",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G7=Z("BookUser",[["path",{d:"M15 13a3 3 0 1 0-6 0",key:"10j68g"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K7=Z("BookX",[["path",{d:"m14.5 7-5 5",key:"dy991v"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9.5 7 5 5",key:"s45iea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z7=Z("Book",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y7=Z("BookmarkCheck",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X7=Z("BookmarkMinus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QE=Z("BookmarkPlus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"12",x2:"12",y1:"7",y2:"13",key:"1cppfj"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q7=Z("BookmarkX",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dg=Z("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J7=Z("BoomBox",[["path",{d:"M4 9V5a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"vvzvr1"}],["path",{d:"M8 8v1",key:"xcqmfk"}],["path",{d:"M12 8v1",key:"1rj8u4"}],["path",{d:"M16 8v1",key:"1q12zr"}],["rect",{width:"20",height:"12",x:"2",y:"9",rx:"2",key:"igpb89"}],["circle",{cx:"8",cy:"15",r:"2",key:"fa4a8s"}],["circle",{cx:"16",cy:"15",r:"2",key:"14c3ya"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eB=Z("BotMessageSquare",[["path",{d:"M12 6V2H8",key:"1155em"}],["path",{d:"m8 18-4 4V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2Z",key:"w2lp3e"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M9 11v2",key:"1ueba0"}],["path",{d:"M15 11v2",key:"i11awn"}],["path",{d:"M20 12h2",key:"1q8mjw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tB=Z("BotOff",[["path",{d:"M13.67 8H18a2 2 0 0 1 2 2v4.33",key:"7az073"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}],["path",{d:"M8 8H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 1.414-.586",key:"s09a7a"}],["path",{d:"M9 13v2",key:"rq6x2g"}],["path",{d:"M9.67 4H12v2.33",key:"110xot"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i5=Z("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sB=Z("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rB=Z("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gw=Z("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nB=Z("Brackets",[["path",{d:"M16 3h3v18h-3",key:"1yor1f"}],["path",{d:"M8 21H5V3h3",key:"1qrfwo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aB=Z("BrainCircuit",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iB=Z("BrainCog",[["path",{d:"M12 5a3 3 0 1 0-5.997.142 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588 4 4 0 0 0 7.636 2.106 3.2 3.2 0 0 0 .164-.546c.028-.13.306-.13.335 0a3.2 3.2 0 0 0 .163.546 4 4 0 0 0 7.636-2.106 4 4 0 0 0 .556-6.588 4 4 0 0 0-2.526-5.77A3 3 0 1 0 12 5",key:"1kgmhc"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m15.7 10.4-.9.4",key:"ayzo6p"}],["path",{d:"m9.2 13.2-.9.4",key:"1uzb3g"}],["path",{d:"m13.6 15.7-.4-.9",key:"11ifqf"}],["path",{d:"m10.8 9.2-.4-.9",key:"1pmk2v"}],["path",{d:"m15.7 13.5-.9-.4",key:"7ng02m"}],["path",{d:"m9.2 10.9-.9-.4",key:"1x66zd"}],["path",{d:"m10.5 15.7.4-.9",key:"3js94g"}],["path",{d:"m13.1 9.2.4-.9",key:"18n7mc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JE=Z("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oB=Z("BrickWall",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 9v6",key:"199k2o"}],["path",{d:"M16 15v6",key:"8rj2es"}],["path",{d:"M16 3v6",key:"1j6rpj"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M8 15v6",key:"1stoo3"}],["path",{d:"M8 3v6",key:"vlvjmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lB=Z("BriefcaseBusiness",[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M22 13a18.15 18.15 0 0 1-20 0",key:"12hx5q"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cB=Z("BriefcaseConveyorBelt",[["path",{d:"M10 20v2",key:"1n8e1g"}],["path",{d:"M14 20v2",key:"1lq872"}],["path",{d:"M18 20v2",key:"10uadw"}],["path",{d:"M21 20H3",key:"kdqkdp"}],["path",{d:"M6 20v2",key:"a9bc87"}],["path",{d:"M8 16V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v12",key:"17n9tx"}],["rect",{x:"4",y:"6",width:"16",height:"10",rx:"2",key:"1097i5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dB=Z("BriefcaseMedical",[["path",{d:"M12 11v4",key:"a6ujw6"}],["path",{d:"M14 13h-4",key:"1pl8zg"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M18 6v14",key:"1mu4gy"}],["path",{d:"M6 6v14",key:"1s15cj"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const th=Z("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uB=Z("BringToFront",[["rect",{x:"8",y:"8",width:"8",height:"8",rx:"2",key:"yj20xf"}],["path",{d:"M4 10a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2",key:"1ltk23"}],["path",{d:"M14 20a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2",key:"1q24h9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hB=Z("Brush",[["path",{d:"m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08",key:"1styjt"}],["path",{d:"M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 0 0-3-3.02z",key:"z0l1mu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mB=Z("BugOff",[["path",{d:"M15 7.13V6a3 3 0 0 0-5.14-2.1L8 2",key:"vl8zik"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M22 13h-4v-2a4 4 0 0 0-4-4h-1.3",key:"1ou0bd"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M7.7 7.7A4 4 0 0 0 6 11v3a6 6 0 0 0 11.13 3.13",key:"1njkjs"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pB=Z("BugPlay",[["path",{d:"M12.765 21.522a.5.5 0 0 1-.765-.424v-8.196a.5.5 0 0 1 .765-.424l5.878 3.674a1 1 0 0 1 0 1.696z",key:"17shqo"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M18 11a4 4 0 0 0-4-4h-4a4 4 0 0 0-4 4v3a6.1 6.1 0 0 0 2 4.5",key:"1tjixy"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fB=Z("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aa=Z("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qk=Z("Building",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gB=Z("BusFront",[["path",{d:"M4 6 2 7",key:"1mqr15"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"m22 7-2-1",key:"1umjhc"}],["rect",{width:"16",height:"16",x:"4",y:"3",rx:"2",key:"1wxw4b"}],["path",{d:"M4 11h16",key:"mpoxn0"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M16 15h.01",key:"rnfrdf"}],["path",{d:"M6 19v2",key:"1loha6"}],["path",{d:"M18 21v-2",key:"sqyl04"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xB=Z("Bus",[["path",{d:"M8 6v6",key:"18i7km"}],["path",{d:"M15 6v6",key:"1sg6z9"}],["path",{d:"M2 12h19.6",key:"de5uta"}],["path",{d:"M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3",key:"1wwztk"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}],["path",{d:"M9 18h5",key:"lrx6i"}],["circle",{cx:"16",cy:"18",r:"2",key:"1v4tcr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yB=Z("CableCar",[["path",{d:"M10 3h.01",key:"lbucoy"}],["path",{d:"M14 2h.01",key:"1k8aa1"}],["path",{d:"m2 9 20-5",key:"1kz0j5"}],["path",{d:"M12 12V6.5",key:"1vbrij"}],["rect",{width:"16",height:"10",x:"4",y:"12",rx:"3",key:"if91er"}],["path",{d:"M9 12v5",key:"3anwtq"}],["path",{d:"M15 12v5",key:"5xh3zn"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vB=Z("Cable",[["path",{d:"M17 21v-2a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1",key:"10bnsj"}],["path",{d:"M19 15V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V9",key:"1eqmu1"}],["path",{d:"M21 21v-2h-4",key:"14zm7j"}],["path",{d:"M3 5h4V3",key:"z442eg"}],["path",{d:"M7 5a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1V3",key:"ebdjd7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _B=Z("CakeSlice",[["circle",{cx:"9",cy:"7",r:"2",key:"1305pl"}],["path",{d:"M7.2 7.9 3 11v9c0 .6.4 1 1 1h16c.6 0 1-.4 1-1v-9c0-2-3-6-7-8l-3.6 2.6",key:"xle13f"}],["path",{d:"M16 13H3",key:"1wpj08"}],["path",{d:"M16 17H3",key:"3lvfcd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ru=Z("Cake",[["path",{d:"M20 21v-8a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8",key:"1w3rig"}],["path",{d:"M4 16s.5-1 2-1 2.5 2 4 2 2.5-2 4-2 2.5 2 4 2 2-1 2-1",key:"n2jgmb"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M7 8v3",key:"1qtyvj"}],["path",{d:"M12 8v3",key:"hwp4zt"}],["path",{d:"M17 8v3",key:"1i6e5u"}],["path",{d:"M7 4h.01",key:"1bh4kh"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M17 4h.01",key:"1upcoc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bB=Z("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wB=Z("Calendar1",[["path",{d:"M11 14h1v4",key:"fy54vd"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jB=Z("CalendarArrowDown",[["path",{d:"m14 18 4 4 4-4",key:"1waygx"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M18 14v8",key:"irew45"}],["path",{d:"M21 11.354V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7.343",key:"bse4f3"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kB=Z("CalendarArrowUp",[["path",{d:"m14 18 4-4 4 4",key:"ftkppy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M18 22v-8",key:"su0gjh"}],["path",{d:"M21 11.343V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h9",key:"1exg90"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NB=Z("CalendarCheck2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 14V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"bce9hv"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m16 20 2 2 4-4",key:"13tcca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SB=Z("CalendarCheck",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m9 16 2 2 4-4",key:"19s6y9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eP=Z("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CB=Z("CalendarCog",[["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"M21 10.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"11kmuh"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ld=Z("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MB=Z("CalendarFold",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 17V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11Z",key:"kg77oy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M15 22v-4a2 2 0 0 1 2-2h4",key:"1gnbqr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TB=Z("CalendarHeart",[["path",{d:"M3 10h18V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7",key:"136lmk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21.29 14.7a2.43 2.43 0 0 0-2.65-.52c-.3.12-.57.3-.8.53l-.34.34-.35-.34a2.43 2.43 0 0 0-2.65-.53c-.3.12-.56.3-.79.53-.95.94-1 2.53.2 3.74L17.5 22l3.6-3.55c1.2-1.21 1.14-2.8.19-3.74Z",key:"1t7hil"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AB=Z("CalendarMinus2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M10 16h4",key:"17e571"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EB=Z("CalendarMinus",[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 15V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1scpom"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tP=Z("CalendarOff",[["path",{d:"M4.2 4.2A2 2 0 0 0 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 1.82-1.18",key:"16swn3"}],["path",{d:"M21 15.5V6a2 2 0 0 0-2-2H9.5",key:"yhw86o"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h7",key:"1wap6i"}],["path",{d:"M21 10h-5.5",key:"quycpq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PB=Z("CalendarPlus2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M10 16h4",key:"17e571"}],["path",{d:"M12 14v4",key:"1thi36"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q1=Z("CalendarPlus",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IB=Z("CalendarRange",[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M17 14h-6",key:"bkmgh3"}],["path",{d:"M13 18H7",key:"bb0bb7"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 18h.01",key:"1bdyru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LB=Z("CalendarSearch",[["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 11.75V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7.25",key:"1jrsq6"}],["path",{d:"m22 22-1.875-1.875",key:"13zax7"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DB=Z("CalendarSync",[["path",{d:"M11 10v4h4",key:"172dkj"}],["path",{d:"m11 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"vu0qm5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"m21 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"1qgeyt"}],["path",{d:"M21 22v-4h-4",key:"hrummi"}],["path",{d:"M21 8.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h4.3",key:"mctw84"}],["path",{d:"M3 10h4",key:"1el30a"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OB=Z("CalendarX2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m17 22 5-5",key:"1k6ppv"}],["path",{d:"m17 17 5 5",key:"p7ous7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RB=Z("CalendarX",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m14 14-4 4",key:"rymu2i"}],["path",{d:"m10 14 4 4",key:"3sz06r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const on=Z("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FB=Z("CameraOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16",key:"qmtpty"}],["path",{d:"M9.5 4h5L17 7h3a2 2 0 0 1 2 2v7.5",key:"1ufyfc"}],["path",{d:"M14.121 15.121A3 3 0 1 1 9.88 10.88",key:"11zox6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Og=Z("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zB=Z("CandyCane",[["path",{d:"M5.7 21a2 2 0 0 1-3.5-2l8.6-14a6 6 0 0 1 10.4 6 2 2 0 1 1-3.464-2 2 2 0 1 0-3.464-2Z",key:"isaq8g"}],["path",{d:"M17.75 7 15 2.1",key:"12x7e8"}],["path",{d:"M10.9 4.8 13 9",key:"100a87"}],["path",{d:"m7.9 9.7 2 4.4",key:"ntfhaj"}],["path",{d:"M4.9 14.7 7 18.9",key:"1x43jy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BB=Z("CandyOff",[["path",{d:"m8.5 8.5-1 1a4.95 4.95 0 0 0 7 7l1-1",key:"1ff4ui"}],["path",{d:"M11.843 6.187A4.947 4.947 0 0 1 16.5 7.5a4.947 4.947 0 0 1 1.313 4.657",key:"1sbrv4"}],["path",{d:"M14 16.5V14",key:"1maf8j"}],["path",{d:"M14 6.5v1.843",key:"1a6u6t"}],["path",{d:"M10 10v7.5",key:"80pj65"}],["path",{d:"m16 7 1-5 1.367.683A3 3 0 0 0 19.708 3H21v1.292a3 3 0 0 0 .317 1.341L22 7l-5 1",key:"11a9mt"}],["path",{d:"m8 17-1 5-1.367-.683A3 3 0 0 0 4.292 21H3v-1.292a3 3 0 0 0-.317-1.341L2 17l5-1",key:"3mjmon"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $B=Z("Candy",[["path",{d:"m9.5 7.5-2 2a4.95 4.95 0 1 0 7 7l2-2a4.95 4.95 0 1 0-7-7Z",key:"ue6khb"}],["path",{d:"M14 6.5v10",key:"5xnk7c"}],["path",{d:"M10 7.5v10",key:"1uew51"}],["path",{d:"m16 7 1-5 1.37.68A3 3 0 0 0 19.7 3H21v1.3c0 .46.1.92.32 1.33L22 7l-5 1",key:"b9cp6k"}],["path",{d:"m8 17-1 5-1.37-.68A3 3 0 0 0 4.3 21H3v-1.3a3 3 0 0 0-.32-1.33L2 17l5-1",key:"5lney8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qB=Z("Cannabis",[["path",{d:"M12 22v-4",key:"1utk9m"}],["path",{d:"M7 12c-1.5 0-4.5 1.5-5 3 3.5 1.5 6 1 6 1-1.5 1.5-2 3.5-2 5 2.5 0 4.5-1.5 6-3 1.5 1.5 3.5 3 6 3 0-1.5-.5-3.5-2-5 0 0 2.5.5 6-1-.5-1.5-3.5-3-5-3 1.5-1 4-4 4-6-2.5 0-5.5 1.5-7 3 0-2.5-.5-5-2-7-1.5 2-2 4.5-2 7-1.5-1.5-4.5-3-7-3 0 2 2.5 5 4 6",key:"1mezod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UB=Z("CaptionsOff",[["path",{d:"M10.5 5H19a2 2 0 0 1 2 2v8.5",key:"jqtk4d"}],["path",{d:"M17 11h-.5",key:"1961ue"}],["path",{d:"M19 19H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2",key:"1keqsi"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M7 11h4",key:"1o1z6v"}],["path",{d:"M7 15h2.5",key:"1ina1g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xw=Z("Captions",[["rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2",key:"12ruh7"}],["path",{d:"M7 15h4M15 15h2M7 11h2M13 11h4",key:"1ueiar"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VB=Z("CarFront",[["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HB=Z("CarTaxiFront",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WB=Z("Car",[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GB=Z("Caravan",[["path",{d:"M18 19V9a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v8a2 2 0 0 0 2 2h2",key:"19jm3t"}],["path",{d:"M2 9h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2",key:"13hakp"}],["path",{d:"M22 17v1a1 1 0 0 1-1 1H10v-9a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v9",key:"1crci8"}],["circle",{cx:"8",cy:"19",r:"2",key:"t8fc5s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KB=Z("Carrot",[["path",{d:"M2.27 21.7s9.87-3.5 12.73-6.36a4.5 4.5 0 0 0-6.36-6.37C5.77 11.84 2.27 21.7 2.27 21.7zM8.64 14l-2.05-2.04M15.34 15l-2.46-2.46",key:"rfqxbe"}],["path",{d:"M22 9s-1.33-2-3.5-2C16.86 7 15 9 15 9s1.33 2 3.5 2S22 9 22 9z",key:"6b25w4"}],["path",{d:"M15 2s-2 1.33-2 3.5S15 9 15 9s2-1.84 2-3.5C17 3.33 15 2 15 2z",key:"fn65lo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZB=Z("CaseLower",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YB=Z("CaseSensitive",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["circle",{cx:"18",cy:"12",r:"3",key:"1kchzo"}],["path",{d:"M21 9v6",key:"anns31"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XB=Z("CaseUpper",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["path",{d:"M15 11h4.5a2 2 0 0 1 0 4H15V7h4a2 2 0 0 1 0 4",key:"1sqfas"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QB=Z("CassetteTape",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["circle",{cx:"8",cy:"10",r:"2",key:"1xl4ub"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"10",r:"2",key:"r14t7q"}],["path",{d:"m6 20 .7-2.9A1.4 1.4 0 0 1 8.1 16h7.8a1.4 1.4 0 0 1 1.4 1l.7 3",key:"l01ucn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JB=Z("Cast",[["path",{d:"M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6",key:"3zrzxg"}],["path",{d:"M2 12a9 9 0 0 1 8 8",key:"g6cvee"}],["path",{d:"M2 16a5 5 0 0 1 4 4",key:"1y1dii"}],["line",{x1:"2",x2:"2.01",y1:"20",y2:"20",key:"xu2jvo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e9=Z("Castle",[["path",{d:"M22 20v-9H2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2Z",key:"109fe4"}],["path",{d:"M18 11V4H6v7",key:"mon5oj"}],["path",{d:"M15 22v-4a3 3 0 0 0-3-3a3 3 0 0 0-3 3v4",key:"1k4jtn"}],["path",{d:"M22 11V9",key:"3zbp94"}],["path",{d:"M2 11V9",key:"1x5rnq"}],["path",{d:"M6 4V2",key:"1rsq15"}],["path",{d:"M18 4V2",key:"1jsdo1"}],["path",{d:"M10 4V2",key:"75d9ly"}],["path",{d:"M14 4V2",key:"8nj3z6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t9=Z("Cat",[["path",{d:"M12 5c.67 0 1.35.09 2 .26 1.78-2 5.03-2.84 6.42-2.26 1.4.58-.42 7-.42 7 .57 1.07 1 2.24 1 3.44C21 17.9 16.97 21 12 21s-9-3-9-7.56c0-1.25.5-2.4 1-3.44 0 0-1.89-6.42-.5-7 1.39-.58 4.72.23 6.5 2.23A9.04 9.04 0 0 1 12 5Z",key:"x6xyqk"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M11.25 16.25h1.5L12 17l-.75-.75Z",key:"12kq1m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s9=Z("Cctv",[["path",{d:"M16.75 12h3.632a1 1 0 0 1 .894 1.447l-2.034 4.069a1 1 0 0 1-1.708.134l-2.124-2.97",key:"ir91b5"}],["path",{d:"M17.106 9.053a1 1 0 0 1 .447 1.341l-3.106 6.211a1 1 0 0 1-1.342.447L3.61 12.3a2.92 2.92 0 0 1-1.3-3.91L3.69 5.6a2.92 2.92 0 0 1 3.92-1.3z",key:"jlp8i1"}],["path",{d:"M2 19h3.76a2 2 0 0 0 1.8-1.1L9 15",key:"19bib8"}],["path",{d:"M2 21v-4",key:"l40lih"}],["path",{d:"M7 9h.01",key:"19b3jx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yw=Z("ChartArea",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vw=Z("ChartBarBig",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"7",y:"13",width:"9",height:"4",rx:"1",key:"1iip1u"}],["rect",{x:"7",y:"5",width:"12",height:"4",rx:"1",key:"1anskk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r9=Z("ChartBarDecreasing",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11h8",key:"1feolt"}],["path",{d:"M7 16h3",key:"ur6vzw"}],["path",{d:"M7 6h12",key:"sz5b0d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n9=Z("ChartBarIncreasing",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11h8",key:"1feolt"}],["path",{d:"M7 16h12",key:"wsnu98"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a9=Z("ChartBarStacked",[["path",{d:"M11 13v4",key:"vyy2rb"}],["path",{d:"M15 5v4",key:"1gx88a"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"7",y:"13",width:"9",height:"4",rx:"1",key:"1iip1u"}],["rect",{x:"7",y:"5",width:"12",height:"4",rx:"1",key:"1anskk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _w=Z("ChartBar",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16h8",key:"srdodz"}],["path",{d:"M7 11h12",key:"127s9w"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bw=Z("ChartCandlestick",[["path",{d:"M9 5v4",key:"14uxtq"}],["rect",{width:"4",height:"6",x:"7",y:"9",rx:"1",key:"f4fvz0"}],["path",{d:"M9 15v2",key:"r5rk32"}],["path",{d:"M17 3v2",key:"1l2re6"}],["rect",{width:"4",height:"8",x:"15",y:"5",rx:"1",key:"z38je5"}],["path",{d:"M17 13v3",key:"5l0wba"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ww=Z("ChartColumnBig",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i9=Z("ChartColumnDecreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17v-3",key:"1sqioe"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17V5",key:"1wzmnc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jw=Z("ChartColumnIncreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17V5",key:"sfb6ij"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o9=Z("ChartColumnStacked",[["path",{d:"M11 13H7",key:"t0o9gq"}],["path",{d:"M19 9h-4",key:"rera1j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xo=Z("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l9=Z("ChartGantt",[["path",{d:"M10 6h8",key:"zvc2xc"}],["path",{d:"M12 16h6",key:"yi5mkt"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 11h7",key:"wz2hg0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kw=Z("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c9=Z("ChartNetwork",[["path",{d:"m13.11 7.664 1.78 2.672",key:"go2gg9"}],["path",{d:"m14.162 12.788-3.324 1.424",key:"11x848"}],["path",{d:"m20 4-6.06 1.515",key:"1wxxh7"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["circle",{cx:"12",cy:"6",r:"2",key:"1jj5th"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}],["circle",{cx:"9",cy:"15",r:"2",key:"lf2ghp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d9=Z("ChartNoAxesColumnDecreasing",[["path",{d:"M12 20V10",key:"g8npz5"}],["path",{d:"M18 20v-4",key:"8uic4z"}],["path",{d:"M6 20V4",key:"1w1bmo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nw=Z("ChartNoAxesColumnIncreasing",[["line",{x1:"12",x2:"12",y1:"20",y2:"10",key:"1vz5eb"}],["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["line",{x1:"6",x2:"6",y1:"20",y2:"16",key:"hq0ia6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sw=Z("ChartNoAxesColumn",[["line",{x1:"18",x2:"18",y1:"20",y2:"10",key:"1xfpm4"}],["line",{x1:"12",x2:"12",y1:"20",y2:"4",key:"be30l9"}],["line",{x1:"6",x2:"6",y1:"20",y2:"14",key:"1r4le6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u9=Z("ChartNoAxesCombined",[["path",{d:"M12 16v5",key:"zza2cw"}],["path",{d:"M16 14v7",key:"1g90b9"}],["path",{d:"M20 10v11",key:"1iqoj0"}],["path",{d:"m22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15",key:"1fw8x9"}],["path",{d:"M4 18v3",key:"1yp0dc"}],["path",{d:"M8 14v7",key:"n3cwzv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cw=Z("ChartNoAxesGantt",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mw=Z("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tw=Z("ChartScatter",[["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["circle",{cx:"18.5",cy:"5.5",r:".5",fill:"currentColor",key:"lysivs"}],["circle",{cx:"11.5",cy:"11.5",r:".5",fill:"currentColor",key:"byv1b8"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["circle",{cx:"17.5",cy:"14.5",r:".5",fill:"currentColor",key:"1gjh6j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h9=Z("ChartSpline",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16c.5-2 1.5-7 4-7 2 0 2 3 4 3 2.5 0 4.5-5 5-7",key:"lw07rv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m9=Z("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ua=Z("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p9=Z("ChefHat",[["path",{d:"M17 21a1 1 0 0 0 1-1v-5.35c0-.457.316-.844.727-1.041a4 4 0 0 0-2.134-7.589 5 5 0 0 0-9.186 0 4 4 0 0 0-2.134 7.588c.411.198.727.585.727 1.041V20a1 1 0 0 0 1 1Z",key:"1qvrer"}],["path",{d:"M6 17h12",key:"1jwigz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f9=Z("Cherry",[["path",{d:"M2 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z",key:"cvxqlc"}],["path",{d:"M12 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z",key:"1ostrc"}],["path",{d:"M7 14c3.22-2.91 4.29-8.75 5-12 1.66 2.38 4.94 9 5 12",key:"hqx58h"}],["path",{d:"M22 9c-4.29 0-7.14-2.33-10-7 5.71 0 10 4.67 10 7Z",key:"eykp1o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vo=Z("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g9=Z("ChevronFirst",[["path",{d:"m17 18-6-6 6-6",key:"1yerx2"}],["path",{d:"M7 6v12",key:"1p53r6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x9=Z("ChevronLast",[["path",{d:"m7 18 6-6-6-6",key:"lwmzdw"}],["path",{d:"M17 6v12",key:"1o0aio"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zl=Z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ha=Z("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rg=Z("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y9=Z("ChevronsDownUp",[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v9=Z("ChevronsDown",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _9=Z("ChevronsLeftRightEllipsis",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b9=Z("ChevronsLeftRight",[["path",{d:"m9 7-5 5 5 5",key:"j5w590"}],["path",{d:"m15 7 5 5-5 5",key:"1bl6da"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w9=Z("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j9=Z("ChevronsRightLeft",[["path",{d:"m20 17-5-5 5-5",key:"30x0n2"}],["path",{d:"m4 17 5-5-5-5",key:"16spf4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k9=Z("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const df=Z("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N9=Z("ChevronsUp",[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S9=Z("Chrome",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["line",{x1:"21.17",x2:"12",y1:"8",y2:"8",key:"a0cw5f"}],["line",{x1:"3.95",x2:"8.54",y1:"6.06",y2:"14",key:"1kftof"}],["line",{x1:"10.88",x2:"15.46",y1:"21.94",y2:"14",key:"1ymyh8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C9=Z("Church",[["path",{d:"M10 9h4",key:"u4k05v"}],["path",{d:"M12 7v5",key:"ma6bk"}],["path",{d:"M14 22v-4a2 2 0 0 0-4 0v4",key:"1pdhuj"}],["path",{d:"M18 22V5.618a1 1 0 0 0-.553-.894l-4.553-2.277a2 2 0 0 0-1.788 0L6.553 4.724A1 1 0 0 0 6 5.618V22",key:"1rkokr"}],["path",{d:"m18 7 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9.618a1 1 0 0 1 .553-.894L6 7",key:"1w6esw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M9=Z("CigaretteOff",[["path",{d:"M12 12H3a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h13",key:"1gdiyg"}],["path",{d:"M18 8c0-2.5-2-2.5-2-5",key:"1il607"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M21 12a1 1 0 0 1 1 1v2a1 1 0 0 1-.5.866",key:"166zjj"}],["path",{d:"M22 8c0-2.5-2-2.5-2-5",key:"1gah44"}],["path",{d:"M7 12v4",key:"jqww69"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T9=Z("Cigarette",[["path",{d:"M17 12H3a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h14",key:"1mb5g1"}],["path",{d:"M18 8c0-2.5-2-2.5-2-5",key:"1il607"}],["path",{d:"M21 16a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"1yl5r7"}],["path",{d:"M22 8c0-2.5-2-2.5-2-5",key:"1gah44"}],["path",{d:"M7 12v4",key:"jqww69"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qo=Z("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aw=Z("CircleArrowDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ew=Z("CircleArrowLeft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"m12 8-4 4 4 4",key:"15vm53"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pw=Z("CircleArrowOutDownLeft",[["path",{d:"M2 12a10 10 0 1 1 10 10",key:"1yn6ov"}],["path",{d:"m2 22 10-10",key:"28ilpk"}],["path",{d:"M8 22H2v-6",key:"sulq54"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iw=Z("CircleArrowOutDownRight",[["path",{d:"M12 22a10 10 0 1 1 10-10",key:"130bv5"}],["path",{d:"M22 22 12 12",key:"131aw7"}],["path",{d:"M22 16v6h-6",key:"1gvm70"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lw=Z("CircleArrowOutUpLeft",[["path",{d:"M2 8V2h6",key:"hiwtdz"}],["path",{d:"m2 2 10 10",key:"1oh8rs"}],["path",{d:"M12 2A10 10 0 1 1 2 12",key:"rrk4fa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dw=Z("CircleArrowOutUpRight",[["path",{d:"M22 12A10 10 0 1 1 12 2",key:"1fm58d"}],["path",{d:"M22 2 12 12",key:"yg2myt"}],["path",{d:"M16 2h6v6",key:"zan5cs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ow=Z("CircleArrowRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rw=Z("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gi=Z("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const da=Z("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fw=Z("CircleChevronDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zw=Z("CircleChevronLeft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14 16-4-4 4-4",key:"ojs7w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bw=Z("CircleChevronRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $w=Z("CircleChevronUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m8 14 4-4 4 4",key:"fy2ptz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A9=Z("CircleDashed",[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qw=Z("CircleDivide",[["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}],["line",{x1:"12",x2:"12",y1:"16",y2:"16",key:"aqc6ln"}],["line",{x1:"12",x2:"12",y1:"8",y2:"8",key:"1mkcni"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E9=Z("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P9=Z("CircleDotDashed",[["path",{d:"M10.1 2.18a9.93 9.93 0 0 1 3.8 0",key:"1qdqn0"}],["path",{d:"M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7",key:"1bq7p6"}],["path",{d:"M21.82 10.1a9.93 9.93 0 0 1 0 3.8",key:"1rlaqf"}],["path",{d:"M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69",key:"1xk03u"}],["path",{d:"M13.9 21.82a9.94 9.94 0 0 1-3.8 0",key:"l7re25"}],["path",{d:"M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7",key:"1v18p6"}],["path",{d:"M2.18 13.9a9.93 9.93 0 0 1 0-3.8",key:"xdo6bj"}],["path",{d:"M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69",key:"1jjmaz"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I9=Z("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L9=Z("CircleEllipsis",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D9=Z("CircleEqual",[["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O9=Z("CircleFadingArrowUp",[["path",{d:"M12 2a10 10 0 0 1 7.38 16.75",key:"175t95"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}],["path",{d:"M2.5 8.875a10 10 0 0 0-.5 3",key:"1vce0s"}],["path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4",key:"o3fkw4"}],["path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857",key:"1szpfk"}],["path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38",key:"9yhvd4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R9=Z("CircleFadingPlus",[["path",{d:"M12 2a10 10 0 0 1 7.38 16.75",key:"175t95"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M2.5 8.875a10 10 0 0 0-.5 3",key:"1vce0s"}],["path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4",key:"o3fkw4"}],["path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857",key:"1szpfk"}],["path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38",key:"9yhvd4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uw=Z("CircleGauge",[["path",{d:"M15.6 2.7a10 10 0 1 0 5.7 5.7",key:"1e0p6d"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M13.4 10.6 19 5",key:"1kr7tw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i0=Z("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vw=Z("CircleMinus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F9=Z("CircleOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.35 2.69A10 10 0 0 1 21.3 15.65",key:"1pfsoa"}],["path",{d:"M19.08 19.08A10 10 0 1 1 4.92 4.92",key:"1ablyi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hw=Z("CircleParkingOff",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m5 5 14 14",key:"11anup"}],["path",{d:"M13 13a3 3 0 1 0 0-6H9v2",key:"uoagbd"}],["path",{d:"M9 17v-2.34",key:"a9qo08"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ww=Z("CircleParking",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9 17V7h4a3 3 0 0 1 0 6H9",key:"1dfk2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gw=Z("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kw=Z("CirclePercent",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ym=Z("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zw=Z("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yw=Z("CirclePower",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xw=Z("CircleSlash2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z9=Z("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qw=Z("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jw=Z("CircleUserRound",[["path",{d:"M18 20a6 6 0 0 0-12 0",key:"1qehca"}],["circle",{cx:"12",cy:"10",r:"4",key:"1h16sb"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e2=Z("CircleUser",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kc=Z("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gc=Z("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B9=Z("CircuitBoard",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M11 9h4a2 2 0 0 0 2-2V3",key:"1ve2rv"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"M7 21v-4a2 2 0 0 1 2-2h4",key:"1fwkro"}],["circle",{cx:"15",cy:"15",r:"2",key:"3i40o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $9=Z("Citrus",[["path",{d:"M21.66 17.67a1.08 1.08 0 0 1-.04 1.6A12 12 0 0 1 4.73 2.38a1.1 1.1 0 0 1 1.61-.04z",key:"4ite01"}],["path",{d:"M19.65 15.66A8 8 0 0 1 8.35 4.34",key:"1gxipu"}],["path",{d:"m14 10-5.5 5.5",key:"92pfem"}],["path",{d:"M14 17.85V10H6.15",key:"xqmtsk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q9=Z("Clapperboard",[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o5=Z("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U9=Z("ClipboardCopy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J1=Z("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V9=Z("ClipboardMinus",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 14h6",key:"159ibu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H9=Z("ClipboardPaste",[["path",{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",key:"1pp7kr"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10",key:"2ik1ml"}],["path",{d:"m17 10 4 4-4 4",key:"vp2hj1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t2=Z("ClipboardPenLine",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.5",key:"1but9f"}],["path",{d:"M16 4h2a2 2 0 0 1 1.73 1",key:"1p8n7l"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s2=Z("ClipboardPen",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-5.5",key:"cereej"}],["path",{d:"M4 13.5V6a2 2 0 0 1 2-2h2",key:"5ua5vh"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W9=Z("ClipboardPlus",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 14h6",key:"159ibu"}],["path",{d:"M12 17v-6",key:"1y8rbf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G9=Z("ClipboardType",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 12v-1h6v1",key:"iehl6m"}],["path",{d:"M11 17h2",key:"12w5me"}],["path",{d:"M12 11v6",key:"1bwqyc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K9=Z("ClipboardX",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m15 11-6 6",key:"1toa9n"}],["path",{d:"m9 11 6 6",key:"wlibny"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z9=Z("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y9=Z("Clock1",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 14.5 8",key:"12zbmj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X9=Z("Clock10",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 10",key:"atfzqc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q9=Z("Clock11",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 9.5 8",key:"l5bg6f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J9=Z("Clock12",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12",key:"1fub01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e$=Z("Clock2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 10",key:"1g230d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t$=Z("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s$=Z("Clock4",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r$=Z("Clock5",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 14.5 16",key:"1pcbox"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n$=Z("Clock6",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 12 16.5",key:"hb2qv6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a$=Z("Clock7",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 9.5 16",key:"ka3394"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i$=Z("Clock8",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 14",key:"tmc9b4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o$=Z("Clock9",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 7.5 12",key:"1k60p0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l$=Z("ClockAlert",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["path",{d:"M16 21.16a10 10 0 1 1 5-13.516",key:"cxo92l"}],["path",{d:"M20 11.5v6",key:"2ei3xq"}],["path",{d:"M20 21.5h.01",key:"1r2dzp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c$=Z("ClockArrowDown",[["path",{d:"M12.338 21.994A10 10 0 1 1 21.925 13.227",key:"1i7shu"}],["path",{d:"M12 6v6l2 1",key:"19cm8n"}],["path",{d:"m14 18 4 4 4-4",key:"1waygx"}],["path",{d:"M18 14v8",key:"irew45"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d$=Z("ClockArrowUp",[["path",{d:"M13.228 21.925A10 10 0 1 1 21.994 12.338",key:"1fzlyi"}],["path",{d:"M12 6v6l1.562.781",key:"1ujuk9"}],["path",{d:"m14 18 4-4 4 4",key:"ftkppy"}],["path",{d:"M18 22v-8",key:"su0gjh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tn=Z("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u$=Z("CloudAlert",[["path",{d:"M12 12v4",key:"tww15h"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M17 18h.5a1 1 0 0 0 0-9h-1.79A7 7 0 1 0 7 17.708",key:"xsb5ju"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h$=Z("CloudCog",[["circle",{cx:"12",cy:"17",r:"3",key:"1spfwm"}],["path",{d:"M4.2 15.1A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2",key:"zaobp"}],["path",{d:"m15.7 18.4-.9-.3",key:"4qxpbn"}],["path",{d:"m9.2 15.9-.9-.3",key:"17q7o2"}],["path",{d:"m10.6 20.7.3-.9",key:"1pf4s2"}],["path",{d:"m13.1 14.2.3-.9",key:"1mnuqm"}],["path",{d:"m13.6 20.7-.4-1",key:"1jpd1m"}],["path",{d:"m10.8 14.3-.4-1",key:"17ugyy"}],["path",{d:"m8.3 18.6 1-.4",key:"s42vdx"}],["path",{d:"m14.7 15.8 1-.4",key:"2wizun"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r2=Z("CloudDownload",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m$=Z("CloudDrizzle",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M8 19v1",key:"1dk2by"}],["path",{d:"M8 14v1",key:"84yxot"}],["path",{d:"M16 19v1",key:"v220m7"}],["path",{d:"M16 14v1",key:"g12gj6"}],["path",{d:"M12 21v1",key:"q8vafk"}],["path",{d:"M12 16v1",key:"1mx6rx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p$=Z("CloudFog",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 17H7",key:"pygtm1"}],["path",{d:"M17 21H9",key:"1u2q02"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f$=Z("CloudHail",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v2",key:"a1is7l"}],["path",{d:"M8 14v2",key:"1e9m6t"}],["path",{d:"M16 20h.01",key:"xwek51"}],["path",{d:"M8 20h.01",key:"1vjney"}],["path",{d:"M12 16v2",key:"z66u1j"}],["path",{d:"M12 22h.01",key:"1urd7a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g$=Z("CloudLightning",[["path",{d:"M6 16.326A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 .5 8.973",key:"1cez44"}],["path",{d:"m13 12-3 5h4l-3 5",key:"1t22er"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x$=Z("CloudMoonRain",[["path",{d:"M10.188 8.5A6 6 0 0 1 16 4a1 1 0 0 0 6 6 6 6 0 0 1-3 5.197",key:"erj67n"}],["path",{d:"M11 20v2",key:"174qtz"}],["path",{d:"M3 20a5 5 0 1 1 8.9-4H13a3 3 0 0 1 2 5.24",key:"1qmrp3"}],["path",{d:"M7 19v2",key:"12npes"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y$=Z("CloudMoon",[["path",{d:"M10.188 8.5A6 6 0 0 1 16 4a1 1 0 0 0 6 6 6 6 0 0 1-3 5.197",key:"erj67n"}],["path",{d:"M13 16a3 3 0 1 1 0 6H7a5 5 0 1 1 4.9-6Z",key:"p44pc9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v$=Z("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _$=Z("CloudRainWind",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m9.2 22 3-7",key:"sb5f6j"}],["path",{d:"m9 13-3 7",key:"500co5"}],["path",{d:"m17 13-3 7",key:"8t2fiy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b$=Z("CloudRain",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v6",key:"1j4efv"}],["path",{d:"M8 14v6",key:"17c4r9"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w$=Z("CloudSnow",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M8 19h.01",key:"puxtts"}],["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M12 21h.01",key:"h35vbk"}],["path",{d:"M16 15h.01",key:"rnfrdf"}],["path",{d:"M16 19h.01",key:"1vcnzz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j$=Z("CloudSunRain",[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M3 20a5 5 0 1 1 8.9-4H13a3 3 0 0 1 2 5.24",key:"1qmrp3"}],["path",{d:"M11 20v2",key:"174qtz"}],["path",{d:"M7 19v2",key:"12npes"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k$=Z("CloudSun",[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z",key:"s09mg5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n2=Z("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N$=Z("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S$=Z("Cloudy",[["path",{d:"M17.5 21H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"gqqjvc"}],["path",{d:"M22 10a3 3 0 0 0-3-3h-2.207a5.502 5.502 0 0 0-10.702.5",key:"1p2s76"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y0=Z("Clover",[["path",{d:"M16.17 7.83 2 22",key:"t58vo8"}],["path",{d:"M4.02 12a2.827 2.827 0 1 1 3.81-4.17A2.827 2.827 0 1 1 12 4.02a2.827 2.827 0 1 1 4.17 3.81A2.827 2.827 0 1 1 19.98 12a2.827 2.827 0 1 1-3.81 4.17A2.827 2.827 0 1 1 12 19.98a2.827 2.827 0 1 1-4.17-3.81A1 1 0 1 1 4 12",key:"17k36q"}],["path",{d:"m7.83 7.83 8.34 8.34",key:"1d7sxk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C$=Z("Club",[["path",{d:"M17.28 9.05a5.5 5.5 0 1 0-10.56 0A5.5 5.5 0 1 0 12 17.66a5.5 5.5 0 1 0 5.28-8.6Z",key:"27yuqz"}],["path",{d:"M12 17.66L12 22",key:"ogfahf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a2=Z("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jk=Z("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M$=Z("Codepen",[["polygon",{points:"12 2 22 8.5 22 15.5 12 22 2 15.5 2 8.5 12 2",key:"srzb37"}],["line",{x1:"12",x2:"12",y1:"22",y2:"15.5",key:"1t73f2"}],["polyline",{points:"22 8.5 12 15.5 2 8.5",key:"ajlxae"}],["polyline",{points:"2 15.5 12 8.5 22 15.5",key:"susrui"}],["line",{x1:"12",x2:"12",y1:"2",y2:"8.5",key:"2cldga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T$=Z("Codesandbox",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}],["polyline",{points:"7.5 4.21 12 6.81 16.5 4.21",key:"fabo96"}],["polyline",{points:"7.5 19.79 7.5 14.6 3 12",key:"z377f1"}],["polyline",{points:"21 12 16.5 14.6 16.5 19.79",key:"9nrev1"}],["polyline",{points:"3.27 6.96 12 12.01 20.73 6.96",key:"1180pa"}],["line",{x1:"12",x2:"12",y1:"22.08",y2:"12",key:"3z3uq6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eN=Z("Coffee",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A$=Z("Cog",[["path",{d:"M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",key:"sobvz5"}],["path",{d:"M12 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",key:"11i496"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sP=Z("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i2=Z("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o2=Z("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E$=Z("Columns4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7.5 3v18",key:"w0wo6v"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M16.5 3v18",key:"10tjh1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P$=Z("Combine",[["path",{d:"M10 18H5a3 3 0 0 1-3-3v-1",key:"ru65g8"}],["path",{d:"M14 2a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"e30een"}],["path",{d:"M20 2a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"2ahx8o"}],["path",{d:"m7 21 3-3-3-3",key:"127cv2"}],["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I$=Z("Command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L$=Z("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D$=Z("Component",[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O$=Z("Computer",[["rect",{width:"14",height:"8",x:"5",y:"2",rx:"2",key:"wc9tft"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h2",key:"rwmk9e"}],["path",{d:"M12 18h6",key:"aqd8w3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R$=Z("ConciergeBell",[["path",{d:"M3 20a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1Z",key:"1pvr1r"}],["path",{d:"M20 16a8 8 0 1 0-16 0",key:"1pa543"}],["path",{d:"M12 4v4",key:"1bq03y"}],["path",{d:"M10 4h4",key:"1xpv9s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F$=Z("Cone",[["path",{d:"m20.9 18.55-8-15.98a1 1 0 0 0-1.8 0l-8 15.98",key:"53pte7"}],["ellipse",{cx:"12",cy:"19",rx:"9",ry:"3",key:"1ji25f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z$=Z("Construction",[["rect",{x:"2",y:"6",width:"20",height:"8",rx:"1",key:"1estib"}],["path",{d:"M17 14v7",key:"7m2elx"}],["path",{d:"M7 14v7",key:"1cm7wv"}],["path",{d:"M17 3v3",key:"1v4jwn"}],["path",{d:"M7 3v3",key:"7o6guu"}],["path",{d:"M10 14 2.3 6.3",key:"1023jk"}],["path",{d:"m14 6 7.7 7.7",key:"1s8pl2"}],["path",{d:"m8 6 8 8",key:"hl96qh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l2=Z("ContactRound",[["path",{d:"M16 2v2",key:"scm5qe"}],["path",{d:"M17.915 22a6 6 0 0 0-12 0",key:"suqz9p"}],["path",{d:"M8 2v2",key:"pbkmx"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tN=Z("Contact",[["path",{d:"M16 2v2",key:"scm5qe"}],["path",{d:"M7 22v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2",key:"1waht3"}],["path",{d:"M8 2v2",key:"pbkmx"}],["circle",{cx:"12",cy:"11",r:"3",key:"itu57m"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B$=Z("Container",[["path",{d:"M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z",key:"1t2lqe"}],["path",{d:"M10 21.9V14L2.1 9.1",key:"o7czzq"}],["path",{d:"m10 14 11.9-6.9",key:"zm5e20"}],["path",{d:"M14 19.8v-8.1",key:"159ecu"}],["path",{d:"M18 17.5V9.4",key:"11uown"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $$=Z("Contrast",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 18a6 6 0 0 0 0-12v12z",key:"j4l70d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q$=Z("Cookie",[["path",{d:"M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5",key:"laymnq"}],["path",{d:"M8.5 8.5v.01",key:"ue8clq"}],["path",{d:"M16 15.5v.01",key:"14dtrp"}],["path",{d:"M12 12v.01",key:"u5ubse"}],["path",{d:"M11 17v.01",key:"1hyl5a"}],["path",{d:"M7 14v.01",key:"uct60s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U$=Z("CookingPot",[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M20 12v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8",key:"u0tga0"}],["path",{d:"m4 8 16-4",key:"16g0ng"}],["path",{d:"m8.86 6.78-.45-1.81a2 2 0 0 1 1.45-2.43l1.94-.48a2 2 0 0 1 2.43 1.46l.45 1.8",key:"12cejc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V$=Z("CopyCheck",[["path",{d:"m12 15 2 2 4-4",key:"2c609p"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H$=Z("CopyMinus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W$=Z("CopyPlus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G$=Z("CopySlash",[["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K$=Z("CopyX",[["line",{x1:"12",x2:"18",y1:"12",y2:"18",key:"1rg63v"}],["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ni=Z("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z$=Z("Copyleft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.17 14.83a4 4 0 1 0 0-5.66",key:"1sveal"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y$=Z("Copyright",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M14.83 14.83a4 4 0 1 1 0-5.66",key:"1i56pz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X$=Z("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q$=Z("CornerDownRight",[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J$=Z("CornerLeftDown",[["polyline",{points:"14 15 9 20 4 15",key:"nkc4i"}],["path",{d:"M20 4h-7a4 4 0 0 0-4 4v12",key:"nbpdq2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eq=Z("CornerLeftUp",[["polyline",{points:"14 9 9 4 4 9",key:"m9oyvo"}],["path",{d:"M20 20h-7a4 4 0 0 1-4-4V4",key:"1blwi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tq=Z("CornerRightDown",[["polyline",{points:"10 15 15 20 20 15",key:"axus6l"}],["path",{d:"M4 4h7a4 4 0 0 1 4 4v12",key:"wcbgct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sq=Z("CornerRightUp",[["polyline",{points:"10 9 15 4 20 9",key:"1lr6px"}],["path",{d:"M4 20h7a4 4 0 0 0 4-4V4",key:"1plgdj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rq=Z("CornerUpLeft",[["polyline",{points:"9 14 4 9 9 4",key:"881910"}],["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nq=Z("CornerUpRight",[["polyline",{points:"15 14 20 9 15 4",key:"1tbx3s"}],["path",{d:"M4 20v-7a4 4 0 0 1 4-4h12",key:"1lu4f8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aq=Z("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iq=Z("CreativeCommons",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M10 9.3a2.8 2.8 0 0 0-3.5 1 3.1 3.1 0 0 0 0 3.4 2.7 2.7 0 0 0 3.5 1",key:"1ss3eq"}],["path",{d:"M17 9.3a2.8 2.8 0 0 0-3.5 1 3.1 3.1 0 0 0 0 3.4 2.7 2.7 0 0 0 3.5 1",key:"1od56t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uf=Z("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oq=Z("Croissant",[["path",{d:"m4.6 13.11 5.79-3.21c1.89-1.05 4.79 1.78 3.71 3.71l-3.22 5.81C8.8 23.16.79 15.23 4.6 13.11Z",key:"1ozxlb"}],["path",{d:"m10.5 9.5-1-2.29C9.2 6.48 8.8 6 8 6H4.5C2.79 6 2 6.5 2 8.5a7.71 7.71 0 0 0 2 4.83",key:"ffuyb5"}],["path",{d:"M8 6c0-1.55.24-4-2-4-2 0-2.5 2.17-2.5 4",key:"osnpzi"}],["path",{d:"m14.5 13.5 2.29 1c.73.3 1.21.7 1.21 1.5v3.5c0 1.71-.5 2.5-2.5 2.5a7.71 7.71 0 0 1-4.83-2",key:"1vubaw"}],["path",{d:"M18 16c1.55 0 4-.24 4 2 0 2-2.17 2.5-4 2.5",key:"wxr772"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lq=Z("Crop",[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cq=Z("Cross",[["path",{d:"M4 9a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h4a1 1 0 0 1 1 1v4a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-4a1 1 0 0 1 1-1h4a2 2 0 0 0 2-2v-2a2 2 0 0 0-2-2h-4a1 1 0 0 1-1-1V4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4a1 1 0 0 1-1 1z",key:"1xbrqy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dq=Z("Crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bh=Z("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uq=Z("Cuboid",[["path",{d:"m21.12 6.4-6.05-4.06a2 2 0 0 0-2.17-.05L2.95 8.41a2 2 0 0 0-.95 1.7v5.82a2 2 0 0 0 .88 1.66l6.05 4.07a2 2 0 0 0 2.17.05l9.95-6.12a2 2 0 0 0 .95-1.7V8.06a2 2 0 0 0-.88-1.66Z",key:"1u2ovd"}],["path",{d:"M10 22v-8L2.25 9.15",key:"11pn4q"}],["path",{d:"m10 14 11.77-6.87",key:"1kt1wh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hq=Z("CupSoda",[["path",{d:"m6 8 1.75 12.28a2 2 0 0 0 2 1.72h4.54a2 2 0 0 0 2-1.72L18 8",key:"8166m8"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M7 15a6.47 6.47 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"yjz344"}],["path",{d:"m12 8 1-6h2",key:"3ybfa4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mq=Z("Currency",[["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}],["line",{x1:"3",x2:"6",y1:"3",y2:"6",key:"1jkytn"}],["line",{x1:"21",x2:"18",y1:"3",y2:"6",key:"14zfjt"}],["line",{x1:"3",x2:"6",y1:"21",y2:"18",key:"iusuec"}],["line",{x1:"21",x2:"18",y1:"21",y2:"18",key:"yj2dd7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pq=Z("Cylinder",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fq=Z("Dam",[["path",{d:"M11 11.31c1.17.56 1.54 1.69 3.5 1.69 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"157kva"}],["path",{d:"M11.75 18c.35.5 1.45 1 2.75 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"d7q6m6"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M7 3a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1L10 4a1 1 0 0 0-1-1z",key:"pr6s65"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gq=Z("DatabaseBackup",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 12a9 3 0 0 0 5 2.69",key:"1ui2ym"}],["path",{d:"M21 9.3V5",key:"6k6cib"}],["path",{d:"M3 5v14a9 3 0 0 0 6.47 2.88",key:"i62tjy"}],["path",{d:"M12 12v4h4",key:"1bxaet"}],["path",{d:"M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16",key:"1f4ei9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xq=Z("DatabaseZap",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 15 21.84",key:"14ibmq"}],["path",{d:"M21 5V8",key:"1marbg"}],["path",{d:"M21 12L18 17H22L19 22",key:"zafso"}],["path",{d:"M3 12A9 3 0 0 0 14.59 14.87",key:"1y4wr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yq=Z("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vq=Z("Delete",[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _q=Z("Dessert",[["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["path",{d:"M10.2 3.2C5.5 4 2 8.1 2 13a2 2 0 0 0 4 0v-1a2 2 0 0 1 4 0v4a2 2 0 0 0 4 0v-4a2 2 0 0 1 4 0v1a2 2 0 0 0 4 0c0-4.9-3.5-9-8.2-9.8",key:"lfo06j"}],["path",{d:"M3.2 14.8a9 9 0 0 0 17.6 0",key:"12xarc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bq=Z("Diameter",[["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["circle",{cx:"5",cy:"5",r:"2",key:"1gwv83"}],["path",{d:"M6.48 3.66a10 10 0 0 1 13.86 13.86",key:"xr8kdq"}],["path",{d:"m6.41 6.41 11.18 11.18",key:"uhpjw7"}],["path",{d:"M3.66 6.48a10 10 0 0 0 13.86 13.86",key:"cldpwv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wq=Z("DiamondMinus",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c2=Z("DiamondPercent",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0Z",key:"1tpxz2"}],["path",{d:"M9.2 9.2h.01",key:"1b7bvt"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"M14.7 14.8h.01",key:"17nsh4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jq=Z("DiamondPlus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kq=Z("Diamond",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nq=Z("Dice1",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sq=Z("Dice2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M15 9h.01",key:"x1ddxp"}],["path",{d:"M9 15h.01",key:"fzyn71"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cq=Z("Dice3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mq=Z("Dice4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tq=Z("Dice5",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aq=Z("Dice6",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eq=Z("Dices",[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pq=Z("Diff",[["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iq=Z("Disc2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lq=Z("Disc3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M6 12c0-1.7.7-3.2 1.8-4.2",key:"oqkarx"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M18 12c0 1.7-.7 3.2-1.8 4.2",key:"1eah9h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dq=Z("DiscAlbum",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"5",key:"nd82uf"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oq=Z("Disc",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rq=Z("Divide",[["circle",{cx:"12",cy:"6",r:"1",key:"1bh7o1"}],["line",{x1:"5",x2:"19",y1:"12",y2:"12",key:"13b5wn"}],["circle",{cx:"12",cy:"18",r:"1",key:"lqb9t5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fq=Z("DnaOff",[["path",{d:"M15 2c-1.35 1.5-2.092 3-2.5 4.5L14 8",key:"1bivrr"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c3.333-3 6.667-3 10-3",key:"nxix30"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M22 9c-1.5 1.35-3 2.092-4.5 2.5l-1-1",key:"18cutr"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.35-1.5 2.092-3 2.5-4.5L10 16",key:"rlvei3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zq=Z("Dna",[["path",{d:"m10 16 1.5 1.5",key:"11lckj"}],["path",{d:"m14 8-1.5-1.5",key:"1ohn8i"}],["path",{d:"M15 2c-1.798 1.998-2.518 3.995-2.807 5.993",key:"80uv8i"}],["path",{d:"m16.5 10.5 1 1",key:"696xn5"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c6.667-6 13.333 0 20-6",key:"1pyr53"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.798-1.998 2.518-3.995 2.807-5.993",key:"q3hbxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bq=Z("Dock",[["path",{d:"M2 8h20",key:"d11cs7"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 16h12",key:"u522kt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $q=Z("Dog",[["path",{d:"M11.25 16.25h1.5L12 17z",key:"w7jh35"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M4.42 11.247A13.152 13.152 0 0 0 4 14.556C4 18.728 7.582 21 12 21s8-2.272 8-6.444a11.702 11.702 0 0 0-.493-3.309",key:"u7s9ue"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M8.5 8.5c-.384 1.05-1.083 2.028-2.344 2.5-1.931.722-3.576-.297-3.656-1-.113-.994 1.177-6.53 4-7 1.923-.321 3.651.845 3.651 2.235A7.497 7.497 0 0 1 14 5.277c0-1.39 1.844-2.598 3.767-2.277 2.823.47 4.113 6.006 4 7-.08.703-1.725 1.722-3.656 1-1.261-.472-1.855-1.45-2.239-2.5",key:"v8hric"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kc=Z("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qq=Z("Donut",[["path",{d:"M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3",key:"19sr3x"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uq=Z("DoorClosed",[["path",{d:"M18 20V6a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v14",key:"36qu9e"}],["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"M14 12v.01",key:"xfcn54"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S0=Z("DoorOpen",[["path",{d:"M13 4h3a2 2 0 0 1 2 2v14",key:"hrm0s9"}],["path",{d:"M2 20h3",key:"1gaodv"}],["path",{d:"M13 20h9",key:"s90cdi"}],["path",{d:"M10 12v.01",key:"vx6srw"}],["path",{d:"M13 4.562v16.157a1 1 0 0 1-1.242.97L5 20V5.562a2 2 0 0 1 1.515-1.94l4-1A2 2 0 0 1 13 4.561Z",key:"199qr4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vq=Z("Dot",[["circle",{cx:"12.1",cy:"12.1",r:"1",key:"18d7e5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xi=Z("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hq=Z("DraftingCompass",[["path",{d:"m12.99 6.74 1.93 3.44",key:"iwagvd"}],["path",{d:"M19.136 12a10 10 0 0 1-14.271 0",key:"ppmlo4"}],["path",{d:"m21 21-2.16-3.84",key:"vylbct"}],["path",{d:"m3 21 8.02-14.26",key:"1ssaw4"}],["circle",{cx:"12",cy:"5",r:"2",key:"f1ur92"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wq=Z("Drama",[["path",{d:"M10 11h.01",key:"d2at3l"}],["path",{d:"M14 6h.01",key:"k028ub"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6.5 13.1h.01",key:"1748ia"}],["path",{d:"M22 5c0 9-4 12-6 12s-6-3-6-12c0-2 2-3 6-3s6 1 6 3",key:"172yzv"}],["path",{d:"M17.4 9.9c-.8.8-2 .8-2.8 0",key:"1obv0w"}],["path",{d:"M10.1 7.1C9 7.2 7.7 7.7 6 8.6c-3.5 2-4.7 3.9-3.7 5.6 4.5 7.8 9.5 8.4 11.2 7.4.9-.5 1.9-2.1 1.9-4.7",key:"rqjl8i"}],["path",{d:"M9.1 16.5c.3-1.1 1.4-1.7 2.4-1.4",key:"1mr6wy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gq=Z("Dribbble",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M19.13 5.09C15.22 9.14 10 10.44 2.25 10.94",key:"hpej1"}],["path",{d:"M21.75 12.84c-6.62-1.41-12.14 1-16.38 6.32",key:"1tr44o"}],["path",{d:"M8.56 2.75c4.37 6 6 9.42 8 17.72",key:"kbh691"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kq=Z("Drill",[["path",{d:"M10 18a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H5a3 3 0 0 1-3-3 1 1 0 0 1 1-1z",key:"ioqxb1"}],["path",{d:"M13 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1l-.81 3.242a1 1 0 0 1-.97.758H8",key:"1rs59n"}],["path",{d:"M14 4h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-3",key:"105ega"}],["path",{d:"M18 6h4",key:"66u95g"}],["path",{d:"m5 10-2 8",key:"xt2lic"}],["path",{d:"m7 18 2-8",key:"1bzku2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zq=Z("Droplet",[["path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z",key:"c7niix"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fg=Z("Droplets",[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yq=Z("Drum",[["path",{d:"m2 2 8 8",key:"1v6059"}],["path",{d:"m22 2-8 8",key:"173r8a"}],["ellipse",{cx:"12",cy:"9",rx:"10",ry:"5",key:"liohsx"}],["path",{d:"M7 13.4v7.9",key:"1yi6u9"}],["path",{d:"M12 14v8",key:"1tn2tj"}],["path",{d:"M17 13.4v7.9",key:"eqz2v3"}],["path",{d:"M2 9v8a10 5 0 0 0 20 0V9",key:"1750ul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xq=Z("Drumstick",[["path",{d:"M15.4 15.63a7.875 6 135 1 1 6.23-6.23 4.5 3.43 135 0 0-6.23 6.23",key:"1dtqwm"}],["path",{d:"m8.29 12.71-2.6 2.6a2.5 2.5 0 1 0-1.65 4.65A2.5 2.5 0 1 0 8.7 18.3l2.59-2.59",key:"1oq1fw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qq=Z("Dumbbell",[["path",{d:"M14.4 14.4 9.6 9.6",key:"ic80wn"}],["path",{d:"M18.657 21.485a2 2 0 1 1-2.829-2.828l-1.767 1.768a2 2 0 1 1-2.829-2.829l6.364-6.364a2 2 0 1 1 2.829 2.829l-1.768 1.767a2 2 0 1 1 2.828 2.829z",key:"nnl7wr"}],["path",{d:"m21.5 21.5-1.4-1.4",key:"1f1ice"}],["path",{d:"M3.9 3.9 2.5 2.5",key:"1evmna"}],["path",{d:"M6.404 12.768a2 2 0 1 1-2.829-2.829l1.768-1.767a2 2 0 1 1-2.828-2.829l2.828-2.828a2 2 0 1 1 2.829 2.828l1.767-1.768a2 2 0 1 1 2.829 2.829z",key:"yhosts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jq=Z("EarOff",[["path",{d:"M6 18.5a3.5 3.5 0 1 0 7 0c0-1.57.92-2.52 2.04-3.46",key:"1qngmn"}],["path",{d:"M6 8.5c0-.75.13-1.47.36-2.14",key:"b06bma"}],["path",{d:"M8.8 3.15A6.5 6.5 0 0 1 19 8.5c0 1.63-.44 2.81-1.09 3.76",key:"g10hsz"}],["path",{d:"M12.5 6A2.5 2.5 0 0 1 15 8.5M10 13a2 2 0 0 0 1.82-1.18",key:"ygzou7"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eU=Z("Ear",[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tU=Z("EarthLock",[["path",{d:"M7 3.34V5a3 3 0 0 0 3 3",key:"w732o8"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"f02343"}],["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M12 2a10 10 0 1 0 9.54 13",key:"zjsr6q"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d2=Z("Earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sU=Z("Eclipse",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a7 7 0 1 0 10 10",key:"1yuj32"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rU=Z("EggFried",[["circle",{cx:"11.5",cy:"12.5",r:"3.5",key:"1cl1mi"}],["path",{d:"M3 8c0-3.5 2.5-6 6.5-6 5 0 4.83 3 7.5 5s5 2 5 6c0 4.5-2.5 6.5-7 6.5-2.5 0-2.5 2.5-6 2.5s-7-2-7-5.5c0-3 1.5-3 1.5-5C3.5 10 3 9 3 8Z",key:"165ef9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nU=Z("EggOff",[["path",{d:"M6.399 6.399C5.362 8.157 4.65 10.189 4.5 12c-.37 4.43 1.27 9.95 7.5 10 3.256-.026 5.259-1.547 6.375-3.625",key:"6et380"}],["path",{d:"M19.532 13.875A14.07 14.07 0 0 0 19.5 12c-.36-4.34-3.95-9.96-7.5-10-1.04.012-2.082.502-3.046 1.297",key:"gcdc3f"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l5=Z("Egg",[["path",{d:"M12 22c6.23-.05 7.87-5.57 7.5-10-.36-4.34-3.95-9.96-7.5-10-3.55.04-7.14 5.66-7.5 10-.37 4.43 1.27 9.95 7.5 10z",key:"1c39pg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jp=Z("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ef=Z("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aU=Z("EqualApproximately",[["path",{d:"M5 15a6.5 6.5 0 0 1 7 0 6.5 6.5 0 0 0 7 0",key:"yrdkhy"}],["path",{d:"M5 9a6.5 6.5 0 0 1 7 0 6.5 6.5 0 0 0 7 0",key:"gzkvyz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iU=Z("EqualNot",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}],["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oU=Z("Equal",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lU=Z("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cU=Z("EthernetPort",[["path",{d:"m15 20 3-3h2a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h2l3 3z",key:"rbahqx"}],["path",{d:"M6 8v1",key:"1636ez"}],["path",{d:"M10 8v1",key:"1talb4"}],["path",{d:"M14 8v1",key:"1rsfgr"}],["path",{d:"M18 8v1",key:"gnkwox"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dU=Z("Euro",[["path",{d:"M4 10h12",key:"1y6xl8"}],["path",{d:"M4 14h9",key:"1loblj"}],["path",{d:"M19 6a7.7 7.7 0 0 0-5.2-2A7.9 7.9 0 0 0 6 12c0 4.4 3.5 8 7.8 8 2 0 3.8-.8 5.2-2",key:"1j6lzo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uU=Z("Expand",[["path",{d:"m21 21-6-6m6 6v-4.8m0 4.8h-4.8",key:"1c15vz"}],["path",{d:"M3 16.2V21m0 0h4.8M3 21l6-6",key:"1fsnz2"}],["path",{d:"M21 7.8V3m0 0h-4.8M21 3l-6 6",key:"hawz9i"}],["path",{d:"M3 7.8V3m0 0h4.8M3 3l6 6",key:"u9ee12"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sn=Z("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hU=Z("EyeClosed",[["path",{d:"m15 18-.722-3.25",key:"1j64jw"}],["path",{d:"M2 8a10.645 10.645 0 0 0 20 0",key:"1e7gxb"}],["path",{d:"m20 15-1.726-2.05",key:"1cnuld"}],["path",{d:"m4 15 1.726-2.05",key:"1dsqqd"}],["path",{d:"m9 18 .722-3.25",key:"ypw2yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Em=Z("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ya=Z("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hd=Z("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mU=Z("Factory",[["path",{d:"M2 20a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8l-7 5V8l-7 5V4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"159hny"}],["path",{d:"M17 18h1",key:"uldtlt"}],["path",{d:"M12 18h1",key:"s9uhes"}],["path",{d:"M7 18h1",key:"1neino"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pU=Z("Fan",[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fU=Z("FastForward",[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gU=Z("Feather",[["path",{d:"M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z",key:"18jl4k"}],["path",{d:"M16 8 2 22",key:"vp34q"}],["path",{d:"M17.5 15H9",key:"1oz8nu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xU=Z("Fence",[["path",{d:"M4 3 2 5v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"1n2rgs"}],["path",{d:"M6 8h4",key:"utf9t1"}],["path",{d:"M6 18h4",key:"12yh4b"}],["path",{d:"m12 3-2 2v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"3ha7mj"}],["path",{d:"M14 8h4",key:"1r8wg2"}],["path",{d:"M14 18h4",key:"1t3kbu"}],["path",{d:"m20 3-2 2v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"dfd4e2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yU=Z("FerrisWheel",[["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m6.8 15-3.5 2",key:"hjy98k"}],["path",{d:"m20.7 7-3.5 2",key:"f08gto"}],["path",{d:"M6.8 9 3.3 7",key:"1aevh4"}],["path",{d:"m20.7 17-3.5-2",key:"1liqo3"}],["path",{d:"m9 22 3-8 3 8",key:"wees03"}],["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M18 18.7a9 9 0 1 0-12 0",key:"dhzg4g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vU=Z("Figma",[["path",{d:"M5 5.5A3.5 3.5 0 0 1 8.5 2H12v7H8.5A3.5 3.5 0 0 1 5 5.5z",key:"1340ok"}],["path",{d:"M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2z",key:"1hz3m3"}],["path",{d:"M12 12.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 1 1-7 0z",key:"1oz8n2"}],["path",{d:"M5 19.5A3.5 3.5 0 0 1 8.5 16H12v3.5a3.5 3.5 0 1 1-7 0z",key:"1ff65i"}],["path",{d:"M5 12.5A3.5 3.5 0 0 1 8.5 9H12v7H8.5A3.5 3.5 0 0 1 5 12.5z",key:"pdip6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _U=Z("FileArchive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bU=Z("FileAudio2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"3",cy:"17",r:"1",key:"vo6nti"}],["path",{d:"M2 17v-3a4 4 0 0 1 8 0v3",key:"1ggdre"}],["circle",{cx:"9",cy:"17",r:"1",key:"bc1fq4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wU=Z("FileAudio",[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u2=Z("FileAxis3d",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 18 4-4",key:"12zab0"}],["path",{d:"M8 10v8h8",key:"tlaukw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jU=Z("FileBadge2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14 12.5 1 5.5-3-1-3 1 1-5.5",key:"14xlky"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kU=Z("FileBadge",[["path",{d:"M12 22h6a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"12ixgl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M5 17a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",key:"u0c8gj"}],["path",{d:"M7 16.5 8 22l-3-1-3 1 1-5.5",key:"5gm2nr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NU=Z("FileBox",[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"16lz6z"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 13.1a2 2 0 0 0-1 1.76v3.24a2 2 0 0 0 .97 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01Z",key:"99pj1s"}],["path",{d:"M7 17v5",key:"1yj1jh"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h2=Z("FileChartColumnIncreasing",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M12 18v-4",key:"q1q25u"}],["path",{d:"M16 18v-6",key:"15y0np"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m2=Z("FileChartColumn",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-1",key:"zg0ygc"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"M16 18v-3",key:"j5jt4h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p2=Z("FileChartLine",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m16 13-3.5 3.5-2-2L8 17",key:"zz7yod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f2=Z("FileChartPie",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3.5",key:"13ddob"}],["path",{d:"M4.017 11.512a6 6 0 1 0 8.466 8.475",key:"s6vs5t"}],["path",{d:"M9 16a1 1 0 0 1-1-1v-4c0-.552.45-1.008.995-.917a6 6 0 0 1 4.922 4.922c.091.544-.365.995-.917.995z",key:"1dl6s6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SU=Z("FileCheck2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3 15 2 2 4-4",key:"1lhrkk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CU=Z("FileCheck",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MU=Z("FileClock",[["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"37hlfg"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"8",cy:"16",r:"6",key:"10v15b"}],["path",{d:"M9.5 17.5 8 16.25V14",key:"1o80t2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TU=Z("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AU=Z("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g2=Z("FileCog",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3.2 12.9-.9-.4",key:"1i3dj5"}],["path",{d:"m3.2 15.1-.9.4",key:"1fvgj0"}],["path",{d:"M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5",key:"1yo3oz"}],["path",{d:"m4.9 11.2-.4-.9",key:"otmhb9"}],["path",{d:"m4.9 16.8-.4.9",key:"1b8z07"}],["path",{d:"m7.5 10.3-.4.9",key:"11k65u"}],["path",{d:"m7.5 17.7-.4-.9",key:"431x55"}],["path",{d:"m9.7 12.5-.9.4",key:"87sjan"}],["path",{d:"m9.7 15.5-.9-.4",key:"khqm91"}],["circle",{cx:"6",cy:"14",r:"3",key:"a1xfv6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EU=Z("FileDiff",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PU=Z("FileDigit",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"4",height:"6",x:"2",y:"12",rx:"2",key:"jm304g"}],["path",{d:"M10 12h2v6",key:"12zw74"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IU=Z("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LU=Z("FileHeart",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10.29 10.7a2.43 2.43 0 0 0-2.66-.52c-.29.12-.56.3-.78.53l-.35.34-.35-.34a2.43 2.43 0 0 0-2.65-.53c-.3.12-.56.3-.79.53-.95.94-1 2.53.2 3.74L6.5 18l3.6-3.55c1.2-1.21 1.14-2.8.19-3.74Z",key:"1c1fso"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e_=Z("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DU=Z("FileInput",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OU=Z("FileJson2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"fq0c9t"}],["path",{d:"M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"4gibmv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RU=Z("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FU=Z("FileKey2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v6",key:"rc0qvx"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"m10 10-4.5 4.5",key:"7fwrp6"}],["path",{d:"m9 11 1 1",key:"wa6s5q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zU=Z("FileKey",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["circle",{cx:"10",cy:"16",r:"2",key:"4ckbqe"}],["path",{d:"m16 10-4.5 4.5",key:"7p3ebg"}],["path",{d:"m15 11 1 1",key:"1bsyx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BU=Z("FileLock2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v1",key:"jmtmu2"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"5",x:"2",y:"13",rx:"1",key:"10y5wo"}],["path",{d:"M8 13v-2a2 2 0 1 0-4 0v2",key:"1pdxzg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $U=Z("FileLock",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["rect",{width:"8",height:"6",x:"8",y:"12",rx:"1",key:"3yr8at"}],["path",{d:"M10 12v-2a2 2 0 1 1 4 0v2",key:"j4i8d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qU=Z("FileMinus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UU=Z("FileMinus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VU=Z("FileMusic",[["path",{d:"M10.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v8.4",key:"1d3kfm"}],["path",{d:"M8 18v-7.7L16 9v7",key:"1oie6o"}],["circle",{cx:"14",cy:"16",r:"2",key:"1bzzi3"}],["circle",{cx:"6",cy:"18",r:"2",key:"1fncim"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HU=Z("FileOutput",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x2=Z("FilePenLine",[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y2=Z("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WU=Z("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GU=Z("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KU=Z("FileQuestion",[["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZU=Z("FileScan",[["path",{d:"M20 10V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h4",key:"1rdf37"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M16 14a2 2 0 0 0-2 2",key:"ceaadl"}],["path",{d:"M20 14a2 2 0 0 1 2 2",key:"1ny6zw"}],["path",{d:"M20 22a2 2 0 0 0 2-2",key:"1l9q4k"}],["path",{d:"M16 22a2 2 0 0 1-2-2",key:"1wqh5n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YU=Z("FileSearch2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XU=Z("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QU=Z("FileSliders",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M10 11v2",key:"1s651w"}],["path",{d:"M8 17h8",key:"wh5c61"}],["path",{d:"M14 16v2",key:"12fp5e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C0=Z("FileSpreadsheet",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rP=Z("FileStack",[["path",{d:"M21 7h-3a2 2 0 0 1-2-2V2",key:"9rb54x"}],["path",{d:"M21 6v6.5c0 .8-.7 1.5-1.5 1.5h-7c-.8 0-1.5-.7-1.5-1.5v-9c0-.8.7-1.5 1.5-1.5H17Z",key:"1059l0"}],["path",{d:"M7 8v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H15",key:"16874u"}],["path",{d:"M3 12v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H11",key:"k2ox98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JU=Z("FileSymlink",[["path",{d:"m10 18 3-3-3-3",key:"18f6ys"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 11V4a2 2 0 0 1 2-2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"50q2rw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eV=Z("FileTerminal",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 16 2-2-2-2",key:"10vzyd"}],["path",{d:"M12 18h4",key:"1wd2n7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const In=Z("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tV=Z("FileType2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 13v-1h6v1",key:"1dh9dg"}],["path",{d:"M5 12v6",key:"150t9c"}],["path",{d:"M4 18h2",key:"1xrofg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sV=Z("FileType",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rV=Z("FileUp",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nV=Z("FileUser",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 18a3 3 0 1 0-6 0",key:"16awa0"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aV=Z("FileVideo2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"6",x:"2",y:"12",rx:"1",key:"1a6c1e"}],["path",{d:"m10 15.5 4 2.5v-6l-4 2.5",key:"t7cp39"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iV=Z("FileVideo",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m10 11 5 3-5 3v-6Z",key:"7ntvm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oV=Z("FileVolume2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M11.5 13.5a2.5 2.5 0 0 1 0 3",key:"1fccat"}],["path",{d:"M15 12a5 5 0 0 1 0 6",key:"ps46cm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lV=Z("FileVolume",[["path",{d:"M11 11a5 5 0 0 1 0 6",key:"193qb2"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 6.765V4a2 2 0 0 1 2-2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-.93-.23",key:"ifyjnl"}],["path",{d:"M7 10.51a.5.5 0 0 0-.826-.38l-1.893 1.628A1 1 0 0 1 3.63 12H2.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h1.129a1 1 0 0 1 .652.242l1.893 1.63a.5.5 0 0 0 .826-.38z",key:"mk8rxu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cV=Z("FileWarning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dV=Z("FileX2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 12.5-5 5",key:"b853mi"}],["path",{d:"m3 12.5 5 5",key:"1qls4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uV=Z("FileX",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c5=Z("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hV=Z("Files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lu=Z("Film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mV=Z("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hx=Z("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pV=Z("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fV=Z("FireExtinguisher",[["path",{d:"M15 6.5V3a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3.5",key:"sqyvz"}],["path",{d:"M9 18h8",key:"i7pszb"}],["path",{d:"M18 3h-3",key:"7idoqj"}],["path",{d:"M11 3a6 6 0 0 0-6 6v11",key:"1v5je3"}],["path",{d:"M5 13h4",key:"svpcxo"}],["path",{d:"M17 10a4 4 0 0 0-8 0v10a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2Z",key:"vsjego"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gV=Z("FishOff",[["path",{d:"M18 12.47v.03m0-.5v.47m-.475 5.056A6.744 6.744 0 0 1 15 18c-3.56 0-7.56-2.53-8.5-6 .348-1.28 1.114-2.433 2.121-3.38m3.444-2.088A8.802 8.802 0 0 1 15 6c3.56 0 6.06 2.54 7 6-.309 1.14-.786 2.177-1.413 3.058",key:"1j1hse"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33m7.48-4.372A9.77 9.77 0 0 1 16 6.07m0 11.86a9.77 9.77 0 0 1-1.728-3.618",key:"1q46z8"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98M8.53 3h5.27a2 2 0 0 1 1.98 1.67l.23 1.4M2 2l20 20",key:"1407gh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xV=Z("FishSymbol",[["path",{d:"M2 16s9-15 20-4C11 23 2 8 2 8",key:"h4oh4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yV=Z("Fish",[["path",{d:"M6.5 12c.94-3.46 4.94-6 8.5-6 3.56 0 6.06 2.54 7 6-.94 3.47-3.44 6-7 6s-7.56-2.53-8.5-6Z",key:"15baut"}],["path",{d:"M18 12v.5",key:"18hhni"}],["path",{d:"M16 17.93a9.77 9.77 0 0 1 0-11.86",key:"16dt7o"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33",key:"l9di03"}],["path",{d:"M10.46 7.26C10.2 5.88 9.17 4.24 8 3h5.8a2 2 0 0 1 1.98 1.67l.23 1.4",key:"1kjonw"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98",key:"1zlm23"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vV=Z("FlagOff",[["path",{d:"M8 2c3 0 5 2 8 2s4-1 4-1v11",key:"9rwyz9"}],["path",{d:"M4 22V4",key:"1plyxx"}],["path",{d:"M4 15s1-1 4-1 5 2 8 2",key:"1myooe"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _V=Z("FlagTriangleLeft",[["path",{d:"M17 22V2L7 7l10 5",key:"1rmf0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bV=Z("FlagTriangleRight",[["path",{d:"M7 22V2l10 5-10 5",key:"17n18y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M0=Z("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wV=Z("FlameKindling",[["path",{d:"M12 2c1 3 2.5 3.5 3.5 4.5A5 5 0 0 1 17 10a5 5 0 1 1-10 0c0-.3 0-.6.1-.9a2 2 0 1 0 3.3-2C8 4.5 11 2 12 2Z",key:"1ir223"}],["path",{d:"m5 22 14-4",key:"1brv4h"}],["path",{d:"m5 18 14 4",key:"lgyyje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $h=Z("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jV=Z("FlashlightOff",[["path",{d:"M16 16v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4",key:"1r120k"}],["path",{d:"M7 2h11v4c0 2-2 2-2 4v1",key:"dz1920"}],["line",{x1:"11",x2:"18",y1:"6",y2:"6",key:"bi1vpe"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kV=Z("Flashlight",[["path",{d:"M18 6c0 2-2 2-2 4v10a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4V2h12z",key:"1orkel"}],["line",{x1:"6",x2:"18",y1:"6",y2:"6",key:"1z11jq"}],["line",{x1:"12",x2:"12",y1:"12",y2:"12",key:"1f4yc1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NV=Z("FlaskConicalOff",[["path",{d:"M10 10 4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-1.272-2.542",key:"59ek9y"}],["path",{d:"M10 2v2.343",key:"15t272"}],["path",{d:"M14 2v6.343",key:"sxr80q"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h9",key:"t5njau"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t_=Z("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SV=Z("FlaskRound",[["path",{d:"M10 2v7.31",key:"5d1hyh"}],["path",{d:"M14 9.3V1.99",key:"14k4l0"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14 9.3a6.5 6.5 0 1 1-4 0",key:"1r8fvy"}],["path",{d:"M5.52 16h12.96",key:"46hh1i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CV=Z("FlipHorizontal2",[["path",{d:"m3 7 5 5-5 5V7",key:"couhi7"}],["path",{d:"m21 7-5 5 5 5V7",key:"6ouia7"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MV=Z("FlipHorizontal",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h3",key:"1i73f7"}],["path",{d:"M16 3h3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-3",key:"saxlbk"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TV=Z("FlipVertical2",[["path",{d:"m17 3-5 5-5-5h10",key:"1ftt6x"}],["path",{d:"m17 21-5-5-5 5h10",key:"1m0wmu"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AV=Z("FlipVertical",[["path",{d:"M21 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v3",key:"14bfxa"}],["path",{d:"M21 16v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-3",key:"14rx03"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ag=Z("Flower2",[["path",{d:"M12 5a3 3 0 1 1 3 3m-3-3a3 3 0 1 0-3 3m3-3v1M9 8a3 3 0 1 0 3 3M9 8h1m5 0a3 3 0 1 1-3 3m3-3h-1m-2 3v-1",key:"3pnvol"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M12 10v12",key:"6ubwww"}],["path",{d:"M12 22c4.2 0 7-1.667 7-5-4.2 0-7 1.667-7 5Z",key:"9hd38g"}],["path",{d:"M12 22c-4.2 0-7-1.667-7-5 4.2 0 7 1.667 7 5Z",key:"ufn41s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EV=Z("Flower",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 16.5A4.5 4.5 0 1 1 7.5 12 4.5 4.5 0 1 1 12 7.5a4.5 4.5 0 1 1 4.5 4.5 4.5 4.5 0 1 1-4.5 4.5",key:"14wa3c"}],["path",{d:"M12 7.5V9",key:"1oy5b0"}],["path",{d:"M7.5 12H9",key:"eltsq1"}],["path",{d:"M16.5 12H15",key:"vk5kw4"}],["path",{d:"M12 16.5V15",key:"k7eayi"}],["path",{d:"m8 8 1.88 1.88",key:"nxy4qf"}],["path",{d:"M14.12 9.88 16 8",key:"1lst6k"}],["path",{d:"m8 16 1.88-1.88",key:"h2eex1"}],["path",{d:"M14.12 14.12 16 16",key:"uqkrx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PV=Z("Focus",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IV=Z("FoldHorizontal",[["path",{d:"M2 12h6",key:"1wqiqv"}],["path",{d:"M22 12h-6",key:"1eg9hc"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 9-3 3 3 3",key:"12ol22"}],["path",{d:"m5 15 3-3-3-3",key:"1kdhjc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LV=Z("FoldVertical",[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DV=Z("FolderArchive",[["circle",{cx:"15",cy:"19",r:"2",key:"u2pros"}],["path",{d:"M20.9 19.8A2 2 0 0 0 22 18V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h5.1",key:"1jj40k"}],["path",{d:"M15 11v-1",key:"cntcp"}],["path",{d:"M15 17v-2",key:"1279jj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OV=Z("FolderCheck",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RV=Z("FolderClock",[["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"M7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2",key:"1urifu"}],["path",{d:"M16 14v2l1 1",key:"xth2jh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FV=Z("FolderClosed",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M2 10h20",key:"1ir3d8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zV=Z("FolderCode",[["path",{d:"M10 10.5 8 13l2 2.5",key:"m4t9c1"}],["path",{d:"m14 10.5 2 2.5-2 2.5",key:"14w2eb"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z",key:"1u1bxd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v2=Z("FolderCog",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"M10.3 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v3.3",key:"1k8050"}],["path",{d:"m21.7 19.4-.9-.3",key:"1qgwi9"}],["path",{d:"m15.2 16.9-.9-.3",key:"1t7mvx"}],["path",{d:"m16.6 21.7.3-.9",key:"1j67ps"}],["path",{d:"m19.1 15.2.3-.9",key:"18r7jp"}],["path",{d:"m19.6 21.7-.4-1",key:"z2vh2"}],["path",{d:"m16.8 15.3-.4-1",key:"1ei7r6"}],["path",{d:"m14.3 19.6 1-.4",key:"11sv9r"}],["path",{d:"m20.7 16.8 1-.4",key:"19m87a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BV=Z("FolderDot",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["circle",{cx:"12",cy:"13",r:"1",key:"49l61u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $V=Z("FolderDown",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m15 13-3 3-3-3",key:"6j2sf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qV=Z("FolderGit2",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["path",{d:"M18 19c-2.8 0-5-2.2-5-5v8",key:"pkpw2h"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UV=Z("FolderGit",[["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M14 13h3",key:"1dgedf"}],["path",{d:"M7 13h3",key:"1pygq7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VV=Z("FolderHeart",[["path",{d:"M11 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v1.5",key:"6hud8k"}],["path",{d:"M13.9 17.45c-1.2-1.2-1.14-2.8-.2-3.73a2.43 2.43 0 0 1 3.44 0l.36.34.34-.34a2.43 2.43 0 0 1 3.45-.01c.95.95 1 2.53-.2 3.74L17.5 21Z",key:"wpff58"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HV=Z("FolderInput",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WV=Z("FolderKanban",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GV=Z("FolderKey",[["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2",key:"3hgo9p"}],["path",{d:"m22 14-4.5 4.5",key:"1ef6z8"}],["path",{d:"m21 15 1 1",key:"1ejcpy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KV=Z("FolderLock",[["rect",{width:"8",height:"5",x:"14",y:"17",rx:"1",key:"19aais"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5",key:"1w6v7t"}],["path",{d:"M20 17v-2a2 2 0 1 0-4 0v2",key:"pwaxnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZV=Z("FolderMinus",[["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YV=Z("FolderOpenDot",[["path",{d:"m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2",key:"1nmvlm"}],["circle",{cx:"14",cy:"15",r:"1",key:"1gm4qj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qh=Z("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XV=Z("FolderOutput",[["path",{d:"M2 7.5V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-1.5",key:"1yk7aj"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m5 10-3 3 3 3",key:"1r8ie0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _2=Z("FolderPen",[["path",{d:"M2 11.5V5a2 2 0 0 1 2-2h3.9c.7 0 1.3.3 1.7.9l.8 1.2c.4.6 1 .9 1.7.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-9.5",key:"a8xqs0"}],["path",{d:"M11.378 13.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1saktj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QV=Z("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JV=Z("FolderRoot",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M12 15v5",key:"11xva1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eH=Z("FolderSearch2",[["circle",{cx:"11.5",cy:"12.5",r:"2.5",key:"1ea5ju"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M13.3 14.3 15 16",key:"1y4v1n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tH=Z("FolderSearch",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sH=Z("FolderSymlink",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"x1c07l"}],["path",{d:"m8 16 3-3-3-3",key:"rlqrt1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rH=Z("FolderSync",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5",key:"1dkoa9"}],["path",{d:"M12 10v4h4",key:"1czhmt"}],["path",{d:"m12 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"lvuxfi"}],["path",{d:"M22 22v-4h-4",key:"1ewp4q"}],["path",{d:"m22 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"14ync0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nH=Z("FolderTree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aH=Z("FolderUp",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m9 13 3-3 3 3",key:"1pxg3c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iH=Z("FolderX",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9.5 10.5 5 5",key:"ra9qjz"}],["path",{d:"m14.5 10.5-5 5",key:"l2rkpq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oH=Z("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lH=Z("Folders",[["path",{d:"M20 17a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.9a2 2 0 0 1-1.69-.9l-.81-1.2a2 2 0 0 0-1.67-.9H8a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2Z",key:"4u7rpt"}],["path",{d:"M2 8v11a2 2 0 0 0 2 2h14",key:"1eicx1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cH=Z("Footprints",[["path",{d:"M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z",key:"1dudjm"}],["path",{d:"M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z",key:"l2t8xc"}],["path",{d:"M16 17h4",key:"1dejxt"}],["path",{d:"M4 13h4",key:"1bwh8b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dH=Z("Forklift",[["path",{d:"M12 12H5a2 2 0 0 0-2 2v5",key:"7zsz91"}],["circle",{cx:"13",cy:"19",r:"2",key:"wjnkru"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M8 19h3m5-17v17h6M6 12V7c0-1.1.9-2 2-2h3l5 5",key:"13bk1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uH=Z("Forward",[["polyline",{points:"15 17 20 12 15 7",key:"1w3sku"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hH=Z("Frame",[["line",{x1:"22",x2:"2",y1:"6",y2:"6",key:"15w7dq"}],["line",{x1:"22",x2:"2",y1:"18",y2:"18",key:"1ip48p"}],["line",{x1:"6",x2:"6",y1:"2",y2:"22",key:"a2lnyx"}],["line",{x1:"18",x2:"18",y1:"2",y2:"22",key:"8vb6jd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mH=Z("Framer",[["path",{d:"M5 16V9h14V2H5l14 14h-7m-7 0 7 7v-7m-7 0h7",key:"1a2nng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pH=Z("Frown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fH=Z("Fuel",[["line",{x1:"3",x2:"15",y1:"22",y2:"22",key:"xegly4"}],["line",{x1:"4",x2:"14",y1:"9",y2:"9",key:"xcnuvu"}],["path",{d:"M14 22V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v18",key:"16j0yd"}],["path",{d:"M14 13h2a2 2 0 0 1 2 2v2a2 2 0 0 0 2 2a2 2 0 0 0 2-2V9.83a2 2 0 0 0-.59-1.42L18 5",key:"7cu91f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gH=Z("Fullscreen",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xH=Z("GalleryHorizontalEnd",[["path",{d:"M2 7v10",key:"a2pl2d"}],["path",{d:"M6 5v14",key:"1kq3d7"}],["rect",{width:"12",height:"18",x:"10",y:"3",rx:"2",key:"13i7bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yH=Z("GalleryHorizontal",[["path",{d:"M2 3v18",key:"pzttux"}],["rect",{width:"12",height:"18",x:"6",y:"3",rx:"2",key:"btr8bg"}],["path",{d:"M22 3v18",key:"6jf3v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vH=Z("GalleryThumbnails",[["rect",{width:"18",height:"14",x:"3",y:"3",rx:"2",key:"74y24f"}],["path",{d:"M4 21h1",key:"16zlid"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M19 21h1",key:"edywat"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _H=Z("GalleryVerticalEnd",[["path",{d:"M7 2h10",key:"nczekb"}],["path",{d:"M5 6h14",key:"u2x4p"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bH=Z("GalleryVertical",[["path",{d:"M3 2h18",key:"15qxfx"}],["rect",{width:"18",height:"12",x:"3",y:"6",rx:"2",key:"1439r6"}],["path",{d:"M3 22h18",key:"8prr45"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wH=Z("Gamepad2",[["line",{x1:"6",x2:"10",y1:"11",y2:"11",key:"1gktln"}],["line",{x1:"8",x2:"8",y1:"9",y2:"13",key:"qnk9ow"}],["line",{x1:"15",x2:"15.01",y1:"12",y2:"12",key:"krot7o"}],["line",{x1:"18",x2:"18.01",y1:"10",y2:"10",key:"1lcuu1"}],["path",{d:"M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z",key:"mfqc10"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jH=Z("Gamepad",[["line",{x1:"6",x2:"10",y1:"12",y2:"12",key:"161bw2"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"15",x2:"15.01",y1:"13",y2:"13",key:"dqpgro"}],["line",{x1:"18",x2:"18.01",y1:"11",y2:"11",key:"meh2c"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kH=Z("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NH=Z("Gavel",[["path",{d:"m14.5 12.5-8 8a2.119 2.119 0 1 1-3-3l8-8",key:"15492f"}],["path",{d:"m16 16 6-6",key:"vzrcl6"}],["path",{d:"m8 8 6-6",key:"18bi4p"}],["path",{d:"m9 7 8 8",key:"5jnvq1"}],["path",{d:"m21 11-8-8",key:"z4y7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SH=Z("Gem",[["path",{d:"M6 3h12l4 6-10 13L2 9Z",key:"1pcd5k"}],["path",{d:"M11 3 8 9l4 13 4-13-3-6",key:"1fcu3u"}],["path",{d:"M2 9h20",key:"16fsjt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sN=Z("Ghost",[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const io=Z("Gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CH=Z("GitBranchPlus",[["path",{d:"M6 3v12",key:"qpgusn"}],["path",{d:"M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"1d02ji"}],["path",{d:"M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"chk6ph"}],["path",{d:"M15 6a9 9 0 0 0-9 9",key:"or332x"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MH=Z("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b2=Z("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TH=Z("GitCommitVertical",[["path",{d:"M12 3v6",key:"1holv5"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 15v6",key:"a9ows0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AH=Z("GitCompareArrows",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EH=Z("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PH=Z("GitFork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IH=Z("GitGraph",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LH=Z("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DH=Z("GitPullRequestArrow",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v12",key:"ih889a"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OH=Z("GitPullRequestClosed",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 9v12",key:"1sc30k"}],["path",{d:"m21 3-6 6",key:"16nqsk"}],["path",{d:"m21 9-6-6",key:"9j17rh"}],["path",{d:"M18 11.5V15",key:"65xf6f"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RH=Z("GitPullRequestCreateArrow",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v12",key:"ih889a"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v3",key:"1rbwk6"}],["path",{d:"M19 15v6",key:"10aioa"}],["path",{d:"M22 18h-6",key:"1d5gi5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FH=Z("GitPullRequestCreate",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 9v12",key:"1sc30k"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v3",key:"1jb6z3"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zH=Z("GitPullRequestDraft",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M18 6V5",key:"1oao2s"}],["path",{d:"M18 11v-1",key:"11c8tz"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BH=Z("GitPullRequest",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $H=Z("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qH=Z("Gitlab",[["path",{d:"m22 13.29-3.33-10a.42.42 0 0 0-.14-.18.38.38 0 0 0-.22-.11.39.39 0 0 0-.23.07.42.42 0 0 0-.14.18l-2.26 6.67H8.32L6.1 3.26a.42.42 0 0 0-.1-.18.38.38 0 0 0-.26-.08.39.39 0 0 0-.23.07.42.42 0 0 0-.14.18L2 13.29a.74.74 0 0 0 .27.83L12 21l9.69-6.88a.71.71 0 0 0 .31-.83Z",key:"148pdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UH=Z("GlassWater",[["path",{d:"M5.116 4.104A1 1 0 0 1 6.11 3h11.78a1 1 0 0 1 .994 1.105L17.19 20.21A2 2 0 0 1 15.2 22H8.8a2 2 0 0 1-2-1.79z",key:"p55z4y"}],["path",{d:"M6 12a5 5 0 0 1 6 0 5 5 0 0 0 6 0",key:"mjntcy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VH=Z("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HH=Z("GlobeLock",[["path",{d:"M15.686 15A14.5 14.5 0 0 1 12 22a14.5 14.5 0 0 1 0-20 10 10 0 1 0 9.542 13",key:"qkt0x6"}],["path",{d:"M2 12h8.5",key:"ovaggd"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pm=Z("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WH=Z("Goal",[["path",{d:"M12 13V2l8 4-8 4",key:"5wlwwj"}],["path",{d:"M20.561 10.222a9 9 0 1 1-12.55-5.29",key:"1c0wjv"}],["path",{d:"M8.002 9.997a5 5 0 1 0 8.9 2.02",key:"gb1g7m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GH=Z("Grab",[["path",{d:"M18 11.5V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1.4",key:"edstyy"}],["path",{d:"M14 10V8a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"19wdwo"}],["path",{d:"M10 9.9V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5",key:"1lugqo"}],["path",{d:"M6 14a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1hbeus"}],["path",{d:"M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-4a8 8 0 0 1-8-8 2 2 0 1 1 4 0",key:"1etffm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sh=Z("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KH=Z("Grape",[["path",{d:"M22 5V2l-5.89 5.89",key:"1eenpo"}],["circle",{cx:"16.6",cy:"15.89",r:"3",key:"xjtalx"}],["circle",{cx:"8.11",cy:"7.4",r:"3",key:"u2fv6i"}],["circle",{cx:"12.35",cy:"11.65",r:"3",key:"i6i8g7"}],["circle",{cx:"13.91",cy:"5.85",r:"3",key:"6ye0dv"}],["circle",{cx:"18.15",cy:"10.09",r:"3",key:"snx9no"}],["circle",{cx:"6.56",cy:"13.2",r:"3",key:"17x4xg"}],["circle",{cx:"10.8",cy:"17.44",r:"3",key:"1hogw9"}],["circle",{cx:"5",cy:"19",r:"3",key:"1sn6vo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZH=Z("Grid2x2Check",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w2=Z("Grid2x2Plus",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 22v-6",key:"qhmiwi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YH=Z("Grid2x2X",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"m16 16 5 5",key:"8tpb07"}],["path",{d:"m16 21 5-5",key:"193jll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j2=Z("Grid2x2",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vp=Z("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XH=Z("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fu=Z("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QH=Z("Grip",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JH=Z("Group",[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2",key:"adw53z"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2",key:"an4l38"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2",key:"144t0e"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2",key:"rtnfgi"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1",key:"1eyiv7"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1",key:"1qlmkx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eW=Z("Guitar",[["path",{d:"m11.9 12.1 4.514-4.514",key:"109xqo"}],["path",{d:"M20.1 2.3a1 1 0 0 0-1.4 0l-1.114 1.114A2 2 0 0 0 17 4.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 17.828 7h1.344a2 2 0 0 0 1.414-.586L21.7 5.3a1 1 0 0 0 0-1.4z",key:"txyc8t"}],["path",{d:"m6 16 2 2",key:"16qmzd"}],["path",{d:"M8.2 9.9C8.7 8.8 9.8 8 11 8c2.8 0 5 2.2 5 5 0 1.2-.8 2.3-1.9 2.8l-.9.4A2 2 0 0 0 12 18a4 4 0 0 1-4 4c-3.3 0-6-2.7-6-6a4 4 0 0 1 4-4 2 2 0 0 0 1.8-1.2z",key:"1u8q3z"}],["circle",{cx:"11.5",cy:"12.5",r:".5",fill:"currentColor",key:"16onso"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tW=Z("Ham",[["path",{d:"M13.144 21.144A7.274 10.445 45 1 0 2.856 10.856",key:"1k1t7q"}],["path",{d:"M13.144 21.144A7.274 4.365 45 0 0 2.856 10.856a7.274 4.365 45 0 0 10.288 10.288",key:"153t1g"}],["path",{d:"M16.565 10.435 18.6 8.4a2.501 2.501 0 1 0 1.65-4.65 2.5 2.5 0 1 0-4.66 1.66l-2.024 2.025",key:"gzrt0n"}],["path",{d:"m8.5 16.5-1-1",key:"otr954"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sW=Z("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rW=Z("HandCoins",[["path",{d:"M11 15h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 17",key:"geh8rc"}],["path",{d:"m7 21 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"1fto5m"}],["path",{d:"m2 16 6 6",key:"1pfhp9"}],["circle",{cx:"16",cy:"9",r:"2.9",key:"1n0dlu"}],["circle",{cx:"6",cy:"5",r:"3",key:"151irh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nW=Z("HandHeart",[["path",{d:"M11 14h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 16",key:"1ifwr1"}],["path",{d:"m7 20 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"17abbs"}],["path",{d:"m2 15 6 6",key:"10dquu"}],["path",{d:"M19.5 8.5c.7-.7 1.5-1.6 1.5-2.7A2.73 2.73 0 0 0 16 4a2.78 2.78 0 0 0-5 1.8c0 1.2.8 2 1.5 2.8L16 12Z",key:"1h3036"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k2=Z("HandHelping",[["path",{d:"M11 12h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 14",key:"1j4xps"}],["path",{d:"m7 18 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"uospg8"}],["path",{d:"m2 13 6 6",key:"16e5sb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aW=Z("HandMetal",[["path",{d:"M18 12.5V10a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1.4",key:"wc6myp"}],["path",{d:"M14 11V9a2 2 0 1 0-4 0v2",key:"94qvcw"}],["path",{d:"M10 10.5V5a2 2 0 1 0-4 0v9",key:"m1ah89"}],["path",{d:"m7 15-1.76-1.76a2 2 0 0 0-2.83 2.82l3.6 3.6C7.5 21.14 9.2 22 12 22h2a8 8 0 0 0 8-8V7a2 2 0 1 0-4 0v5",key:"t1skq1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iW=Z("HandPlatter",[["path",{d:"M12 3V2",key:"ar7q03"}],["path",{d:"m15.4 17.4 3.2-2.8a2 2 0 1 1 2.8 2.9l-3.6 3.3c-.7.8-1.7 1.2-2.8 1.2h-4c-1.1 0-2.1-.4-2.8-1.2l-1.302-1.464A1 1 0 0 0 6.151 19H5",key:"n2g93r"}],["path",{d:"M2 14h12a2 2 0 0 1 0 4h-2",key:"1o2jem"}],["path",{d:"M4 10h16",key:"img6z1"}],["path",{d:"M5 10a7 7 0 0 1 14 0",key:"1ega1o"}],["path",{d:"M5 14v6a1 1 0 0 1-1 1H2",key:"1hescx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nP=Z("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aP=Z("Handshake",[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oW=Z("HardDriveDownload",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lW=Z("HardDriveUpload",[["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M12 2v8",key:"1q4o3n"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iP=Z("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cW=Z("HardHat",[["path",{d:"M10 10V5a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v5",key:"1p9q5i"}],["path",{d:"M14 6a6 6 0 0 1 6 6v3",key:"1hnv84"}],["path",{d:"M4 15v-3a6 6 0 0 1 6-6",key:"9ciidu"}],["rect",{x:"2",y:"15",width:"20",height:"4",rx:"1",key:"g3x8cw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d5=Z("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dW=Z("Haze",[["path",{d:"m5.2 6.2 1.4 1.4",key:"17imol"}],["path",{d:"M2 13h2",key:"13gyu8"}],["path",{d:"M20 13h2",key:"16rner"}],["path",{d:"m17.4 7.6 1.4-1.4",key:"t4xlah"}],["path",{d:"M22 17H2",key:"1gtaj3"}],["path",{d:"M22 21H2",key:"1gy6en"}],["path",{d:"M16 13a4 4 0 0 0-8 0",key:"1dyczq"}],["path",{d:"M12 5V2.5",key:"1vytko"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uW=Z("HdmiPort",[["path",{d:"M22 9a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v4a1 1 0 0 0 1 1h1l2 2h12l2-2h1a1 1 0 0 0 1-1Z",key:"2128wb"}],["path",{d:"M7.5 12h9",key:"1t0ckc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oP=Z("Heading1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lP=Z("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hW=Z("Heading3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mW=Z("Heading4",[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pW=Z("Heading5",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fW=Z("Heading6",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gW=Z("Heading",[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xW=Z("HeadphoneOff",[["path",{d:"M21 14h-1.343",key:"1jdnxi"}],["path",{d:"M9.128 3.47A9 9 0 0 1 21 12v3.343",key:"6kipu2"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20.414 20.414A2 2 0 0 1 19 21h-1a2 2 0 0 1-2-2v-3",key:"9x50f4"}],["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 2.636-6.364",key:"1bkxnm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yW=Z("Headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vW=Z("Headset",[["path",{d:"M3 11h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5Zm0 0a9 9 0 1 1 18 0m0 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3Z",key:"12oyoe"}],["path",{d:"M21 16v2a4 4 0 0 1-4 4h-5",key:"1x7m43"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _W=Z("HeartCrack",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"m12 13-1-1 2-2-3-3 2-2",key:"xjdxli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bW=Z("HeartHandshake",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M12 5 9.04 7.96a2.17 2.17 0 0 0 0 3.08c.82.82 2.13.85 3 .07l2.07-1.9a2.82 2.82 0 0 1 3.79 0l2.96 2.66",key:"4oyue0"}],["path",{d:"m18 15-2-2",key:"60u0ii"}],["path",{d:"m15 18-2-2",key:"6p76be"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wW=Z("HeartOff",[["line",{x1:"2",y1:"2",x2:"22",y2:"22",key:"1w4vcy"}],["path",{d:"M16.5 16.5 12 21l-7-7c-1.5-1.45-3-3.2-3-5.5a5.5 5.5 0 0 1 2.14-4.35",key:"3mpagl"}],["path",{d:"M8.76 3.1c1.15.22 2.13.78 3.24 1.9 1.5-1.5 2.74-2 4.5-2A5.5 5.5 0 0 1 22 8.5c0 2.12-1.3 3.78-2.67 5.17",key:"1gh3v3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jW=Z("HeartPulse",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27",key:"1uw2ng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Si=Z("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kW=Z("Heater",[["path",{d:"M11 8c2-3-2-3 0-6",key:"1ldv5m"}],["path",{d:"M15.5 8c2-3-2-3 0-6",key:"1otqoz"}],["path",{d:"M6 10h.01",key:"1lbq93"}],["path",{d:"M6 14h.01",key:"zudwn7"}],["path",{d:"M10 16v-4",key:"1c25yv"}],["path",{d:"M14 16v-4",key:"1dkbt8"}],["path",{d:"M18 16v-4",key:"1yg9me"}],["path",{d:"M20 6a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h3",key:"1ubg90"}],["path",{d:"M5 20v2",key:"1abpe8"}],["path",{d:"M19 20v2",key:"kqn6ft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NW=Z("Hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SW=Z("Highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u5=Z("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CW=Z("HopOff",[["path",{d:"M10.82 16.12c1.69.6 3.91.79 5.18.85.28.01.53-.09.7-.27",key:"qyzcap"}],["path",{d:"M11.14 20.57c.52.24 2.44 1.12 4.08 1.37.46.06.86-.25.9-.71.12-1.52-.3-3.43-.5-4.28",key:"y078lb"}],["path",{d:"M16.13 21.05c1.65.63 3.68.84 4.87.91a.9.9 0 0 0 .7-.26",key:"1utre3"}],["path",{d:"M17.99 5.52a20.83 20.83 0 0 1 3.15 4.5.8.8 0 0 1-.68 1.13c-1.17.1-2.5.02-3.9-.25",key:"17o9hm"}],["path",{d:"M20.57 11.14c.24.52 1.12 2.44 1.37 4.08.04.3-.08.59-.31.75",key:"1d1n4p"}],["path",{d:"M4.93 4.93a10 10 0 0 0-.67 13.4c.35.43.96.4 1.17-.12.69-1.71 1.07-5.07 1.07-6.71 1.34.45 3.1.9 4.88.62a.85.85 0 0 0 .48-.24",key:"9uv3tt"}],["path",{d:"M5.52 17.99c1.05.95 2.91 2.42 4.5 3.15a.8.8 0 0 0 1.13-.68c.2-2.34-.33-5.3-1.57-8.28",key:"1292wz"}],["path",{d:"M8.35 2.68a10 10 0 0 1 9.98 1.58c.43.35.4.96-.12 1.17-1.5.6-4.3.98-6.07 1.05",key:"7ozu9p"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MW=Z("Hop",[["path",{d:"M10.82 16.12c1.69.6 3.91.79 5.18.85.55.03 1-.42.97-.97-.06-1.27-.26-3.5-.85-5.18",key:"18lxf1"}],["path",{d:"M11.5 6.5c1.64 0 5-.38 6.71-1.07.52-.2.55-.82.12-1.17A10 10 0 0 0 4.26 18.33c.35.43.96.4 1.17-.12.69-1.71 1.07-5.07 1.07-6.71 1.34.45 3.1.9 4.88.62a.88.88 0 0 0 .73-.74c.3-2.14-.15-3.5-.61-4.88",key:"vtfxrw"}],["path",{d:"M15.62 16.95c.2.85.62 2.76.5 4.28a.77.77 0 0 1-.9.7 16.64 16.64 0 0 1-4.08-1.36",key:"13hl71"}],["path",{d:"M16.13 21.05c1.65.63 3.68.84 4.87.91a.9.9 0 0 0 .96-.96 17.68 17.68 0 0 0-.9-4.87",key:"1sl8oj"}],["path",{d:"M16.94 15.62c.86.2 2.77.62 4.29.5a.77.77 0 0 0 .7-.9 16.64 16.64 0 0 0-1.36-4.08",key:"19c6kt"}],["path",{d:"M17.99 5.52a20.82 20.82 0 0 1 3.15 4.5.8.8 0 0 1-.68 1.13c-2.33.2-5.3-.32-8.27-1.57",key:"85ghs3"}],["path",{d:"M4.93 4.93 3 3a.7.7 0 0 1 0-1",key:"x087yj"}],["path",{d:"M9.58 12.18c1.24 2.98 1.77 5.95 1.57 8.28a.8.8 0 0 1-1.13.68 20.82 20.82 0 0 1-4.5-3.15",key:"11xdqo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TW=Z("Hospital",[["path",{d:"M12 6v4",key:"16clxf"}],["path",{d:"M14 14h-4",key:"esezmu"}],["path",{d:"M14 18h-4",key:"16mqa2"}],["path",{d:"M14 8h-4",key:"z8ypaz"}],["path",{d:"M18 12h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2",key:"b1k337"}],["path",{d:"M18 22V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v18",key:"16g51d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AW=Z("Hotel",[["path",{d:"M10 22v-6.57",key:"1wmca3"}],["path",{d:"M12 11h.01",key:"z322tv"}],["path",{d:"M12 7h.01",key:"1ivr5q"}],["path",{d:"M14 15.43V22",key:"1q2vjd"}],["path",{d:"M15 16a5 5 0 0 0-6 0",key:"o9wqvi"}],["path",{d:"M16 11h.01",key:"xkw8gn"}],["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 7h.01",key:"1vti4s"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2",key:"1uxh74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EW=Z("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PW=Z("HousePlug",[["path",{d:"M10 12V8.964",key:"1vll13"}],["path",{d:"M14 12V8.964",key:"1x3qvg"}],["path",{d:"M15 12a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-2a1 1 0 0 1 1-1z",key:"ppykja"}],["path",{d:"M8.5 21H5a2 2 0 0 1-2-2v-9a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2h-5a2 2 0 0 1-2-2v-2",key:"1gvg2z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IW=Z("HousePlus",[["path",{d:"M13.22 2.416a2 2 0 0 0-2.511.057l-7 5.999A2 2 0 0 0 3 10v9a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7.354",key:"5phn05"}],["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"M18 3v6",key:"x1uolp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Un=Z("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N2=Z("IceCreamBowl",[["path",{d:"M12 17c5 0 8-2.69 8-6H4c0 3.31 3 6 8 6m-4 4h8m-4-3v3M5.14 11a3.5 3.5 0 1 1 6.71 0",key:"1uxfcu"}],["path",{d:"M12.14 11a3.5 3.5 0 1 1 6.71 0",key:"4k3m1s"}],["path",{d:"M15.5 6.5a3.5 3.5 0 1 0-7 0",key:"zmuahr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S2=Z("IceCreamCone",[["path",{d:"m7 11 4.08 10.35a1 1 0 0 0 1.84 0L17 11",key:"1v6356"}],["path",{d:"M17 7A5 5 0 0 0 7 7",key:"151p3v"}],["path",{d:"M17 7a2 2 0 0 1 0 4H7a2 2 0 0 1 0-4",key:"1sdaij"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LW=Z("IdCard",[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DW=Z("ImageDown",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19 3 3v-5.5",key:"9ldu5r"}],["path",{d:"m17 22 3-3",key:"1nkfve"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OW=Z("ImageMinus",[["path",{d:"M21 9v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"m87ecr"}],["line",{x1:"16",x2:"22",y1:"5",y2:"5",key:"ez7e4s"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RW=Z("ImageOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FW=Z("ImagePlay",[["path",{d:"m11 16-5 5",key:"j5f7ct"}],["path",{d:"M11 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6.5",key:"7s81lt"}],["path",{d:"M15.765 22a.5.5 0 0 1-.765-.424V13.38a.5.5 0 0 1 .765-.424l5.878 3.674a1 1 0 0 1 0 1.696z",key:"1omb6s"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T0=Z("ImagePlus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zW=Z("ImageUp",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19.5 3-3 3 3",key:"9vmjn0"}],["path",{d:"M17 22v-5.5",key:"1aa6fl"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BW=Z("ImageUpscale",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M17 21h2a2 2 0 0 0 2-2",key:"130fy9"}],["path",{d:"M21 12v3",key:"1wzk3p"}],["path",{d:"m21 3-5 5",key:"1g5oa7"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2",key:"kk3yz1"}],["path",{d:"m5 21 4.144-4.144a1.21 1.21 0 0 1 1.712 0L13 19",key:"fyekpt"}],["path",{d:"M9 3h3",key:"d52fa"}],["rect",{x:"3",y:"11",width:"10",height:"10",rx:"1",key:"1wpmix"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jo=Z("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $W=Z("Images",[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qW=Z("Import",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UW=Z("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C2=Z("IndentDecrease",[["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 18H11",key:"4wu86t"}],["path",{d:"M21 6H11",key:"6dy1d6"}],["path",{d:"m7 8-4 4 4 4",key:"o5hrat"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M2=Z("IndentIncrease",[["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 18H11",key:"4wu86t"}],["path",{d:"M21 6H11",key:"6dy1d6"}],["path",{d:"m3 8 4 4-4 4",key:"1a3j6y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VW=Z("IndianRupee",[["path",{d:"M6 3h12",key:"ggurg9"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"m6 13 8.5 8",key:"u1kupk"}],["path",{d:"M6 13h3",key:"wdp6ag"}],["path",{d:"M9 13c6.667 0 6.667-10 0-10",key:"1nkvk2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HW=Z("Infinity",[["path",{d:"M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z",key:"1z0uae"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cP=Z("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WW=Z("InspectionPanel",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7h.01",key:"7u93v4"}],["path",{d:"M17 7h.01",key:"14a9sn"}],["path",{d:"M7 17h.01",key:"19xn7k"}],["path",{d:"M17 17h.01",key:"1sd3ek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wd=Z("Instagram",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h5=Z("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GW=Z("IterationCcw",[["path",{d:"M20 10c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8h8",key:"4znkd0"}],["polyline",{points:"16 14 20 18 16 22",key:"11njsm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KW=Z("IterationCw",[["path",{d:"M4 10c0-4.4 3.6-8 8-8s8 3.6 8 8-3.6 8-8 8H4",key:"tuf4su"}],["polyline",{points:"8 22 4 18 8 14",key:"evkj9s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZW=Z("JapaneseYen",[["path",{d:"M12 9.5V21m0-11.5L6 3m6 6.5L18 3",key:"2ej80x"}],["path",{d:"M6 15h12",key:"1hwgt5"}],["path",{d:"M6 11h12",key:"wf4gp6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YW=Z("Joystick",[["path",{d:"M21 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-2Z",key:"jg2n2t"}],["path",{d:"M6 15v-2",key:"gd6mvg"}],["path",{d:"M12 15V9",key:"8c7uyn"}],["circle",{cx:"12",cy:"6",r:"3",key:"1gm2ql"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wx=Z("Kanban",[["path",{d:"M6 5v11",key:"mdvv1e"}],["path",{d:"M12 5v6",key:"14ar3b"}],["path",{d:"M18 5v14",key:"7ji314"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rN=Z("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XW=Z("KeySquare",[["path",{d:"M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z",key:"165ttr"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814",key:"1ubxi2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Im=Z("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QW=Z("KeyboardMusic",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 8h4",key:"utf9t1"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M6 12v4",key:"dy92yo"}],["path",{d:"M10 12v4",key:"1fxnav"}],["path",{d:"M14 12v4",key:"1hft58"}],["path",{d:"M18 12v4",key:"tjjnbz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JW=Z("KeyboardOff",[["path",{d:"M 20 4 A2 2 0 0 1 22 6",key:"1g1fkt"}],["path",{d:"M 22 6 L 22 16.41",key:"1qjg3w"}],["path",{d:"M 7 16 L 16 16",key:"n0yqwb"}],["path",{d:"M 9.69 4 L 20 4",key:"kbpcgx"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20 20H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2",key:"s23sx2"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M8 12h.01",key:"czm47f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eG=Z("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tG=Z("LampCeiling",[["path",{d:"M12 2v5",key:"nd4vlx"}],["path",{d:"M6 7h12l4 9H2l4-9Z",key:"123d64"}],["path",{d:"M9.17 16a3 3 0 1 0 5.66 0",key:"1061mw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sG=Z("LampDesk",[["path",{d:"m14 5-3 3 2 7 8-8-7-2Z",key:"1b0msb"}],["path",{d:"m14 5-3 3-3-3 3-3 3 3Z",key:"1uemms"}],["path",{d:"M9.5 6.5 4 12l3 6",key:"1bx08v"}],["path",{d:"M3 22v-2c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v2H3Z",key:"wap775"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rG=Z("LampFloor",[["path",{d:"M9 2h6l3 7H6l3-7Z",key:"wcx6mj"}],["path",{d:"M12 9v13",key:"3n1su1"}],["path",{d:"M9 22h6",key:"1rlq3v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nG=Z("LampWallDown",[["path",{d:"M11 13h6l3 7H8l3-7Z",key:"9n3qlo"}],["path",{d:"M14 13V8a2 2 0 0 0-2-2H8",key:"1hu4hb"}],["path",{d:"M4 9h2a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H4v6Z",key:"s053bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aG=Z("LampWallUp",[["path",{d:"M11 4h6l3 7H8l3-7Z",key:"11x1ee"}],["path",{d:"M14 11v5a2 2 0 0 1-2 2H8",key:"eutp5o"}],["path",{d:"M4 15h2a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2H4v-6Z",key:"1iuthr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iG=Z("Lamp",[["path",{d:"M8 2h8l4 10H4L8 2Z",key:"9dma5w"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M8 22v-2c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v2H8Z",key:"mwf4oh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oG=Z("LandPlot",[["path",{d:"m12 8 6-3-6-3v10",key:"mvpnpy"}],["path",{d:"m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12",key:"ek95tt"}],["path",{d:"m6.49 12.85 11.02 6.3",key:"1kt42w"}],["path",{d:"M17.51 12.85 6.5 19.15",key:"v55bdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lG=Z("Landmark",[["line",{x1:"3",x2:"21",y1:"22",y2:"22",key:"j8o0r"}],["line",{x1:"6",x2:"6",y1:"18",y2:"11",key:"10tf0k"}],["line",{x1:"10",x2:"10",y1:"18",y2:"11",key:"54lgf6"}],["line",{x1:"14",x2:"14",y1:"18",y2:"11",key:"380y"}],["line",{x1:"18",x2:"18",y1:"18",y2:"11",key:"1kevvc"}],["polygon",{points:"12 2 20 7 4 7",key:"jkujk7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cG=Z("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dG=Z("LaptopMinimalCheck",[["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}],["rect",{x:"3",y:"4",width:"18",height:"12",rx:"2",key:"8ur36m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T2=Z("LaptopMinimal",[["rect",{width:"18",height:"12",x:"3",y:"4",rx:"2",ry:"2",key:"1qhy41"}],["line",{x1:"2",x2:"22",y1:"20",y2:"20",key:"ni3hll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uG=Z("Laptop",[["path",{d:"M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16",key:"tarvll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hG=Z("LassoSelect",[["path",{d:"M7 22a5 5 0 0 1-2-4",key:"umushi"}],["path",{d:"M7 16.93c.96.43 1.96.74 2.99.91",key:"ybbtv3"}],["path",{d:"M3.34 14A6.8 6.8 0 0 1 2 10c0-4.42 4.48-8 10-8s10 3.58 10 8a7.19 7.19 0 0 1-.33 2",key:"gt5e1w"}],["path",{d:"M5 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z",key:"bq3ynw"}],["path",{d:"M14.33 22h-.09a.35.35 0 0 1-.24-.32v-10a.34.34 0 0 1 .33-.34c.08 0 .15.03.21.08l7.34 6a.33.33 0 0 1-.21.59h-4.49l-2.57 3.85a.35.35 0 0 1-.28.14z",key:"72q637"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mG=Z("Lasso",[["path",{d:"M7 22a5 5 0 0 1-2-4",key:"umushi"}],["path",{d:"M3.3 14A6.8 6.8 0 0 1 2 10c0-4.4 4.5-8 10-8s10 3.6 10 8-4.5 8-10 8a12 12 0 0 1-5-1",key:"146dds"}],["path",{d:"M5 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z",key:"bq3ynw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pG=Z("Laugh",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12Z",key:"b2q4dd"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fG=Z("Layers2",[["path",{d:"m16.02 12 5.48 3.13a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74L7.98 12",key:"1cuww1"}],["path",{d:"M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74Z",key:"pdlvxu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gG=Z("Layers3",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m6.08 9.5-3.5 1.6a1 1 0 0 0 0 1.81l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9a1 1 0 0 0 0-1.83l-3.5-1.59",key:"1e5n1m"}],["path",{d:"m6.08 14.5-3.5 1.6a1 1 0 0 0 0 1.81l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9a1 1 0 0 0 0-1.83l-3.5-1.59",key:"1iwflc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xG=Z("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nN=Z("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mp=Z("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yG=Z("LayoutList",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vG=Z("LayoutPanelLeft",[["rect",{width:"7",height:"18",x:"3",y:"3",rx:"1",key:"2obqm"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _G=Z("LayoutPanelTop",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aN=Z("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bG=Z("Leaf",[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wG=Z("LeafyGreen",[["path",{d:"M2 22c1.25-.987 2.27-1.975 3.9-2.2a5.56 5.56 0 0 1 3.8 1.5 4 4 0 0 0 6.187-2.353 3.5 3.5 0 0 0 3.69-5.116A3.5 3.5 0 0 0 20.95 8 3.5 3.5 0 1 0 16 3.05a3.5 3.5 0 0 0-5.831 1.373 3.5 3.5 0 0 0-5.116 3.69 4 4 0 0 0-2.348 6.155C3.499 15.42 4.409 16.712 4.2 18.1 3.926 19.743 3.014 20.732 2 22",key:"1134nt"}],["path",{d:"M2 22 17 7",key:"1q7jp2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jG=Z("Lectern",[["path",{d:"M16 12h3a2 2 0 0 0 1.902-1.38l1.056-3.333A1 1 0 0 0 21 6H3a1 1 0 0 0-.958 1.287l1.056 3.334A2 2 0 0 0 5 12h3",key:"13jjxg"}],["path",{d:"M18 6V3a1 1 0 0 0-1-1h-3",key:"1550fe"}],["rect",{width:"8",height:"12",x:"8",y:"10",rx:"1",key:"qmu8b6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kG=Z("LetterText",[["path",{d:"M15 12h6",key:"upa0zy"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"m3 13 3.553-7.724a.5.5 0 0 1 .894 0L11 13",key:"blevx4"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M4 11h6",key:"olkgv1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NG=Z("LibraryBig",[["rect",{width:"8",height:"18",x:"3",y:"3",rx:"1",key:"oynpb5"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M20.4 18.9c.2.5-.1 1.1-.6 1.3l-1.9.7c-.5.2-1.1-.1-1.3-.6L11.1 5.1c-.2-.5.1-1.1.6-1.3l1.9-.7c.5-.2 1.1.1 1.3.6Z",key:"1qboyk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m5=Z("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p5=Z("LifeBuoy",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SG=Z("Ligature",[["path",{d:"M8 20V8c0-2.2 1.8-4 4-4 1.5 0 2.8.8 3.5 2",key:"1rtphz"}],["path",{d:"M6 12h4",key:"a4o3ry"}],["path",{d:"M14 12h2v8",key:"c1fccl"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 20h4",key:"lzx1xo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CG=Z("LightbulbOff",[["path",{d:"M16.8 11.2c.8-.9 1.2-2 1.2-3.2a6 6 0 0 0-9.3-5",key:"1fkcox"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M6.3 6.3a4.67 4.67 0 0 0 1.2 5.2c.7.7 1.3 1.5 1.5 2.5",key:"10m8kw"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s_=Z("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MG=Z("Link2Off",[["path",{d:"M9 17H7A5 5 0 0 1 7 7",key:"10o201"}],["path",{d:"M15 7h2a5 5 0 0 1 4 8",key:"1d3206"}],["line",{x1:"8",x2:"12",y1:"12",y2:"12",key:"rvw6j4"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ho=Z("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lo=Z("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lm=Z("Linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TG=Z("ListCheck",[["path",{d:"M11 18H3",key:"n3j2dh"}],["path",{d:"m15 18 2 2 4-4",key:"1szwhi"}],["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AG=Z("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EG=Z("ListCollapse",[["path",{d:"m3 10 2.5-2.5L3 5",key:"i6eama"}],["path",{d:"m3 19 2.5-2.5L3 14",key:"w2gmor"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PG=Z("ListEnd",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M10 18H3",key:"13769t"}],["path",{d:"M21 6v10a2 2 0 0 1-2 2h-5",key:"ilrcs8"}],["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IG=Z("ListFilter",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LG=Z("ListMinus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DG=Z("ListMusic",[["path",{d:"M21 15V6",key:"h1cx4g"}],["path",{d:"M18.5 18a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z",key:"8saifv"}],["path",{d:"M12 12H3",key:"18klou"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M12 18H3",key:"11ftsu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A0=Z("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OG=Z("ListPlus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RG=Z("ListRestart",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M7 12H3",key:"13ou7f"}],["path",{d:"M7 18H3",key:"1sijw9"}],["path",{d:"M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14",key:"qth677"}],["path",{d:"M11 10v4h4",key:"172dkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FG=Z("ListStart",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M10 6H3",key:"lf8lx7"}],["path",{d:"M21 18V8a2 2 0 0 0-2-2h-5",key:"1hghli"}],["path",{d:"m16 8-2-2 2-2",key:"160uvd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zG=Z("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BG=Z("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $G=Z("ListVideo",[["path",{d:"M12 12H3",key:"18klou"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M12 18H3",key:"11ftsu"}],["path",{d:"m16 12 5 3-5 3v-6Z",key:"zpskkp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qG=Z("ListX",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uh=Z("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const As=Z("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UG=Z("LoaderPinwheel",[["path",{d:"M22 12a1 1 0 0 1-10 0 1 1 0 0 0-10 0",key:"1lzz15"}],["path",{d:"M7 20.7a1 1 0 1 1 5-8.7 1 1 0 1 0 5-8.6",key:"1gnrpi"}],["path",{d:"M7 3.3a1 1 0 1 1 5 8.6 1 1 0 1 0 5 8.6",key:"u9yy5q"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VG=Z("Loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HG=Z("LocateFixed",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WG=Z("LocateOff",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["path",{d:"M7.11 7.11C5.83 8.39 5 10.1 5 12c0 3.87 3.13 7 7 7 1.9 0 3.61-.83 4.89-2.11",key:"1oh7ia"}],["path",{d:"M18.71 13.96c.19-.63.29-1.29.29-1.96 0-3.87-3.13-7-7-7-.67 0-1.33.1-1.96.29",key:"3qdecy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dP=Z("Locate",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A2=Z("LockKeyholeOpen",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}],["path",{d:"M7 10V7a5 5 0 0 1 9.33-2.5",key:"car5b7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GG=Z("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E2=Z("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zu=Z("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f5=Z("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g5=Z("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KG=Z("Logs",[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZG=Z("Lollipop",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M11 11a2 2 0 0 0 4 0 4 4 0 0 0-8 0 6 6 0 0 0 12 0",key:"107gwy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YG=Z("Luggage",[["path",{d:"M6 20a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2",key:"1m57jg"}],["path",{d:"M8 18V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v14",key:"1l99gc"}],["path",{d:"M10 20h4",key:"ni2waw"}],["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XG=Z("Magnet",[["path",{d:"m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15",key:"1i3lhw"}],["path",{d:"m5 8 4 4",key:"j6kj7e"}],["path",{d:"m12 15 4 4",key:"lnac28"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QG=Z("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JG=Z("MailMinus",[["path",{d:"M22 15V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"fuxbkv"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M16 19h6",key:"xwg31i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eK=Z("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tK=Z("MailPlus",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M16 19h6",key:"xwg31i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sK=Z("MailQuestion",[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 15.28c.2-.4.5-.8.9-1a2.1 2.1 0 0 1 2.6.4c.3.4.5.8.5 1.3 0 1.3-2 2-2 2",key:"7z9rxb"}],["path",{d:"M20 22v.01",key:"12bgn6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rK=Z("MailSearch",[["path",{d:"M22 12.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h7.5",key:"w80f2v"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",key:"8lzu5m"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m22 22-1.5-1.5",key:"1x83k4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nK=Z("MailWarning",[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M20 14v4",key:"1hm744"}],["path",{d:"M20 22v.01",key:"12bgn6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uP=Z("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _r=Z("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aK=Z("Mailbox",[["path",{d:"M22 17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9.5C2 7 4 5 6.5 5H18c2.2 0 4 1.8 4 4v8Z",key:"1lbycx"}],["polyline",{points:"15,9 18,9 18,11",key:"1pm9c0"}],["path",{d:"M6.5 5C9 5 11 7 11 9.5V17a2 2 0 0 1-2 2",key:"15i455"}],["line",{x1:"6",x2:"7",y1:"10",y2:"10",key:"1e2scm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iK=Z("Mails",[["rect",{width:"16",height:"13",x:"6",y:"4",rx:"2",key:"1drq3f"}],["path",{d:"m22 7-7.1 3.78c-.57.3-1.23.3-1.8 0L6 7",key:"xn252p"}],["path",{d:"M2 8v11c0 1.1.9 2 2 2h14",key:"n13cji"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oK=Z("MapPinCheckInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lK=Z("MapPinCheck",[["path",{d:"M19.43 12.935c.357-.967.57-1.955.57-2.935a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32.197 32.197 0 0 0 .813-.728",key:"1dq61d"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"m16 18 2 2 4-4",key:"1mkfmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cK=Z("MapPinHouse",[["path",{d:"M15 22a1 1 0 0 1-1-1v-4a1 1 0 0 1 .445-.832l3-2a1 1 0 0 1 1.11 0l3 2A1 1 0 0 1 22 17v4a1 1 0 0 1-1 1z",key:"1p1rcz"}],["path",{d:"M18 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 .601.2",key:"mcbcs9"}],["path",{d:"M18 22v-3",key:"1t1ugv"}],["circle",{cx:"10",cy:"10",r:"3",key:"1ns7v1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dK=Z("MapPinMinusInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uK=Z("MapPinMinus",[["path",{d:"M18.977 14C19.6 12.701 20 11.343 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32 32 0 0 0 .824-.738",key:"11uxia"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M16 18h6",key:"987eiv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hK=Z("MapPinOff",[["path",{d:"M12.75 7.09a3 3 0 0 1 2.16 2.16",key:"1d4wjd"}],["path",{d:"M17.072 17.072c-1.634 2.17-3.527 3.912-4.471 4.727a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 1.432-4.568",key:"12yil7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.475 2.818A8 8 0 0 1 20 10c0 1.183-.31 2.377-.81 3.533",key:"lhrkcz"}],["path",{d:"M9.13 9.13a3 3 0 0 0 3.74 3.74",key:"13wojd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mK=Z("MapPinPlusInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pK=Z("MapPinPlus",[["path",{d:"M19.914 11.105A7.298 7.298 0 0 0 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32 32 0 0 0 .824-.738",key:"fcdtly"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M16 18h6",key:"987eiv"}],["path",{d:"M19 15v6",key:"10aioa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fK=Z("MapPinXInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gK=Z("MapPinX",[["path",{d:"M19.752 11.901A7.78 7.78 0 0 0 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 19 19 0 0 0 .09-.077",key:"y0ewhp"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"m21.5 15.5-5 5",key:"11iqnx"}],["path",{d:"m21.5 20.5-5-5",key:"1bylgx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ai=Z("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xK=Z("MapPinned",[["path",{d:"M18 8c0 3.613-3.869 7.429-5.393 8.795a1 1 0 0 1-1.214 0C9.87 15.429 6 11.613 6 8a6 6 0 0 1 12 0",key:"11u0oz"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M8.714 14h-3.71a1 1 0 0 0-.948.683l-2.004 6A1 1 0 0 0 3 22h18a1 1 0 0 0 .948-1.316l-2-6a1 1 0 0 0-.949-.684h-3.712",key:"q8zwxj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yK=Z("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vK=Z("Martini",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M12 11v11",key:"ur9y6a"}],["path",{d:"m19 3-7 8-7-8Z",key:"1sgpiw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _K=Z("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hP=Z("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E0=Z("Medal",[["path",{d:"M7.21 15 2.66 7.14a2 2 0 0 1 .13-2.2L4.4 2.8A2 2 0 0 1 6 2h12a2 2 0 0 1 1.6.8l1.6 2.14a2 2 0 0 1 .14 2.2L16.79 15",key:"143lza"}],["path",{d:"M11 12 5.12 2.2",key:"qhuxz6"}],["path",{d:"m13 12 5.88-9.8",key:"hbye0f"}],["path",{d:"M8 7h8",key:"i86dvs"}],["circle",{cx:"12",cy:"17",r:"5",key:"qbz8iq"}],["path",{d:"M12 18v-2h-.5",key:"fawc4q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bK=Z("MegaphoneOff",[["path",{d:"M9.26 9.26 3 11v3l14.14 3.14",key:"3429n"}],["path",{d:"M21 15.34V6l-7.31 2.03",key:"4o1dh8"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zg=Z("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wK=Z("Meh",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"8",x2:"16",y1:"15",y2:"15",key:"1xb1d9"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jK=Z("MemoryStick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mP=Z("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kK=Z("Merge",[["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22",key:"1hyw0i"}],["path",{d:"m20 22-5-5",key:"1m27yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NK=Z("MessageCircleCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22z",key:"k85zhp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SK=Z("MessageCircleDashed",[["path",{d:"M13.5 3.1c-.5 0-1-.1-1.5-.1s-1 .1-1.5.1",key:"16ll65"}],["path",{d:"M19.3 6.8a10.45 10.45 0 0 0-2.1-2.1",key:"1nq77a"}],["path",{d:"M20.9 13.5c.1-.5.1-1 .1-1.5s-.1-1-.1-1.5",key:"1sf7wn"}],["path",{d:"M17.2 19.3a10.45 10.45 0 0 0 2.1-2.1",key:"x1hs5g"}],["path",{d:"M10.5 20.9c.5.1 1 .1 1.5.1s1-.1 1.5-.1",key:"19m18z"}],["path",{d:"M3.5 17.5 2 22l4.5-1.5",key:"1f36qi"}],["path",{d:"M3.1 10.5c0 .5-.1 1-.1 1.5s.1 1 .1 1.5",key:"1vz3ju"}],["path",{d:"M6.8 4.7a10.45 10.45 0 0 0-2.1 2.1",key:"19f9do"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x5=Z("MessageCircleHeart",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M15.8 9.2a2.5 2.5 0 0 0-3.5 0l-.3.4-.35-.3a2.42 2.42 0 1 0-3.2 3.6l3.6 3.5 3.6-3.5c1.2-1.2 1.1-2.7.2-3.7",key:"43lnbm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CK=Z("MessageCircleMore",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MK=Z("MessageCircleOff",[["path",{d:"M20.5 14.9A9 9 0 0 0 9.1 3.5",key:"1iebmn"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.6 5.6C3 8.3 2.2 12.5 4 16l-2 6 6-2c3.4 1.8 7.6 1.1 10.3-1.7",key:"1ov8ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TK=Z("MessageCirclePlus",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pP=Z("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AK=Z("MessageCircleReply",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}],["path",{d:"M7 12h7a2 2 0 0 1 2 2v1",key:"1gheu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EK=Z("MessageCircleWarning",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PK=Z("MessageCircleX",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gc=Z("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IK=Z("MessageSquareCode",[["path",{d:"M10 7.5 8 10l2 2.5",key:"xb17xw"}],["path",{d:"m14 7.5 2 2.5-2 2.5",key:"5rap1v"}],["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LK=Z("MessageSquareDashed",[["path",{d:"M10 17H7l-4 4v-7",key:"1r71xu"}],["path",{d:"M14 17h1",key:"nufu4t"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 14v1a2 2 0 0 1-2 2",key:"29akq3"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M9 3h1",key:"1yesri"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DK=Z("MessageSquareDiff",[["path",{d:"m5 19-2 2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2",key:"1xuzuj"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OK=Z("MessageSquareDot",[["path",{d:"M11.7 3H5a2 2 0 0 0-2 2v16l4-4h12a2 2 0 0 0 2-2v-2.7",key:"uodpkb"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RK=Z("MessageSquareHeart",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M14.8 7.5a1.84 1.84 0 0 0-2.6 0l-.2.3-.3-.3a1.84 1.84 0 1 0-2.4 2.8L12 13l2.7-2.7c.9-.9.8-2.1.1-2.8",key:"1blaws"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FK=Z("MessageSquareLock",[["path",{d:"M19 15v-2a2 2 0 1 0-4 0v2",key:"h3d1vz"}],["path",{d:"M9 17H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v3.5",key:"xsnnhn"}],["rect",{x:"13",y:"15",width:"8",height:"5",rx:"1",key:"1ccwuk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fP=Z("MessageSquareMore",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M16 10h.01",key:"1m94wz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zK=Z("MessageSquareOff",[["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M3.6 3.6c-.4.3-.6.8-.6 1.4v16l4-4h10",key:"pwpm4a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y5=Z("MessageSquarePlus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gP=Z("MessageSquareQuote",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 12a2 2 0 0 0 2-2V8H8",key:"1jfesj"}],["path",{d:"M14 12a2 2 0 0 0 2-2V8h-2",key:"1dq9mh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BK=Z("MessageSquareReply",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"m10 7-3 3 3 3",key:"1eugdv"}],["path",{d:"M17 13v-1a2 2 0 0 0-2-2H7",key:"ernfh3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $K=Z("MessageSquareShare",[["path",{d:"M21 12v3a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h7",key:"tqtdkg"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"m16 8 5-5",key:"15mbrl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qK=Z("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UK=Z("MessageSquareWarning",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v2",key:"stiyo7"}],["path",{d:"M12 13h.01",key:"y0uutt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VK=Z("MessageSquareX",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oo=Z("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HK=Z("MessagesSquare",[["path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z",key:"p1xzt8"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1",key:"1cx29u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WK=Z("MicOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P2=Z("MicVocal",[["path",{d:"m11 7.601-5.994 8.19a1 1 0 0 0 .1 1.298l.817.818a1 1 0 0 0 1.314.087L15.09 12",key:"80a601"}],["path",{d:"M16.5 21.174C15.5 20.5 14.372 20 13 20c-2.058 0-3.928 2.356-6 2-2.072-.356-2.775-3.369-1.5-4.5",key:"j0ngtp"}],["circle",{cx:"16",cy:"7",r:"5",key:"d08jfb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xP=Z("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GK=Z("Microchip",[["path",{d:"M18 12h2",key:"quuxs7"}],["path",{d:"M18 16h2",key:"zsn3lv"}],["path",{d:"M18 20h2",key:"9x5y9y"}],["path",{d:"M18 4h2",key:"1luxfb"}],["path",{d:"M18 8h2",key:"nxqzg"}],["path",{d:"M4 12h2",key:"1ltxp0"}],["path",{d:"M4 16h2",key:"8a5zha"}],["path",{d:"M4 20h2",key:"27dk57"}],["path",{d:"M4 4h2",key:"10groj"}],["path",{d:"M4 8h2",key:"18vq6w"}],["path",{d:"M8 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-1.5c-.276 0-.494.227-.562.495a2 2 0 0 1-3.876 0C9.994 2.227 9.776 2 9.5 2z",key:"1681fp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KK=Z("Microscope",[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZK=Z("Microwave",[["rect",{width:"20",height:"15",x:"2",y:"4",rx:"2",key:"2no95f"}],["rect",{width:"8",height:"7",x:"6",y:"8",rx:"1",key:"zh9wx"}],["path",{d:"M18 8v7",key:"o5zi4n"}],["path",{d:"M6 19v2",key:"1loha6"}],["path",{d:"M18 19v2",key:"1dawf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YK=Z("Milestone",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M12 3v3",key:"1n5kay"}],["path",{d:"M4 6a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h13a2 2 0 0 0 1.152-.365l3.424-2.317a1 1 0 0 0 0-1.635l-3.424-2.318A2 2 0 0 0 17 6z",key:"1btarq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XK=Z("MilkOff",[["path",{d:"M8 2h8",key:"1ssgc1"}],["path",{d:"M9 2v1.343M15 2v2.789a4 4 0 0 0 .672 2.219l.656.984a4 4 0 0 1 .672 2.22v1.131M7.8 7.8l-.128.192A4 4 0 0 0 7 10.212V20a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-3",key:"y0ejgx"}],["path",{d:"M7 15a6.47 6.47 0 0 1 5 0 6.472 6.472 0 0 0 3.435.435",key:"iaxqsy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QK=Z("Milk",[["path",{d:"M8 2h8",key:"1ssgc1"}],["path",{d:"M9 2v2.789a4 4 0 0 1-.672 2.219l-.656.984A4 4 0 0 0 7 10.212V20a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-9.789a4 4 0 0 0-.672-2.219l-.656-.984A4 4 0 0 1 15 4.788V2",key:"qtp12x"}],["path",{d:"M7 15a6.472 6.472 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"ygeh44"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JK=Z("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eZ=Z("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P0=Z("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tZ=Z("MonitorCheck",[["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sZ=Z("MonitorCog",[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m15.2 4.9-.9-.4",key:"12wd2u"}],["path",{d:"m15.2 7.1-.9.4",key:"1r2vl7"}],["path",{d:"m16.9 3.2-.4-.9",key:"3zbo91"}],["path",{d:"m16.9 8.8-.4.9",key:"1qr2dn"}],["path",{d:"m19.5 2.3-.4.9",key:"1rjrkq"}],["path",{d:"m19.5 9.7-.4-.9",key:"heryx5"}],["path",{d:"m21.7 4.5-.9.4",key:"17fqt1"}],["path",{d:"m21.7 7.5-.9-.4",key:"14zyni"}],["path",{d:"M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"1tnzv8"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rZ=Z("MonitorDot",[["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M22 12v3a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9",key:"1fet9y"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nZ=Z("MonitorDown",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"m15 10-3 3-3-3",key:"lzhmyn"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aZ=Z("MonitorOff",[["path",{d:"M17 17H4a2 2 0 0 1-2-2V5c0-1.5 1-2 1-2",key:"k0q8oc"}],["path",{d:"M22 15V5a2 2 0 0 0-2-2H9",key:"cp1ac0"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iZ=Z("MonitorPause",[["path",{d:"M10 13V7",key:"1u13u9"}],["path",{d:"M14 13V7",key:"1vj9om"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oZ=Z("MonitorPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lZ=Z("MonitorSmartphone",[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cZ=Z("MonitorSpeaker",[["path",{d:"M5.5 20H8",key:"1k40s5"}],["path",{d:"M17 9h.01",key:"1j24nn"}],["rect",{width:"10",height:"16",x:"12",y:"4",rx:"2",key:"ixliua"}],["path",{d:"M8 6H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h4",key:"1mp6e1"}],["circle",{cx:"17",cy:"15",r:"1",key:"tqvash"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dZ=Z("MonitorStop",[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}],["rect",{x:"9",y:"7",width:"6",height:"6",rx:"1",key:"5m2oou"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uZ=Z("MonitorUp",[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hZ=Z("MonitorX",[["path",{d:"m14.5 12.5-5-5",key:"1jahn5"}],["path",{d:"m9.5 12.5 5-5",key:"1k2t7b"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iN=Z("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mZ=Z("MoonStar",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9",key:"4ay0iu"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pZ=Z("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fZ=Z("MountainSnow",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}],["path",{d:"M4.14 15.08c2.62-1.57 5.24-1.43 7.86.42 2.74 1.94 5.49 2 8.23.19",key:"1pvmmp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gZ=Z("Mountain",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xZ=Z("MouseOff",[["path",{d:"M12 6v.343",key:"1gyhex"}],["path",{d:"M18.218 18.218A7 7 0 0 1 5 15V9a7 7 0 0 1 .782-3.218",key:"ukzz01"}],["path",{d:"M19 13.343V9A7 7 0 0 0 8.56 2.902",key:"104jy9"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yZ=Z("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vZ=Z("MousePointerBan",[["path",{d:"M2.034 2.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.944L8.204 7.545a1 1 0 0 0-.66.66l-1.066 3.443a.5.5 0 0 1-.944.033z",key:"11pp1i"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"m11.8 11.8 8.4 8.4",key:"oogvdj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r_=Z("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jm=Z("MousePointer",[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Z=Z("Mouse",[["rect",{x:"5",y:"2",width:"14",height:"20",rx:"7",key:"11ol66"}],["path",{d:"M12 6v4",key:"16clxf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I2=Z("Move3d",[["path",{d:"M5 3v16h16",key:"1mqmf9"}],["path",{d:"m5 19 6-6",key:"jh6hbb"}],["path",{d:"m2 6 3-3 3 3",key:"tkyvxa"}],["path",{d:"m18 16 3 3-3 3",key:"1d4glt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bZ=Z("MoveDiagonal2",[["path",{d:"M19 13v6h-6",key:"1hxl6d"}],["path",{d:"M5 11V5h6",key:"12e2xe"}],["path",{d:"m5 5 14 14",key:"11anup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wZ=Z("MoveDiagonal",[["path",{d:"M11 19H5v-6",key:"8awifj"}],["path",{d:"M13 5h6v6",key:"7voy1q"}],["path",{d:"M19 5 5 19",key:"wwaj1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jZ=Z("MoveDownLeft",[["path",{d:"M11 19H5V13",key:"1akmht"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kZ=Z("MoveDownRight",[["path",{d:"M19 13V19H13",key:"10vkzq"}],["path",{d:"M5 5L19 19",key:"5zm2fv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NZ=Z("MoveDown",[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SZ=Z("MoveHorizontal",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CZ=Z("MoveLeft",[["path",{d:"M6 8L2 12L6 16",key:"kyvwex"}],["path",{d:"M2 12H22",key:"1m8cig"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MZ=Z("MoveRight",[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TZ=Z("MoveUpLeft",[["path",{d:"M5 11V5H11",key:"3q78g9"}],["path",{d:"M5 5L19 19",key:"5zm2fv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AZ=Z("MoveUpRight",[["path",{d:"M13 5H19V11",key:"1n1gyv"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EZ=Z("MoveUp",[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PZ=Z("MoveVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IZ=Z("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LZ=Z("Music2",[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DZ=Z("Music3",[["circle",{cx:"12",cy:"18",r:"4",key:"m3r9ws"}],["path",{d:"M16 18V2",key:"40x2m5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OZ=Z("Music4",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["path",{d:"m9 9 12-2",key:"1e64n2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RZ=Z("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FZ=Z("Navigation2Off",[["path",{d:"M9.31 9.31 5 21l7-4 7 4-1.17-3.17",key:"qoq2o2"}],["path",{d:"M14.53 8.88 12 2l-1.17 3.17",key:"k3sjzy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zZ=Z("Navigation2",[["polygon",{points:"12 2 19 21 12 17 5 21 12 2",key:"x8c0qg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BZ=Z("NavigationOff",[["path",{d:"M8.43 8.43 3 11l8 2 2 8 2.57-5.43",key:"1vdtb7"}],["path",{d:"M17.39 11.73 22 2l-9.73 4.61",key:"tya3r6"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yP=Z("Navigation",[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Z=Z("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I0=Z("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qZ=Z("Nfc",[["path",{d:"M6 8.32a7.43 7.43 0 0 1 0 7.36",key:"9iaqei"}],["path",{d:"M9.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"1yha7l"}],["path",{d:"M12.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"4iu2gk"}],["path",{d:"M16.37 2a20.16 20.16 0 0 1 0 20",key:"sap9u2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UZ=Z("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VZ=Z("NotebookTabs",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M15 2v20",key:"dcj49h"}],["path",{d:"M15 7h5",key:"1xj5lc"}],["path",{d:"M15 12h5",key:"w5shd9"}],["path",{d:"M15 17h5",key:"1qaofu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HZ=Z("NotebookText",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M9.5 8h5",key:"11mslq"}],["path",{d:"M9.5 12H16",key:"ktog6x"}],["path",{d:"M9.5 16H14",key:"p1seyn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WZ=Z("Notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GZ=Z("NotepadTextDashed",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v2",key:"j91f56"}],["path",{d:"M20 12v2",key:"w8o0tu"}],["path",{d:"M20 18v2a2 2 0 0 1-2 2h-1",key:"1c9ggx"}],["path",{d:"M13 22h-2",key:"191ugt"}],["path",{d:"M7 22H6a2 2 0 0 1-2-2v-2",key:"1rt9px"}],["path",{d:"M4 14v-2",key:"1v0sqh"}],["path",{d:"M4 8V6a2 2 0 0 1 2-2h2",key:"1mwabg"}],["path",{d:"M8 10h6",key:"3oa6kw"}],["path",{d:"M8 14h8",key:"1fgep2"}],["path",{d:"M8 18h5",key:"17enja"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KZ=Z("NotepadText",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"16",height:"18",x:"4",y:"4",rx:"2",key:"1u9h20"}],["path",{d:"M8 10h6",key:"3oa6kw"}],["path",{d:"M8 14h8",key:"1fgep2"}],["path",{d:"M8 18h5",key:"17enja"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZZ=Z("NutOff",[["path",{d:"M12 4V2",key:"1k5q1u"}],["path",{d:"M5 10v4a7.004 7.004 0 0 0 5.277 6.787c.412.104.802.292 1.102.592L12 22l.621-.621c.3-.3.69-.488 1.102-.592a7.01 7.01 0 0 0 4.125-2.939",key:"1xcvy9"}],["path",{d:"M19 10v3.343",key:"163tfc"}],["path",{d:"M12 12c-1.349-.573-1.905-1.005-2.5-2-.546.902-1.048 1.353-2.5 2-1.018-.644-1.46-1.08-2-2-1.028.71-1.69.918-3 1 1.081-1.048 1.757-2.03 2-3 .194-.776.84-1.551 1.79-2.21m11.654 5.997c.887-.457 1.28-.891 1.556-1.787 1.032.916 1.683 1.157 3 1-1.297-1.036-1.758-2.03-2-3-.5-2-4-4-8-4-.74 0-1.461.068-2.15.192",key:"17914v"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YZ=Z("Nut",[["path",{d:"M12 4V2",key:"1k5q1u"}],["path",{d:"M5 10v4a7.004 7.004 0 0 0 5.277 6.787c.412.104.802.292 1.102.592L12 22l.621-.621c.3-.3.69-.488 1.102-.592A7.003 7.003 0 0 0 19 14v-4",key:"1tgyif"}],["path",{d:"M12 4C8 4 4.5 6 4 8c-.243.97-.919 1.952-2 3 1.31-.082 1.972-.29 3-1 .54.92.982 1.356 2 2 1.452-.647 1.954-1.098 2.5-2 .595.995 1.151 1.427 2.5 2 1.31-.621 1.862-1.058 2.5-2 .629.977 1.162 1.423 2.5 2 1.209-.548 1.68-.967 2-2 1.032.916 1.683 1.157 3 1-1.297-1.036-1.758-2.03-2-3-.5-2-4-4-8-4Z",key:"tnsqj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o0=Z("OctagonAlert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XZ=Z("OctagonMinus",[["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L2=Z("OctagonPause",[["path",{d:"M10 15V9",key:"1lckn7"}],["path",{d:"M14 15V9",key:"1muqhk"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D2=Z("OctagonX",[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QZ=Z("Octagon",[["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JZ=Z("Omega",[["path",{d:"M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21",key:"1x94xo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eY=Z("Option",[["path",{d:"M3 3h6l6 18h6",key:"ph9rgk"}],["path",{d:"M14 3h7",key:"16f0ms"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tY=Z("Orbit",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M10.4 21.9a10 10 0 0 0 9.941-15.416",key:"eohfx2"}],["path",{d:"M13.5 2.1a10 10 0 0 0-9.841 15.416",key:"19pvbm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sY=Z("Origami",[["path",{d:"M12 12V4a1 1 0 0 1 1-1h6.297a1 1 0 0 1 .651 1.759l-4.696 4.025",key:"1bx4vc"}],["path",{d:"m12 21-7.414-7.414A2 2 0 0 1 4 12.172V6.415a1.002 1.002 0 0 1 1.707-.707L20 20.009",key:"1h3km6"}],["path",{d:"m12.214 3.381 8.414 14.966a1 1 0 0 1-.167 1.199l-1.168 1.163a1 1 0 0 1-.706.291H6.351a1 1 0 0 1-.625-.219L3.25 18.8a1 1 0 0 1 .631-1.781l4.165.027",key:"1hj4wg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rY=Z("Package2",[["path",{d:"M3 9h18v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9Z",key:"1ront0"}],["path",{d:"m3 9 2.45-4.9A2 2 0 0 1 7.24 3h9.52a2 2 0 0 1 1.8 1.1L21 9",key:"19h2x1"}],["path",{d:"M12 3v6",key:"1holv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nY=Z("PackageCheck",[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aY=Z("PackageMinus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iY=Z("PackageOpen",[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oY=Z("PackagePlus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lY=Z("PackageSearch",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["circle",{cx:"18.5",cy:"15.5",r:"2.5",key:"b5zd12"}],["path",{d:"M20.27 17.27 22 19",key:"1l4muz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cY=Z("PackageX",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["path",{d:"m17 13 5 5m-5 0 5-5",key:"im3w4b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dl=Z("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dY=Z("PaintBucket",[["path",{d:"m19 11-8-8-8.6 8.6a2 2 0 0 0 0 2.8l5.2 5.2c.8.8 2 .8 2.8 0L19 11Z",key:"irua1i"}],["path",{d:"m5 2 5 5",key:"1lls2c"}],["path",{d:"M2 13h15",key:"1hkzvu"}],["path",{d:"M22 20a2 2 0 1 1-4 0c0-1.6 1.7-2.4 2-4 .3 1.6 2 2.4 2 4Z",key:"xk76lq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uY=Z("PaintRoller",[["rect",{width:"16",height:"6",x:"2",y:"2",rx:"2",key:"jcyz7m"}],["path",{d:"M10 16v-2a2 2 0 0 1 2-2h8a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2",key:"1b9h7c"}],["rect",{width:"4",height:"6",x:"8",y:"16",rx:"1",key:"d6e7yl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O2=Z("PaintbrushVertical",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v4",key:"qmzblu"}],["path",{d:"M17 2a1 1 0 0 1 1 1v9H6V3a1 1 0 0 1 1-1z",key:"ycvu00"}],["path",{d:"M6 12a1 1 0 0 0-1 1v1a2 2 0 0 0 2 2h2a1 1 0 0 1 1 1v2.9a2 2 0 1 0 4 0V17a1 1 0 0 1 1-1h2a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1",key:"iw4wnp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hY=Z("Paintbrush",[["path",{d:"m14.622 17.897-10.68-2.913",key:"vj2p1u"}],["path",{d:"M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z",key:"18tc5c"}],["path",{d:"M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15",key:"ytzfxy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bl=Z("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mY=Z("PanelBottomClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m15 8-3 3-3-3",key:"1oxy1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R2=Z("PanelBottomDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M14 15h1",key:"171nev"}],["path",{d:"M19 15h2",key:"1vnucp"}],["path",{d:"M3 15h2",key:"8bym0q"}],["path",{d:"M9 15h1",key:"1tg3ks"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pY=Z("PanelBottomOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fY=Z("PanelBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F2=Z("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z2=Z("PanelLeftDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 14v1",key:"askpd8"}],["path",{d:"M9 19v2",key:"16tejx"}],["path",{d:"M9 3v2",key:"1noubl"}],["path",{d:"M9 9v1",key:"19ebxg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B2=Z("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $2=Z("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gY=Z("PanelRightClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q2=Z("PanelRightDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 14v1",key:"ilsfch"}],["path",{d:"M15 19v2",key:"1fst2f"}],["path",{d:"M15 3v2",key:"z204g4"}],["path",{d:"M15 9v1",key:"z2a8b1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xY=Z("PanelRightOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yY=Z("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vY=Z("PanelTopClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m9 16 3-3 3 3",key:"1idcnm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U2=Z("PanelTopDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M14 9h1",key:"l0svgy"}],["path",{d:"M19 9h2",key:"te2zfg"}],["path",{d:"M3 9h2",key:"1h4ldw"}],["path",{d:"M9 9h1",key:"15jzuz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Y=Z("PanelTopOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m15 14-3 3-3-3",key:"g215vf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bY=Z("PanelTop",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wY=Z("PanelsLeftBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M9 15h12",key:"5ijen5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jY=Z("PanelsRightBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h12",key:"1wkqb3"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l0=Z("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oN=Z("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kY=Z("Parentheses",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NY=Z("ParkingMeter",[["path",{d:"M11 15h2",key:"199qp6"}],["path",{d:"M12 12v3",key:"158kv8"}],["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15.282 19a1 1 0 0 0 .948-.68l2.37-6.988a7 7 0 1 0-13.2 0l2.37 6.988a1 1 0 0 0 .948.68z",key:"1jofit"}],["path",{d:"M9 9a3 3 0 1 1 6 0",key:"jdoeu8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sd=Z("PartyPopper",[["path",{d:"M5.8 11.3 2 22l10.7-3.79",key:"gwxi1d"}],["path",{d:"M4 3h.01",key:"1vcuye"}],["path",{d:"M22 8h.01",key:"1mrtc2"}],["path",{d:"M15 2h.01",key:"1cjtqr"}],["path",{d:"M22 20h.01",key:"1mrys2"}],["path",{d:"m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10",key:"hbicv8"}],["path",{d:"m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17",key:"1i94pl"}],["path",{d:"m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7",key:"1cofks"}],["path",{d:"M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z",key:"4kbmks"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pp=Z("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SY=Z("PawPrint",[["circle",{cx:"11",cy:"4",r:"2",key:"vol9p0"}],["circle",{cx:"18",cy:"8",r:"2",key:"17gozi"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}],["path",{d:"M9 10a5 5 0 0 1 5 5v3.5a3.5 3.5 0 0 1-6.84 1.045Q6.52 17.48 4.46 16.84A3.5 3.5 0 0 1 5.5 10Z",key:"1ydw1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CY=Z("PcCase",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",key:"1uq1d7"}],["path",{d:"M15 14h.01",key:"1kp3bh"}],["path",{d:"M9 6h6",key:"dgm16u"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c0=Z("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MY=Z("PenOff",[["path",{d:"m10 10-6.157 6.162a2 2 0 0 0-.5.833l-1.322 4.36a.5.5 0 0 0 .622.624l4.358-1.323a2 2 0 0 0 .83-.5L14 13.982",key:"bjo8r8"}],["path",{d:"m12.829 7.172 4.359-4.346a1 1 0 1 1 3.986 3.986l-4.353 4.353",key:"16h5ne"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n_=Z("PenTool",[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ix=Z("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TY=Z("PencilLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}],["path",{d:"m15 5 3 3",key:"1w25hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AY=Z("PencilOff",[["path",{d:"m10 10-6.157 6.162a2 2 0 0 0-.5.833l-1.322 4.36a.5.5 0 0 0 .622.624l4.358-1.323a2 2 0 0 0 .83-.5L14 13.982",key:"bjo8r8"}],["path",{d:"m12.829 7.172 4.359-4.346a1 1 0 1 1 3.986 3.986l-4.353 4.353",key:"16h5ne"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EY=Z("PencilRuler",[["path",{d:"M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13",key:"orapub"}],["path",{d:"m8 6 2-2",key:"115y1s"}],["path",{d:"m18 16 2-2",key:"ee94s4"}],["path",{d:"m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17",key:"cfq27r"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ra=Z("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PY=Z("Pentagon",[["path",{d:"M10.83 2.38a2 2 0 0 1 2.34 0l8 5.74a2 2 0 0 1 .73 2.25l-3.04 9.26a2 2 0 0 1-1.9 1.37H7.04a2 2 0 0 1-1.9-1.37L2.1 10.37a2 2 0 0 1 .73-2.25z",key:"2hea0t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v5=Z("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IY=Z("PersonStanding",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["path",{d:"m9 20 3-6 3 6",key:"se2kox"}],["path",{d:"m6 8 6 2 6-2",key:"4o3us4"}],["path",{d:"M12 10v4",key:"1kjpxc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LY=Z("PhilippinePeso",[["path",{d:"M20 11H4",key:"6ut86h"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"M7 21V4a1 1 0 0 1 1-1h4a1 1 0 0 1 0 12H7",key:"1ana5r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DY=Z("PhoneCall",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}],["path",{d:"M14.05 2a9 9 0 0 1 8 7.94",key:"vmijpz"}],["path",{d:"M14.05 6A5 5 0 0 1 18 10",key:"13nbpp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OY=Z("PhoneForwarded",[["polyline",{points:"18 2 22 6 18 10",key:"6vjanh"}],["line",{x1:"14",x2:"22",y1:"6",y2:"6",key:"1jsywh"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RY=Z("PhoneIncoming",[["polyline",{points:"16 2 16 8 22 8",key:"1ygljm"}],["line",{x1:"22",x2:"16",y1:"2",y2:"8",key:"1xzwqn"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FY=Z("PhoneMissed",[["line",{x1:"22",x2:"16",y1:"2",y2:"8",key:"1xzwqn"}],["line",{x1:"16",x2:"22",y1:"2",y2:"8",key:"13zxdn"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zY=Z("PhoneOff",[["path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91",key:"z86iuo"}],["line",{x1:"22",x2:"2",y1:"2",y2:"22",key:"11kh81"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BY=Z("PhoneOutgoing",[["polyline",{points:"22 8 22 2 16 2",key:"1g204g"}],["line",{x1:"16",x2:"22",y1:"8",y2:"2",key:"1ggias"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zn=Z("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Y=Z("Pi",[["line",{x1:"9",x2:"9",y1:"4",y2:"20",key:"ovs5a5"}],["path",{d:"M4 7c0-1.7 1.3-3 3-3h13",key:"10pag4"}],["path",{d:"M18 20c-1.7 0-3-1.3-3-3V4",key:"1gaosr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qY=Z("Piano",[["path",{d:"M18.5 8c-1.4 0-2.6-.8-3.2-2A6.87 6.87 0 0 0 2 9v11a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-8.5C22 9.6 20.4 8 18.5 8",key:"lag0yf"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M6 14v4",key:"9ng0ue"}],["path",{d:"M10 14v4",key:"1v8uk5"}],["path",{d:"M14 14v4",key:"1tqops"}],["path",{d:"M18 14v4",key:"18uqwm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UY=Z("Pickaxe",[["path",{d:"M14.531 12.469 6.619 20.38a1 1 0 1 1-3-3l7.912-7.912",key:"we99rg"}],["path",{d:"M15.686 4.314A12.5 12.5 0 0 0 5.461 2.958 1 1 0 0 0 5.58 4.71a22 22 0 0 1 6.318 3.393",key:"1w6hck"}],["path",{d:"M17.7 3.7a1 1 0 0 0-1.4 0l-4.6 4.6a1 1 0 0 0 0 1.4l2.6 2.6a1 1 0 0 0 1.4 0l4.6-4.6a1 1 0 0 0 0-1.4z",key:"15hgfx"}],["path",{d:"M19.686 8.314a12.501 12.501 0 0 1 1.356 10.225 1 1 0 0 1-1.751-.119 22 22 0 0 0-3.393-6.319",key:"452b4h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VY=Z("PictureInPicture2",[["path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4",key:"daa4of"}],["rect",{width:"10",height:"7",x:"12",y:"13",rx:"2",key:"1nb8gs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HY=Z("PictureInPicture",[["path",{d:"M8 4.5v5H3m-1-6 6 6m13 0v-3c0-1.16-.84-2-2-2h-7m-9 9v2c0 1.05.95 2 2 2h3",key:"bcd8fb"}],["rect",{width:"10",height:"7",x:"12",y:"13.5",ry:"2",key:"136fx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WY=Z("PiggyBank",[["path",{d:"M19 5c-1.5 0-2.8 1.4-3 2-3.5-1.5-11-.3-11 5 0 1.8 0 3 2 4.5V20h4v-2h3v2h4v-4c1-.5 1.7-1 2-2h2v-4h-2c0-1-.5-1.5-1-2V5z",key:"1ivx2i"}],["path",{d:"M2 9v1c0 1.1.9 2 2 2h1",key:"nm575m"}],["path",{d:"M16 11h.01",key:"xkw8gn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GY=Z("PilcrowLeft",[["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"M14 9h-3a3 3 0 0 1 0-6h9",key:"1ulc19"}],["path",{d:"M18 3v11",key:"1phi0r"}],["path",{d:"M22 18H2l4-4",key:"yt65j9"}],["path",{d:"m6 22-4-4",key:"6jgyf5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KY=Z("PilcrowRight",[["path",{d:"M10 3v11",key:"o3l5kj"}],["path",{d:"M10 9H7a1 1 0 0 1 0-6h8",key:"1wb1nc"}],["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"m18 14 4 4H2",key:"4r8io1"}],["path",{d:"m22 18-4 4",key:"1hjjrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZY=Z("Pilcrow",[["path",{d:"M13 4v16",key:"8vvj80"}],["path",{d:"M17 4v16",key:"7dpous"}],["path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13",key:"sh4n9v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YY=Z("PillBottle",[["path",{d:"M18 11h-4a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h4",key:"17ldeb"}],["path",{d:"M6 7v13a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7",key:"nc37y6"}],["rect",{width:"16",height:"5",x:"4",y:"2",rx:"1",key:"3jeezo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XY=Z("Pill",[["path",{d:"m10.5 20.5 10-10a4.95 4.95 0 1 0-7-7l-10 10a4.95 4.95 0 1 0 7 7Z",key:"wa1lgi"}],["path",{d:"m8.5 8.5 7 7",key:"rvfmvr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vP=Z("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a_=Z("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QY=Z("Pipette",[["path",{d:"m2 22 1-1h3l9-9",key:"1sre89"}],["path",{d:"M3 21v-3l9-9",key:"hpe2y6"}],["path",{d:"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z",key:"196du1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JY=Z("Pizza",[["path",{d:"m12 14-1 1",key:"11onhr"}],["path",{d:"m13.75 18.25-1.25 1.42",key:"1yisr3"}],["path",{d:"M17.775 5.654a15.68 15.68 0 0 0-12.121 12.12",key:"1qtqk6"}],["path",{d:"M18.8 9.3a1 1 0 0 0 2.1 7.7",key:"fbbbr2"}],["path",{d:"M21.964 20.732a1 1 0 0 1-1.232 1.232l-18-5a1 1 0 0 1-.695-1.232A19.68 19.68 0 0 1 15.732 2.037a1 1 0 0 1 1.232.695z",key:"1hyfdd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eX=Z("PlaneLanding",[["path",{d:"M2 22h20",key:"272qi7"}],["path",{d:"M3.77 10.77 2 9l2-4.5 1.1.55c.55.28.9.84.9 1.45s.35 1.17.9 1.45L8 8.5l3-6 1.05.53a2 2 0 0 1 1.09 1.52l.72 5.4a2 2 0 0 0 1.09 1.52l4.4 2.2c.42.22.78.55 1.01.96l.6 1.03c.49.88-.06 1.98-1.06 2.1l-1.18.15c-.47.06-.95-.02-1.37-.24L4.29 11.15a2 2 0 0 1-.52-.38Z",key:"1ma21e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tX=Z("PlaneTakeoff",[["path",{d:"M2 22h20",key:"272qi7"}],["path",{d:"M6.36 17.4 4 17l-2-4 1.1-.55a2 2 0 0 1 1.8 0l.17.1a2 2 0 0 0 1.8 0L8 12 5 6l.9-.45a2 2 0 0 1 2.09.2l4.02 3a2 2 0 0 0 2.1.2l4.19-2.06a2.41 2.41 0 0 1 1.73-.17L21 7a1.4 1.4 0 0 1 .87 1.99l-.38.76c-.23.46-.6.84-1.07 1.08L7.58 17.2a2 2 0 0 1-1.22.18Z",key:"fkigj9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sX=Z("Plane",[["path",{d:"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z",key:"1v9wt8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ul=Z("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rX=Z("Plug2",[["path",{d:"M9 2v6",key:"17ngun"}],["path",{d:"M15 2v6",key:"s7yy2p"}],["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M6 11V8h12v3a6 6 0 1 1-12 0Z",key:"wtfw2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V2=Z("PlugZap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _P=Z("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zs=Z("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nX=Z("PocketKnife",[["path",{d:"M3 2v1c0 1 2 1 2 2S3 6 3 7s2 1 2 2-2 1-2 2 2 1 2 2",key:"19w3oe"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M20.83 8.83a4 4 0 0 0-5.66-5.66l-12 12a4 4 0 1 0 5.66 5.66Z",key:"6fykxj"}],["path",{d:"M18 11.66V22a4 4 0 0 0 4-4V6",key:"1utzek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aX=Z("Pocket",[["path",{d:"M4 3h16a2 2 0 0 1 2 2v6a10 10 0 0 1-10 10A10 10 0 0 1 2 11V5a2 2 0 0 1 2-2z",key:"1mz881"}],["polyline",{points:"8 10 12 14 16 10",key:"w4mbv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iX=Z("Podcast",[["path",{d:"M16.85 18.58a9 9 0 1 0-9.7 0",key:"d71mpg"}],["path",{d:"M8 14a5 5 0 1 1 8 0",key:"fc81rn"}],["circle",{cx:"12",cy:"11",r:"1",key:"1gvufo"}],["path",{d:"M13 17a1 1 0 1 0-2 0l.5 4.5a.5.5 0 1 0 1 0Z",key:"za5kbj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oX=Z("PointerOff",[["path",{d:"M10 4.5V4a2 2 0 0 0-2.41-1.957",key:"jsi14n"}],["path",{d:"M13.9 8.4a2 2 0 0 0-1.26-1.295",key:"hirc7f"}],["path",{d:"M21.7 16.2A8 8 0 0 0 22 14v-3a2 2 0 1 0-4 0v-1a2 2 0 0 0-3.63-1.158",key:"1jxb2e"}],["path",{d:"m7 15-1.8-1.8a2 2 0 0 0-2.79 2.86L6 19.7a7.74 7.74 0 0 0 6 2.3h2a8 8 0 0 0 5.657-2.343",key:"10r7hm"}],["path",{d:"M6 6v8",key:"tv5xkp"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lX=Z("Pointer",[["path",{d:"M22 14a8 8 0 0 1-8 8",key:"56vcr3"}],["path",{d:"M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1agjmk"}],["path",{d:"M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1",key:"wdbh2u"}],["path",{d:"M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10",key:"1ibuk9"}],["path",{d:"M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"g6ys72"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cX=Z("Popcorn",[["path",{d:"M18 8a2 2 0 0 0 0-4 2 2 0 0 0-4 0 2 2 0 0 0-4 0 2 2 0 0 0-4 0 2 2 0 0 0 0 4",key:"10td1f"}],["path",{d:"M10 22 9 8",key:"yjptiv"}],["path",{d:"m14 22 1-14",key:"8jwc8b"}],["path",{d:"M20 8c.5 0 .9.4.8 1l-2.6 12c-.1.5-.7 1-1.2 1H7c-.6 0-1.1-.4-1.2-1L3.2 9c-.1-.6.3-1 .8-1Z",key:"1qo33t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dX=Z("Popsicle",[["path",{d:"M18.6 14.4c.8-.8.8-2 0-2.8l-8.1-8.1a4.95 4.95 0 1 0-7.1 7.1l8.1 8.1c.9.7 2.1.7 2.9-.1Z",key:"1o68ps"}],["path",{d:"m22 22-5.5-5.5",key:"17o70y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uX=Z("PoundSterling",[["path",{d:"M18 7c0-5.333-8-5.333-8 0",key:"1prm2n"}],["path",{d:"M10 7v14",key:"18tmcs"}],["path",{d:"M6 21h12",key:"4dkmi1"}],["path",{d:"M6 13h10",key:"ybwr4a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hX=Z("PowerOff",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bP=Z("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bg=Z("Presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mX=Z("PrinterCheck",[["path",{d:"M13.5 22H7a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v.5",key:"qeb09x"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}],["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v2",key:"1md90i"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wP=Z("Printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pX=Z("Projector",[["path",{d:"M5 7 3 5",key:"1yys58"}],["path",{d:"M9 6V3",key:"1ptz9u"}],["path",{d:"m13 7 2-2",key:"1w3vmq"}],["circle",{cx:"9",cy:"13",r:"3",key:"1mma13"}],["path",{d:"M11.83 12H20a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h2.17",key:"2frwzc"}],["path",{d:"M16 16h2",key:"dnq2od"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fX=Z("Proportions",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M12 9v11",key:"1fnkrn"}],["path",{d:"M2 9h13a2 2 0 0 1 2 2v9",key:"11z3ex"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gX=Z("Puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xX=Z("Pyramid",[["path",{d:"M2.5 16.88a1 1 0 0 1-.32-1.43l9-13.02a1 1 0 0 1 1.64 0l9 13.01a1 1 0 0 1-.32 1.44l-8.51 4.86a2 2 0 0 1-1.98 0Z",key:"aenxs0"}],["path",{d:"M12 2v20",key:"t6zp3m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L0=Z("QrCode",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _5=Z("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yX=Z("Rabbit",[["path",{d:"M13 16a3 3 0 0 1 2.24 5",key:"1epib5"}],["path",{d:"M18 12h.01",key:"yjnet6"}],["path",{d:"M18 21h-8a4 4 0 0 1-4-4 7 7 0 0 1 7-7h.2L9.6 6.4a1 1 0 1 1 2.8-2.8L15.8 7h.2c3.3 0 6 2.7 6 6v1a2 2 0 0 1-2 2h-1a3 3 0 0 0-3 3",key:"ue9ozu"}],["path",{d:"M20 8.54V4a2 2 0 1 0-4 0v3",key:"49iql8"}],["path",{d:"M7.612 12.524a3 3 0 1 0-1.6 4.3",key:"1e33i0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vX=Z("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _X=Z("Radiation",[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7.5 4.2c-.3-.5-.9-.7-1.3-.4C3.9 5.5 2.3 8.1 2 11c-.1.5.4 1 1 1h5c0-1.5.8-2.8 2-3.4-1.1-1.9-2-3.5-2.5-4.4z",key:"wy49g3"}],["path",{d:"M21 12c.6 0 1-.4 1-1-.3-2.9-1.8-5.5-4.1-7.1-.4-.3-1.1-.2-1.3.3-.6.9-1.5 2.5-2.6 4.3 1.2.7 2 2 2 3.5h5z",key:"vklnvr"}],["path",{d:"M7.5 19.8c-.3.5-.1 1.1.4 1.3 2.6 1.2 5.6 1.2 8.2 0 .5-.2.7-.8.4-1.3-.5-.9-1.4-2.5-2.5-4.3-1.2.7-2.8.7-4 0-1.1 1.8-2 3.4-2.5 4.3z",key:"wkdf1o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bX=Z("Radical",[["path",{d:"M3 12h3.28a1 1 0 0 1 .948.684l2.298 7.934a.5.5 0 0 0 .96-.044L13.82 4.771A1 1 0 0 1 14.792 4H21",key:"1mqj8i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wX=Z("RadioReceiver",[["path",{d:"M5 16v2",key:"g5qcv5"}],["path",{d:"M19 16v2",key:"1gbaio"}],["rect",{width:"20",height:"8",x:"2",y:"8",rx:"2",key:"vjsjur"}],["path",{d:"M18 12h.01",key:"yjnet6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jX=Z("RadioTower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lN=Z("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kX=Z("Radius",[["path",{d:"M20.34 17.52a10 10 0 1 0-2.82 2.82",key:"fydyku"}],["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["path",{d:"m13.41 13.41 4.18 4.18",key:"1gqbwc"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NX=Z("RailSymbol",[["path",{d:"M5 15h14",key:"m0yey3"}],["path",{d:"M5 9h14",key:"7tsvo6"}],["path",{d:"m14 20-5-5 6-6-5-5",key:"1jo42i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SX=Z("Rainbow",[["path",{d:"M22 17a10 10 0 0 0-20 0",key:"ozegv"}],["path",{d:"M6 17a6 6 0 0 1 12 0",key:"5giftw"}],["path",{d:"M10 17a2 2 0 0 1 4 0",key:"gnsikk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CX=Z("Rat",[["path",{d:"M17 5c0-1.7-1.3-3-3-3s-3 1.3-3 3c0 .8.3 1.5.8 2H11c-3.9 0-7 3.1-7 7c0 2.2 1.8 4 4 4",key:"1wq71c"}],["path",{d:"M16.8 3.9c.3-.3.6-.5 1-.7 1.5-.6 3.3.1 3.9 1.6.6 1.5-.1 3.3-1.6 3.9l1.6 2.8c.2.3.2.7.2 1-.2.8-.9 1.2-1.7 1.1 0 0-1.6-.3-2.7-.6H17c-1.7 0-3 1.3-3 3",key:"1crdmb"}],["path",{d:"M13.2 18a3 3 0 0 0-2.2-5",key:"1ol3lk"}],["path",{d:"M13 22H4a2 2 0 0 1 0-4h12",key:"bt3f23"}],["path",{d:"M16 9h.01",key:"1bdo4e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MX=Z("Ratio",[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TX=Z("ReceiptCent",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M12 6.5v11",key:"ecfhkf"}],["path",{d:"M15 9.4a4 4 0 1 0 0 5.2",key:"1makmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AX=Z("ReceiptEuro",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 12h5",key:"1g6qi8"}],["path",{d:"M16 9.5a4 4 0 1 0 0 5.2",key:"b2px4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EX=Z("ReceiptIndianRupee",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 7h8",key:"i86dvs"}],["path",{d:"M12 17.5 8 15h1a4 4 0 0 0 0-8",key:"grpkl4"}],["path",{d:"M8 11h8",key:"vwpz6n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PX=Z("ReceiptJapaneseYen",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"m12 10 3-3",key:"1mc12w"}],["path",{d:"m9 7 3 3v7.5",key:"39i0xv"}],["path",{d:"M9 11h6",key:"1fldmi"}],["path",{d:"M9 15h6",key:"cctwl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IX=Z("ReceiptPoundSterling",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 13h5",key:"1k9z8w"}],["path",{d:"M10 17V9.5a2.5 2.5 0 0 1 5 0",key:"1dzgp0"}],["path",{d:"M8 17h7",key:"8mjdqu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LX=Z("ReceiptRussianRuble",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 15h5",key:"vxg57a"}],["path",{d:"M8 11h5a2 2 0 1 0 0-4h-3v10",key:"1usi5u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DX=Z("ReceiptSwissFranc",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M10 17V7h5",key:"k7jq18"}],["path",{d:"M10 11h4",key:"1i0mka"}],["path",{d:"M8 15h5",key:"vxg57a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OX=Z("ReceiptText",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M14 8H8",key:"1l3xfs"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M13 16H8",key:"wsln4y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RX=Z("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H2=Z("RectangleEllipsis",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FX=Z("RectangleHorizontal",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zX=Z("RectangleVertical",[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BX=Z("Recycle",[["path",{d:"M7 19H4.815a1.83 1.83 0 0 1-1.57-.881 1.785 1.785 0 0 1-.004-1.784L7.196 9.5",key:"x6z5xu"}],["path",{d:"M11 19h8.203a1.83 1.83 0 0 0 1.556-.89 1.784 1.784 0 0 0 0-1.775l-1.226-2.12",key:"1x4zh5"}],["path",{d:"m14 16-3 3 3 3",key:"f6jyew"}],["path",{d:"M8.293 13.596 7.196 9.5 3.1 10.598",key:"wf1obh"}],["path",{d:"m9.344 5.811 1.093-1.892A1.83 1.83 0 0 1 11.985 3a1.784 1.784 0 0 1 1.546.888l3.943 6.843",key:"9tzpgr"}],["path",{d:"m13.378 9.633 4.096 1.098 1.097-4.096",key:"1oe83g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $X=Z("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qX=Z("RedoDot",[["circle",{cx:"12",cy:"17",r:"1",key:"1ixnty"}],["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b5=Z("Redo",[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UX=Z("RefreshCcwDot",[["path",{d:"M3 2v6h6",key:"18ldww"}],["path",{d:"M21 12A9 9 0 0 0 6 5.3L3 8",key:"1pbrqz"}],["path",{d:"M21 22v-6h-6",key:"usdfbe"}],["path",{d:"M3 12a9 9 0 0 0 15 6.7l3-2.7",key:"1hosoe"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VX=Z("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HX=Z("RefreshCwOff",[["path",{d:"M21 8L18.74 5.74A9.75 9.75 0 0 0 12 3C11 3 10.03 3.16 9.13 3.47",key:"1krf6h"}],["path",{d:"M8 16H3v5",key:"1cv678"}],["path",{d:"M3 12C3 9.51 4 7.26 5.64 5.64",key:"ruvoct"}],["path",{d:"m3 16 2.26 2.26A9.75 9.75 0 0 0 12 21c2.49 0 4.74-1 6.36-2.64",key:"19q130"}],["path",{d:"M21 12c0 1-.16 1.97-.47 2.87",key:"4w8emr"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Po=Z("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WX=Z("Refrigerator",[["path",{d:"M5 6a4 4 0 0 1 4-4h6a4 4 0 0 1 4 4v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6Z",key:"fpq118"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M15 7v6",key:"1nx30x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GX=Z("Regex",[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KX=Z("RemoveFormatting",[["path",{d:"M4 7V4h16v3",key:"9msm58"}],["path",{d:"M5 20h6",key:"1h6pxn"}],["path",{d:"M13 4 8 20",key:"kqq6aj"}],["path",{d:"m15 15 5 5",key:"me55sn"}],["path",{d:"m20 15-5 5",key:"11p7ol"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZX=Z("Repeat1",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}],["path",{d:"M11 10h1v4",key:"70cz1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YX=Z("Repeat2",[["path",{d:"m2 9 3-3 3 3",key:"1ltn5i"}],["path",{d:"M13 18H7a2 2 0 0 1-2-2V6",key:"1r6tfw"}],["path",{d:"m22 15-3 3-3-3",key:"4rnwn2"}],["path",{d:"M11 6h6a2 2 0 0 1 2 2v10",key:"2f72bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jP=Z("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XX=Z("ReplaceAll",[["path",{d:"M14 14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"1yyzbs"}],["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"zfj4xr"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a 3 3 0 0 1 3-3h1",key:"1ageje"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QX=Z("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JX=Z("ReplyAll",[["polyline",{points:"7 17 2 12 7 7",key:"t83bqg"}],["polyline",{points:"12 17 7 12 12 7",key:"1g4ajm"}],["path",{d:"M22 18v-2a4 4 0 0 0-4-4H7",key:"1fcyog"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kP=Z("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eQ=Z("Rewind",[["polygon",{points:"11 19 2 12 11 5 11 19",key:"14yba5"}],["polygon",{points:"22 19 13 12 22 5 22 19",key:"1pi1cj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tQ=Z("Ribbon",[["path",{d:"M12 11.22C11 9.997 10 9 10 8a2 2 0 0 1 4 0c0 1-.998 2.002-2.01 3.22",key:"1rnhq3"}],["path",{d:"m12 18 2.57-3.5",key:"116vt7"}],["path",{d:"M6.243 9.016a7 7 0 0 1 11.507-.009",key:"10dq0b"}],["path",{d:"M9.35 14.53 12 11.22",key:"tdsyp2"}],["path",{d:"M9.35 14.53C7.728 12.246 6 10.221 6 7a6 5 0 0 1 12 0c-.005 3.22-1.778 5.235-3.43 7.5l3.557 4.527a1 1 0 0 1-.203 1.43l-1.894 1.36a1 1 0 0 1-1.384-.215L12 18l-2.679 3.593a1 1 0 0 1-1.39.213l-1.865-1.353a1 1 0 0 1-.203-1.422z",key:"nmifey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gx=Z("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sQ=Z("RockingChair",[["polyline",{points:"3.5 2 6.5 12.5 18 12.5",key:"y3iy52"}],["line",{x1:"9.5",x2:"5.5",y1:"12.5",y2:"20",key:"19vg5i"}],["line",{x1:"15",x2:"18.5",y1:"12.5",y2:"20",key:"1inpmv"}],["path",{d:"M2.75 18a13 13 0 0 0 18.5 0",key:"1nquas"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rQ=Z("RollerCoaster",[["path",{d:"M6 19V5",key:"1r845m"}],["path",{d:"M10 19V6.8",key:"9j2tfs"}],["path",{d:"M14 19v-7.8",key:"10s8qv"}],["path",{d:"M18 5v4",key:"1tajlv"}],["path",{d:"M18 19v-6",key:"ielfq3"}],["path",{d:"M22 19V9",key:"158nzp"}],["path",{d:"M2 19V9a4 4 0 0 1 4-4c2 0 4 1.33 6 4s4 4 6 4a4 4 0 1 0-3-6.65",key:"1930oh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W2=Z("Rotate3d",[["path",{d:"M16.466 7.5C15.643 4.237 13.952 2 12 2 9.239 2 7 6.477 7 12s2.239 10 5 10c.342 0 .677-.069 1-.2",key:"10n0gc"}],["path",{d:"m15.194 13.707 3.814 1.86-1.86 3.814",key:"16shm9"}],["path",{d:"M19 15.57c-1.804.885-4.274 1.43-7 1.43-5.523 0-10-2.239-10-5s4.477-5 10-5c4.838 0 8.873 1.718 9.8 4",key:"1lxi77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nQ=Z("RotateCcwSquare",[["path",{d:"M20 9V7a2 2 0 0 0-2-2h-6",key:"19z8uc"}],["path",{d:"m15 2-3 3 3 3",key:"177bxs"}],["path",{d:"M20 13v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2",key:"d36hnl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D0=Z("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aQ=Z("RotateCwSquare",[["path",{d:"M12 5H6a2 2 0 0 0-2 2v3",key:"l96uqu"}],["path",{d:"m9 8 3-3-3-3",key:"1gzgc3"}],["path",{d:"M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2",key:"1w2k5h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NP=Z("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iQ=Z("RouteOff",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5c.4 0 .9-.1 1.3-.2",key:"1effex"}],["path",{d:"M5.2 5.2A3.5 3.53 0 0 0 6.5 12H12",key:"k9y2ds"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M21 15.3a3.5 3.5 0 0 0-3.3-3.3",key:"11nlu2"}],["path",{d:"M15 5h-4.3",key:"6537je"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oQ=Z("Route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lQ=Z("Router",[["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6.01 18H6",key:"19vcac"}],["path",{d:"M10.01 18H10",key:"uamcmx"}],["path",{d:"M15 10v4",key:"qjz1xs"}],["path",{d:"M17.84 7.17a4 4 0 0 0-5.66 0",key:"1rif40"}],["path",{d:"M20.66 4.34a8 8 0 0 0-11.31 0",key:"6a5xfq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G2=Z("Rows2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K2=Z("Rows3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cQ=Z("Rows4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 7.5H3",key:"1hm9pq"}],["path",{d:"M21 12H3",key:"2avoz0"}],["path",{d:"M21 16.5H3",key:"n7jzkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dQ=Z("Rss",[["path",{d:"M4 11a9 9 0 0 1 9 9",key:"pv89mb"}],["path",{d:"M4 4a16 16 0 0 1 16 16",key:"k0647b"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SP=Z("Ruler",[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uQ=Z("RussianRuble",[["path",{d:"M6 11h8a4 4 0 0 0 0-8H9v18",key:"18ai8t"}],["path",{d:"M6 15h8",key:"1y8f6l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hQ=Z("Sailboat",[["path",{d:"M22 18H2a4 4 0 0 0 4 4h12a4 4 0 0 0 4-4Z",key:"1404fh"}],["path",{d:"M21 14 10 2 3 14h18Z",key:"1nzg7v"}],["path",{d:"M10 2v16",key:"1labyt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mQ=Z("Salad",[["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 21a9 9 0 0 0 9-9H3a9 9 0 0 0 9 9Z",key:"4rw317"}],["path",{d:"M11.38 12a2.4 2.4 0 0 1-.4-4.77 2.4 2.4 0 0 1 3.2-2.77 2.4 2.4 0 0 1 3.47-.63 2.4 2.4 0 0 1 3.37 3.37 2.4 2.4 0 0 1-1.1 3.7 2.51 2.51 0 0 1 .03 1.1",key:"10xrj0"}],["path",{d:"m13 12 4-4",key:"1hckqy"}],["path",{d:"M10.9 7.25A3.99 3.99 0 0 0 4 10c0 .73.2 1.41.54 2",key:"1p4srx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pQ=Z("Sandwich",[["path",{d:"m2.37 11.223 8.372-6.777a2 2 0 0 1 2.516 0l8.371 6.777",key:"f1wd0e"}],["path",{d:"M21 15a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-5.25",key:"1pfu07"}],["path",{d:"M3 15a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h9",key:"1oq9qw"}],["path",{d:"m6.67 15 6.13 4.6a2 2 0 0 0 2.8-.4l3.15-4.2",key:"1fnwu5"}],["rect",{width:"20",height:"4",x:"2",y:"11",rx:"1",key:"itshg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fQ=Z("SatelliteDish",[["path",{d:"M4 10a7.31 7.31 0 0 0 10 10Z",key:"1fzpp3"}],["path",{d:"m9 15 3-3",key:"88sc13"}],["path",{d:"M17 13a6 6 0 0 0-6-6",key:"15cc6u"}],["path",{d:"M21 13A10 10 0 0 0 11 3",key:"11nf8s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gQ=Z("Satellite",[["path",{d:"M13 7 9 3 5 7l4 4",key:"vyckw6"}],["path",{d:"m17 11 4 4-4 4-4-4",key:"rchckc"}],["path",{d:"m8 12 4 4 6-6-4-4Z",key:"1sshf7"}],["path",{d:"m16 8 3-3",key:"x428zp"}],["path",{d:"M9 21a6 6 0 0 0-6-6",key:"1iajcf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xQ=Z("SaveAll",[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yQ=Z("SaveOff",[["path",{d:"M13 13H8a1 1 0 0 0-1 1v7",key:"h8g396"}],["path",{d:"M14 8h1",key:"1lfen6"}],["path",{d:"M17 21v-4",key:"1yknxs"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20.41 20.41A2 2 0 0 1 19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 .59-1.41",key:"1t4vdl"}],["path",{d:"M29.5 11.5s5 5 4 5",key:"zzn4i6"}],["path",{d:"M9 3h6.2a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V15",key:"24cby9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bu=Z("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z2=Z("Scale3d",[["path",{d:"M5 7v11a1 1 0 0 0 1 1h11",key:"13dt1j"}],["path",{d:"M5.293 18.707 11 13",key:"ezgbsx"}],["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["circle",{cx:"5",cy:"5",r:"2",key:"1gwv83"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vQ=Z("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Q=Z("Scaling",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M14 15H9v-5",key:"pi4jk9"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M21 3 9 15",key:"15kdhq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bQ=Z("ScanBarcode",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 7v10",key:"23sfjj"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M17 7v10",key:"578dap"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wQ=Z("ScanEye",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jQ=Z("ScanFace",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 9h.01",key:"x1ddxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kQ=Z("ScanLine",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NQ=Z("ScanQrCode",[["path",{d:"M17 12v4a1 1 0 0 1-1 1h-4",key:"uk4fdo"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M17 8V7",key:"q2g9wo"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M7 17h.01",key:"19xn7k"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{x:"7",y:"7",width:"5",height:"5",rx:"1",key:"m9kyts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SQ=Z("ScanSearch",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CQ=Z("ScanText",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 8h8",key:"1jbsf9"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h6",key:"1vyc9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MQ=Z("Scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TQ=Z("School",[["path",{d:"M14 22v-4a2 2 0 1 0-4 0v4",key:"hhkicm"}],["path",{d:"m18 10 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-7.382a1 1 0 0 1 .553-.894L6 10",key:"1xqip1"}],["path",{d:"M18 5v17",key:"1sw6gf"}],["path",{d:"m4 6 7.106-3.553a2 2 0 0 1 1.788 0L20 6",key:"9d2mlk"}],["path",{d:"M6 5v17",key:"1xfsm0"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AQ=Z("ScissorsLineDashed",[["path",{d:"M5.42 9.42 8 12",key:"12pkuq"}],["circle",{cx:"4",cy:"8",r:"2",key:"107mxr"}],["path",{d:"m14 6-8.58 8.58",key:"gvzu5l"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"M10.8 14.8 14 18",key:"ax7m9r"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EQ=Z("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PQ=Z("ScreenShareOff",[["path",{d:"M13 3H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-3",key:"i8wdob"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IQ=Z("ScreenShare",[["path",{d:"M13 3H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-3",key:"i8wdob"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m17 8 5-5",key:"fqif7o"}],["path",{d:"M17 3h5v5",key:"1o3tu8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LQ=Z("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DQ=Z("Scroll",[["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OQ=Z("SearchCheck",[["path",{d:"m8 11 2 2 4-4",key:"1sed1v"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RQ=Z("SearchCode",[["path",{d:"m13 13.5 2-2.5-2-2.5",key:"1rvxrh"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M9 8.5 7 11l2 2.5",key:"6ffwbx"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FQ=Z("SearchSlash",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CP=Z("SearchX",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fn=Z("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zQ=Z("Section",[["path",{d:"M16 5a4 3 0 0 0-8 0c0 4 8 3 8 7a4 3 0 0 1-8 0",key:"vqan6v"}],["path",{d:"M8 19a4 3 0 0 0 8 0c0-4-8-3-8-7a4 3 0 0 1 8 0",key:"wdjd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y2=Z("SendHorizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BQ=Z("SendToBack",[["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}],["path",{d:"M7 14v1a2 2 0 0 0 2 2h1",key:"pao6x6"}],["path",{d:"M14 7h1a2 2 0 0 1 2 2v1",key:"19tdru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ka=Z("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Q=Z("SeparatorHorizontal",[["line",{x1:"3",x2:"21",y1:"12",y2:"12",key:"10d38w"}],["polyline",{points:"8 8 12 4 16 8",key:"zo8t4w"}],["polyline",{points:"16 16 12 20 8 16",key:"1oyrid"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qQ=Z("SeparatorVertical",[["line",{x1:"12",x2:"12",y1:"3",y2:"21",key:"1efggb"}],["polyline",{points:"8 8 4 12 8 16",key:"bnfmv4"}],["polyline",{points:"16 16 20 12 16 8",key:"u90052"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UQ=Z("ServerCog",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m15.7 13.4-.9-.3",key:"1jwmzr"}],["path",{d:"m9.2 10.9-.9-.3",key:"qapnim"}],["path",{d:"m10.6 15.7.3-.9",key:"quwk0k"}],["path",{d:"m13.6 15.7-.4-1",key:"cb9xp7"}],["path",{d:"m10.8 9.3-.4-1",key:"1uaiz5"}],["path",{d:"m8.3 13.6 1-.4",key:"s6srou"}],["path",{d:"m14.7 10.8 1-.4",key:"4d31cq"}],["path",{d:"m13.4 8.3-.3.9",key:"1bm987"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VQ=Z("ServerCrash",[["path",{d:"M6 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-2",key:"4b9dqc"}],["path",{d:"M6 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-2",key:"22nnkd"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m13 6-4 6h6l-4 6",key:"14hqih"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HQ=Z("ServerOff",[["path",{d:"M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5",key:"bt2siv"}],["path",{d:"M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z",key:"1hjrv1"}],["path",{d:"M22 17v-1a2 2 0 0 0-2-2h-1",key:"1iynyr"}],["path",{d:"M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z",key:"161ggg"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WQ=Z("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MP=Z("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $l=Z("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GQ=Z("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cd=Z("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TP=Z("Share",[["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["polyline",{points:"16 6 12 2 8 6",key:"m901s6"}],["line",{x1:"12",x2:"12",y1:"2",y2:"15",key:"1p0rca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KQ=Z("Sheet",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"9",y2:"9",key:"1vqk6q"}],["line",{x1:"3",x2:"21",y1:"15",y2:"15",key:"o2sbyz"}],["line",{x1:"9",x2:"9",y1:"9",y2:"21",key:"1ib60c"}],["line",{x1:"15",x2:"15",y1:"9",y2:"21",key:"1n26ft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZQ=Z("Shell",[["path",{d:"M14 11a2 2 0 1 1-4 0 4 4 0 0 1 8 0 6 6 0 0 1-12 0 8 8 0 0 1 16 0 10 10 0 1 1-20 0 11.93 11.93 0 0 1 2.42-7.22 2 2 0 1 1 3.16 2.44",key:"1cn552"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YQ=Z("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XQ=Z("ShieldBan",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m4.243 5.21 14.39 12.472",key:"1c9a7c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AP=Z("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QQ=Z("ShieldEllipsis",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JQ=Z("ShieldHalf",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 22V2",key:"zs6s6o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eJ=Z("ShieldMinus",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9 12h6",key:"1c52cq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tJ=Z("ShieldOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sJ=Z("ShieldPlus",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M12 9v6",key:"199k2o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rJ=Z("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X2=Z("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rh=Z("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nJ=Z("ShipWheel",[["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}],["path",{d:"M12 2v7.5",key:"1e5rl5"}],["path",{d:"m19 5-5.23 5.23",key:"1ezxxf"}],["path",{d:"M22 12h-7.5",key:"le1719"}],["path",{d:"m19 19-5.23-5.23",key:"p3fmgn"}],["path",{d:"M12 14.5V22",key:"dgcmos"}],["path",{d:"M10.23 13.77 5 19",key:"qwopd4"}],["path",{d:"M9.5 12H2",key:"r7bup8"}],["path",{d:"M10.23 10.23 5 5",key:"k2y7lj"}],["circle",{cx:"12",cy:"12",r:"2.5",key:"ix0uyj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aJ=Z("Ship",[["path",{d:"M12 10.189V14",key:"1p8cqu"}],["path",{d:"M12 2v3",key:"qbqxhf"}],["path",{d:"M19 13V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6",key:"qpkstq"}],["path",{d:"M19.38 20A11.6 11.6 0 0 0 21 14l-8.188-3.639a2 2 0 0 0-1.624 0L3 14a11.6 11.6 0 0 0 2.81 7.76",key:"7tigtc"}],["path",{d:"M2 21c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1s1.2 1 2.5 1c2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"1924j5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iJ=Z("Shirt",[["path",{d:"M20.38 3.46 16 2a4 4 0 0 1-8 0L3.62 3.46a2 2 0 0 0-1.34 2.23l.58 3.47a1 1 0 0 0 .99.84H6v10c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V10h2.15a1 1 0 0 0 .99-.84l.58-3.47a2 2 0 0 0-1.34-2.23z",key:"1wgbhj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kx=Z("ShoppingBag",[["path",{d:"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z",key:"hou9p0"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oJ=Z("ShoppingBasket",[["path",{d:"m15 11-1 9",key:"5wnq3a"}],["path",{d:"m19 11-4-7",key:"cnml18"}],["path",{d:"M2 11h20",key:"3eubbj"}],["path",{d:"m3.5 11 1.6 7.4a2 2 0 0 0 2 1.6h9.8a2 2 0 0 0 2-1.6l1.7-7.4",key:"yiazzp"}],["path",{d:"M4.5 15.5h15",key:"13mye1"}],["path",{d:"m5 11 4-7",key:"116ra9"}],["path",{d:"m9 11 1 9",key:"1ojof7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const km=Z("ShoppingCart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lJ=Z("Shovel",[["path",{d:"M2 22v-5l5-5 5 5-5 5z",key:"1fh25c"}],["path",{d:"M9.5 14.5 16 8",key:"1smz5x"}],["path",{d:"m17 2 5 5-.5.5a3.53 3.53 0 0 1-5 0s0 0 0 0a3.53 3.53 0 0 1 0-5L17 2",key:"1q8uv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cJ=Z("ShowerHead",[["path",{d:"m4 4 2.5 2.5",key:"uv2vmf"}],["path",{d:"M13.5 6.5a4.95 4.95 0 0 0-7 7",key:"frdkwv"}],["path",{d:"M15 5 5 15",key:"1ag8rq"}],["path",{d:"M14 17v.01",key:"eokfpp"}],["path",{d:"M10 16v.01",key:"14uyyl"}],["path",{d:"M13 13v.01",key:"1v1k97"}],["path",{d:"M16 10v.01",key:"5169yg"}],["path",{d:"M11 20v.01",key:"cj92p8"}],["path",{d:"M17 14v.01",key:"11cswd"}],["path",{d:"M20 11v.01",key:"19e0od"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dJ=Z("Shrink",[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uJ=Z("Shrub",[["path",{d:"M12 22v-7l-2-2",key:"eqv9mc"}],["path",{d:"M17 8v.8A6 6 0 0 1 13.8 20H10A6.5 6.5 0 0 1 7 8a5 5 0 0 1 10 0Z",key:"ubcgy"}],["path",{d:"m14 14-2 2",key:"847xa2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cN=Z("Shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hJ=Z("Sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mJ=Z("SignalHigh",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pJ=Z("SignalLow",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fJ=Z("SignalMedium",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gJ=Z("SignalZero",[["path",{d:"M2 20h.01",key:"4haj6o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xJ=Z("Signal",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}],["path",{d:"M22 4v16",key:"sih9yq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yJ=Z("Signature",[["path",{d:"m21 17-2.156-1.868A.5.5 0 0 0 18 15.5v.5a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1c0-2.545-3.991-3.97-8.5-4a1 1 0 0 0 0 5c4.153 0 4.745-11.295 5.708-13.5a2.5 2.5 0 1 1 3.31 3.284",key:"y32ogt"}],["path",{d:"M3 21h18",key:"itz85i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vJ=Z("SignpostBig",[["path",{d:"M10 9H4L2 7l2-2h6",key:"1hq7x2"}],["path",{d:"M14 5h6l2 2-2 2h-6",key:"bv62ej"}],["path",{d:"M10 22V4a2 2 0 1 1 4 0v18",key:"eqpcf2"}],["path",{d:"M8 22h8",key:"rmew8v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _J=Z("Signpost",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M12 3v3",key:"1n5kay"}],["path",{d:"M18 6a2 2 0 0 1 1.387.56l2.307 2.22a1 1 0 0 1 0 1.44l-2.307 2.22A2 2 0 0 1 18 13H6a2 2 0 0 1-1.387-.56l-2.306-2.22a1 1 0 0 1 0-1.44l2.306-2.22A2 2 0 0 1 6 6z",key:"gqqp9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bJ=Z("Siren",[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wJ=Z("SkipBack",[["polygon",{points:"19 20 9 12 19 4 19 20",key:"o2sva"}],["line",{x1:"5",x2:"5",y1:"19",y2:"5",key:"1ocqjk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jJ=Z("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kJ=Z("Skull",[["path",{d:"m12.5 17-.5-1-.5 1h1z",key:"3me087"}],["path",{d:"M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",key:"1o5pge"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NJ=Z("Slack",[["rect",{width:"3",height:"8",x:"13",y:"2",rx:"1.5",key:"diqz80"}],["path",{d:"M19 8.5V10h1.5A1.5 1.5 0 1 0 19 8.5",key:"183iwg"}],["rect",{width:"3",height:"8",x:"8",y:"14",rx:"1.5",key:"hqg7r1"}],["path",{d:"M5 15.5V14H3.5A1.5 1.5 0 1 0 5 15.5",key:"76g71w"}],["rect",{width:"8",height:"3",x:"14",y:"13",rx:"1.5",key:"1kmz0a"}],["path",{d:"M15.5 19H14v1.5a1.5 1.5 0 1 0 1.5-1.5",key:"jc4sz0"}],["rect",{width:"8",height:"3",x:"2",y:"8",rx:"1.5",key:"1omvl4"}],["path",{d:"M8.5 5H10V3.5A1.5 1.5 0 1 0 8.5 5",key:"16f3cl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SJ=Z("Slash",[["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CJ=Z("Slice",[["path",{d:"M11 16.586V19a1 1 0 0 1-1 1H2L18.37 3.63a1 1 0 1 1 3 3l-9.663 9.663a1 1 0 0 1-1.414 0L8 14",key:"1sllp5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EP=Z("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q2=Z("SlidersVertical",[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MJ=Z("SmartphoneCharging",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12.667 8 10 12h4l-2.667 4",key:"h9lk2d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TJ=Z("SmartphoneNfc",[["rect",{width:"7",height:"12",x:"2",y:"6",rx:"1",key:"5nje8w"}],["path",{d:"M13 8.32a7.43 7.43 0 0 1 0 7.36",key:"1g306n"}],["path",{d:"M16.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"uqvjvo"}],["path",{d:"M19.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"ujntz3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O0=Z("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AJ=Z("SmilePlus",[["path",{d:"M22 11v1a10 10 0 1 1-9-10",key:"ew0xw9"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}],["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EJ=Z("Smile",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PJ=Z("Snail",[["path",{d:"M2 13a6 6 0 1 0 12 0 4 4 0 1 0-8 0 2 2 0 0 0 4 0",key:"hneq2s"}],["circle",{cx:"10",cy:"13",r:"8",key:"194lz3"}],["path",{d:"M2 21h12c4.4 0 8-3.6 8-8V7a2 2 0 1 0-4 0v6",key:"ixqyt7"}],["path",{d:"M18 3 19.1 5.2",key:"9tjm43"}],["path",{d:"M22 3 20.9 5.2",key:"j3odrs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D1=Z("Snowflake",[["line",{x1:"2",x2:"22",y1:"12",y2:"12",key:"1dnqot"}],["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"m20 16-4-4 4-4",key:"rquw4f"}],["path",{d:"m4 8 4 4-4 4",key:"12s3z9"}],["path",{d:"m16 4-4 4-4-4",key:"1tumq1"}],["path",{d:"m8 20 4-4 4 4",key:"9p200w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IJ=Z("Sofa",[["path",{d:"M20 9V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v3",key:"1dgpiv"}],["path",{d:"M2 16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"xacw8m"}],["path",{d:"M4 18v2",key:"jwo5n2"}],["path",{d:"M20 18v2",key:"1ar1qi"}],["path",{d:"M12 4v9",key:"oqhhn3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LJ=Z("Soup",[["path",{d:"M12 21a9 9 0 0 0 9-9H3a9 9 0 0 0 9 9Z",key:"4rw317"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M19.5 12 22 6",key:"shfsr5"}],["path",{d:"M16.25 3c.27.1.8.53.75 1.36-.06.83-.93 1.2-1 2.02-.05.78.34 1.24.73 1.62",key:"rpc6vp"}],["path",{d:"M11.25 3c.27.1.8.53.74 1.36-.05.83-.93 1.2-.98 2.02-.06.78.33 1.24.72 1.62",key:"1lf63m"}],["path",{d:"M6.25 3c.27.1.8.53.75 1.36-.06.83-.93 1.2-1 2.02-.05.78.34 1.24.74 1.62",key:"97tijn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DJ=Z("Space",[["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OJ=Z("Spade",[["path",{d:"M5 9c-1.5 1.5-3 3.2-3 5.5A5.5 5.5 0 0 0 7.5 20c1.8 0 3-.5 4.5-2 1.5 1.5 2.7 2 4.5 2a5.5 5.5 0 0 0 5.5-5.5c0-2.3-1.5-4-3-5.5l-7-7-7 7Z",key:"40bo9n"}],["path",{d:"M12 18v4",key:"jadmvz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RJ=Z("Sparkle",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hn=Z("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FJ=Z("Speaker",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["circle",{cx:"12",cy:"14",r:"4",key:"1jruaj"}],["path",{d:"M12 14h.01",key:"1etili"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zJ=Z("Speech",[["path",{d:"M8.8 20v-4.1l1.9.2a2.3 2.3 0 0 0 2.164-2.1V8.3A5.37 5.37 0 0 0 2 8.25c0 2.8.656 3.054 1 4.55a5.77 5.77 0 0 1 .029 2.758L2 20",key:"11atix"}],["path",{d:"M19.8 17.8a7.5 7.5 0 0 0 .003-10.603",key:"yol142"}],["path",{d:"M17 15a3.5 3.5 0 0 0-.025-4.975",key:"ssbmkc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BJ=Z("SpellCheck2",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M4 21c1.1 0 1.1-1 2.3-1s1.1 1 2.3 1c1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1",key:"8mdmtu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $J=Z("SpellCheck",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m16 20 2 2 4-4",key:"13tcca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qJ=Z("Spline",[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UJ=Z("Split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VJ=Z("SprayCan",[["path",{d:"M3 3h.01",key:"159qn6"}],["path",{d:"M7 5h.01",key:"1hq22a"}],["path",{d:"M11 7h.01",key:"1osv80"}],["path",{d:"M3 7h.01",key:"1xzrh3"}],["path",{d:"M7 9h.01",key:"19b3jx"}],["path",{d:"M3 11h.01",key:"1eifu7"}],["rect",{width:"4",height:"4",x:"15",y:"5",key:"mri9e4"}],["path",{d:"m19 9 2 2v10c0 .6-.4 1-1 1h-6c-.6 0-1-.4-1-1V11l2-2",key:"aib6hk"}],["path",{d:"m13 14 8-2",key:"1d7bmk"}],["path",{d:"m13 19 8-2",key:"1y2vml"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HJ=Z("Sprout",[["path",{d:"M7 20h10",key:"e6iznv"}],["path",{d:"M10 20c5.5-2.5.8-6.4 3-10",key:"161w41"}],["path",{d:"M9.5 9.4c1.1.8 1.8 2.2 2.3 3.7-2 .4-3.5.4-4.8-.3-1.2-.6-2.3-1.9-3-4.2 2.8-.5 4.4 0 5.5.8z",key:"9gtqwd"}],["path",{d:"M14.1 6a7 7 0 0 0-1.1 4c1.9-.1 3.3-.6 4.3-1.4 1-1 1.6-2.3 1.7-4.6-2.7.1-4 1-4.9 2z",key:"bkxnd2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J2=Z("SquareActivity",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M17 12h-2l-2 5-2-10-2 5H7",key:"15hlnc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ej=Z("SquareArrowDownLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 8-8 8",key:"166keh"}],["path",{d:"M16 16H8V8",key:"1w2ppm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tj=Z("SquareArrowDownRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m8 8 8 8",key:"1imecy"}],["path",{d:"M16 8v8H8",key:"1lbpgo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sj=Z("SquareArrowDown",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rj=Z("SquareArrowLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m12 8-4 4 4 4",key:"15vm53"}],["path",{d:"M16 12H8",key:"1fr5h0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nj=Z("SquareArrowOutDownLeft",[["path",{d:"M13 21h6a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v6",key:"14qz4y"}],["path",{d:"m3 21 9-9",key:"1jfql5"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aj=Z("SquareArrowOutDownRight",[["path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"14rsvq"}],["path",{d:"m21 21-9-9",key:"1et2py"}],["path",{d:"M21 15v6h-6",key:"1jko0i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ij=Z("SquareArrowOutUpLeft",[["path",{d:"M13 3h6a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-6",key:"14mv1t"}],["path",{d:"m3 3 9 9",key:"rks13r"}],["path",{d:"M3 9V3h6",key:"ira0h2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oj=Z("SquareArrowOutUpRight",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lj=Z("SquareArrowRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cj=Z("SquareArrowUpLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8h8",key:"19xb1h"}],["path",{d:"M16 16 8 8",key:"1qdy8n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dj=Z("SquareArrowUpRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 8h8v8",key:"b65dnt"}],["path",{d:"m8 16 8-8",key:"13b9ih"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uj=Z("SquareArrowUp",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hj=Z("SquareAsterisk",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8.5 14 7-4",key:"12hpby"}],["path",{d:"m8.5 10 7 4",key:"wwy2dy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mj=Z("SquareBottomDashedScissors",[["path",{d:"M4 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2",key:"1vzg26"}],["path",{d:"M10 22H8",key:"euku7a"}],["path",{d:"M16 22h-2",key:"18d249"}],["circle",{cx:"8",cy:"8",r:"2",key:"14cg06"}],["path",{d:"M9.414 9.414 12 12",key:"qz4lzr"}],["path",{d:"M14.8 14.8 18 18",key:"11flf1"}],["circle",{cx:"8",cy:"16",r:"2",key:"1acxsx"}],["path",{d:"m18 6-8.586 8.586",key:"11kzk1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jx=Z("SquareChartGantt",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 8h7",key:"kbo1nt"}],["path",{d:"M8 12h6",key:"ikassy"}],["path",{d:"M11 16h5",key:"oq65wt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d0=Z("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pj=Z("SquareCheck",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fj=Z("SquareChevronDown",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gj=Z("SquareChevronLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m14 16-4-4 4-4",key:"ojs7w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xj=Z("SquareChevronRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yj=Z("SquareChevronUp",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m8 14 4-4 4 4",key:"fy2ptz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vj=Z("SquareCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WJ=Z("SquareDashedBottomCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GJ=Z("SquareDashedBottom",[["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 21h1",key:"v9vybs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _j=Z("SquareDashedKanban",[["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M21 14v1",key:"169vum"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M3 9v1",key:"1r0deq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bj=Z("SquareDashedMousePointer",[["path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z",key:"xwnzip"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h2",key:"1qve2z"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v2",key:"p14lih"}],["path",{d:"M3 14v1",key:"vnatye"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wj=Z("SquareDashed",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jj=Z("SquareDivide",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}],["line",{x1:"12",x2:"12",y1:"16",y2:"16",key:"aqc6ln"}],["line",{x1:"12",x2:"12",y1:"8",y2:"8",key:"1mkcni"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kj=Z("SquareDot",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nj=Z("SquareEqual",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sj=Z("SquareFunction",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3",key:"m1af9g"}],["path",{d:"M9 11.2h5.7",key:"3zgcl2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cj=Z("SquareKanban",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mj=Z("SquareLibrary",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7v10",key:"d5nglc"}],["path",{d:"M11 7v10",key:"pptsnr"}],["path",{d:"m15 7 2 10",key:"1m7qm5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tj=Z("SquareM",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8l4 4 4-4v8",key:"141u4e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aj=Z("SquareMenu",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 8h10",key:"1jw688"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ej=Z("SquareMinus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pj=Z("SquareMousePointer",[["path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z",key:"xwnzip"}],["path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"14rsvq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ij=Z("SquareParkingOff",[["path",{d:"M3.6 3.6A2 2 0 0 1 5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-.59 1.41",key:"9l1ft6"}],["path",{d:"M3 8.7V19a2 2 0 0 0 2 2h10.3",key:"17knke"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M13 13a3 3 0 1 0 0-6H9v2",key:"uoagbd"}],["path",{d:"M9 17v-2.3",key:"1jxgo2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lj=Z("SquareParking",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 17V7h4a3 3 0 0 1 0 6H9",key:"1dfk2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oc=Z("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dj=Z("SquarePercent",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oj=Z("SquarePi",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7h10",key:"udp07y"}],["path",{d:"M10 7v10",key:"i1d9ee"}],["path",{d:"M16 17a2 2 0 0 1-2-2V7",key:"ftwdc7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rj=Z("SquarePilcrow",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 12H9.5a2.5 2.5 0 0 1 0-5H17",key:"1l9586"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M16 7v10",key:"lavkr4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fj=Z("SquarePlay",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 8 6 4-6 4Z",key:"f1r3lt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zj=Z("SquarePlus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bj=Z("SquarePower",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KJ=Z("SquareRadical",[["path",{d:"M7 12h2l2 5 2-10h4",key:"1fxv6h"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $j=Z("SquareScissors",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"2",key:"1btzen"}],["circle",{cx:"8",cy:"8",r:"2",key:"14cg06"}],["path",{d:"M9.414 9.414 12 12",key:"qz4lzr"}],["path",{d:"M14.8 14.8 18 18",key:"11flf1"}],["circle",{cx:"8",cy:"16",r:"2",key:"1acxsx"}],["path",{d:"m18 6-8.586 8.586",key:"11kzk1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qj=Z("SquareSigma",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M16 8.9V7H8l4 5-4 5h8v-1.9",key:"9nih0i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uj=Z("SquareSlash",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vj=Z("SquareSplitHorizontal",[["path",{d:"M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3",key:"lubmu8"}],["path",{d:"M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3",key:"1ag34g"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hj=Z("SquareSplitVertical",[["path",{d:"M5 8V5c0-1 1-2 2-2h10c1 0 2 1 2 2v3",key:"1pi83i"}],["path",{d:"M19 16v3c0 1-1 2-2 2H7c-1 0-2-1-2-2v-3",key:"ido5k7"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZJ=Z("SquareSquare",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YJ=Z("SquareStack",[["path",{d:"M4 10c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"4i38lg"}],["path",{d:"M10 16c-1.1 0-2-.9-2-2v-4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"mlte4a"}],["rect",{width:"8",height:"8",x:"14",y:"14",rx:"2",key:"1fa9i4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wj=Z("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gj=Z("SquareUserRound",[["path",{d:"M18 21a6 6 0 0 0-12 0",key:"kaz2du"}],["circle",{cx:"12",cy:"11",r:"4",key:"1gt34v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kj=Z("SquareUser",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 21v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2",key:"1m6ac2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zj=Z("SquareX",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zx=Z("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XJ=Z("Squircle",[["path",{d:"M12 3c7.2 0 9 1.8 9 9s-1.8 9-9 9-9-1.8-9-9 1.8-9 9-9",key:"garfkc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QJ=Z("Squirrel",[["path",{d:"M15.236 22a3 3 0 0 0-2.2-5",key:"21bitc"}],["path",{d:"M16 20a3 3 0 0 1 3-3h1a2 2 0 0 0 2-2v-2a4 4 0 0 0-4-4V4",key:"oh0fg0"}],["path",{d:"M18 13h.01",key:"9veqaj"}],["path",{d:"M18 6a4 4 0 0 0-4 4 7 7 0 0 0-7 7c0-5 4-5 4-10.5a4.5 4.5 0 1 0-9 0 2.5 2.5 0 0 0 5 0C7 10 3 11 3 17c0 2.8 2.2 5 5 5h10",key:"980v8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JJ=Z("Stamp",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M19.27 13.73A2.5 2.5 0 0 0 17.5 13h-11A2.5 2.5 0 0 0 4 15.5V17a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-1.5c0-.66-.26-1.3-.73-1.77Z",key:"1sy9ra"}],["path",{d:"M14 13V8.5C14 7 15 7 15 5a3 3 0 0 0-3-3c-1.66 0-3 1-3 3s1 2 1 3.5V13",key:"cnxgux"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eee=Z("StarHalf",[["path",{d:"M12 18.338a2.1 2.1 0 0 0-.987.244L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.12 2.12 0 0 0 1.597-1.16l2.309-4.679A.53.53 0 0 1 12 2",key:"2ksp49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tee=Z("StarOff",[["path",{d:"M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43",key:"16m0ql"}],["path",{d:"M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91",key:"1vt8nq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gn=Z("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const see=Z("StepBack",[["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["polygon",{points:"14,20 4,12 14,4",key:"ypakod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ree=Z("StepForward",[["line",{x1:"6",x2:"6",y1:"4",y2:"20",key:"fy8qot"}],["polygon",{points:"10,4 20,12 10,20",key:"1mc1pf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nee=Z("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aee=Z("Sticker",[["path",{d:"M15.5 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2V8.5L15.5 3Z",key:"1wis1t"}],["path",{d:"M14 3v4a2 2 0 0 0 2 2h4",key:"36rjfy"}],["path",{d:"M8 13h.01",key:"1sbv64"}],["path",{d:"M16 13h.01",key:"wip0gl"}],["path",{d:"M10 16s.8 1 2 1c1.3 0 2-1 2-1",key:"1vvgv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iee=Z("StickyNote",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oee=Z("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lee=Z("StretchHorizontal",[["rect",{width:"20",height:"6",x:"2",y:"4",rx:"2",key:"qdearl"}],["rect",{width:"20",height:"6",x:"2",y:"14",rx:"2",key:"1xrn6j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cee=Z("StretchVertical",[["rect",{width:"6",height:"20",x:"4",y:"2",rx:"2",key:"19qu7m"}],["rect",{width:"6",height:"20",x:"14",y:"2",rx:"2",key:"24v0nk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dee=Z("Strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uee=Z("Subscript",[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hee=Z("SunDim",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M20 12h.01",key:"1ykeid"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M4 12h.01",key:"158zrr"}],["path",{d:"M17.657 6.343h.01",key:"31pqzk"}],["path",{d:"M17.657 17.657h.01",key:"jehnf4"}],["path",{d:"M6.343 17.657h.01",key:"gdk6ow"}],["path",{d:"M6.343 6.343h.01",key:"1uurf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mee=Z("SunMedium",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 3v1",key:"1asbbs"}],["path",{d:"M12 20v1",key:"1wcdkc"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M20 12h1",key:"1vloll"}],["path",{d:"m18.364 5.636-.707.707",key:"1hakh0"}],["path",{d:"m6.343 17.657-.707.707",key:"18m9nf"}],["path",{d:"m5.636 5.636.707.707",key:"1xv1c5"}],["path",{d:"m17.657 17.657.707.707",key:"vl76zb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pee=Z("SunMoon",[["path",{d:"M12 8a2.83 2.83 0 0 0 4 4 4 4 0 1 1-4-4",key:"1fu5g2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.9 4.9 1.4 1.4",key:"b9915j"}],["path",{d:"m17.7 17.7 1.4 1.4",key:"qc3ed3"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.3 17.7-1.4 1.4",key:"5gca6"}],["path",{d:"m19.1 4.9-1.4 1.4",key:"wpu9u6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fee=Z("SunSnow",[["path",{d:"M10 9a3 3 0 1 0 0 6",key:"6zmtdl"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M14 21V3",key:"1llu3z"}],["path",{d:"M10 4V3",key:"pkzwkn"}],["path",{d:"M10 21v-1",key:"1u8rkd"}],["path",{d:"m3.64 18.36.7-.7",key:"105rm9"}],["path",{d:"m4.34 6.34-.7-.7",key:"d3unjp"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"m17 4-3 3",key:"15jcng"}],["path",{d:"m14 17 3 3",key:"6tlq38"}],["path",{d:"m21 15-3-3 3-3",key:"1nlnje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i_=Z("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gee=Z("Sunrise",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xee=Z("Sunset",[["path",{d:"M12 10V2",key:"16sf7g"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yee=Z("Superscript",[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vee=Z("SwatchBook",[["path",{d:"M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z",key:"1ldrpk"}],["path",{d:"M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7",key:"11i5po"}],["path",{d:"M 7 17h.01",key:"1euzgo"}],["path",{d:"m11 8 2.3-2.3a2.4 2.4 0 0 1 3.404.004L18.6 7.6a2.4 2.4 0 0 1 .026 3.434L9.9 19.8",key:"o2gii7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ee=Z("SwissFranc",[["path",{d:"M10 21V3h8",key:"br2l0g"}],["path",{d:"M6 16h9",key:"2py0wn"}],["path",{d:"M10 9.5h7",key:"13dmhz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bee=Z("SwitchCamera",[["path",{d:"M11 19H4a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5",key:"mtk2lu"}],["path",{d:"M13 5h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-5",key:"120jsl"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m18 22-3-3 3-3",key:"kgdoj7"}],["path",{d:"m6 2 3 3-3 3",key:"1fnbkv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wee=Z("Sword",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jee=Z("Swords",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kee=Z("Syringe",[["path",{d:"m18 2 4 4",key:"22kx64"}],["path",{d:"m17 7 3-3",key:"1w1zoj"}],["path",{d:"M19 9 8.7 19.3c-1 1-2.5 1-3.4 0l-.6-.6c-1-1-1-2.5 0-3.4L15 5",key:"1exhtz"}],["path",{d:"m9 11 4 4",key:"rovt3i"}],["path",{d:"m5 19-3 3",key:"59f2uf"}],["path",{d:"m14 4 6 6",key:"yqp9t2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w5=Z("Table2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nee=Z("TableCellsMerge",[["path",{d:"M12 21v-6",key:"lihzve"}],["path",{d:"M12 9V3",key:"da5inc"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const See=Z("TableCellsSplit",[["path",{d:"M12 15V9",key:"8c7uyn"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cee=Z("TableColumnsSplit",[["path",{d:"M14 14v2",key:"w2a1xv"}],["path",{d:"M14 20v2",key:"1lq872"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M14 8v2",key:"i67w9a"}],["path",{d:"M2 15h8",key:"82wtch"}],["path",{d:"M2 3h6a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H2",key:"up0l64"}],["path",{d:"M2 9h8",key:"yelfik"}],["path",{d:"M22 15h-4",key:"1es58f"}],["path",{d:"M22 3h-2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h2",key:"pdjoqf"}],["path",{d:"M22 9h-4",key:"1luja7"}],["path",{d:"M5 3v18",key:"14hmio"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mee=Z("TableOfContents",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M21 12h.01",key:"msek7k"}],["path",{d:"M21 18h.01",key:"1e8rq1"}],["path",{d:"M21 6h.01",key:"1koanj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tee=Z("TableProperties",[["path",{d:"M15 3v18",key:"14nvp0"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aee=Z("TableRowsSplit",[["path",{d:"M14 10h2",key:"1lstlu"}],["path",{d:"M15 22v-8",key:"1fwwgm"}],["path",{d:"M15 2v4",key:"1044rn"}],["path",{d:"M2 10h2",key:"1r8dkt"}],["path",{d:"M20 10h2",key:"1ug425"}],["path",{d:"M3 19h18",key:"awlh7x"}],["path",{d:"M3 22v-6a2 2 135 0 1 2-2h14a2 2 45 0 1 2 2v6",key:"ibqhof"}],["path",{d:"M3 2v2a2 2 45 0 0 2 2h14a2 2 135 0 0 2-2V2",key:"1uenja"}],["path",{d:"M8 10h2",key:"66od0"}],["path",{d:"M9 22v-8",key:"fmnu31"}],["path",{d:"M9 2v4",key:"j1yeou"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PP=Z("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eee=Z("TabletSmartphone",[["rect",{width:"10",height:"14",x:"3",y:"8",rx:"2",key:"1vrsiq"}],["path",{d:"M5 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2h-2.4",key:"1j4zmg"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pee=Z("Tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iee=Z("Tablets",[["circle",{cx:"7",cy:"7",r:"5",key:"x29byf"}],["circle",{cx:"17",cy:"17",r:"5",key:"1op1d2"}],["path",{d:"M12 17h10",key:"ls21zv"}],["path",{d:"m3.46 10.54 7.08-7.08",key:"1rehiu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vh=Z("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lee=Z("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dee=Z("Tally1",[["path",{d:"M4 4v16",key:"6qkkli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oee=Z("Tally2",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ree=Z("Tally3",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fee=Z("Tally4",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}],["path",{d:"M19 4v16",key:"8ij5ei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zee=Z("Tally5",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}],["path",{d:"M19 4v16",key:"8ij5ei"}],["path",{d:"M22 6 2 18",key:"h9moai"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bee=Z("Tangent",[["circle",{cx:"17",cy:"4",r:"2",key:"y5j2s2"}],["path",{d:"M15.59 5.41 5.41 15.59",key:"l0vprr"}],["circle",{cx:"4",cy:"17",r:"2",key:"9p4efm"}],["path",{d:"M12 22s-4-9-1.5-11.5S22 12 22 12",key:"1twk4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hh=Z("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ee=Z("Telescope",[["path",{d:"m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44",key:"k4qptu"}],["path",{d:"m13.56 11.747 4.332-.924",key:"19l80z"}],["path",{d:"m16 21-3.105-6.21",key:"7oh9d"}],["path",{d:"M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z",key:"m7xp4m"}],["path",{d:"m6.158 8.633 1.114 4.456",key:"74o979"}],["path",{d:"m8 21 3.105-6.21",key:"1fvxut"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qee=Z("TentTree",[["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}],["path",{d:"m14 5 3-3 3 3",key:"1sorif"}],["path",{d:"m14 10 3-3 3 3",key:"1jyi9h"}],["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M17 14H7l-5 8h20Z",key:"13ar7p"}],["path",{d:"M8 14v8",key:"1ghmqk"}],["path",{d:"m9 14 5 8",key:"13pgi6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uee=Z("Tent",[["path",{d:"M3.5 21 14 3",key:"1szst5"}],["path",{d:"M20.5 21 10 3",key:"1310c3"}],["path",{d:"M15.5 21 12 15l-3.5 6",key:"1ddtfw"}],["path",{d:"M2 21h20",key:"1nyx9w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vee=Z("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yj=Z("TestTubeDiagonal",[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hee=Z("TestTube",[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wee=Z("TestTubes",[["path",{d:"M9 2v17.5A2.5 2.5 0 0 1 6.5 22A2.5 2.5 0 0 1 4 19.5V2",key:"1hjrqt"}],["path",{d:"M20 2v17.5a2.5 2.5 0 0 1-2.5 2.5a2.5 2.5 0 0 1-2.5-2.5V2",key:"16lc8n"}],["path",{d:"M3 2h7",key:"7s29d5"}],["path",{d:"M14 2h7",key:"7sicin"}],["path",{d:"M9 16H4",key:"1bfye3"}],["path",{d:"M20 16h-5",key:"ddnjpe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gee=Z("TextCursorInput",[["path",{d:"M5 4h1a3 3 0 0 1 3 3 3 3 0 0 1 3-3h1",key:"18xjzo"}],["path",{d:"M13 20h-1a3 3 0 0 1-3-3 3 3 0 0 1-3 3H5",key:"fj48gi"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M9 7v10",key:"1vc8ob"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kee=Z("TextCursor",[["path",{d:"M17 22h-1a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4h1",key:"uvaxm9"}],["path",{d:"M7 22h1a4 4 0 0 0 4-4v-1",key:"11xy8d"}],["path",{d:"M7 2h1a4 4 0 0 1 4 4v1",key:"1uw06m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zee=Z("TextQuote",[["path",{d:"M17 6H3",key:"16j9eg"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 18H8",key:"1wfozv"}],["path",{d:"M3 12v6",key:"fv4c87"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yee=Z("TextSearch",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xj=Z("TextSelect",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}],["line",{x1:"7",x2:"15",y1:"8",y2:"8",key:"1758g8"}],["line",{x1:"7",x2:"17",y1:"12",y2:"12",key:"197423"}],["line",{x1:"7",x2:"13",y1:"16",y2:"16",key:"37cgm6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xee=Z("Text",[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qee=Z("Theater",[["path",{d:"M2 10s3-3 3-8",key:"3xiif0"}],["path",{d:"M22 10s-3-3-3-8",key:"ioaa5q"}],["path",{d:"M10 2c0 4.4-3.6 8-8 8",key:"16fkpi"}],["path",{d:"M14 2c0 4.4 3.6 8 8 8",key:"b9eulq"}],["path",{d:"M2 10s2 2 2 5",key:"1au1lb"}],["path",{d:"M22 10s-2 2-2 5",key:"qi2y5e"}],["path",{d:"M8 15h8",key:"45n4r"}],["path",{d:"M2 22v-1a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1",key:"1vsc2m"}],["path",{d:"M14 22v-1a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1",key:"hrha4u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jee=Z("ThermometerSnowflake",[["path",{d:"M2 12h10",key:"19562f"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"m3 9 3 3-3 3",key:"1sas0l"}],["path",{d:"M12 6 9 9 6 6",key:"pfrgxu"}],["path",{d:"m6 18 3-3 1.5 1.5",key:"1e277p"}],["path",{d:"M20 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"iof6y5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ete=Z("ThermometerSun",[["path",{d:"M12 9a4 4 0 0 0-2 7.5",key:"1jvsq6"}],["path",{d:"M12 3v2",key:"1w22ol"}],["path",{d:"m6.6 18.4-1.4 1.4",key:"w2yidj"}],["path",{d:"M20 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"iof6y5"}],["path",{d:"M4 13H2",key:"118le4"}],["path",{d:"M6.34 7.34 4.93 5.93",key:"1brd51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tte=Z("Thermometer",[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IP=Z("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pu=Z("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ste=Z("TicketCheck",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rte=Z("TicketMinus",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M9 12h6",key:"1c52cq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nte=Z("TicketPercent",[["path",{d:"M2 9a3 3 0 1 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 1 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"1l48ns"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ate=Z("TicketPlus",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M12 9v6",key:"199k2o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ite=Z("TicketSlash",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ote=Z("TicketX",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LP=Z("Ticket",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lte=Z("TicketsPlane",[["path",{d:"M10.5 17h1.227a2 2 0 0 0 1.345-.52L18 12",key:"16muxl"}],["path",{d:"m12 13.5 3.75.5",key:"1i9qhk"}],["path",{d:"m4.5 8 10.58-5.06a1 1 0 0 1 1.342.488L18.5 8",key:"12lg5p"}],["path",{d:"M6 10V8",key:"1y41hn"}],["path",{d:"M6 14v1",key:"cao2tf"}],["path",{d:"M6 19v2",key:"1loha6"}],["rect",{x:"2",y:"8",width:"20",height:"13",rx:"2",key:"p3bz5l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cte=Z("Tickets",[["path",{d:"m4.5 8 10.58-5.06a1 1 0 0 1 1.342.488L18.5 8",key:"12lg5p"}],["path",{d:"M6 10V8",key:"1y41hn"}],["path",{d:"M6 14v1",key:"cao2tf"}],["path",{d:"M6 19v2",key:"1loha6"}],["rect",{x:"2",y:"8",width:"20",height:"13",rx:"2",key:"p3bz5l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dte=Z("TimerOff",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M4.6 11a8 8 0 0 0 1.7 8.7 8 8 0 0 0 8.7 1.7",key:"10he05"}],["path",{d:"M7.4 7.4a8 8 0 0 1 10.3 1 8 8 0 0 1 .9 10.2",key:"15f7sh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M12 12v-2",key:"fwoke6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ute=Z("TimerReset",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M12 14v-4",key:"1evpnu"}],["path",{d:"M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6",key:"1ts96g"}],["path",{d:"M9 17H4v5",key:"8t5av"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hte=Z("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mte=Z("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pte=Z("ToggleRight",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fte=Z("Toilet",[["path",{d:"M7 12h13a1 1 0 0 1 1 1 5 5 0 0 1-5 5h-.598a.5.5 0 0 0-.424.765l1.544 2.47a.5.5 0 0 1-.424.765H5.402a.5.5 0 0 1-.424-.765L7 18",key:"kc4kqr"}],["path",{d:"M8 18a5 5 0 0 1-5-5V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8",key:"1tqs57"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gte=Z("Tornado",[["path",{d:"M21 4H3",key:"1hwok0"}],["path",{d:"M18 8H6",key:"41n648"}],["path",{d:"M19 12H9",key:"1g4lpz"}],["path",{d:"M16 16h-6",key:"1j5d54"}],["path",{d:"M11 20H9",key:"39obr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xte=Z("Torus",[["ellipse",{cx:"12",cy:"11",rx:"3",ry:"2",key:"1b2qxu"}],["ellipse",{cx:"12",cy:"12.5",rx:"10",ry:"8.5",key:"h8emeu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yte=Z("TouchpadOff",[["path",{d:"M4 4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16",key:"lnt0bk"}],["path",{d:"M2 14h12",key:"d8icqz"}],["path",{d:"M22 14h-2",key:"jrx26d"}],["path",{d:"M12 20v-6",key:"1rm09r"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M22 16V6a2 2 0 0 0-2-2H10",key:"11y8e4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vte=Z("Touchpad",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M12 20v-6",key:"1rm09r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _te=Z("TowerControl",[["path",{d:"M18.2 12.27 20 6H4l1.8 6.27a1 1 0 0 0 .95.73h10.5a1 1 0 0 0 .96-.73Z",key:"1pledb"}],["path",{d:"M8 13v9",key:"hmv0ci"}],["path",{d:"M16 22v-9",key:"ylnf1u"}],["path",{d:"m9 6 1 7",key:"dpdgam"}],["path",{d:"m15 6-1 7",key:"ls7zgu"}],["path",{d:"M12 6V2",key:"1pj48d"}],["path",{d:"M13 2h-2",key:"mj6ths"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bte=Z("ToyBrick",[["rect",{width:"18",height:"12",x:"3",y:"8",rx:"1",key:"158fvp"}],["path",{d:"M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3",key:"s0042v"}],["path",{d:"M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3",key:"9wmeh2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wte=Z("Tractor",[["path",{d:"m10 11 11 .9a1 1 0 0 1 .8 1.1l-.665 4.158a1 1 0 0 1-.988.842H20",key:"she1j9"}],["path",{d:"M16 18h-5",key:"bq60fd"}],["path",{d:"M18 5a1 1 0 0 0-1 1v5.573",key:"1kv8ia"}],["path",{d:"M3 4h8.129a1 1 0 0 1 .99.863L13 11.246",key:"1q1ert"}],["path",{d:"M4 11V4",key:"9ft8pt"}],["path",{d:"M7 15h.01",key:"k5ht0j"}],["path",{d:"M8 10.1V4",key:"1jgyzo"}],["circle",{cx:"18",cy:"18",r:"2",key:"1emm8v"}],["circle",{cx:"7",cy:"15",r:"5",key:"ddtuc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jte=Z("TrafficCone",[["path",{d:"M9.3 6.2a4.55 4.55 0 0 0 5.4 0",key:"flyxqv"}],["path",{d:"M7.9 10.7c.9.8 2.4 1.3 4.1 1.3s3.2-.5 4.1-1.3",key:"1nlxxg"}],["path",{d:"M13.9 3.5a1.93 1.93 0 0 0-3.8-.1l-3 10c-.1.2-.1.4-.1.6 0 1.7 2.2 3 5 3s5-1.3 5-3c0-.2 0-.4-.1-.5Z",key:"vz7x1l"}],["path",{d:"m7.5 12.2-4.7 2.7c-.5.3-.8.7-.8 1.1s.3.8.8 1.1l7.6 4.5c.9.5 2.1.5 3 0l7.6-4.5c.7-.3 1-.7 1-1.1s-.3-.8-.8-1.1l-4.7-2.8",key:"1xfzlw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kte=Z("TrainFrontTunnel",[["path",{d:"M2 22V12a10 10 0 1 1 20 0v10",key:"o0fyp0"}],["path",{d:"M15 6.8v1.4a3 2.8 0 1 1-6 0V6.8",key:"m8q3n9"}],["path",{d:"M10 15h.01",key:"44in9x"}],["path",{d:"M14 15h.01",key:"5mohn5"}],["path",{d:"M10 19a4 4 0 0 1-4-4v-3a6 6 0 1 1 12 0v3a4 4 0 0 1-4 4Z",key:"hckbmu"}],["path",{d:"m9 19-2 3",key:"iij7hm"}],["path",{d:"m15 19 2 3",key:"npx8sa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nte=Z("TrainFront",[["path",{d:"M8 3.1V7a4 4 0 0 0 8 0V3.1",key:"1v71zp"}],["path",{d:"m9 15-1-1",key:"1yrq24"}],["path",{d:"m15 15 1-1",key:"1t0d6s"}],["path",{d:"M9 19c-2.8 0-5-2.2-5-5v-4a8 8 0 0 1 16 0v4c0 2.8-2.2 5-5 5Z",key:"1p0hjs"}],["path",{d:"m8 19-2 3",key:"13i0xs"}],["path",{d:"m16 19 2 3",key:"xo31yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ste=Z("TrainTrack",[["path",{d:"M2 17 17 2",key:"18b09t"}],["path",{d:"m2 14 8 8",key:"1gv9hu"}],["path",{d:"m5 11 8 8",key:"189pqp"}],["path",{d:"m8 8 8 8",key:"1imecy"}],["path",{d:"m11 5 8 8",key:"ummqn6"}],["path",{d:"m14 2 8 8",key:"1vk7dn"}],["path",{d:"M7 22 22 7",key:"15mb1i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qj=Z("TramFront",[["rect",{width:"16",height:"16",x:"4",y:"3",rx:"2",key:"1wxw4b"}],["path",{d:"M4 11h16",key:"mpoxn0"}],["path",{d:"M12 3v8",key:"1h2ygw"}],["path",{d:"m8 19-2 3",key:"13i0xs"}],["path",{d:"m18 22-2-3",key:"1p0ohu"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M16 15h.01",key:"rnfrdf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const br=Z("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cte=Z("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mte=Z("TreeDeciduous",[["path",{d:"M8 19a4 4 0 0 1-2.24-7.32A3.5 3.5 0 0 1 9 6.03V6a3 3 0 1 1 6 0v.04a3.5 3.5 0 0 1 3.24 5.65A4 4 0 0 1 16 19Z",key:"oadzkq"}],["path",{d:"M12 19v3",key:"npa21l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jj=Z("TreePalm",[["path",{d:"M13 8c0-2.76-2.46-5-5.5-5S2 5.24 2 8h2l1-1 1 1h4",key:"foxbe7"}],["path",{d:"M13 7.14A5.82 5.82 0 0 1 16.5 6c3.04 0 5.5 2.24 5.5 5h-3l-1-1-1 1h-3",key:"18arnh"}],["path",{d:"M5.89 9.71c-2.15 2.15-2.3 5.47-.35 7.43l4.24-4.25.7-.7.71-.71 2.12-2.12c-1.95-1.96-5.27-1.8-7.42.35",key:"ywahnh"}],["path",{d:"M11 15.5c.5 2.5-.17 4.5-1 6.5h4c2-5.5-.5-12-1-14",key:"ft0feo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o_=Z("TreePine",[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tte=Z("Trees",[["path",{d:"M10 10v.2A3 3 0 0 1 8.9 16H5a3 3 0 0 1-1-5.8V10a3 3 0 0 1 6 0Z",key:"1l6gj6"}],["path",{d:"M7 16v6",key:"1a82de"}],["path",{d:"M13 19v3",key:"13sx9i"}],["path",{d:"M12 19h8.3a1 1 0 0 0 .7-1.7L18 14h.3a1 1 0 0 0 .7-1.7L16 9h.2a1 1 0 0 0 .8-1.7L13 3l-1.4 1.5",key:"1sj9kv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ate=Z("Trello",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["rect",{width:"3",height:"9",x:"7",y:"7",key:"14n3xi"}],["rect",{width:"3",height:"5",x:"14",y:"7",key:"s4azjd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dN=Z("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ete=Z("TrendingUpDown",[["path",{d:"M14.828 14.828 21 21",key:"ar5fw7"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"m21 3-9 9-4-4-6 6",key:"1h02xo"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cc=Z("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Th=Z("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pte=Z("TriangleRight",[["path",{d:"M22 18a2 2 0 0 1-2 2H3c-1.1 0-1.3-.6-.4-1.3L20.4 4.3c.9-.7 1.6-.4 1.6.7Z",key:"183wce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ite=Z("Triangle",[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ki=Z("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DP=Z("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lte=Z("Turtle",[["path",{d:"m12 10 2 4v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3a8 8 0 1 0-16 0v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3l2-4h4Z",key:"1lbbv7"}],["path",{d:"M4.82 7.9 8 10",key:"m9wose"}],["path",{d:"M15.18 7.9 12 10",key:"p8dp2u"}],["path",{d:"M16.93 10H20a2 2 0 0 1 0 4H2",key:"12nsm7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dte=Z("TvMinimalPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ek=Z("TvMinimal",[["path",{d:"M7 21h10",key:"1b0cd5"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ote=Z("Tv",[["rect",{width:"20",height:"15",x:"2",y:"7",rx:"2",ry:"2",key:"10ag99"}],["polyline",{points:"17 2 12 7 7 2",key:"11pgbg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rte=Z("Twitch",[["path",{d:"M21 2H3v16h5v4l4-4h5l4-4V2zm-10 9V7m5 4V7",key:"c0yzno"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fte=Z("Twitter",[["path",{d:"M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z",key:"pff0z6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zte=Z("TypeOutline",[["path",{d:"M14 16.5a.5.5 0 0 0 .5.5h.5a2 2 0 0 1 0 4H9a2 2 0 0 1 0-4h.5a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5V8a2 2 0 0 1-4 0V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3a2 2 0 0 1-4 0v-.5a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5Z",key:"1reda3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bte=Z("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $te=Z("UmbrellaOff",[["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"M15.5 21a1.85 1.85 0 0 1-3.5-1v-8H2a10 10 0 0 1 3.428-6.575",key:"eki10q"}],["path",{d:"M17.5 12H22A10 10 0 0 0 9.004 3.455",key:"n2ayka"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qte=Z("Umbrella",[["path",{d:"M22 12a10.06 10.06 1 0 0-20 0Z",key:"1teyop"}],["path",{d:"M12 12v8a2 2 0 0 0 4 0",key:"ulpmoc"}],["path",{d:"M12 2v1",key:"11qlp1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ute=Z("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vte=Z("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hte=Z("UndoDot",[["path",{d:"M21 17a9 9 0 0 0-15-6.7L3 13",key:"8mp6z9"}],["path",{d:"M3 7v6h6",key:"1v2h90"}],["circle",{cx:"12",cy:"17",r:"1",key:"1ixnty"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j5=Z("Undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wte=Z("UnfoldHorizontal",[["path",{d:"M16 12h6",key:"15xry1"}],["path",{d:"M8 12H2",key:"1jqql6"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 15 3-3-3-3",key:"wjy7rq"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gte=Z("UnfoldVertical",[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kte=Z("Ungroup",[["rect",{width:"8",height:"6",x:"5",y:"4",rx:"1",key:"nzclkv"}],["rect",{width:"8",height:"6",x:"11",y:"14",rx:"1",key:"4tytwb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tk=Z("University",[["circle",{cx:"12",cy:"10",r:"1",key:"1gnqs8"}],["path",{d:"M22 20V8h-4l-6-4-6 4H2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"1qj5sn"}],["path",{d:"M6 17v.01",key:"roodi6"}],["path",{d:"M6 13v.01",key:"67c122"}],["path",{d:"M18 17v.01",key:"12ktxm"}],["path",{d:"M18 13v.01",key:"tn1rt1"}],["path",{d:"M14 22v-5a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5",key:"11g7fi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zte=Z("Unlink2",[["path",{d:"M15 7h2a5 5 0 0 1 0 10h-2m-6 0H7A5 5 0 0 1 7 7h2",key:"1re2ne"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uN=Z("Unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yte=Z("Unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ya=Z("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xte=Z("Usb",[["circle",{cx:"10",cy:"7",r:"1",key:"dypaad"}],["circle",{cx:"4",cy:"20",r:"1",key:"22iqad"}],["path",{d:"M4.7 19.3 19 5",key:"1enqfc"}],["path",{d:"m21 3-3 1 2 2Z",key:"d3ov82"}],["path",{d:"M9.26 7.68 5 12l2 5",key:"1esawj"}],["path",{d:"m10 14 5 2 3.5-3.5",key:"v8oal5"}],["path",{d:"m18 12 1-1 1 1-1 1Z",key:"1bh22v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l_=Z("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OP=Z("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RP=Z("UserMinus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qte=Z("UserPen",[["path",{d:"M11.5 15H7a4 4 0 0 0-4 4v2",key:"15lzij"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xc=Z("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sk=Z("UserRoundCheck",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rk=Z("UserRoundCog",[["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nk=Z("UserRoundMinus",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 19h-6",key:"vcuq98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jte=Z("UserRoundPen",[["path",{d:"M2 21a8 8 0 0 1 10.821-7.487",key:"1c8h7z"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ak=Z("UserRoundPlus",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M22 19h-6",key:"vcuq98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ese=Z("UserRoundSearch",[["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m22 22-1.9-1.9",key:"1e5ubv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ik=Z("UserRoundX",[["path",{d:"M2 21a8 8 0 0 1 11.873-7",key:"74fkxq"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m17 17 5 5",key:"p7ous7"}],["path",{d:"m22 17-5 5",key:"gqnmv0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ok=Z("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tse=Z("UserSearch",[["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}],["path",{d:"M10.3 15H7a4 4 0 0 0-4 4v2",key:"3bnktk"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sse=Z("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xi=Z("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lk=Z("UsersRound",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hr=Z("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ck=Z("UtensilsCrossed",[["path",{d:"m16 2-2.3 2.3a3 3 0 0 0 0 4.2l1.8 1.8a3 3 0 0 0 4.2 0L22 8",key:"n7qcjb"}],["path",{d:"M15 15 3.3 3.3a4.2 4.2 0 0 0 0 6l7.3 7.3c.7.7 2 .7 2.8 0L15 15Zm0 0 7 7",key:"d0u48b"}],["path",{d:"m2.1 21.8 6.4-6.3",key:"yn04lh"}],["path",{d:"m19 5-7 7",key:"194lzd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dk=Z("Utensils",[["path",{d:"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2",key:"cjf0a3"}],["path",{d:"M7 2v20",key:"1473qp"}],["path",{d:"M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7",key:"j28e5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rse=Z("UtilityPole",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M3 3v2",key:"9imdir"}],["path",{d:"M7 3v2",key:"n0os7"}],["path",{d:"M17 3v2",key:"1l2re6"}],["path",{d:"M21 3v2",key:"1duuac"}],["path",{d:"m19 5-7 7-7-7",key:"133zxf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FP=Z("Variable",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nse=Z("Vault",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["path",{d:"m7.9 7.9 2.7 2.7",key:"hpeyl3"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}],["path",{d:"m13.4 10.6 2.7-2.7",key:"264c1n"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["path",{d:"m7.9 16.1 2.7-2.7",key:"p81g5e"}],["circle",{cx:"16.5",cy:"16.5",r:".5",fill:"currentColor",key:"fubopw"}],["path",{d:"m13.4 13.4 2.7 2.7",key:"abhel3"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ase=Z("Vegan",[["path",{d:"M16 8q6 0 6-6-6 0-6 6",key:"qsyyc4"}],["path",{d:"M17.41 3.59a10 10 0 1 0 3 3",key:"41m9h7"}],["path",{d:"M2 2a26.6 26.6 0 0 1 10 20c.9-6.82 1.5-9.5 4-14",key:"qiv7li"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ise=Z("VenetianMask",[["path",{d:"M18 11c-1.5 0-2.5.5-3 2",key:"1fod00"}],["path",{d:"M4 6a2 2 0 0 0-2 2v4a5 5 0 0 0 5 5 8 8 0 0 1 5 2 8 8 0 0 1 5-2 5 5 0 0 0 5-5V8a2 2 0 0 0-2-2h-3a8 8 0 0 0-5 2 8 8 0 0 0-5-2z",key:"d70hit"}],["path",{d:"M6 11c1.5 0 2.5.5 3 2",key:"136fht"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ose=Z("VibrateOff",[["path",{d:"m2 8 2 2-2 2 2 2-2 2",key:"sv1b1"}],["path",{d:"m22 8-2 2 2 2-2 2 2 2",key:"101i4y"}],["path",{d:"M8 8v10c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2",key:"1hbad5"}],["path",{d:"M16 10.34V6c0-.55-.45-1-1-1h-4.34",key:"1x5tf0"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lse=Z("Vibrate",[["path",{d:"m2 8 2 2-2 2 2 2-2 2",key:"sv1b1"}],["path",{d:"m22 8-2 2 2 2-2 2 2 2",key:"101i4y"}],["rect",{width:"8",height:"14",x:"8",y:"5",rx:"1",key:"1oyrl4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cse=Z("VideoOff",[["path",{d:"M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196",key:"w8jjjt"}],["path",{d:"M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"1xawa7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kn=Z("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dse=Z("Videotape",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 8h20",key:"d11cs7"}],["circle",{cx:"8",cy:"14",r:"2",key:"1k2qr5"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"14",r:"2",key:"14k7lr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const use=Z("View",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hse=Z("Voicemail",[["circle",{cx:"6",cy:"12",r:"4",key:"1ehtga"}],["circle",{cx:"18",cy:"12",r:"4",key:"4vafl8"}],["line",{x1:"6",x2:"18",y1:"16",y2:"16",key:"pmt8us"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mse=Z("Volleyball",[["path",{d:"M11.1 7.1a16.55 16.55 0 0 1 10.9 4",key:"2880wi"}],["path",{d:"M12 12a12.6 12.6 0 0 1-8.7 5",key:"113sja"}],["path",{d:"M16.8 13.6a16.55 16.55 0 0 1-9 7.5",key:"1qmsgl"}],["path",{d:"M20.7 17a12.8 12.8 0 0 0-8.7-5 13.3 13.3 0 0 1 0-10",key:"1bmeqp"}],["path",{d:"M6.3 3.8a16.55 16.55 0 0 0 1.9 11.5",key:"iekzv9"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pse=Z("Volume1",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fse=Z("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gse=Z("VolumeOff",[["path",{d:"M16 9a5 5 0 0 1 .95 2.293",key:"1fgyg8"}],["path",{d:"M19.364 5.636a9 9 0 0 1 1.889 9.96",key:"l3zxae"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m7 7-.587.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298V11",key:"1gbwow"}],["path",{d:"M9.828 4.172A.686.686 0 0 1 11 4.657v.686",key:"s2je0y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xse=Z("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yse=Z("Volume",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vse=Z("Vote",[["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}],["path",{d:"M5 7c0-1.1.9-2 2-2h10a2 2 0 0 1 2 2v12H5V7Z",key:"1ezoue"}],["path",{d:"M22 19H2",key:"nuriw5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _se=Z("WalletCards",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2",key:"4125el"}],["path",{d:"M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21",key:"1dpki6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uk=Z("WalletMinimal",[["path",{d:"M17 14h.01",key:"7oqj8z"}],["path",{d:"M7 7h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14",key:"u1rqew"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zP=Z("Wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bse=Z("Wallpaper",[["circle",{cx:"8",cy:"9",r:"2",key:"gjzl9d"}],["path",{d:"m9 17 6.1-6.1a2 2 0 0 1 2.81.01L22 15V5a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"69xh40"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u0=Z("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wse=Z("Wand",[["path",{d:"M15 4V2",key:"z1p9b7"}],["path",{d:"M15 16v-2",key:"px0unx"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M17.8 11.8 19 13",key:"yihg8r"}],["path",{d:"M15 9h.01",key:"x1ddxp"}],["path",{d:"M17.8 6.2 19 5",key:"fd4us0"}],["path",{d:"m3 21 9-9",key:"1jfql5"}],["path",{d:"M12.2 6.2 11 5",key:"i3da3b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jse=Z("Warehouse",[["path",{d:"M22 8.35V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8.35A2 2 0 0 1 3.26 6.5l8-3.2a2 2 0 0 1 1.48 0l8 3.2A2 2 0 0 1 22 8.35Z",key:"gksnxg"}],["path",{d:"M6 18h12",key:"9pbo8z"}],["path",{d:"M6 14h12",key:"4cwo0f"}],["rect",{width:"12",height:"12",x:"6",y:"10",key:"apd30q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kse=Z("WashingMachine",[["path",{d:"M3 6h3",key:"155dbl"}],["path",{d:"M17 6h.01",key:"e2y6kg"}],["rect",{width:"18",height:"20",x:"3",y:"2",rx:"2",key:"od3kk9"}],["circle",{cx:"12",cy:"13",r:"5",key:"nlbqau"}],["path",{d:"M12 18a2.5 2.5 0 0 0 0-5 2.5 2.5 0 0 1 0-5",key:"17lach"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nse=Z("Watch",[["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["polyline",{points:"12 10 12 12 13 13",key:"19dquz"}],["path",{d:"m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05",key:"18k57s"}],["path",{d:"m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05",key:"16ny36"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sse=Z("Waves",[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cse=Z("Waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mse=Z("Webcam",[["circle",{cx:"12",cy:"10",r:"8",key:"1gshiw"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 22h10",key:"10w4w3"}],["path",{d:"M12 22v-4",key:"1utk9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tse=Z("WebhookOff",[["path",{d:"M17 17h-5c-1.09-.02-1.94.92-2.5 1.9A3 3 0 1 1 2.57 15",key:"1tvl6x"}],["path",{d:"M9 3.4a4 4 0 0 1 6.52.66",key:"q04jfq"}],["path",{d:"m6 17 3.1-5.8a2.5 2.5 0 0 0 .057-2.05",key:"azowf0"}],["path",{d:"M20.3 20.3a4 4 0 0 1-2.3.7",key:"5joiws"}],["path",{d:"M18.6 13a4 4 0 0 1 3.357 3.414",key:"cangb8"}],["path",{d:"m12 6 .6 1",key:"tpjl1n"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ase=Z("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ese=Z("Weight",[["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}],["path",{d:"M6.5 8a2 2 0 0 0-1.905 1.46L2.1 18.5A2 2 0 0 0 4 21h16a2 2 0 0 0 1.925-2.54L19.4 9.5A2 2 0 0 0 17.48 8Z",key:"56o5sh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pse=Z("WheatOff",[["path",{d:"m2 22 10-10",key:"28ilpk"}],["path",{d:"m16 8-1.17 1.17",key:"1qqm82"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"m8 8-.53.53a3.5 3.5 0 0 0 0 4.94L9 15l1.53-1.53c.55-.55.88-1.25.98-1.97",key:"4wz8re"}],["path",{d:"M10.91 5.26c.15-.26.34-.51.56-.73L13 3l1.53 1.53a3.5 3.5 0 0 1 .28 4.62",key:"rves66"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"m16 16-.53.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.49 3.49 0 0 1 1.97-.98",key:"ak46r"}],["path",{d:"M18.74 13.09c.26-.15.51-.34.73-.56L21 11l-1.53-1.53a3.5 3.5 0 0 0-4.62-.28",key:"1tw520"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ise=Z("Wheat",[["path",{d:"M2 22 16 8",key:"60hf96"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"M7.47 8.53 9 7l1.53 1.53a3.5 3.5 0 0 1 0 4.94L9 15l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1sdzmb"}],["path",{d:"M11.47 4.53 13 3l1.53 1.53a3.5 3.5 0 0 1 0 4.94L13 11l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"eoatbi"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"M15.47 13.47 17 15l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"2m8kc5"}],["path",{d:"M19.47 9.47 21 11l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L13 11l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"vex3ng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lse=Z("WholeWord",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dse=Z("WifiHigh",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ose=Z("WifiLow",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rse=Z("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fse=Z("WifiZero",[["path",{d:"M12 20h.01",key:"zekei9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zse=Z("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bse=Z("WindArrowDown",[["path",{d:"M10 2v8",key:"d4bbey"}],["path",{d:"M12.8 21.6A2 2 0 1 0 14 18H2",key:"19kp1d"}],["path",{d:"M17.5 10a2.5 2.5 0 1 1 2 4H2",key:"19kpjc"}],["path",{d:"m6 6 4 4 4-4",key:"k13n16"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $se=Z("Wind",[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qse=Z("WineOff",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h3m7 0h-1.343",key:"v48bem"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M7.307 7.307A12.33 12.33 0 0 0 7 10a5 5 0 0 0 7.391 4.391M8.638 2.981C8.75 2.668 8.872 2.34 9 2h6c1.5 4 2 6 2 8 0 .407-.05.809-.145 1.198",key:"1ymjlu"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Use=Z("Wine",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M12 15a5 5 0 0 0 5-5c0-2-.5-4-2-8H9c-1.5 4-2 6-2 8a5 5 0 0 0 5 5Z",key:"10ffi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vse=Z("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hse=Z("Worm",[["path",{d:"m19 12-1.5 3",key:"9bcu4o"}],["path",{d:"M19.63 18.81 22 20",key:"121v98"}],["path",{d:"M6.47 8.23a1.68 1.68 0 0 1 2.44 1.93l-.64 2.08a6.76 6.76 0 0 0 10.16 7.67l.42-.27a1 1 0 1 0-2.73-4.21l-.42.27a1.76 1.76 0 0 1-2.63-1.99l.64-2.08A6.66 6.66 0 0 0 3.94 3.9l-.7.4a1 1 0 1 0 2.55 4.34z",key:"1tij6q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wse=Z("WrapText",[["line",{x1:"3",x2:"21",y1:"6",y2:"6",key:"4m8b97"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["polyline",{points:"16 16 14 18 16 20",key:"1jznyi"}],["line",{x1:"3",x2:"10",y1:"18",y2:"18",key:"1h33wv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $g=Z("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ur=Z("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gse=Z("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kse=Z("ZapOff",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dm=Z("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c_=Z("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k5=Z("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pot=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:WR,AArrowUp:GR,ALargeSmall:KR,Accessibility:ZR,Activity:Am,AirVent:YR,Airplay:XR,AlarmClock:JR,AlarmClockCheck:sw,AlarmClockMinus:rw,AlarmClockOff:QR,AlarmClockPlus:nw,AlarmSmoke:eF,Album:tF,AlignCenter:t5,AlignCenterHorizontal:sF,AlignCenterVertical:rF,AlignEndHorizontal:nF,AlignEndVertical:aF,AlignHorizontalDistributeCenter:iF,AlignHorizontalDistributeEnd:oF,AlignHorizontalDistributeStart:lF,AlignHorizontalJustifyCenter:cF,AlignHorizontalJustifyEnd:dF,AlignHorizontalJustifyStart:uF,AlignHorizontalSpaceAround:hF,AlignHorizontalSpaceBetween:mF,AlignJustify:pF,AlignLeft:s5,AlignRight:r5,AlignStartHorizontal:fF,AlignStartVertical:gF,AlignVerticalDistributeCenter:xF,AlignVerticalDistributeEnd:yF,AlignVerticalDistributeStart:vF,AlignVerticalJustifyCenter:_F,AlignVerticalJustifyEnd:bF,AlignVerticalJustifyStart:wF,AlignVerticalSpaceAround:jF,AlignVerticalSpaceBetween:kF,Ambulance:NF,Ampersand:SF,Ampersands:CF,Amphora:MF,Anchor:TF,Angry:AF,Annoyed:EF,Antenna:PF,Anvil:IF,Aperture:LF,AppWindow:GE,AppWindowMac:DF,Apple:OF,Archive:n5,ArchiveRestore:KE,ArchiveX:RF,Armchair:FF,ArrowBigDown:BF,ArrowBigDownDash:zF,ArrowBigLeft:qF,ArrowBigLeftDash:$F,ArrowBigRight:VF,ArrowBigRightDash:UF,ArrowBigUp:WF,ArrowBigUpDash:HF,ArrowDown:eh,ArrowDown01:GF,ArrowDown10:KF,ArrowDownAZ:aw,ArrowDownFromLine:ZF,ArrowDownLeft:YF,ArrowDownNarrowWide:XF,ArrowDownRight:ZE,ArrowDownToDot:QF,ArrowDownToLine:JF,ArrowDownUp:ez,ArrowDownWideNarrow:iw,ArrowDownZA:ow,ArrowLeft:Ua,ArrowLeftFromLine:tz,ArrowLeftRight:sz,ArrowLeftToLine:rz,ArrowRight:Fi,ArrowRightFromLine:nz,ArrowRightLeft:k0,ArrowRightToLine:az,ArrowUp:Vd,ArrowUp01:iz,ArrowUp10:oz,ArrowUpAZ:lw,ArrowUpDown:Hc,ArrowUpFromDot:lz,ArrowUpFromLine:cz,ArrowUpLeft:dz,ArrowUpNarrowWide:cw,ArrowUpRight:YE,ArrowUpToLine:uz,ArrowUpWideNarrow:hz,ArrowUpZA:dw,ArrowsUpFromLine:mz,Asterisk:pz,AtSign:fz,Atom:gz,AudioLines:xz,AudioWaveform:yz,Award:rc,Axe:vz,Axis3d:uw,Baby:_z,Backpack:bz,Badge:Rz,BadgeAlert:wz,BadgeCent:jz,BadgeCheck:hw,BadgeDollarSign:kz,BadgeEuro:Nz,BadgeHelp:Sz,BadgeIndianRupee:Cz,BadgeInfo:Mz,BadgeJapaneseYen:Tz,BadgeMinus:Az,BadgePercent:Ez,BadgePlus:Pz,BadgePoundSterling:Iz,BadgeRussianRuble:Lz,BadgeSwissFranc:Dz,BadgeX:Oz,BaggageClaim:Fz,Ban:zz,Banana:Bz,Bandage:$z,Banknote:qz,Barcode:Uz,Baseline:Vz,Bath:Vx,Battery:Yz,BatteryCharging:Hz,BatteryFull:Wz,BatteryLow:Gz,BatteryMedium:Kz,BatteryWarning:Zz,Beaker:Xz,Bean:Jz,BeanOff:Qz,Bed:N0,BedDouble:XE,BedSingle:e7,Beef:t7,Beer:r7,BeerOff:s7,Bell:cf,BellDot:n7,BellElectric:a7,BellMinus:i7,BellOff:X1,BellPlus:o7,BellRing:l7,BetweenHorizontalEnd:mw,BetweenHorizontalStart:pw,BetweenVerticalEnd:c7,BetweenVerticalStart:d7,BicepsFlexed:u7,Bike:h7,Binary:m7,Binoculars:p7,Biohazard:f7,Bird:g7,Bitcoin:x7,Blend:y7,Blinds:v7,Blocks:_7,Bluetooth:k7,BluetoothConnected:b7,BluetoothOff:w7,BluetoothSearching:j7,Bold:a5,Bolt:N7,Bomb:S7,Bone:C7,Book:Z7,BookA:M7,BookAudio:T7,BookCheck:A7,BookCopy:E7,BookDashed:fw,BookDown:P7,BookHeadphones:I7,BookHeart:L7,BookImage:D7,BookKey:O7,BookLock:R7,BookMarked:F7,BookMinus:z7,BookOpen:Ou,BookOpenCheck:B7,BookOpenText:$7,BookPlus:q7,BookText:U7,BookType:V7,BookUp:W7,BookUp2:H7,BookUser:G7,BookX:K7,Bookmark:Dg,BookmarkCheck:Y7,BookmarkMinus:X7,BookmarkPlus:QE,BookmarkX:Q7,BoomBox:J7,Bot:i5,BotMessageSquare:eB,BotOff:tB,Box:sB,Boxes:rB,Braces:gw,Brackets:nB,Brain:JE,BrainCircuit:aB,BrainCog:iB,BrickWall:oB,Briefcase:th,BriefcaseBusiness:lB,BriefcaseConveyorBelt:cB,BriefcaseMedical:dB,BringToFront:uB,Brush:hB,Bug:fB,BugOff:mB,BugPlay:pB,Building:Qk,Building2:Aa,Bus:xB,BusFront:gB,Cable:vB,CableCar:yB,Cake:Ru,CakeSlice:_B,Calculator:bB,Calendar:on,Calendar1:wB,CalendarArrowDown:jB,CalendarArrowUp:kB,CalendarCheck:SB,CalendarCheck2:NB,CalendarClock:eP,CalendarCog:CB,CalendarDays:ld,CalendarFold:MB,CalendarHeart:TB,CalendarMinus:EB,CalendarMinus2:AB,CalendarOff:tP,CalendarPlus:Q1,CalendarPlus2:PB,CalendarRange:IB,CalendarSearch:LB,CalendarSync:DB,CalendarX:RB,CalendarX2:OB,Camera:Og,CameraOff:FB,Candy:$B,CandyCane:zB,CandyOff:BB,Cannabis:qB,Captions:xw,CaptionsOff:UB,Car:WB,CarFront:VB,CarTaxiFront:HB,Caravan:GB,Carrot:KB,CaseLower:ZB,CaseSensitive:YB,CaseUpper:XB,CassetteTape:QB,Cast:JB,Castle:e9,Cat:t9,Cctv:s9,ChartArea:yw,ChartBar:_w,ChartBarBig:vw,ChartBarDecreasing:r9,ChartBarIncreasing:n9,ChartBarStacked:a9,ChartCandlestick:bw,ChartColumn:Xo,ChartColumnBig:ww,ChartColumnDecreasing:i9,ChartColumnIncreasing:jw,ChartColumnStacked:o9,ChartGantt:l9,ChartLine:kw,ChartNetwork:c9,ChartNoAxesColumn:Sw,ChartNoAxesColumnDecreasing:d9,ChartNoAxesColumnIncreasing:Nw,ChartNoAxesCombined:u9,ChartNoAxesGantt:Cw,ChartPie:Mw,ChartScatter:Tw,ChartSpline:h9,Check:ua,CheckCheck:m9,ChefHat:p9,Cherry:f9,ChevronDown:Vo,ChevronFirst:g9,ChevronLast:x9,ChevronLeft:zl,ChevronRight:Ha,ChevronUp:Rg,ChevronsDown:v9,ChevronsDownUp:y9,ChevronsLeft:w9,ChevronsLeftRight:b9,ChevronsLeftRightEllipsis:_9,ChevronsRight:k9,ChevronsRightLeft:j9,ChevronsUp:N9,ChevronsUpDown:df,Chrome:S9,Church:C9,Cigarette:T9,CigaretteOff:M9,Circle:Gc,CircleAlert:Qo,CircleArrowDown:Aw,CircleArrowLeft:Ew,CircleArrowOutDownLeft:Pw,CircleArrowOutDownRight:Iw,CircleArrowOutUpLeft:Lw,CircleArrowOutUpRight:Dw,CircleArrowRight:Ow,CircleArrowUp:Rw,CircleCheck:da,CircleCheckBig:gi,CircleChevronDown:Fw,CircleChevronLeft:zw,CircleChevronRight:Bw,CircleChevronUp:$w,CircleDashed:A9,CircleDivide:qw,CircleDollarSign:E9,CircleDot:I9,CircleDotDashed:P9,CircleEllipsis:L9,CircleEqual:D9,CircleFadingArrowUp:O9,CircleFadingPlus:R9,CircleGauge:Uw,CircleHelp:i0,CircleMinus:Vw,CircleOff:F9,CircleParking:Ww,CircleParkingOff:Hw,CirclePause:Gw,CirclePercent:Kw,CirclePlay:ym,CirclePlus:Zw,CirclePower:Yw,CircleSlash:z9,CircleSlash2:Xw,CircleStop:Qw,CircleUser:e2,CircleUserRound:Jw,CircleX:kc,CircuitBoard:B9,Citrus:$9,Clapperboard:q9,Clipboard:Z9,ClipboardCheck:o5,ClipboardCopy:U9,ClipboardList:J1,ClipboardMinus:V9,ClipboardPaste:H9,ClipboardPen:s2,ClipboardPenLine:t2,ClipboardPlus:W9,ClipboardType:G9,ClipboardX:K9,Clock:Tn,Clock1:Y9,Clock10:X9,Clock11:Q9,Clock12:J9,Clock2:e$,Clock3:t$,Clock4:s$,Clock5:r$,Clock6:n$,Clock7:a$,Clock8:i$,Clock9:o$,ClockAlert:l$,ClockArrowDown:c$,ClockArrowUp:d$,Cloud:N$,CloudAlert:u$,CloudCog:h$,CloudDownload:r2,CloudDrizzle:m$,CloudFog:p$,CloudHail:f$,CloudLightning:g$,CloudMoon:y$,CloudMoonRain:x$,CloudOff:v$,CloudRain:b$,CloudRainWind:_$,CloudSnow:w$,CloudSun:k$,CloudSunRain:j$,CloudUpload:n2,Cloudy:S$,Clover:y0,Club:C$,Code:Jk,CodeXml:a2,Codepen:M$,Codesandbox:T$,Coffee:eN,Cog:A$,Coins:sP,Columns2:i2,Columns3:o2,Columns4:E$,Combine:P$,Command:I$,Compass:L$,Component:D$,Computer:O$,ConciergeBell:R$,Cone:F$,Construction:z$,Contact:tN,ContactRound:l2,Container:B$,Contrast:$$,Cookie:q$,CookingPot:U$,Copy:ni,CopyCheck:V$,CopyMinus:H$,CopyPlus:W$,CopySlash:G$,CopyX:K$,Copyleft:Z$,Copyright:Y$,CornerDownLeft:X$,CornerDownRight:Q$,CornerLeftDown:J$,CornerLeftUp:eq,CornerRightDown:tq,CornerRightUp:sq,CornerUpLeft:rq,CornerUpRight:nq,Cpu:aq,CreativeCommons:iq,CreditCard:uf,Croissant:oq,Crop:lq,Cross:cq,Crosshair:dq,Crown:Bh,Cuboid:uq,CupSoda:hq,Currency:mq,Cylinder:pq,Dam:fq,Database:yq,DatabaseBackup:gq,DatabaseZap:xq,Delete:vq,Dessert:_q,Diameter:bq,Diamond:kq,DiamondMinus:wq,DiamondPercent:c2,DiamondPlus:jq,Dice1:Nq,Dice2:Sq,Dice3:Cq,Dice4:Mq,Dice5:Tq,Dice6:Aq,Dices:Eq,Diff:Pq,Disc:Oq,Disc2:Iq,Disc3:Lq,DiscAlbum:Dq,Divide:Rq,Dna:zq,DnaOff:Fq,Dock:Bq,Dog:$q,DollarSign:Kc,Donut:qq,DoorClosed:Uq,DoorOpen:S0,Dot:Vq,Download:xi,DraftingCompass:Hq,Drama:Wq,Dribbble:Gq,Drill:Kq,Droplet:Zq,Droplets:Fg,Drum:Yq,Drumstick:Xq,Dumbbell:Qq,Ear:eU,EarOff:Jq,Earth:d2,EarthLock:tU,Eclipse:sU,Egg:l5,EggFried:rU,EggOff:nU,Ellipsis:ef,EllipsisVertical:Jp,Equal:oU,EqualApproximately:aU,EqualNot:iU,Eraser:lU,EthernetPort:cU,Euro:dU,Expand:uU,ExternalLink:sn,Eye:ya,EyeClosed:hU,EyeOff:Em,Facebook:Hd,Factory:mU,Fan:pU,FastForward:fU,Feather:gU,Fence:xU,FerrisWheel:yU,Figma:vU,File:c5,FileArchive:_U,FileAudio:wU,FileAudio2:bU,FileAxis3d:u2,FileBadge:kU,FileBadge2:jU,FileBox:NU,FileChartColumn:m2,FileChartColumnIncreasing:h2,FileChartLine:p2,FileChartPie:f2,FileCheck:CU,FileCheck2:SU,FileClock:MU,FileCode:AU,FileCode2:TU,FileCog:g2,FileDiff:EU,FileDigit:PU,FileDown:IU,FileHeart:LU,FileImage:e_,FileInput:DU,FileJson:RU,FileJson2:OU,FileKey:zU,FileKey2:FU,FileLock:$U,FileLock2:BU,FileMinus:UU,FileMinus2:qU,FileMusic:VU,FileOutput:HU,FilePen:y2,FilePenLine:x2,FilePlus:GU,FilePlus2:WU,FileQuestion:KU,FileScan:ZU,FileSearch:XU,FileSearch2:YU,FileSliders:QU,FileSpreadsheet:C0,FileStack:rP,FileSymlink:JU,FileTerminal:eV,FileText:In,FileType:sV,FileType2:tV,FileUp:rV,FileUser:nV,FileVideo:iV,FileVideo2:aV,FileVolume:lV,FileVolume2:oV,FileWarning:cV,FileX:uV,FileX2:dV,Files:hV,Film:lu,Filter:Hx,FilterX:mV,Fingerprint:pV,FireExtinguisher:fV,Fish:yV,FishOff:gV,FishSymbol:xV,Flag:M0,FlagOff:vV,FlagTriangleLeft:_V,FlagTriangleRight:bV,Flame:$h,FlameKindling:wV,Flashlight:kV,FlashlightOff:jV,FlaskConical:t_,FlaskConicalOff:NV,FlaskRound:SV,FlipHorizontal:MV,FlipHorizontal2:CV,FlipVertical:AV,FlipVertical2:TV,Flower:EV,Flower2:Ag,Focus:PV,FoldHorizontal:IV,FoldVertical:LV,Folder:oH,FolderArchive:DV,FolderCheck:OV,FolderClock:RV,FolderClosed:FV,FolderCode:zV,FolderCog:v2,FolderDot:BV,FolderDown:$V,FolderGit:UV,FolderGit2:qV,FolderHeart:VV,FolderInput:HV,FolderKanban:WV,FolderKey:GV,FolderLock:KV,FolderMinus:ZV,FolderOpen:qh,FolderOpenDot:YV,FolderOutput:XV,FolderPen:_2,FolderPlus:QV,FolderRoot:JV,FolderSearch:tH,FolderSearch2:eH,FolderSymlink:sH,FolderSync:rH,FolderTree:nH,FolderUp:aH,FolderX:iH,Folders:lH,Footprints:cH,Forklift:dH,Forward:uH,Frame:hH,Framer:mH,Frown:pH,Fuel:fH,Fullscreen:gH,GalleryHorizontal:yH,GalleryHorizontalEnd:xH,GalleryThumbnails:vH,GalleryVertical:bH,GalleryVerticalEnd:_H,Gamepad:jH,Gamepad2:wH,Gauge:kH,Gavel:NH,Gem:SH,Ghost:sN,Gift:io,GitBranch:MH,GitBranchPlus:CH,GitCommitHorizontal:b2,GitCommitVertical:TH,GitCompare:EH,GitCompareArrows:AH,GitFork:PH,GitGraph:IH,GitMerge:LH,GitPullRequest:BH,GitPullRequestArrow:DH,GitPullRequestClosed:OH,GitPullRequestCreate:FH,GitPullRequestCreateArrow:RH,GitPullRequestDraft:zH,Github:$H,Gitlab:qH,GlassWater:UH,Glasses:VH,Globe:Pm,GlobeLock:HH,Goal:WH,Grab:GH,GraduationCap:sh,Grape:KH,Grid2x2:j2,Grid2x2Check:ZH,Grid2x2Plus:w2,Grid2x2X:YH,Grid3x3:Vp,Grip:QH,GripHorizontal:XH,GripVertical:Fu,Group:JH,Guitar:eW,Ham:tW,Hammer:sW,Hand:nP,HandCoins:rW,HandHeart:nW,HandHelping:k2,HandMetal:aW,HandPlatter:iW,Handshake:aP,HardDrive:iP,HardDriveDownload:oW,HardDriveUpload:lW,HardHat:cW,Hash:d5,Haze:dW,HdmiPort:uW,Heading:gW,Heading1:oP,Heading2:lP,Heading3:hW,Heading4:mW,Heading5:pW,Heading6:fW,HeadphoneOff:xW,Headphones:yW,Headset:vW,Heart:Si,HeartCrack:_W,HeartHandshake:bW,HeartOff:wW,HeartPulse:jW,Heater:kW,Hexagon:NW,Highlighter:SW,History:u5,Hop:MW,HopOff:CW,Hospital:TW,Hotel:AW,Hourglass:EW,House:Un,HousePlug:PW,HousePlus:IW,IceCreamBowl:N2,IceCreamCone:S2,IdCard:LW,Image:Jo,ImageDown:DW,ImageMinus:OW,ImageOff:RW,ImagePlay:FW,ImagePlus:T0,ImageUp:zW,ImageUpscale:BW,Images:$W,Import:qW,Inbox:UW,IndentDecrease:C2,IndentIncrease:M2,IndianRupee:VW,Infinity:HW,Info:cP,InspectionPanel:WW,Instagram:Wd,Italic:h5,IterationCcw:GW,IterationCw:KW,JapaneseYen:ZW,Joystick:YW,Kanban:Wx,Key:Im,KeyRound:rN,KeySquare:XW,Keyboard:eG,KeyboardMusic:QW,KeyboardOff:JW,Lamp:iG,LampCeiling:tG,LampDesk:sG,LampFloor:rG,LampWallDown:nG,LampWallUp:aG,LandPlot:oG,Landmark:lG,Languages:cG,Laptop:uG,LaptopMinimal:T2,LaptopMinimalCheck:dG,Lasso:mG,LassoSelect:hG,Laugh:pG,Layers:xG,Layers2:fG,Layers3:gG,LayoutDashboard:nN,LayoutGrid:mp,LayoutList:yG,LayoutPanelLeft:vG,LayoutPanelTop:_G,LayoutTemplate:aN,Leaf:bG,LeafyGreen:wG,Lectern:jG,LetterText:kG,Library:m5,LibraryBig:NG,LifeBuoy:p5,Ligature:SG,Lightbulb:s_,LightbulbOff:CG,Link:Lo,Link2:Ho,Link2Off:MG,Linkedin:Lm,List:Uh,ListCheck:TG,ListChecks:AG,ListCollapse:EG,ListEnd:PG,ListFilter:IG,ListMinus:LG,ListMusic:DG,ListOrdered:A0,ListPlus:OG,ListRestart:RG,ListStart:FG,ListTodo:zG,ListTree:BG,ListVideo:$G,ListX:qG,Loader:VG,LoaderCircle:As,LoaderPinwheel:UG,Locate:dP,LocateFixed:HG,LocateOff:WG,Lock:zu,LockKeyhole:GG,LockKeyholeOpen:A2,LockOpen:E2,LogIn:f5,LogOut:g5,Logs:KG,Lollipop:ZG,Luggage:YG,Magnet:XG,Mail:_r,MailCheck:QG,MailMinus:JG,MailOpen:eK,MailPlus:tK,MailQuestion:sK,MailSearch:rK,MailWarning:nK,MailX:uP,Mailbox:aK,Mails:iK,Map:yK,MapPin:Ai,MapPinCheck:lK,MapPinCheckInside:oK,MapPinHouse:cK,MapPinMinus:uK,MapPinMinusInside:dK,MapPinOff:hK,MapPinPlus:pK,MapPinPlusInside:mK,MapPinX:gK,MapPinXInside:fK,MapPinned:xK,Martini:vK,Maximize:hP,Maximize2:_K,Medal:E0,Megaphone:zg,MegaphoneOff:bK,Meh:wK,MemoryStick:jK,Menu:mP,Merge:kK,MessageCircle:gc,MessageCircleCode:NK,MessageCircleDashed:SK,MessageCircleHeart:x5,MessageCircleMore:CK,MessageCircleOff:MK,MessageCirclePlus:TK,MessageCircleQuestion:pP,MessageCircleReply:AK,MessageCircleWarning:EK,MessageCircleX:PK,MessageSquare:oo,MessageSquareCode:IK,MessageSquareDashed:LK,MessageSquareDiff:DK,MessageSquareDot:OK,MessageSquareHeart:RK,MessageSquareLock:FK,MessageSquareMore:fP,MessageSquareOff:zK,MessageSquarePlus:y5,MessageSquareQuote:gP,MessageSquareReply:BK,MessageSquareShare:$K,MessageSquareText:qK,MessageSquareWarning:UK,MessageSquareX:VK,MessagesSquare:HK,Mic:xP,MicOff:WK,MicVocal:P2,Microchip:GK,Microscope:KK,Microwave:ZK,Milestone:YK,Milk:QK,MilkOff:XK,Minimize:eZ,Minimize2:JK,Minus:P0,Monitor:iN,MonitorCheck:tZ,MonitorCog:sZ,MonitorDot:rZ,MonitorDown:nZ,MonitorOff:aZ,MonitorPause:iZ,MonitorPlay:oZ,MonitorSmartphone:lZ,MonitorSpeaker:cZ,MonitorStop:dZ,MonitorUp:uZ,MonitorX:hZ,Moon:pZ,MoonStar:mZ,Mountain:gZ,MountainSnow:fZ,Mouse:_Z,MouseOff:xZ,MousePointer:jm,MousePointer2:yZ,MousePointerBan:vZ,MousePointerClick:r_,Move:IZ,Move3d:I2,MoveDiagonal:wZ,MoveDiagonal2:bZ,MoveDown:NZ,MoveDownLeft:jZ,MoveDownRight:kZ,MoveHorizontal:SZ,MoveLeft:CZ,MoveRight:MZ,MoveUp:EZ,MoveUpLeft:TZ,MoveUpRight:AZ,MoveVertical:PZ,Music:RZ,Music2:LZ,Music3:DZ,Music4:OZ,Navigation:yP,Navigation2:zZ,Navigation2Off:FZ,NavigationOff:BZ,Network:$Z,Newspaper:I0,Nfc:qZ,Notebook:WZ,NotebookPen:UZ,NotebookTabs:VZ,NotebookText:HZ,NotepadText:KZ,NotepadTextDashed:GZ,Nut:YZ,NutOff:ZZ,Octagon:QZ,OctagonAlert:o0,OctagonMinus:XZ,OctagonPause:L2,OctagonX:D2,Omega:JZ,Option:eY,Orbit:tY,Origami:sY,Package:dl,Package2:rY,PackageCheck:nY,PackageMinus:aY,PackageOpen:iY,PackagePlus:oY,PackageSearch:lY,PackageX:cY,PaintBucket:dY,PaintRoller:uY,Paintbrush:hY,PaintbrushVertical:O2,Palette:Bl,PanelBottom:fY,PanelBottomClose:mY,PanelBottomDashed:R2,PanelBottomOpen:pY,PanelLeft:$2,PanelLeftClose:F2,PanelLeftDashed:z2,PanelLeftOpen:B2,PanelRight:yY,PanelRightClose:gY,PanelRightDashed:q2,PanelRightOpen:xY,PanelTop:bY,PanelTopClose:vY,PanelTopDashed:U2,PanelTopOpen:_Y,PanelsLeftBottom:wY,PanelsRightBottom:jY,PanelsTopLeft:l0,Paperclip:oN,Parentheses:kY,ParkingMeter:NY,PartyPopper:Sd,Pause:pp,PawPrint:SY,PcCase:CY,Pen:Ix,PenLine:c0,PenOff:MY,PenTool:n_,Pencil:Ra,PencilLine:TY,PencilOff:AY,PencilRuler:EY,Pentagon:PY,Percent:v5,PersonStanding:IY,PhilippinePeso:LY,Phone:Zn,PhoneCall:DY,PhoneForwarded:OY,PhoneIncoming:RY,PhoneMissed:FY,PhoneOff:zY,PhoneOutgoing:BY,Pi:$Y,Piano:qY,Pickaxe:UY,PictureInPicture:HY,PictureInPicture2:VY,PiggyBank:WY,Pilcrow:ZY,PilcrowLeft:GY,PilcrowRight:KY,Pill:XY,PillBottle:YY,Pin:a_,PinOff:vP,Pipette:QY,Pizza:JY,Plane:sX,PlaneLanding:eX,PlaneTakeoff:tX,Play:ul,Plug:_P,Plug2:rX,PlugZap:V2,Plus:Zs,Pocket:aX,PocketKnife:nX,Podcast:iX,Pointer:lX,PointerOff:oX,Popcorn:cX,Popsicle:dX,PoundSterling:uX,Power:bP,PowerOff:hX,Presentation:Bg,Printer:wP,PrinterCheck:mX,Projector:pX,Proportions:fX,Puzzle:gX,Pyramid:xX,QrCode:L0,Quote:_5,Rabbit:yX,Radar:vX,Radiation:_X,Radical:bX,Radio:lN,RadioReceiver:wX,RadioTower:jX,Radius:kX,RailSymbol:NX,Rainbow:SX,Rat:CX,Ratio:MX,Receipt:RX,ReceiptCent:TX,ReceiptEuro:AX,ReceiptIndianRupee:EX,ReceiptJapaneseYen:PX,ReceiptPoundSterling:IX,ReceiptRussianRuble:LX,ReceiptSwissFranc:DX,ReceiptText:OX,RectangleEllipsis:H2,RectangleHorizontal:FX,RectangleVertical:zX,Recycle:BX,Redo:b5,Redo2:$X,RedoDot:qX,RefreshCcw:VX,RefreshCcwDot:UX,RefreshCw:Po,RefreshCwOff:HX,Refrigerator:WX,Regex:GX,RemoveFormatting:KX,Repeat:jP,Repeat1:ZX,Repeat2:YX,Replace:QX,ReplaceAll:XX,Reply:kP,ReplyAll:JX,Rewind:eQ,Ribbon:tQ,Rocket:Gx,RockingChair:sQ,RollerCoaster:rQ,Rotate3d:W2,RotateCcw:D0,RotateCcwSquare:nQ,RotateCw:NP,RotateCwSquare:aQ,Route:oQ,RouteOff:iQ,Router:lQ,Rows2:G2,Rows3:K2,Rows4:cQ,Rss:dQ,Ruler:SP,RussianRuble:uQ,Sailboat:hQ,Salad:mQ,Sandwich:pQ,Satellite:gQ,SatelliteDish:fQ,Save:Bu,SaveAll:xQ,SaveOff:yQ,Scale:vQ,Scale3d:Z2,Scaling:_Q,Scan:MQ,ScanBarcode:bQ,ScanEye:wQ,ScanFace:jQ,ScanLine:kQ,ScanQrCode:NQ,ScanSearch:SQ,ScanText:CQ,School:TQ,Scissors:EQ,ScissorsLineDashed:AQ,ScreenShare:IQ,ScreenShareOff:PQ,Scroll:DQ,ScrollText:LQ,Search:fn,SearchCheck:OQ,SearchCode:RQ,SearchSlash:FQ,SearchX:CP,Section:zQ,Send:ka,SendHorizontal:Y2,SendToBack:BQ,SeparatorHorizontal:$Q,SeparatorVertical:qQ,Server:WQ,ServerCog:UQ,ServerCrash:VQ,ServerOff:HQ,Settings:$l,Settings2:MP,Shapes:GQ,Share:TP,Share2:cd,Sheet:KQ,Shell:ZQ,Shield:rh,ShieldAlert:YQ,ShieldBan:XQ,ShieldCheck:AP,ShieldEllipsis:QQ,ShieldHalf:JQ,ShieldMinus:eJ,ShieldOff:tJ,ShieldPlus:sJ,ShieldQuestion:rJ,ShieldX:X2,Ship:aJ,ShipWheel:nJ,Shirt:iJ,ShoppingBag:Kx,ShoppingBasket:oJ,ShoppingCart:km,Shovel:lJ,ShowerHead:cJ,Shrink:dJ,Shrub:uJ,Shuffle:cN,Sigma:hJ,Signal:xJ,SignalHigh:mJ,SignalLow:pJ,SignalMedium:fJ,SignalZero:gJ,Signature:yJ,Signpost:_J,SignpostBig:vJ,Siren:bJ,SkipBack:wJ,SkipForward:jJ,Skull:kJ,Slack:NJ,Slash:SJ,Slice:CJ,SlidersHorizontal:EP,SlidersVertical:Q2,Smartphone:O0,SmartphoneCharging:MJ,SmartphoneNfc:TJ,Smile:EJ,SmilePlus:AJ,Snail:PJ,Snowflake:D1,Sofa:IJ,Soup:LJ,Space:DJ,Spade:OJ,Sparkle:RJ,Sparkles:hn,Speaker:FJ,Speech:zJ,SpellCheck:$J,SpellCheck2:BJ,Spline:qJ,Split:UJ,SprayCan:VJ,Sprout:HJ,Square:Zx,SquareActivity:J2,SquareArrowDown:sj,SquareArrowDownLeft:ej,SquareArrowDownRight:tj,SquareArrowLeft:rj,SquareArrowOutDownLeft:nj,SquareArrowOutDownRight:aj,SquareArrowOutUpLeft:ij,SquareArrowOutUpRight:oj,SquareArrowRight:lj,SquareArrowUp:uj,SquareArrowUpLeft:cj,SquareArrowUpRight:dj,SquareAsterisk:hj,SquareBottomDashedScissors:mj,SquareChartGantt:jx,SquareCheck:pj,SquareCheckBig:d0,SquareChevronDown:fj,SquareChevronLeft:gj,SquareChevronRight:xj,SquareChevronUp:yj,SquareCode:vj,SquareDashed:wj,SquareDashedBottom:GJ,SquareDashedBottomCode:WJ,SquareDashedKanban:_j,SquareDashedMousePointer:bj,SquareDivide:jj,SquareDot:kj,SquareEqual:Nj,SquareFunction:Sj,SquareKanban:Cj,SquareLibrary:Mj,SquareM:Tj,SquareMenu:Aj,SquareMinus:Ej,SquareMousePointer:Pj,SquareParking:Lj,SquareParkingOff:Ij,SquarePen:Oc,SquarePercent:Dj,SquarePi:Oj,SquarePilcrow:Rj,SquarePlay:Fj,SquarePlus:zj,SquarePower:Bj,SquareRadical:KJ,SquareScissors:$j,SquareSigma:qj,SquareSlash:Uj,SquareSplitHorizontal:Vj,SquareSplitVertical:Hj,SquareSquare:ZJ,SquareStack:YJ,SquareTerminal:Wj,SquareUser:Kj,SquareUserRound:Gj,SquareX:Zj,Squircle:XJ,Squirrel:QJ,Stamp:JJ,Star:Gn,StarHalf:eee,StarOff:tee,StepBack:see,StepForward:ree,Stethoscope:nee,Sticker:aee,StickyNote:iee,Store:oee,StretchHorizontal:lee,StretchVertical:cee,Strikethrough:dee,Subscript:uee,Sun:i_,SunDim:hee,SunMedium:mee,SunMoon:pee,SunSnow:fee,Sunrise:gee,Sunset:xee,Superscript:yee,SwatchBook:vee,SwissFranc:_ee,SwitchCamera:bee,Sword:wee,Swords:jee,Syringe:kee,Table:PP,Table2:w5,TableCellsMerge:Nee,TableCellsSplit:See,TableColumnsSplit:Cee,TableOfContents:Mee,TableProperties:Tee,TableRowsSplit:Aee,Tablet:Pee,TabletSmartphone:Eee,Tablets:Iee,Tag:Vh,Tags:Lee,Tally1:Dee,Tally2:Oee,Tally3:Ree,Tally4:Fee,Tally5:zee,Tangent:Bee,Target:Hh,Telescope:$ee,Tent:Uee,TentTree:qee,Terminal:Vee,TestTube:Hee,TestTubeDiagonal:Yj,TestTubes:Wee,Text:Xee,TextCursor:Kee,TextCursorInput:Gee,TextQuote:Zee,TextSearch:Yee,TextSelect:Xj,Theater:Qee,Thermometer:tte,ThermometerSnowflake:Jee,ThermometerSun:ete,ThumbsDown:IP,ThumbsUp:pu,Ticket:LP,TicketCheck:ste,TicketMinus:rte,TicketPercent:nte,TicketPlus:ate,TicketSlash:ite,TicketX:ote,Tickets:cte,TicketsPlane:lte,Timer:hte,TimerOff:dte,TimerReset:ute,ToggleLeft:mte,ToggleRight:pte,Toilet:fte,Tornado:gte,Torus:xte,Touchpad:vte,TouchpadOff:yte,TowerControl:_te,ToyBrick:bte,Tractor:wte,TrafficCone:jte,TrainFront:Nte,TrainFrontTunnel:kte,TrainTrack:Ste,TramFront:Qj,Trash:Cte,Trash2:br,TreeDeciduous:Mte,TreePalm:Jj,TreePine:o_,Trees:Tte,Trello:Ate,TrendingDown:dN,TrendingUp:Cc,TrendingUpDown:Ete,Triangle:Ite,TriangleAlert:Th,TriangleRight:Pte,Trophy:Ki,Truck:DP,Turtle:Lte,Tv:Ote,TvMinimal:ek,TvMinimalPlay:Dte,Twitch:Rte,Twitter:Fte,Type:Bte,TypeOutline:zte,Umbrella:qte,UmbrellaOff:$te,Underline:Ute,Undo:j5,Undo2:Vte,UndoDot:Hte,UnfoldHorizontal:Wte,UnfoldVertical:Gte,Ungroup:Kte,University:tk,Unlink:uN,Unlink2:Zte,Unplug:Yte,Upload:Ya,Usb:Xte,User:Xi,UserCheck:l_,UserCog:OP,UserMinus:RP,UserPen:Qte,UserPlus:xc,UserRound:ok,UserRoundCheck:sk,UserRoundCog:rk,UserRoundMinus:nk,UserRoundPen:Jte,UserRoundPlus:ak,UserRoundSearch:ese,UserRoundX:ik,UserSearch:tse,UserX:sse,Users:hr,UsersRound:lk,Utensils:dk,UtensilsCrossed:ck,UtilityPole:rse,Variable:FP,Vault:nse,Vegan:ase,VenetianMask:ise,Vibrate:lse,VibrateOff:ose,Video:kn,VideoOff:cse,Videotape:dse,View:use,Voicemail:hse,Volleyball:mse,Volume:yse,Volume1:pse,Volume2:fse,VolumeOff:gse,VolumeX:xse,Vote:vse,Wallet:zP,WalletCards:_se,WalletMinimal:uk,Wallpaper:bse,Wand:wse,WandSparkles:u0,Warehouse:jse,WashingMachine:kse,Watch:Nse,Waves:Sse,Waypoints:Cse,Webcam:Mse,Webhook:Ase,WebhookOff:Tse,Weight:Ese,Wheat:Ise,WheatOff:Pse,WholeWord:Lse,Wifi:zse,WifiHigh:Dse,WifiLow:Ose,WifiOff:Rse,WifiZero:Fse,Wind:$se,WindArrowDown:Bse,Wine:Use,WineOff:qse,Workflow:Vse,Worm:Hse,WrapText:Wse,Wrench:$g,X:Ur,Youtube:Gse,Zap:Dm,ZapOff:Kse,ZoomIn:c_,ZoomOut:k5},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 Xve=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:WR,AArrowDownIcon:WR,AArrowUp:GR,AArrowUpIcon:GR,ALargeSmall:KR,ALargeSmallIcon:KR,Accessibility:ZR,AccessibilityIcon:ZR,Activity:Am,ActivityIcon:Am,ActivitySquare:J2,ActivitySquareIcon:J2,AirVent:YR,AirVentIcon:YR,Airplay:XR,AirplayIcon:XR,AlarmCheck:sw,AlarmCheckIcon:sw,AlarmClock:JR,AlarmClockCheck:sw,AlarmClockCheckIcon:sw,AlarmClockIcon:JR,AlarmClockMinus:rw,AlarmClockMinusIcon:rw,AlarmClockOff:QR,AlarmClockOffIcon:QR,AlarmClockPlus:nw,AlarmClockPlusIcon:nw,AlarmMinus:rw,AlarmMinusIcon:rw,AlarmPlus:nw,AlarmPlusIcon:nw,AlarmSmoke:eF,AlarmSmokeIcon:eF,Album:tF,AlbumIcon:tF,AlertCircle:Qo,AlertCircleIcon:Qo,AlertOctagon:o0,AlertOctagonIcon:o0,AlertTriangle:Th,AlertTriangleIcon:Th,AlignCenter:t5,AlignCenterHorizontal:sF,AlignCenterHorizontalIcon:sF,AlignCenterIcon:t5,AlignCenterVertical:rF,AlignCenterVerticalIcon:rF,AlignEndHorizontal:nF,AlignEndHorizontalIcon:nF,AlignEndVertical:aF,AlignEndVerticalIcon:aF,AlignHorizontalDistributeCenter:iF,AlignHorizontalDistributeCenterIcon:iF,AlignHorizontalDistributeEnd:oF,AlignHorizontalDistributeEndIcon:oF,AlignHorizontalDistributeStart:lF,AlignHorizontalDistributeStartIcon:lF,AlignHorizontalJustifyCenter:cF,AlignHorizontalJustifyCenterIcon:cF,AlignHorizontalJustifyEnd:dF,AlignHorizontalJustifyEndIcon:dF,AlignHorizontalJustifyStart:uF,AlignHorizontalJustifyStartIcon:uF,AlignHorizontalSpaceAround:hF,AlignHorizontalSpaceAroundIcon:hF,AlignHorizontalSpaceBetween:mF,AlignHorizontalSpaceBetweenIcon:mF,AlignJustify:pF,AlignJustifyIcon:pF,AlignLeft:s5,AlignLeftIcon:s5,AlignRight:r5,AlignRightIcon:r5,AlignStartHorizontal:fF,AlignStartHorizontalIcon:fF,AlignStartVertical:gF,AlignStartVerticalIcon:gF,AlignVerticalDistributeCenter:xF,AlignVerticalDistributeCenterIcon:xF,AlignVerticalDistributeEnd:yF,AlignVerticalDistributeEndIcon:yF,AlignVerticalDistributeStart:vF,AlignVerticalDistributeStartIcon:vF,AlignVerticalJustifyCenter:_F,AlignVerticalJustifyCenterIcon:_F,AlignVerticalJustifyEnd:bF,AlignVerticalJustifyEndIcon:bF,AlignVerticalJustifyStart:wF,AlignVerticalJustifyStartIcon:wF,AlignVerticalSpaceAround:jF,AlignVerticalSpaceAroundIcon:jF,AlignVerticalSpaceBetween:kF,AlignVerticalSpaceBetweenIcon:kF,Ambulance:NF,AmbulanceIcon:NF,Ampersand:SF,AmpersandIcon:SF,Ampersands:CF,AmpersandsIcon:CF,Amphora:MF,AmphoraIcon:MF,Anchor:TF,AnchorIcon:TF,Angry:AF,AngryIcon:AF,Annoyed:EF,AnnoyedIcon:EF,Antenna:PF,AntennaIcon:PF,Anvil:IF,AnvilIcon:IF,Aperture:LF,ApertureIcon:LF,AppWindow:GE,AppWindowIcon:GE,AppWindowMac:DF,AppWindowMacIcon:DF,Apple:OF,AppleIcon:OF,Archive:n5,ArchiveIcon:n5,ArchiveRestore:KE,ArchiveRestoreIcon:KE,ArchiveX:RF,ArchiveXIcon:RF,AreaChart:yw,AreaChartIcon:yw,Armchair:FF,ArmchairIcon:FF,ArrowBigDown:BF,ArrowBigDownDash:zF,ArrowBigDownDashIcon:zF,ArrowBigDownIcon:BF,ArrowBigLeft:qF,ArrowBigLeftDash:$F,ArrowBigLeftDashIcon:$F,ArrowBigLeftIcon:qF,ArrowBigRight:VF,ArrowBigRightDash:UF,ArrowBigRightDashIcon:UF,ArrowBigRightIcon:VF,ArrowBigUp:WF,ArrowBigUpDash:HF,ArrowBigUpDashIcon:HF,ArrowBigUpIcon:WF,ArrowDown:eh,ArrowDown01:GF,ArrowDown01Icon:GF,ArrowDown10:KF,ArrowDown10Icon:KF,ArrowDownAZ:aw,ArrowDownAZIcon:aw,ArrowDownAz:aw,ArrowDownAzIcon:aw,ArrowDownCircle:Aw,ArrowDownCircleIcon:Aw,ArrowDownFromLine:ZF,ArrowDownFromLineIcon:ZF,ArrowDownIcon:eh,ArrowDownLeft:YF,ArrowDownLeftFromCircle:Pw,ArrowDownLeftFromCircleIcon:Pw,ArrowDownLeftFromSquare:nj,ArrowDownLeftFromSquareIcon:nj,ArrowDownLeftIcon:YF,ArrowDownLeftSquare:ej,ArrowDownLeftSquareIcon:ej,ArrowDownNarrowWide:XF,ArrowDownNarrowWideIcon:XF,ArrowDownRight:ZE,ArrowDownRightFromCircle:Iw,ArrowDownRightFromCircleIcon:Iw,ArrowDownRightFromSquare:aj,ArrowDownRightFromSquareIcon:aj,ArrowDownRightIcon:ZE,ArrowDownRightSquare:tj,ArrowDownRightSquareIcon:tj,ArrowDownSquare:sj,ArrowDownSquareIcon:sj,ArrowDownToDot:QF,ArrowDownToDotIcon:QF,ArrowDownToLine:JF,ArrowDownToLineIcon:JF,ArrowDownUp:ez,ArrowDownUpIcon:ez,ArrowDownWideNarrow:iw,ArrowDownWideNarrowIcon:iw,ArrowDownZA:ow,ArrowDownZAIcon:ow,ArrowDownZa:ow,ArrowDownZaIcon:ow,ArrowLeft:Ua,ArrowLeftCircle:Ew,ArrowLeftCircleIcon:Ew,ArrowLeftFromLine:tz,ArrowLeftFromLineIcon:tz,ArrowLeftIcon:Ua,ArrowLeftRight:sz,ArrowLeftRightIcon:sz,ArrowLeftSquare:rj,ArrowLeftSquareIcon:rj,ArrowLeftToLine:rz,ArrowLeftToLineIcon:rz,ArrowRight:Fi,ArrowRightCircle:Ow,ArrowRightCircleIcon:Ow,ArrowRightFromLine:nz,ArrowRightFromLineIcon:nz,ArrowRightIcon:Fi,ArrowRightLeft:k0,ArrowRightLeftIcon:k0,ArrowRightSquare:lj,ArrowRightSquareIcon:lj,ArrowRightToLine:az,ArrowRightToLineIcon:az,ArrowUp:Vd,ArrowUp01:iz,ArrowUp01Icon:iz,ArrowUp10:oz,ArrowUp10Icon:oz,ArrowUpAZ:lw,ArrowUpAZIcon:lw,ArrowUpAz:lw,ArrowUpAzIcon:lw,ArrowUpCircle:Rw,ArrowUpCircleIcon:Rw,ArrowUpDown:Hc,ArrowUpDownIcon:Hc,ArrowUpFromDot:lz,ArrowUpFromDotIcon:lz,ArrowUpFromLine:cz,ArrowUpFromLineIcon:cz,ArrowUpIcon:Vd,ArrowUpLeft:dz,ArrowUpLeftFromCircle:Lw,ArrowUpLeftFromCircleIcon:Lw,ArrowUpLeftFromSquare:ij,ArrowUpLeftFromSquareIcon:ij,ArrowUpLeftIcon:dz,ArrowUpLeftSquare:cj,ArrowUpLeftSquareIcon:cj,ArrowUpNarrowWide:cw,ArrowUpNarrowWideIcon:cw,ArrowUpRight:YE,ArrowUpRightFromCircle:Dw,ArrowUpRightFromCircleIcon:Dw,ArrowUpRightFromSquare:oj,ArrowUpRightFromSquareIcon:oj,ArrowUpRightIcon:YE,ArrowUpRightSquare:dj,ArrowUpRightSquareIcon:dj,ArrowUpSquare:uj,ArrowUpSquareIcon:uj,ArrowUpToLine:uz,ArrowUpToLineIcon:uz,ArrowUpWideNarrow:hz,ArrowUpWideNarrowIcon:hz,ArrowUpZA:dw,ArrowUpZAIcon:dw,ArrowUpZa:dw,ArrowUpZaIcon:dw,ArrowsUpFromLine:mz,ArrowsUpFromLineIcon:mz,Asterisk:pz,AsteriskIcon:pz,AsteriskSquare:hj,AsteriskSquareIcon:hj,AtSign:fz,AtSignIcon:fz,Atom:gz,AtomIcon:gz,AudioLines:xz,AudioLinesIcon:xz,AudioWaveform:yz,AudioWaveformIcon:yz,Award:rc,AwardIcon:rc,Axe:vz,AxeIcon:vz,Axis3D:uw,Axis3DIcon:uw,Axis3d:uw,Axis3dIcon:uw,Baby:_z,BabyIcon:_z,Backpack:bz,BackpackIcon:bz,Badge:Rz,BadgeAlert:wz,BadgeAlertIcon:wz,BadgeCent:jz,BadgeCentIcon:jz,BadgeCheck:hw,BadgeCheckIcon:hw,BadgeDollarSign:kz,BadgeDollarSignIcon:kz,BadgeEuro:Nz,BadgeEuroIcon:Nz,BadgeHelp:Sz,BadgeHelpIcon:Sz,BadgeIcon:Rz,BadgeIndianRupee:Cz,BadgeIndianRupeeIcon:Cz,BadgeInfo:Mz,BadgeInfoIcon:Mz,BadgeJapaneseYen:Tz,BadgeJapaneseYenIcon:Tz,BadgeMinus:Az,BadgeMinusIcon:Az,BadgePercent:Ez,BadgePercentIcon:Ez,BadgePlus:Pz,BadgePlusIcon:Pz,BadgePoundSterling:Iz,BadgePoundSterlingIcon:Iz,BadgeRussianRuble:Lz,BadgeRussianRubleIcon:Lz,BadgeSwissFranc:Dz,BadgeSwissFrancIcon:Dz,BadgeX:Oz,BadgeXIcon:Oz,BaggageClaim:Fz,BaggageClaimIcon:Fz,Ban:zz,BanIcon:zz,Banana:Bz,BananaIcon:Bz,Bandage:$z,BandageIcon:$z,Banknote:qz,BanknoteIcon:qz,BarChart:Nw,BarChart2:Sw,BarChart2Icon:Sw,BarChart3:Xo,BarChart3Icon:Xo,BarChart4:jw,BarChart4Icon:jw,BarChartBig:ww,BarChartBigIcon:ww,BarChartHorizontal:_w,BarChartHorizontalBig:vw,BarChartHorizontalBigIcon:vw,BarChartHorizontalIcon:_w,BarChartIcon:Nw,Barcode:Uz,BarcodeIcon:Uz,Baseline:Vz,BaselineIcon:Vz,Bath:Vx,BathIcon:Vx,Battery:Yz,BatteryCharging:Hz,BatteryChargingIcon:Hz,BatteryFull:Wz,BatteryFullIcon:Wz,BatteryIcon:Yz,BatteryLow:Gz,BatteryLowIcon:Gz,BatteryMedium:Kz,BatteryMediumIcon:Kz,BatteryWarning:Zz,BatteryWarningIcon:Zz,Beaker:Xz,BeakerIcon:Xz,Bean:Jz,BeanIcon:Jz,BeanOff:Qz,BeanOffIcon:Qz,Bed:N0,BedDouble:XE,BedDoubleIcon:XE,BedIcon:N0,BedSingle:e7,BedSingleIcon:e7,Beef:t7,BeefIcon:t7,Beer:r7,BeerIcon:r7,BeerOff:s7,BeerOffIcon:s7,Bell:cf,BellDot:n7,BellDotIcon:n7,BellElectric:a7,BellElectricIcon:a7,BellIcon:cf,BellMinus:i7,BellMinusIcon:i7,BellOff:X1,BellOffIcon:X1,BellPlus:o7,BellPlusIcon:o7,BellRing:l7,BellRingIcon:l7,BetweenHorizonalEnd:mw,BetweenHorizonalEndIcon:mw,BetweenHorizonalStart:pw,BetweenHorizonalStartIcon:pw,BetweenHorizontalEnd:mw,BetweenHorizontalEndIcon:mw,BetweenHorizontalStart:pw,BetweenHorizontalStartIcon:pw,BetweenVerticalEnd:c7,BetweenVerticalEndIcon:c7,BetweenVerticalStart:d7,BetweenVerticalStartIcon:d7,BicepsFlexed:u7,BicepsFlexedIcon:u7,Bike:h7,BikeIcon:h7,Binary:m7,BinaryIcon:m7,Binoculars:p7,BinocularsIcon:p7,Biohazard:f7,BiohazardIcon:f7,Bird:g7,BirdIcon:g7,Bitcoin:x7,BitcoinIcon:x7,Blend:y7,BlendIcon:y7,Blinds:v7,BlindsIcon:v7,Blocks:_7,BlocksIcon:_7,Bluetooth:k7,BluetoothConnected:b7,BluetoothConnectedIcon:b7,BluetoothIcon:k7,BluetoothOff:w7,BluetoothOffIcon:w7,BluetoothSearching:j7,BluetoothSearchingIcon:j7,Bold:a5,BoldIcon:a5,Bolt:N7,BoltIcon:N7,Bomb:S7,BombIcon:S7,Bone:C7,BoneIcon:C7,Book:Z7,BookA:M7,BookAIcon:M7,BookAudio:T7,BookAudioIcon:T7,BookCheck:A7,BookCheckIcon:A7,BookCopy:E7,BookCopyIcon:E7,BookDashed:fw,BookDashedIcon:fw,BookDown:P7,BookDownIcon:P7,BookHeadphones:I7,BookHeadphonesIcon:I7,BookHeart:L7,BookHeartIcon:L7,BookIcon:Z7,BookImage:D7,BookImageIcon:D7,BookKey:O7,BookKeyIcon:O7,BookLock:R7,BookLockIcon:R7,BookMarked:F7,BookMarkedIcon:F7,BookMinus:z7,BookMinusIcon:z7,BookOpen:Ou,BookOpenCheck:B7,BookOpenCheckIcon:B7,BookOpenIcon:Ou,BookOpenText:$7,BookOpenTextIcon:$7,BookPlus:q7,BookPlusIcon:q7,BookTemplate:fw,BookTemplateIcon:fw,BookText:U7,BookTextIcon:U7,BookType:V7,BookTypeIcon:V7,BookUp:W7,BookUp2:H7,BookUp2Icon:H7,BookUpIcon:W7,BookUser:G7,BookUserIcon:G7,BookX:K7,BookXIcon:K7,Bookmark:Dg,BookmarkCheck:Y7,BookmarkCheckIcon:Y7,BookmarkIcon:Dg,BookmarkMinus:X7,BookmarkMinusIcon:X7,BookmarkPlus:QE,BookmarkPlusIcon:QE,BookmarkX:Q7,BookmarkXIcon:Q7,BoomBox:J7,BoomBoxIcon:J7,Bot:i5,BotIcon:i5,BotMessageSquare:eB,BotMessageSquareIcon:eB,BotOff:tB,BotOffIcon:tB,Box:sB,BoxIcon:sB,BoxSelect:wj,BoxSelectIcon:wj,Boxes:rB,BoxesIcon:rB,Braces:gw,BracesIcon:gw,Brackets:nB,BracketsIcon:nB,Brain:JE,BrainCircuit:aB,BrainCircuitIcon:aB,BrainCog:iB,BrainCogIcon:iB,BrainIcon:JE,BrickWall:oB,BrickWallIcon:oB,Briefcase:th,BriefcaseBusiness:lB,BriefcaseBusinessIcon:lB,BriefcaseConveyorBelt:cB,BriefcaseConveyorBeltIcon:cB,BriefcaseIcon:th,BriefcaseMedical:dB,BriefcaseMedicalIcon:dB,BringToFront:uB,BringToFrontIcon:uB,Brush:hB,BrushIcon:hB,Bug:fB,BugIcon:fB,BugOff:mB,BugOffIcon:mB,BugPlay:pB,BugPlayIcon:pB,Building:Qk,Building2:Aa,Building2Icon:Aa,BuildingIcon:Qk,Bus:xB,BusFront:gB,BusFrontIcon:gB,BusIcon:xB,Cable:vB,CableCar:yB,CableCarIcon:yB,CableIcon:vB,Cake:Ru,CakeIcon:Ru,CakeSlice:_B,CakeSliceIcon:_B,Calculator:bB,CalculatorIcon:bB,Calendar:on,Calendar1:wB,Calendar1Icon:wB,CalendarArrowDown:jB,CalendarArrowDownIcon:jB,CalendarArrowUp:kB,CalendarArrowUpIcon:kB,CalendarCheck:SB,CalendarCheck2:NB,CalendarCheck2Icon:NB,CalendarCheckIcon:SB,CalendarClock:eP,CalendarClockIcon:eP,CalendarCog:CB,CalendarCogIcon:CB,CalendarDays:ld,CalendarDaysIcon:ld,CalendarFold:MB,CalendarFoldIcon:MB,CalendarHeart:TB,CalendarHeartIcon:TB,CalendarIcon:on,CalendarMinus:EB,CalendarMinus2:AB,CalendarMinus2Icon:AB,CalendarMinusIcon:EB,CalendarOff:tP,CalendarOffIcon:tP,CalendarPlus:Q1,CalendarPlus2:PB,CalendarPlus2Icon:PB,CalendarPlusIcon:Q1,CalendarRange:IB,CalendarRangeIcon:IB,CalendarSearch:LB,CalendarSearchIcon:LB,CalendarSync:DB,CalendarSyncIcon:DB,CalendarX:RB,CalendarX2:OB,CalendarX2Icon:OB,CalendarXIcon:RB,Camera:Og,CameraIcon:Og,CameraOff:FB,CameraOffIcon:FB,CandlestickChart:bw,CandlestickChartIcon:bw,Candy:$B,CandyCane:zB,CandyCaneIcon:zB,CandyIcon:$B,CandyOff:BB,CandyOffIcon:BB,Cannabis:qB,CannabisIcon:qB,Captions:xw,CaptionsIcon:xw,CaptionsOff:UB,CaptionsOffIcon:UB,Car:WB,CarFront:VB,CarFrontIcon:VB,CarIcon:WB,CarTaxiFront:HB,CarTaxiFrontIcon:HB,Caravan:GB,CaravanIcon:GB,Carrot:KB,CarrotIcon:KB,CaseLower:ZB,CaseLowerIcon:ZB,CaseSensitive:YB,CaseSensitiveIcon:YB,CaseUpper:XB,CaseUpperIcon:XB,CassetteTape:QB,CassetteTapeIcon:QB,Cast:JB,CastIcon:JB,Castle:e9,CastleIcon:e9,Cat:t9,CatIcon:t9,Cctv:s9,CctvIcon:s9,ChartArea:yw,ChartAreaIcon:yw,ChartBar:_w,ChartBarBig:vw,ChartBarBigIcon:vw,ChartBarDecreasing:r9,ChartBarDecreasingIcon:r9,ChartBarIcon:_w,ChartBarIncreasing:n9,ChartBarIncreasingIcon:n9,ChartBarStacked:a9,ChartBarStackedIcon:a9,ChartCandlestick:bw,ChartCandlestickIcon:bw,ChartColumn:Xo,ChartColumnBig:ww,ChartColumnBigIcon:ww,ChartColumnDecreasing:i9,ChartColumnDecreasingIcon:i9,ChartColumnIcon:Xo,ChartColumnIncreasing:jw,ChartColumnIncreasingIcon:jw,ChartColumnStacked:o9,ChartColumnStackedIcon:o9,ChartGantt:l9,ChartGanttIcon:l9,ChartLine:kw,ChartLineIcon:kw,ChartNetwork:c9,ChartNetworkIcon:c9,ChartNoAxesColumn:Sw,ChartNoAxesColumnDecreasing:d9,ChartNoAxesColumnDecreasingIcon:d9,ChartNoAxesColumnIcon:Sw,ChartNoAxesColumnIncreasing:Nw,ChartNoAxesColumnIncreasingIcon:Nw,ChartNoAxesCombined:u9,ChartNoAxesCombinedIcon:u9,ChartNoAxesGantt:Cw,ChartNoAxesGanttIcon:Cw,ChartPie:Mw,ChartPieIcon:Mw,ChartScatter:Tw,ChartScatterIcon:Tw,ChartSpline:h9,ChartSplineIcon:h9,Check:ua,CheckCheck:m9,CheckCheckIcon:m9,CheckCircle:gi,CheckCircle2:da,CheckCircle2Icon:da,CheckCircleIcon:gi,CheckIcon:ua,CheckSquare:d0,CheckSquare2:pj,CheckSquare2Icon:pj,CheckSquareIcon:d0,ChefHat:p9,ChefHatIcon:p9,Cherry:f9,CherryIcon:f9,ChevronDown:Vo,ChevronDownCircle:Fw,ChevronDownCircleIcon:Fw,ChevronDownIcon:Vo,ChevronDownSquare:fj,ChevronDownSquareIcon:fj,ChevronFirst:g9,ChevronFirstIcon:g9,ChevronLast:x9,ChevronLastIcon:x9,ChevronLeft:zl,ChevronLeftCircle:zw,ChevronLeftCircleIcon:zw,ChevronLeftIcon:zl,ChevronLeftSquare:gj,ChevronLeftSquareIcon:gj,ChevronRight:Ha,ChevronRightCircle:Bw,ChevronRightCircleIcon:Bw,ChevronRightIcon:Ha,ChevronRightSquare:xj,ChevronRightSquareIcon:xj,ChevronUp:Rg,ChevronUpCircle:$w,ChevronUpCircleIcon:$w,ChevronUpIcon:Rg,ChevronUpSquare:yj,ChevronUpSquareIcon:yj,ChevronsDown:v9,ChevronsDownIcon:v9,ChevronsDownUp:y9,ChevronsDownUpIcon:y9,ChevronsLeft:w9,ChevronsLeftIcon:w9,ChevronsLeftRight:b9,ChevronsLeftRightEllipsis:_9,ChevronsLeftRightEllipsisIcon:_9,ChevronsLeftRightIcon:b9,ChevronsRight:k9,ChevronsRightIcon:k9,ChevronsRightLeft:j9,ChevronsRightLeftIcon:j9,ChevronsUp:N9,ChevronsUpDown:df,ChevronsUpDownIcon:df,ChevronsUpIcon:N9,Chrome:S9,ChromeIcon:S9,Church:C9,ChurchIcon:C9,Cigarette:T9,CigaretteIcon:T9,CigaretteOff:M9,CigaretteOffIcon:M9,Circle:Gc,CircleAlert:Qo,CircleAlertIcon:Qo,CircleArrowDown:Aw,CircleArrowDownIcon:Aw,CircleArrowLeft:Ew,CircleArrowLeftIcon:Ew,CircleArrowOutDownLeft:Pw,CircleArrowOutDownLeftIcon:Pw,CircleArrowOutDownRight:Iw,CircleArrowOutDownRightIcon:Iw,CircleArrowOutUpLeft:Lw,CircleArrowOutUpLeftIcon:Lw,CircleArrowOutUpRight:Dw,CircleArrowOutUpRightIcon:Dw,CircleArrowRight:Ow,CircleArrowRightIcon:Ow,CircleArrowUp:Rw,CircleArrowUpIcon:Rw,CircleCheck:da,CircleCheckBig:gi,CircleCheckBigIcon:gi,CircleCheckIcon:da,CircleChevronDown:Fw,CircleChevronDownIcon:Fw,CircleChevronLeft:zw,CircleChevronLeftIcon:zw,CircleChevronRight:Bw,CircleChevronRightIcon:Bw,CircleChevronUp:$w,CircleChevronUpIcon:$w,CircleDashed:A9,CircleDashedIcon:A9,CircleDivide:qw,CircleDivideIcon:qw,CircleDollarSign:E9,CircleDollarSignIcon:E9,CircleDot:I9,CircleDotDashed:P9,CircleDotDashedIcon:P9,CircleDotIcon:I9,CircleEllipsis:L9,CircleEllipsisIcon:L9,CircleEqual:D9,CircleEqualIcon:D9,CircleFadingArrowUp:O9,CircleFadingArrowUpIcon:O9,CircleFadingPlus:R9,CircleFadingPlusIcon:R9,CircleGauge:Uw,CircleGaugeIcon:Uw,CircleHelp:i0,CircleHelpIcon:i0,CircleIcon:Gc,CircleMinus:Vw,CircleMinusIcon:Vw,CircleOff:F9,CircleOffIcon:F9,CircleParking:Ww,CircleParkingIcon:Ww,CircleParkingOff:Hw,CircleParkingOffIcon:Hw,CirclePause:Gw,CirclePauseIcon:Gw,CirclePercent:Kw,CirclePercentIcon:Kw,CirclePlay:ym,CirclePlayIcon:ym,CirclePlus:Zw,CirclePlusIcon:Zw,CirclePower:Yw,CirclePowerIcon:Yw,CircleSlash:z9,CircleSlash2:Xw,CircleSlash2Icon:Xw,CircleSlashIcon:z9,CircleSlashed:Xw,CircleSlashedIcon:Xw,CircleStop:Qw,CircleStopIcon:Qw,CircleUser:e2,CircleUserIcon:e2,CircleUserRound:Jw,CircleUserRoundIcon:Jw,CircleX:kc,CircleXIcon:kc,CircuitBoard:B9,CircuitBoardIcon:B9,Citrus:$9,CitrusIcon:$9,Clapperboard:q9,ClapperboardIcon:q9,Clipboard:Z9,ClipboardCheck:o5,ClipboardCheckIcon:o5,ClipboardCopy:U9,ClipboardCopyIcon:U9,ClipboardEdit:s2,ClipboardEditIcon:s2,ClipboardIcon:Z9,ClipboardList:J1,ClipboardListIcon:J1,ClipboardMinus:V9,ClipboardMinusIcon:V9,ClipboardPaste:H9,ClipboardPasteIcon:H9,ClipboardPen:s2,ClipboardPenIcon:s2,ClipboardPenLine:t2,ClipboardPenLineIcon:t2,ClipboardPlus:W9,ClipboardPlusIcon:W9,ClipboardSignature:t2,ClipboardSignatureIcon:t2,ClipboardType:G9,ClipboardTypeIcon:G9,ClipboardX:K9,ClipboardXIcon:K9,Clock:Tn,Clock1:Y9,Clock10:X9,Clock10Icon:X9,Clock11:Q9,Clock11Icon:Q9,Clock12:J9,Clock12Icon:J9,Clock1Icon:Y9,Clock2:e$,Clock2Icon:e$,Clock3:t$,Clock3Icon:t$,Clock4:s$,Clock4Icon:s$,Clock5:r$,Clock5Icon:r$,Clock6:n$,Clock6Icon:n$,Clock7:a$,Clock7Icon:a$,Clock8:i$,Clock8Icon:i$,Clock9:o$,Clock9Icon:o$,ClockAlert:l$,ClockAlertIcon:l$,ClockArrowDown:c$,ClockArrowDownIcon:c$,ClockArrowUp:d$,ClockArrowUpIcon:d$,ClockIcon:Tn,Cloud:N$,CloudAlert:u$,CloudAlertIcon:u$,CloudCog:h$,CloudCogIcon:h$,CloudDownload:r2,CloudDownloadIcon:r2,CloudDrizzle:m$,CloudDrizzleIcon:m$,CloudFog:p$,CloudFogIcon:p$,CloudHail:f$,CloudHailIcon:f$,CloudIcon:N$,CloudLightning:g$,CloudLightningIcon:g$,CloudMoon:y$,CloudMoonIcon:y$,CloudMoonRain:x$,CloudMoonRainIcon:x$,CloudOff:v$,CloudOffIcon:v$,CloudRain:b$,CloudRainIcon:b$,CloudRainWind:_$,CloudRainWindIcon:_$,CloudSnow:w$,CloudSnowIcon:w$,CloudSun:k$,CloudSunIcon:k$,CloudSunRain:j$,CloudSunRainIcon:j$,CloudUpload:n2,CloudUploadIcon:n2,Cloudy:S$,CloudyIcon:S$,Clover:y0,CloverIcon:y0,Club:C$,ClubIcon:C$,Code:Jk,Code2:a2,Code2Icon:a2,CodeIcon:Jk,CodeSquare:vj,CodeSquareIcon:vj,CodeXml:a2,CodeXmlIcon:a2,Codepen:M$,CodepenIcon:M$,Codesandbox:T$,CodesandboxIcon:T$,Coffee:eN,CoffeeIcon:eN,Cog:A$,CogIcon:A$,Coins:sP,CoinsIcon:sP,Columns:i2,Columns2:i2,Columns2Icon:i2,Columns3:o2,Columns3Icon:o2,Columns4:E$,Columns4Icon:E$,ColumnsIcon:i2,Combine:P$,CombineIcon:P$,Command:I$,CommandIcon:I$,Compass:L$,CompassIcon:L$,Component:D$,ComponentIcon:D$,Computer:O$,ComputerIcon:O$,ConciergeBell:R$,ConciergeBellIcon:R$,Cone:F$,ConeIcon:F$,Construction:z$,ConstructionIcon:z$,Contact:tN,Contact2:l2,Contact2Icon:l2,ContactIcon:tN,ContactRound:l2,ContactRoundIcon:l2,Container:B$,ContainerIcon:B$,Contrast:$$,ContrastIcon:$$,Cookie:q$,CookieIcon:q$,CookingPot:U$,CookingPotIcon:U$,Copy:ni,CopyCheck:V$,CopyCheckIcon:V$,CopyIcon:ni,CopyMinus:H$,CopyMinusIcon:H$,CopyPlus:W$,CopyPlusIcon:W$,CopySlash:G$,CopySlashIcon:G$,CopyX:K$,CopyXIcon:K$,Copyleft:Z$,CopyleftIcon:Z$,Copyright:Y$,CopyrightIcon:Y$,CornerDownLeft:X$,CornerDownLeftIcon:X$,CornerDownRight:Q$,CornerDownRightIcon:Q$,CornerLeftDown:J$,CornerLeftDownIcon:J$,CornerLeftUp:eq,CornerLeftUpIcon:eq,CornerRightDown:tq,CornerRightDownIcon:tq,CornerRightUp:sq,CornerRightUpIcon:sq,CornerUpLeft:rq,CornerUpLeftIcon:rq,CornerUpRight:nq,CornerUpRightIcon:nq,Cpu:aq,CpuIcon:aq,CreativeCommons:iq,CreativeCommonsIcon:iq,CreditCard:uf,CreditCardIcon:uf,Croissant:oq,CroissantIcon:oq,Crop:lq,CropIcon:lq,Cross:cq,CrossIcon:cq,Crosshair:dq,CrosshairIcon:dq,Crown:Bh,CrownIcon:Bh,Cuboid:uq,CuboidIcon:uq,CupSoda:hq,CupSodaIcon:hq,CurlyBraces:gw,CurlyBracesIcon:gw,Currency:mq,CurrencyIcon:mq,Cylinder:pq,CylinderIcon:pq,Dam:fq,DamIcon:fq,Database:yq,DatabaseBackup:gq,DatabaseBackupIcon:gq,DatabaseIcon:yq,DatabaseZap:xq,DatabaseZapIcon:xq,Delete:vq,DeleteIcon:vq,Dessert:_q,DessertIcon:_q,Diameter:bq,DiameterIcon:bq,Diamond:kq,DiamondIcon:kq,DiamondMinus:wq,DiamondMinusIcon:wq,DiamondPercent:c2,DiamondPercentIcon:c2,DiamondPlus:jq,DiamondPlusIcon:jq,Dice1:Nq,Dice1Icon:Nq,Dice2:Sq,Dice2Icon:Sq,Dice3:Cq,Dice3Icon:Cq,Dice4:Mq,Dice4Icon:Mq,Dice5:Tq,Dice5Icon:Tq,Dice6:Aq,Dice6Icon:Aq,Dices:Eq,DicesIcon:Eq,Diff:Pq,DiffIcon:Pq,Disc:Oq,Disc2:Iq,Disc2Icon:Iq,Disc3:Lq,Disc3Icon:Lq,DiscAlbum:Dq,DiscAlbumIcon:Dq,DiscIcon:Oq,Divide:Rq,DivideCircle:qw,DivideCircleIcon:qw,DivideIcon:Rq,DivideSquare:jj,DivideSquareIcon:jj,Dna:zq,DnaIcon:zq,DnaOff:Fq,DnaOffIcon:Fq,Dock:Bq,DockIcon:Bq,Dog:$q,DogIcon:$q,DollarSign:Kc,DollarSignIcon:Kc,Donut:qq,DonutIcon:qq,DoorClosed:Uq,DoorClosedIcon:Uq,DoorOpen:S0,DoorOpenIcon:S0,Dot:Vq,DotIcon:Vq,DotSquare:kj,DotSquareIcon:kj,Download:xi,DownloadCloud:r2,DownloadCloudIcon:r2,DownloadIcon:xi,DraftingCompass:Hq,DraftingCompassIcon:Hq,Drama:Wq,DramaIcon:Wq,Dribbble:Gq,DribbbleIcon:Gq,Drill:Kq,DrillIcon:Kq,Droplet:Zq,DropletIcon:Zq,Droplets:Fg,DropletsIcon:Fg,Drum:Yq,DrumIcon:Yq,Drumstick:Xq,DrumstickIcon:Xq,Dumbbell:Qq,DumbbellIcon:Qq,Ear:eU,EarIcon:eU,EarOff:Jq,EarOffIcon:Jq,Earth:d2,EarthIcon:d2,EarthLock:tU,EarthLockIcon:tU,Eclipse:sU,EclipseIcon:sU,Edit:Oc,Edit2:Ix,Edit2Icon:Ix,Edit3:c0,Edit3Icon:c0,EditIcon:Oc,Egg:l5,EggFried:rU,EggFriedIcon:rU,EggIcon:l5,EggOff:nU,EggOffIcon:nU,Ellipsis:ef,EllipsisIcon:ef,EllipsisVertical:Jp,EllipsisVerticalIcon:Jp,Equal:oU,EqualApproximately:aU,EqualApproximatelyIcon:aU,EqualIcon:oU,EqualNot:iU,EqualNotIcon:iU,EqualSquare:Nj,EqualSquareIcon:Nj,Eraser:lU,EraserIcon:lU,EthernetPort:cU,EthernetPortIcon:cU,Euro:dU,EuroIcon:dU,Expand:uU,ExpandIcon:uU,ExternalLink:sn,ExternalLinkIcon:sn,Eye:ya,EyeClosed:hU,EyeClosedIcon:hU,EyeIcon:ya,EyeOff:Em,EyeOffIcon:Em,Facebook:Hd,FacebookIcon:Hd,Factory:mU,FactoryIcon:mU,Fan:pU,FanIcon:pU,FastForward:fU,FastForwardIcon:fU,Feather:gU,FeatherIcon:gU,Fence:xU,FenceIcon:xU,FerrisWheel:yU,FerrisWheelIcon:yU,Figma:vU,FigmaIcon:vU,File:c5,FileArchive:_U,FileArchiveIcon:_U,FileAudio:wU,FileAudio2:bU,FileAudio2Icon:bU,FileAudioIcon:wU,FileAxis3D:u2,FileAxis3DIcon:u2,FileAxis3d:u2,FileAxis3dIcon:u2,FileBadge:kU,FileBadge2:jU,FileBadge2Icon:jU,FileBadgeIcon:kU,FileBarChart:h2,FileBarChart2:m2,FileBarChart2Icon:m2,FileBarChartIcon:h2,FileBox:NU,FileBoxIcon:NU,FileChartColumn:m2,FileChartColumnIcon:m2,FileChartColumnIncreasing:h2,FileChartColumnIncreasingIcon:h2,FileChartLine:p2,FileChartLineIcon:p2,FileChartPie:f2,FileChartPieIcon:f2,FileCheck:CU,FileCheck2:SU,FileCheck2Icon:SU,FileCheckIcon:CU,FileClock:MU,FileClockIcon:MU,FileCode:AU,FileCode2:TU,FileCode2Icon:TU,FileCodeIcon:AU,FileCog:g2,FileCog2:g2,FileCog2Icon:g2,FileCogIcon:g2,FileDiff:EU,FileDiffIcon:EU,FileDigit:PU,FileDigitIcon:PU,FileDown:IU,FileDownIcon:IU,FileEdit:y2,FileEditIcon:y2,FileHeart:LU,FileHeartIcon:LU,FileIcon:c5,FileImage:e_,FileImageIcon:e_,FileInput:DU,FileInputIcon:DU,FileJson:RU,FileJson2:OU,FileJson2Icon:OU,FileJsonIcon:RU,FileKey:zU,FileKey2:FU,FileKey2Icon:FU,FileKeyIcon:zU,FileLineChart:p2,FileLineChartIcon:p2,FileLock:$U,FileLock2:BU,FileLock2Icon:BU,FileLockIcon:$U,FileMinus:UU,FileMinus2:qU,FileMinus2Icon:qU,FileMinusIcon:UU,FileMusic:VU,FileMusicIcon:VU,FileOutput:HU,FileOutputIcon:HU,FilePen:y2,FilePenIcon:y2,FilePenLine:x2,FilePenLineIcon:x2,FilePieChart:f2,FilePieChartIcon:f2,FilePlus:GU,FilePlus2:WU,FilePlus2Icon:WU,FilePlusIcon:GU,FileQuestion:KU,FileQuestionIcon:KU,FileScan:ZU,FileScanIcon:ZU,FileSearch:XU,FileSearch2:YU,FileSearch2Icon:YU,FileSearchIcon:XU,FileSignature:x2,FileSignatureIcon:x2,FileSliders:QU,FileSlidersIcon:QU,FileSpreadsheet:C0,FileSpreadsheetIcon:C0,FileStack:rP,FileStackIcon:rP,FileSymlink:JU,FileSymlinkIcon:JU,FileTerminal:eV,FileTerminalIcon:eV,FileText:In,FileTextIcon:In,FileType:sV,FileType2:tV,FileType2Icon:tV,FileTypeIcon:sV,FileUp:rV,FileUpIcon:rV,FileUser:nV,FileUserIcon:nV,FileVideo:iV,FileVideo2:aV,FileVideo2Icon:aV,FileVideoIcon:iV,FileVolume:lV,FileVolume2:oV,FileVolume2Icon:oV,FileVolumeIcon:lV,FileWarning:cV,FileWarningIcon:cV,FileX:uV,FileX2:dV,FileX2Icon:dV,FileXIcon:uV,Files:hV,FilesIcon:hV,Film:lu,FilmIcon:lu,Filter:Hx,FilterIcon:Hx,FilterX:mV,FilterXIcon:mV,Fingerprint:pV,FingerprintIcon:pV,FireExtinguisher:fV,FireExtinguisherIcon:fV,Fish:yV,FishIcon:yV,FishOff:gV,FishOffIcon:gV,FishSymbol:xV,FishSymbolIcon:xV,Flag:M0,FlagIcon:M0,FlagOff:vV,FlagOffIcon:vV,FlagTriangleLeft:_V,FlagTriangleLeftIcon:_V,FlagTriangleRight:bV,FlagTriangleRightIcon:bV,Flame:$h,FlameIcon:$h,FlameKindling:wV,FlameKindlingIcon:wV,Flashlight:kV,FlashlightIcon:kV,FlashlightOff:jV,FlashlightOffIcon:jV,FlaskConical:t_,FlaskConicalIcon:t_,FlaskConicalOff:NV,FlaskConicalOffIcon:NV,FlaskRound:SV,FlaskRoundIcon:SV,FlipHorizontal:MV,FlipHorizontal2:CV,FlipHorizontal2Icon:CV,FlipHorizontalIcon:MV,FlipVertical:AV,FlipVertical2:TV,FlipVertical2Icon:TV,FlipVerticalIcon:AV,Flower:EV,Flower2:Ag,Flower2Icon:Ag,FlowerIcon:EV,Focus:PV,FocusIcon:PV,FoldHorizontal:IV,FoldHorizontalIcon:IV,FoldVertical:LV,FoldVerticalIcon:LV,Folder:oH,FolderArchive:DV,FolderArchiveIcon:DV,FolderCheck:OV,FolderCheckIcon:OV,FolderClock:RV,FolderClockIcon:RV,FolderClosed:FV,FolderClosedIcon:FV,FolderCode:zV,FolderCodeIcon:zV,FolderCog:v2,FolderCog2:v2,FolderCog2Icon:v2,FolderCogIcon:v2,FolderDot:BV,FolderDotIcon:BV,FolderDown:$V,FolderDownIcon:$V,FolderEdit:_2,FolderEditIcon:_2,FolderGit:UV,FolderGit2:qV,FolderGit2Icon:qV,FolderGitIcon:UV,FolderHeart:VV,FolderHeartIcon:VV,FolderIcon:oH,FolderInput:HV,FolderInputIcon:HV,FolderKanban:WV,FolderKanbanIcon:WV,FolderKey:GV,FolderKeyIcon:GV,FolderLock:KV,FolderLockIcon:KV,FolderMinus:ZV,FolderMinusIcon:ZV,FolderOpen:qh,FolderOpenDot:YV,FolderOpenDotIcon:YV,FolderOpenIcon:qh,FolderOutput:XV,FolderOutputIcon:XV,FolderPen:_2,FolderPenIcon:_2,FolderPlus:QV,FolderPlusIcon:QV,FolderRoot:JV,FolderRootIcon:JV,FolderSearch:tH,FolderSearch2:eH,FolderSearch2Icon:eH,FolderSearchIcon:tH,FolderSymlink:sH,FolderSymlinkIcon:sH,FolderSync:rH,FolderSyncIcon:rH,FolderTree:nH,FolderTreeIcon:nH,FolderUp:aH,FolderUpIcon:aH,FolderX:iH,FolderXIcon:iH,Folders:lH,FoldersIcon:lH,Footprints:cH,FootprintsIcon:cH,ForkKnife:dk,ForkKnifeCrossed:ck,ForkKnifeCrossedIcon:ck,ForkKnifeIcon:dk,Forklift:dH,ForkliftIcon:dH,FormInput:H2,FormInputIcon:H2,Forward:uH,ForwardIcon:uH,Frame:hH,FrameIcon:hH,Framer:mH,FramerIcon:mH,Frown:pH,FrownIcon:pH,Fuel:fH,FuelIcon:fH,Fullscreen:gH,FullscreenIcon:gH,FunctionSquare:Sj,FunctionSquareIcon:Sj,GalleryHorizontal:yH,GalleryHorizontalEnd:xH,GalleryHorizontalEndIcon:xH,GalleryHorizontalIcon:yH,GalleryThumbnails:vH,GalleryThumbnailsIcon:vH,GalleryVertical:bH,GalleryVerticalEnd:_H,GalleryVerticalEndIcon:_H,GalleryVerticalIcon:bH,Gamepad:jH,Gamepad2:wH,Gamepad2Icon:wH,GamepadIcon:jH,GanttChart:Cw,GanttChartIcon:Cw,GanttChartSquare:jx,GanttChartSquareIcon:jx,Gauge:kH,GaugeCircle:Uw,GaugeCircleIcon:Uw,GaugeIcon:kH,Gavel:NH,GavelIcon:NH,Gem:SH,GemIcon:SH,Ghost:sN,GhostIcon:sN,Gift:io,GiftIcon:io,GitBranch:MH,GitBranchIcon:MH,GitBranchPlus:CH,GitBranchPlusIcon:CH,GitCommit:b2,GitCommitHorizontal:b2,GitCommitHorizontalIcon:b2,GitCommitIcon:b2,GitCommitVertical:TH,GitCommitVerticalIcon:TH,GitCompare:EH,GitCompareArrows:AH,GitCompareArrowsIcon:AH,GitCompareIcon:EH,GitFork:PH,GitForkIcon:PH,GitGraph:IH,GitGraphIcon:IH,GitMerge:LH,GitMergeIcon:LH,GitPullRequest:BH,GitPullRequestArrow:DH,GitPullRequestArrowIcon:DH,GitPullRequestClosed:OH,GitPullRequestClosedIcon:OH,GitPullRequestCreate:FH,GitPullRequestCreateArrow:RH,GitPullRequestCreateArrowIcon:RH,GitPullRequestCreateIcon:FH,GitPullRequestDraft:zH,GitPullRequestDraftIcon:zH,GitPullRequestIcon:BH,Github:$H,GithubIcon:$H,Gitlab:qH,GitlabIcon:qH,GlassWater:UH,GlassWaterIcon:UH,Glasses:VH,GlassesIcon:VH,Globe:Pm,Globe2:d2,Globe2Icon:d2,GlobeIcon:Pm,GlobeLock:HH,GlobeLockIcon:HH,Goal:WH,GoalIcon:WH,Grab:GH,GrabIcon:GH,GraduationCap:sh,GraduationCapIcon:sh,Grape:KH,GrapeIcon:KH,Grid:Vp,Grid2X2:j2,Grid2X2Icon:j2,Grid2X2Plus:w2,Grid2X2PlusIcon:w2,Grid2x2:j2,Grid2x2Check:ZH,Grid2x2CheckIcon:ZH,Grid2x2Icon:j2,Grid2x2Plus:w2,Grid2x2PlusIcon:w2,Grid2x2X:YH,Grid2x2XIcon:YH,Grid3X3:Vp,Grid3X3Icon:Vp,Grid3x3:Vp,Grid3x3Icon:Vp,GridIcon:Vp,Grip:QH,GripHorizontal:XH,GripHorizontalIcon:XH,GripIcon:QH,GripVertical:Fu,GripVerticalIcon:Fu,Group:JH,GroupIcon:JH,Guitar:eW,GuitarIcon:eW,Ham:tW,HamIcon:tW,Hammer:sW,HammerIcon:sW,Hand:nP,HandCoins:rW,HandCoinsIcon:rW,HandHeart:nW,HandHeartIcon:nW,HandHelping:k2,HandHelpingIcon:k2,HandIcon:nP,HandMetal:aW,HandMetalIcon:aW,HandPlatter:iW,HandPlatterIcon:iW,Handshake:aP,HandshakeIcon:aP,HardDrive:iP,HardDriveDownload:oW,HardDriveDownloadIcon:oW,HardDriveIcon:iP,HardDriveUpload:lW,HardDriveUploadIcon:lW,HardHat:cW,HardHatIcon:cW,Hash:d5,HashIcon:d5,Haze:dW,HazeIcon:dW,HdmiPort:uW,HdmiPortIcon:uW,Heading:gW,Heading1:oP,Heading1Icon:oP,Heading2:lP,Heading2Icon:lP,Heading3:hW,Heading3Icon:hW,Heading4:mW,Heading4Icon:mW,Heading5:pW,Heading5Icon:pW,Heading6:fW,Heading6Icon:fW,HeadingIcon:gW,HeadphoneOff:xW,HeadphoneOffIcon:xW,Headphones:yW,HeadphonesIcon:yW,Headset:vW,HeadsetIcon:vW,Heart:Si,HeartCrack:_W,HeartCrackIcon:_W,HeartHandshake:bW,HeartHandshakeIcon:bW,HeartIcon:Si,HeartOff:wW,HeartOffIcon:wW,HeartPulse:jW,HeartPulseIcon:jW,Heater:kW,HeaterIcon:kW,HelpCircle:i0,HelpCircleIcon:i0,HelpingHand:k2,HelpingHandIcon:k2,Hexagon:NW,HexagonIcon:NW,Highlighter:SW,HighlighterIcon:SW,History:u5,HistoryIcon:u5,Home:Un,HomeIcon:Un,Hop:MW,HopIcon:MW,HopOff:CW,HopOffIcon:CW,Hospital:TW,HospitalIcon:TW,Hotel:AW,HotelIcon:AW,Hourglass:EW,HourglassIcon:EW,House:Un,HouseIcon:Un,HousePlug:PW,HousePlugIcon:PW,HousePlus:IW,HousePlusIcon:IW,IceCream:S2,IceCream2:N2,IceCream2Icon:N2,IceCreamBowl:N2,IceCreamBowlIcon:N2,IceCreamCone:S2,IceCreamConeIcon:S2,IceCreamIcon:S2,Icon:mRe,IdCard:LW,IdCardIcon:LW,Image:Jo,ImageDown:DW,ImageDownIcon:DW,ImageIcon:Jo,ImageMinus:OW,ImageMinusIcon:OW,ImageOff:RW,ImageOffIcon:RW,ImagePlay:FW,ImagePlayIcon:FW,ImagePlus:T0,ImagePlusIcon:T0,ImageUp:zW,ImageUpIcon:zW,ImageUpscale:BW,ImageUpscaleIcon:BW,Images:$W,ImagesIcon:$W,Import:qW,ImportIcon:qW,Inbox:UW,InboxIcon:UW,Indent:M2,IndentDecrease:C2,IndentDecreaseIcon:C2,IndentIcon:M2,IndentIncrease:M2,IndentIncreaseIcon:M2,IndianRupee:VW,IndianRupeeIcon:VW,Infinity:HW,InfinityIcon:HW,Info:cP,InfoIcon:cP,Inspect:Pj,InspectIcon:Pj,InspectionPanel:WW,InspectionPanelIcon:WW,Instagram:Wd,InstagramIcon:Wd,Italic:h5,ItalicIcon:h5,IterationCcw:GW,IterationCcwIcon:GW,IterationCw:KW,IterationCwIcon:KW,JapaneseYen:ZW,JapaneseYenIcon:ZW,Joystick:YW,JoystickIcon:YW,Kanban:Wx,KanbanIcon:Wx,KanbanSquare:Cj,KanbanSquareDashed:_j,KanbanSquareDashedIcon:_j,KanbanSquareIcon:Cj,Key:Im,KeyIcon:Im,KeyRound:rN,KeyRoundIcon:rN,KeySquare:XW,KeySquareIcon:XW,Keyboard:eG,KeyboardIcon:eG,KeyboardMusic:QW,KeyboardMusicIcon:QW,KeyboardOff:JW,KeyboardOffIcon:JW,Lamp:iG,LampCeiling:tG,LampCeilingIcon:tG,LampDesk:sG,LampDeskIcon:sG,LampFloor:rG,LampFloorIcon:rG,LampIcon:iG,LampWallDown:nG,LampWallDownIcon:nG,LampWallUp:aG,LampWallUpIcon:aG,LandPlot:oG,LandPlotIcon:oG,Landmark:lG,LandmarkIcon:lG,Languages:cG,LanguagesIcon:cG,Laptop:uG,Laptop2:T2,Laptop2Icon:T2,LaptopIcon:uG,LaptopMinimal:T2,LaptopMinimalCheck:dG,LaptopMinimalCheckIcon:dG,LaptopMinimalIcon:T2,Lasso:mG,LassoIcon:mG,LassoSelect:hG,LassoSelectIcon:hG,Laugh:pG,LaughIcon:pG,Layers:xG,Layers2:fG,Layers2Icon:fG,Layers3:gG,Layers3Icon:gG,LayersIcon:xG,Layout:l0,LayoutDashboard:nN,LayoutDashboardIcon:nN,LayoutGrid:mp,LayoutGridIcon:mp,LayoutIcon:l0,LayoutList:yG,LayoutListIcon:yG,LayoutPanelLeft:vG,LayoutPanelLeftIcon:vG,LayoutPanelTop:_G,LayoutPanelTopIcon:_G,LayoutTemplate:aN,LayoutTemplateIcon:aN,Leaf:bG,LeafIcon:bG,LeafyGreen:wG,LeafyGreenIcon:wG,Lectern:jG,LecternIcon:jG,LetterText:kG,LetterTextIcon:kG,Library:m5,LibraryBig:NG,LibraryBigIcon:NG,LibraryIcon:m5,LibrarySquare:Mj,LibrarySquareIcon:Mj,LifeBuoy:p5,LifeBuoyIcon:p5,Ligature:SG,LigatureIcon:SG,Lightbulb:s_,LightbulbIcon:s_,LightbulbOff:CG,LightbulbOffIcon:CG,LineChart:kw,LineChartIcon:kw,Link:Lo,Link2:Ho,Link2Icon:Ho,Link2Off:MG,Link2OffIcon:MG,LinkIcon:Lo,Linkedin:Lm,LinkedinIcon:Lm,List:Uh,ListCheck:TG,ListCheckIcon:TG,ListChecks:AG,ListChecksIcon:AG,ListCollapse:EG,ListCollapseIcon:EG,ListEnd:PG,ListEndIcon:PG,ListFilter:IG,ListFilterIcon:IG,ListIcon:Uh,ListMinus:LG,ListMinusIcon:LG,ListMusic:DG,ListMusicIcon:DG,ListOrdered:A0,ListOrderedIcon:A0,ListPlus:OG,ListPlusIcon:OG,ListRestart:RG,ListRestartIcon:RG,ListStart:FG,ListStartIcon:FG,ListTodo:zG,ListTodoIcon:zG,ListTree:BG,ListTreeIcon:BG,ListVideo:$G,ListVideoIcon:$G,ListX:qG,ListXIcon:qG,Loader:VG,Loader2:As,Loader2Icon:As,LoaderCircle:As,LoaderCircleIcon:As,LoaderIcon:VG,LoaderPinwheel:UG,LoaderPinwheelIcon:UG,Locate:dP,LocateFixed:HG,LocateFixedIcon:HG,LocateIcon:dP,LocateOff:WG,LocateOffIcon:WG,Lock:zu,LockIcon:zu,LockKeyhole:GG,LockKeyholeIcon:GG,LockKeyholeOpen:A2,LockKeyholeOpenIcon:A2,LockOpen:E2,LockOpenIcon:E2,LogIn:f5,LogInIcon:f5,LogOut:g5,LogOutIcon:g5,Logs:KG,LogsIcon:KG,Lollipop:ZG,LollipopIcon:ZG,LucideAArrowDown:WR,LucideAArrowUp:GR,LucideALargeSmall:KR,LucideAccessibility:ZR,LucideActivity:Am,LucideActivitySquare:J2,LucideAirVent:YR,LucideAirplay:XR,LucideAlarmCheck:sw,LucideAlarmClock:JR,LucideAlarmClockCheck:sw,LucideAlarmClockMinus:rw,LucideAlarmClockOff:QR,LucideAlarmClockPlus:nw,LucideAlarmMinus:rw,LucideAlarmPlus:nw,LucideAlarmSmoke:eF,LucideAlbum:tF,LucideAlertCircle:Qo,LucideAlertOctagon:o0,LucideAlertTriangle:Th,LucideAlignCenter:t5,LucideAlignCenterHorizontal:sF,LucideAlignCenterVertical:rF,LucideAlignEndHorizontal:nF,LucideAlignEndVertical:aF,LucideAlignHorizontalDistributeCenter:iF,LucideAlignHorizontalDistributeEnd:oF,LucideAlignHorizontalDistributeStart:lF,LucideAlignHorizontalJustifyCenter:cF,LucideAlignHorizontalJustifyEnd:dF,LucideAlignHorizontalJustifyStart:uF,LucideAlignHorizontalSpaceAround:hF,LucideAlignHorizontalSpaceBetween:mF,LucideAlignJustify:pF,LucideAlignLeft:s5,LucideAlignRight:r5,LucideAlignStartHorizontal:fF,LucideAlignStartVertical:gF,LucideAlignVerticalDistributeCenter:xF,LucideAlignVerticalDistributeEnd:yF,LucideAlignVerticalDistributeStart:vF,LucideAlignVerticalJustifyCenter:_F,LucideAlignVerticalJustifyEnd:bF,LucideAlignVerticalJustifyStart:wF,LucideAlignVerticalSpaceAround:jF,LucideAlignVerticalSpaceBetween:kF,LucideAmbulance:NF,LucideAmpersand:SF,LucideAmpersands:CF,LucideAmphora:MF,LucideAnchor:TF,LucideAngry:AF,LucideAnnoyed:EF,LucideAntenna:PF,LucideAnvil:IF,LucideAperture:LF,LucideAppWindow:GE,LucideAppWindowMac:DF,LucideApple:OF,LucideArchive:n5,LucideArchiveRestore:KE,LucideArchiveX:RF,LucideAreaChart:yw,LucideArmchair:FF,LucideArrowBigDown:BF,LucideArrowBigDownDash:zF,LucideArrowBigLeft:qF,LucideArrowBigLeftDash:$F,LucideArrowBigRight:VF,LucideArrowBigRightDash:UF,LucideArrowBigUp:WF,LucideArrowBigUpDash:HF,LucideArrowDown:eh,LucideArrowDown01:GF,LucideArrowDown10:KF,LucideArrowDownAZ:aw,LucideArrowDownAz:aw,LucideArrowDownCircle:Aw,LucideArrowDownFromLine:ZF,LucideArrowDownLeft:YF,LucideArrowDownLeftFromCircle:Pw,LucideArrowDownLeftFromSquare:nj,LucideArrowDownLeftSquare:ej,LucideArrowDownNarrowWide:XF,LucideArrowDownRight:ZE,LucideArrowDownRightFromCircle:Iw,LucideArrowDownRightFromSquare:aj,LucideArrowDownRightSquare:tj,LucideArrowDownSquare:sj,LucideArrowDownToDot:QF,LucideArrowDownToLine:JF,LucideArrowDownUp:ez,LucideArrowDownWideNarrow:iw,LucideArrowDownZA:ow,LucideArrowDownZa:ow,LucideArrowLeft:Ua,LucideArrowLeftCircle:Ew,LucideArrowLeftFromLine:tz,LucideArrowLeftRight:sz,LucideArrowLeftSquare:rj,LucideArrowLeftToLine:rz,LucideArrowRight:Fi,LucideArrowRightCircle:Ow,LucideArrowRightFromLine:nz,LucideArrowRightLeft:k0,LucideArrowRightSquare:lj,LucideArrowRightToLine:az,LucideArrowUp:Vd,LucideArrowUp01:iz,LucideArrowUp10:oz,LucideArrowUpAZ:lw,LucideArrowUpAz:lw,LucideArrowUpCircle:Rw,LucideArrowUpDown:Hc,LucideArrowUpFromDot:lz,LucideArrowUpFromLine:cz,LucideArrowUpLeft:dz,LucideArrowUpLeftFromCircle:Lw,LucideArrowUpLeftFromSquare:ij,LucideArrowUpLeftSquare:cj,LucideArrowUpNarrowWide:cw,LucideArrowUpRight:YE,LucideArrowUpRightFromCircle:Dw,LucideArrowUpRightFromSquare:oj,LucideArrowUpRightSquare:dj,LucideArrowUpSquare:uj,LucideArrowUpToLine:uz,LucideArrowUpWideNarrow:hz,LucideArrowUpZA:dw,LucideArrowUpZa:dw,LucideArrowsUpFromLine:mz,LucideAsterisk:pz,LucideAsteriskSquare:hj,LucideAtSign:fz,LucideAtom:gz,LucideAudioLines:xz,LucideAudioWaveform:yz,LucideAward:rc,LucideAxe:vz,LucideAxis3D:uw,LucideAxis3d:uw,LucideBaby:_z,LucideBackpack:bz,LucideBadge:Rz,LucideBadgeAlert:wz,LucideBadgeCent:jz,LucideBadgeCheck:hw,LucideBadgeDollarSign:kz,LucideBadgeEuro:Nz,LucideBadgeHelp:Sz,LucideBadgeIndianRupee:Cz,LucideBadgeInfo:Mz,LucideBadgeJapaneseYen:Tz,LucideBadgeMinus:Az,LucideBadgePercent:Ez,LucideBadgePlus:Pz,LucideBadgePoundSterling:Iz,LucideBadgeRussianRuble:Lz,LucideBadgeSwissFranc:Dz,LucideBadgeX:Oz,LucideBaggageClaim:Fz,LucideBan:zz,LucideBanana:Bz,LucideBandage:$z,LucideBanknote:qz,LucideBarChart:Nw,LucideBarChart2:Sw,LucideBarChart3:Xo,LucideBarChart4:jw,LucideBarChartBig:ww,LucideBarChartHorizontal:_w,LucideBarChartHorizontalBig:vw,LucideBarcode:Uz,LucideBaseline:Vz,LucideBath:Vx,LucideBattery:Yz,LucideBatteryCharging:Hz,LucideBatteryFull:Wz,LucideBatteryLow:Gz,LucideBatteryMedium:Kz,LucideBatteryWarning:Zz,LucideBeaker:Xz,LucideBean:Jz,LucideBeanOff:Qz,LucideBed:N0,LucideBedDouble:XE,LucideBedSingle:e7,LucideBeef:t7,LucideBeer:r7,LucideBeerOff:s7,LucideBell:cf,LucideBellDot:n7,LucideBellElectric:a7,LucideBellMinus:i7,LucideBellOff:X1,LucideBellPlus:o7,LucideBellRing:l7,LucideBetweenHorizonalEnd:mw,LucideBetweenHorizonalStart:pw,LucideBetweenHorizontalEnd:mw,LucideBetweenHorizontalStart:pw,LucideBetweenVerticalEnd:c7,LucideBetweenVerticalStart:d7,LucideBicepsFlexed:u7,LucideBike:h7,LucideBinary:m7,LucideBinoculars:p7,LucideBiohazard:f7,LucideBird:g7,LucideBitcoin:x7,LucideBlend:y7,LucideBlinds:v7,LucideBlocks:_7,LucideBluetooth:k7,LucideBluetoothConnected:b7,LucideBluetoothOff:w7,LucideBluetoothSearching:j7,LucideBold:a5,LucideBolt:N7,LucideBomb:S7,LucideBone:C7,LucideBook:Z7,LucideBookA:M7,LucideBookAudio:T7,LucideBookCheck:A7,LucideBookCopy:E7,LucideBookDashed:fw,LucideBookDown:P7,LucideBookHeadphones:I7,LucideBookHeart:L7,LucideBookImage:D7,LucideBookKey:O7,LucideBookLock:R7,LucideBookMarked:F7,LucideBookMinus:z7,LucideBookOpen:Ou,LucideBookOpenCheck:B7,LucideBookOpenText:$7,LucideBookPlus:q7,LucideBookTemplate:fw,LucideBookText:U7,LucideBookType:V7,LucideBookUp:W7,LucideBookUp2:H7,LucideBookUser:G7,LucideBookX:K7,LucideBookmark:Dg,LucideBookmarkCheck:Y7,LucideBookmarkMinus:X7,LucideBookmarkPlus:QE,LucideBookmarkX:Q7,LucideBoomBox:J7,LucideBot:i5,LucideBotMessageSquare:eB,LucideBotOff:tB,LucideBox:sB,LucideBoxSelect:wj,LucideBoxes:rB,LucideBraces:gw,LucideBrackets:nB,LucideBrain:JE,LucideBrainCircuit:aB,LucideBrainCog:iB,LucideBrickWall:oB,LucideBriefcase:th,LucideBriefcaseBusiness:lB,LucideBriefcaseConveyorBelt:cB,LucideBriefcaseMedical:dB,LucideBringToFront:uB,LucideBrush:hB,LucideBug:fB,LucideBugOff:mB,LucideBugPlay:pB,LucideBuilding:Qk,LucideBuilding2:Aa,LucideBus:xB,LucideBusFront:gB,LucideCable:vB,LucideCableCar:yB,LucideCake:Ru,LucideCakeSlice:_B,LucideCalculator:bB,LucideCalendar:on,LucideCalendar1:wB,LucideCalendarArrowDown:jB,LucideCalendarArrowUp:kB,LucideCalendarCheck:SB,LucideCalendarCheck2:NB,LucideCalendarClock:eP,LucideCalendarCog:CB,LucideCalendarDays:ld,LucideCalendarFold:MB,LucideCalendarHeart:TB,LucideCalendarMinus:EB,LucideCalendarMinus2:AB,LucideCalendarOff:tP,LucideCalendarPlus:Q1,LucideCalendarPlus2:PB,LucideCalendarRange:IB,LucideCalendarSearch:LB,LucideCalendarSync:DB,LucideCalendarX:RB,LucideCalendarX2:OB,LucideCamera:Og,LucideCameraOff:FB,LucideCandlestickChart:bw,LucideCandy:$B,LucideCandyCane:zB,LucideCandyOff:BB,LucideCannabis:qB,LucideCaptions:xw,LucideCaptionsOff:UB,LucideCar:WB,LucideCarFront:VB,LucideCarTaxiFront:HB,LucideCaravan:GB,LucideCarrot:KB,LucideCaseLower:ZB,LucideCaseSensitive:YB,LucideCaseUpper:XB,LucideCassetteTape:QB,LucideCast:JB,LucideCastle:e9,LucideCat:t9,LucideCctv:s9,LucideChartArea:yw,LucideChartBar:_w,LucideChartBarBig:vw,LucideChartBarDecreasing:r9,LucideChartBarIncreasing:n9,LucideChartBarStacked:a9,LucideChartCandlestick:bw,LucideChartColumn:Xo,LucideChartColumnBig:ww,LucideChartColumnDecreasing:i9,LucideChartColumnIncreasing:jw,LucideChartColumnStacked:o9,LucideChartGantt:l9,LucideChartLine:kw,LucideChartNetwork:c9,LucideChartNoAxesColumn:Sw,LucideChartNoAxesColumnDecreasing:d9,LucideChartNoAxesColumnIncreasing:Nw,LucideChartNoAxesCombined:u9,LucideChartNoAxesGantt:Cw,LucideChartPie:Mw,LucideChartScatter:Tw,LucideChartSpline:h9,LucideCheck:ua,LucideCheckCheck:m9,LucideCheckCircle:gi,LucideCheckCircle2:da,LucideCheckSquare:d0,LucideCheckSquare2:pj,LucideChefHat:p9,LucideCherry:f9,LucideChevronDown:Vo,LucideChevronDownCircle:Fw,LucideChevronDownSquare:fj,LucideChevronFirst:g9,LucideChevronLast:x9,LucideChevronLeft:zl,LucideChevronLeftCircle:zw,LucideChevronLeftSquare:gj,LucideChevronRight:Ha,LucideChevronRightCircle:Bw,LucideChevronRightSquare:xj,LucideChevronUp:Rg,LucideChevronUpCircle:$w,LucideChevronUpSquare:yj,LucideChevronsDown:v9,LucideChevronsDownUp:y9,LucideChevronsLeft:w9,LucideChevronsLeftRight:b9,LucideChevronsLeftRightEllipsis:_9,LucideChevronsRight:k9,LucideChevronsRightLeft:j9,LucideChevronsUp:N9,LucideChevronsUpDown:df,LucideChrome:S9,LucideChurch:C9,LucideCigarette:T9,LucideCigaretteOff:M9,LucideCircle:Gc,LucideCircleAlert:Qo,LucideCircleArrowDown:Aw,LucideCircleArrowLeft:Ew,LucideCircleArrowOutDownLeft:Pw,LucideCircleArrowOutDownRight:Iw,LucideCircleArrowOutUpLeft:Lw,LucideCircleArrowOutUpRight:Dw,LucideCircleArrowRight:Ow,LucideCircleArrowUp:Rw,LucideCircleCheck:da,LucideCircleCheckBig:gi,LucideCircleChevronDown:Fw,LucideCircleChevronLeft:zw,LucideCircleChevronRight:Bw,LucideCircleChevronUp:$w,LucideCircleDashed:A9,LucideCircleDivide:qw,LucideCircleDollarSign:E9,LucideCircleDot:I9,LucideCircleDotDashed:P9,LucideCircleEllipsis:L9,LucideCircleEqual:D9,LucideCircleFadingArrowUp:O9,LucideCircleFadingPlus:R9,LucideCircleGauge:Uw,LucideCircleHelp:i0,LucideCircleMinus:Vw,LucideCircleOff:F9,LucideCircleParking:Ww,LucideCircleParkingOff:Hw,LucideCirclePause:Gw,LucideCirclePercent:Kw,LucideCirclePlay:ym,LucideCirclePlus:Zw,LucideCirclePower:Yw,LucideCircleSlash:z9,LucideCircleSlash2:Xw,LucideCircleSlashed:Xw,LucideCircleStop:Qw,LucideCircleUser:e2,LucideCircleUserRound:Jw,LucideCircleX:kc,LucideCircuitBoard:B9,LucideCitrus:$9,LucideClapperboard:q9,LucideClipboard:Z9,LucideClipboardCheck:o5,LucideClipboardCopy:U9,LucideClipboardEdit:s2,LucideClipboardList:J1,LucideClipboardMinus:V9,LucideClipboardPaste:H9,LucideClipboardPen:s2,LucideClipboardPenLine:t2,LucideClipboardPlus:W9,LucideClipboardSignature:t2,LucideClipboardType:G9,LucideClipboardX:K9,LucideClock:Tn,LucideClock1:Y9,LucideClock10:X9,LucideClock11:Q9,LucideClock12:J9,LucideClock2:e$,LucideClock3:t$,LucideClock4:s$,LucideClock5:r$,LucideClock6:n$,LucideClock7:a$,LucideClock8:i$,LucideClock9:o$,LucideClockAlert:l$,LucideClockArrowDown:c$,LucideClockArrowUp:d$,LucideCloud:N$,LucideCloudAlert:u$,LucideCloudCog:h$,LucideCloudDownload:r2,LucideCloudDrizzle:m$,LucideCloudFog:p$,LucideCloudHail:f$,LucideCloudLightning:g$,LucideCloudMoon:y$,LucideCloudMoonRain:x$,LucideCloudOff:v$,LucideCloudRain:b$,LucideCloudRainWind:_$,LucideCloudSnow:w$,LucideCloudSun:k$,LucideCloudSunRain:j$,LucideCloudUpload:n2,LucideCloudy:S$,LucideClover:y0,LucideClub:C$,LucideCode:Jk,LucideCode2:a2,LucideCodeSquare:vj,LucideCodeXml:a2,LucideCodepen:M$,LucideCodesandbox:T$,LucideCoffee:eN,LucideCog:A$,LucideCoins:sP,LucideColumns:i2,LucideColumns2:i2,LucideColumns3:o2,LucideColumns4:E$,LucideCombine:P$,LucideCommand:I$,LucideCompass:L$,LucideComponent:D$,LucideComputer:O$,LucideConciergeBell:R$,LucideCone:F$,LucideConstruction:z$,LucideContact:tN,LucideContact2:l2,LucideContactRound:l2,LucideContainer:B$,LucideContrast:$$,LucideCookie:q$,LucideCookingPot:U$,LucideCopy:ni,LucideCopyCheck:V$,LucideCopyMinus:H$,LucideCopyPlus:W$,LucideCopySlash:G$,LucideCopyX:K$,LucideCopyleft:Z$,LucideCopyright:Y$,LucideCornerDownLeft:X$,LucideCornerDownRight:Q$,LucideCornerLeftDown:J$,LucideCornerLeftUp:eq,LucideCornerRightDown:tq,LucideCornerRightUp:sq,LucideCornerUpLeft:rq,LucideCornerUpRight:nq,LucideCpu:aq,LucideCreativeCommons:iq,LucideCreditCard:uf,LucideCroissant:oq,LucideCrop:lq,LucideCross:cq,LucideCrosshair:dq,LucideCrown:Bh,LucideCuboid:uq,LucideCupSoda:hq,LucideCurlyBraces:gw,LucideCurrency:mq,LucideCylinder:pq,LucideDam:fq,LucideDatabase:yq,LucideDatabaseBackup:gq,LucideDatabaseZap:xq,LucideDelete:vq,LucideDessert:_q,LucideDiameter:bq,LucideDiamond:kq,LucideDiamondMinus:wq,LucideDiamondPercent:c2,LucideDiamondPlus:jq,LucideDice1:Nq,LucideDice2:Sq,LucideDice3:Cq,LucideDice4:Mq,LucideDice5:Tq,LucideDice6:Aq,LucideDices:Eq,LucideDiff:Pq,LucideDisc:Oq,LucideDisc2:Iq,LucideDisc3:Lq,LucideDiscAlbum:Dq,LucideDivide:Rq,LucideDivideCircle:qw,LucideDivideSquare:jj,LucideDna:zq,LucideDnaOff:Fq,LucideDock:Bq,LucideDog:$q,LucideDollarSign:Kc,LucideDonut:qq,LucideDoorClosed:Uq,LucideDoorOpen:S0,LucideDot:Vq,LucideDotSquare:kj,LucideDownload:xi,LucideDownloadCloud:r2,LucideDraftingCompass:Hq,LucideDrama:Wq,LucideDribbble:Gq,LucideDrill:Kq,LucideDroplet:Zq,LucideDroplets:Fg,LucideDrum:Yq,LucideDrumstick:Xq,LucideDumbbell:Qq,LucideEar:eU,LucideEarOff:Jq,LucideEarth:d2,LucideEarthLock:tU,LucideEclipse:sU,LucideEdit:Oc,LucideEdit2:Ix,LucideEdit3:c0,LucideEgg:l5,LucideEggFried:rU,LucideEggOff:nU,LucideEllipsis:ef,LucideEllipsisVertical:Jp,LucideEqual:oU,LucideEqualApproximately:aU,LucideEqualNot:iU,LucideEqualSquare:Nj,LucideEraser:lU,LucideEthernetPort:cU,LucideEuro:dU,LucideExpand:uU,LucideExternalLink:sn,LucideEye:ya,LucideEyeClosed:hU,LucideEyeOff:Em,LucideFacebook:Hd,LucideFactory:mU,LucideFan:pU,LucideFastForward:fU,LucideFeather:gU,LucideFence:xU,LucideFerrisWheel:yU,LucideFigma:vU,LucideFile:c5,LucideFileArchive:_U,LucideFileAudio:wU,LucideFileAudio2:bU,LucideFileAxis3D:u2,LucideFileAxis3d:u2,LucideFileBadge:kU,LucideFileBadge2:jU,LucideFileBarChart:h2,LucideFileBarChart2:m2,LucideFileBox:NU,LucideFileChartColumn:m2,LucideFileChartColumnIncreasing:h2,LucideFileChartLine:p2,LucideFileChartPie:f2,LucideFileCheck:CU,LucideFileCheck2:SU,LucideFileClock:MU,LucideFileCode:AU,LucideFileCode2:TU,LucideFileCog:g2,LucideFileCog2:g2,LucideFileDiff:EU,LucideFileDigit:PU,LucideFileDown:IU,LucideFileEdit:y2,LucideFileHeart:LU,LucideFileImage:e_,LucideFileInput:DU,LucideFileJson:RU,LucideFileJson2:OU,LucideFileKey:zU,LucideFileKey2:FU,LucideFileLineChart:p2,LucideFileLock:$U,LucideFileLock2:BU,LucideFileMinus:UU,LucideFileMinus2:qU,LucideFileMusic:VU,LucideFileOutput:HU,LucideFilePen:y2,LucideFilePenLine:x2,LucideFilePieChart:f2,LucideFilePlus:GU,LucideFilePlus2:WU,LucideFileQuestion:KU,LucideFileScan:ZU,LucideFileSearch:XU,LucideFileSearch2:YU,LucideFileSignature:x2,LucideFileSliders:QU,LucideFileSpreadsheet:C0,LucideFileStack:rP,LucideFileSymlink:JU,LucideFileTerminal:eV,LucideFileText:In,LucideFileType:sV,LucideFileType2:tV,LucideFileUp:rV,LucideFileUser:nV,LucideFileVideo:iV,LucideFileVideo2:aV,LucideFileVolume:lV,LucideFileVolume2:oV,LucideFileWarning:cV,LucideFileX:uV,LucideFileX2:dV,LucideFiles:hV,LucideFilm:lu,LucideFilter:Hx,LucideFilterX:mV,LucideFingerprint:pV,LucideFireExtinguisher:fV,LucideFish:yV,LucideFishOff:gV,LucideFishSymbol:xV,LucideFlag:M0,LucideFlagOff:vV,LucideFlagTriangleLeft:_V,LucideFlagTriangleRight:bV,LucideFlame:$h,LucideFlameKindling:wV,LucideFlashlight:kV,LucideFlashlightOff:jV,LucideFlaskConical:t_,LucideFlaskConicalOff:NV,LucideFlaskRound:SV,LucideFlipHorizontal:MV,LucideFlipHorizontal2:CV,LucideFlipVertical:AV,LucideFlipVertical2:TV,LucideFlower:EV,LucideFlower2:Ag,LucideFocus:PV,LucideFoldHorizontal:IV,LucideFoldVertical:LV,LucideFolder:oH,LucideFolderArchive:DV,LucideFolderCheck:OV,LucideFolderClock:RV,LucideFolderClosed:FV,LucideFolderCode:zV,LucideFolderCog:v2,LucideFolderCog2:v2,LucideFolderDot:BV,LucideFolderDown:$V,LucideFolderEdit:_2,LucideFolderGit:UV,LucideFolderGit2:qV,LucideFolderHeart:VV,LucideFolderInput:HV,LucideFolderKanban:WV,LucideFolderKey:GV,LucideFolderLock:KV,LucideFolderMinus:ZV,LucideFolderOpen:qh,LucideFolderOpenDot:YV,LucideFolderOutput:XV,LucideFolderPen:_2,LucideFolderPlus:QV,LucideFolderRoot:JV,LucideFolderSearch:tH,LucideFolderSearch2:eH,LucideFolderSymlink:sH,LucideFolderSync:rH,LucideFolderTree:nH,LucideFolderUp:aH,LucideFolderX:iH,LucideFolders:lH,LucideFootprints:cH,LucideForkKnife:dk,LucideForkKnifeCrossed:ck,LucideForklift:dH,LucideFormInput:H2,LucideForward:uH,LucideFrame:hH,LucideFramer:mH,LucideFrown:pH,LucideFuel:fH,LucideFullscreen:gH,LucideFunctionSquare:Sj,LucideGalleryHorizontal:yH,LucideGalleryHorizontalEnd:xH,LucideGalleryThumbnails:vH,LucideGalleryVertical:bH,LucideGalleryVerticalEnd:_H,LucideGamepad:jH,LucideGamepad2:wH,LucideGanttChart:Cw,LucideGanttChartSquare:jx,LucideGauge:kH,LucideGaugeCircle:Uw,LucideGavel:NH,LucideGem:SH,LucideGhost:sN,LucideGift:io,LucideGitBranch:MH,LucideGitBranchPlus:CH,LucideGitCommit:b2,LucideGitCommitHorizontal:b2,LucideGitCommitVertical:TH,LucideGitCompare:EH,LucideGitCompareArrows:AH,LucideGitFork:PH,LucideGitGraph:IH,LucideGitMerge:LH,LucideGitPullRequest:BH,LucideGitPullRequestArrow:DH,LucideGitPullRequestClosed:OH,LucideGitPullRequestCreate:FH,LucideGitPullRequestCreateArrow:RH,LucideGitPullRequestDraft:zH,LucideGithub:$H,LucideGitlab:qH,LucideGlassWater:UH,LucideGlasses:VH,LucideGlobe:Pm,LucideGlobe2:d2,LucideGlobeLock:HH,LucideGoal:WH,LucideGrab:GH,LucideGraduationCap:sh,LucideGrape:KH,LucideGrid:Vp,LucideGrid2X2:j2,LucideGrid2X2Plus:w2,LucideGrid2x2:j2,LucideGrid2x2Check:ZH,LucideGrid2x2Plus:w2,LucideGrid2x2X:YH,LucideGrid3X3:Vp,LucideGrid3x3:Vp,LucideGrip:QH,LucideGripHorizontal:XH,LucideGripVertical:Fu,LucideGroup:JH,LucideGuitar:eW,LucideHam:tW,LucideHammer:sW,LucideHand:nP,LucideHandCoins:rW,LucideHandHeart:nW,LucideHandHelping:k2,LucideHandMetal:aW,LucideHandPlatter:iW,LucideHandshake:aP,LucideHardDrive:iP,LucideHardDriveDownload:oW,LucideHardDriveUpload:lW,LucideHardHat:cW,LucideHash:d5,LucideHaze:dW,LucideHdmiPort:uW,LucideHeading:gW,LucideHeading1:oP,LucideHeading2:lP,LucideHeading3:hW,LucideHeading4:mW,LucideHeading5:pW,LucideHeading6:fW,LucideHeadphoneOff:xW,LucideHeadphones:yW,LucideHeadset:vW,LucideHeart:Si,LucideHeartCrack:_W,LucideHeartHandshake:bW,LucideHeartOff:wW,LucideHeartPulse:jW,LucideHeater:kW,LucideHelpCircle:i0,LucideHelpingHand:k2,LucideHexagon:NW,LucideHighlighter:SW,LucideHistory:u5,LucideHome:Un,LucideHop:MW,LucideHopOff:CW,LucideHospital:TW,LucideHotel:AW,LucideHourglass:EW,LucideHouse:Un,LucideHousePlug:PW,LucideHousePlus:IW,LucideIceCream:S2,LucideIceCream2:N2,LucideIceCreamBowl:N2,LucideIceCreamCone:S2,LucideIdCard:LW,LucideImage:Jo,LucideImageDown:DW,LucideImageMinus:OW,LucideImageOff:RW,LucideImagePlay:FW,LucideImagePlus:T0,LucideImageUp:zW,LucideImageUpscale:BW,LucideImages:$W,LucideImport:qW,LucideInbox:UW,LucideIndent:M2,LucideIndentDecrease:C2,LucideIndentIncrease:M2,LucideIndianRupee:VW,LucideInfinity:HW,LucideInfo:cP,LucideInspect:Pj,LucideInspectionPanel:WW,LucideInstagram:Wd,LucideItalic:h5,LucideIterationCcw:GW,LucideIterationCw:KW,LucideJapaneseYen:ZW,LucideJoystick:YW,LucideKanban:Wx,LucideKanbanSquare:Cj,LucideKanbanSquareDashed:_j,LucideKey:Im,LucideKeyRound:rN,LucideKeySquare:XW,LucideKeyboard:eG,LucideKeyboardMusic:QW,LucideKeyboardOff:JW,LucideLamp:iG,LucideLampCeiling:tG,LucideLampDesk:sG,LucideLampFloor:rG,LucideLampWallDown:nG,LucideLampWallUp:aG,LucideLandPlot:oG,LucideLandmark:lG,LucideLanguages:cG,LucideLaptop:uG,LucideLaptop2:T2,LucideLaptopMinimal:T2,LucideLaptopMinimalCheck:dG,LucideLasso:mG,LucideLassoSelect:hG,LucideLaugh:pG,LucideLayers:xG,LucideLayers2:fG,LucideLayers3:gG,LucideLayout:l0,LucideLayoutDashboard:nN,LucideLayoutGrid:mp,LucideLayoutList:yG,LucideLayoutPanelLeft:vG,LucideLayoutPanelTop:_G,LucideLayoutTemplate:aN,LucideLeaf:bG,LucideLeafyGreen:wG,LucideLectern:jG,LucideLetterText:kG,LucideLibrary:m5,LucideLibraryBig:NG,LucideLibrarySquare:Mj,LucideLifeBuoy:p5,LucideLigature:SG,LucideLightbulb:s_,LucideLightbulbOff:CG,LucideLineChart:kw,LucideLink:Lo,LucideLink2:Ho,LucideLink2Off:MG,LucideLinkedin:Lm,LucideList:Uh,LucideListCheck:TG,LucideListChecks:AG,LucideListCollapse:EG,LucideListEnd:PG,LucideListFilter:IG,LucideListMinus:LG,LucideListMusic:DG,LucideListOrdered:A0,LucideListPlus:OG,LucideListRestart:RG,LucideListStart:FG,LucideListTodo:zG,LucideListTree:BG,LucideListVideo:$G,LucideListX:qG,LucideLoader:VG,LucideLoader2:As,LucideLoaderCircle:As,LucideLoaderPinwheel:UG,LucideLocate:dP,LucideLocateFixed:HG,LucideLocateOff:WG,LucideLock:zu,LucideLockKeyhole:GG,LucideLockKeyholeOpen:A2,LucideLockOpen:E2,LucideLogIn:f5,LucideLogOut:g5,LucideLogs:KG,LucideLollipop:ZG,LucideLuggage:YG,LucideMSquare:Tj,LucideMagnet:XG,LucideMail:_r,LucideMailCheck:QG,LucideMailMinus:JG,LucideMailOpen:eK,LucideMailPlus:tK,LucideMailQuestion:sK,LucideMailSearch:rK,LucideMailWarning:nK,LucideMailX:uP,LucideMailbox:aK,LucideMails:iK,LucideMap:yK,LucideMapPin:Ai,LucideMapPinCheck:lK,LucideMapPinCheckInside:oK,LucideMapPinHouse:cK,LucideMapPinMinus:uK,LucideMapPinMinusInside:dK,LucideMapPinOff:hK,LucideMapPinPlus:pK,LucideMapPinPlusInside:mK,LucideMapPinX:gK,LucideMapPinXInside:fK,LucideMapPinned:xK,LucideMartini:vK,LucideMaximize:hP,LucideMaximize2:_K,LucideMedal:E0,LucideMegaphone:zg,LucideMegaphoneOff:bK,LucideMeh:wK,LucideMemoryStick:jK,LucideMenu:mP,LucideMenuSquare:Aj,LucideMerge:kK,LucideMessageCircle:gc,LucideMessageCircleCode:NK,LucideMessageCircleDashed:SK,LucideMessageCircleHeart:x5,LucideMessageCircleMore:CK,LucideMessageCircleOff:MK,LucideMessageCirclePlus:TK,LucideMessageCircleQuestion:pP,LucideMessageCircleReply:AK,LucideMessageCircleWarning:EK,LucideMessageCircleX:PK,LucideMessageSquare:oo,LucideMessageSquareCode:IK,LucideMessageSquareDashed:LK,LucideMessageSquareDiff:DK,LucideMessageSquareDot:OK,LucideMessageSquareHeart:RK,LucideMessageSquareLock:FK,LucideMessageSquareMore:fP,LucideMessageSquareOff:zK,LucideMessageSquarePlus:y5,LucideMessageSquareQuote:gP,LucideMessageSquareReply:BK,LucideMessageSquareShare:$K,LucideMessageSquareText:qK,LucideMessageSquareWarning:UK,LucideMessageSquareX:VK,LucideMessagesSquare:HK,LucideMic:xP,LucideMic2:P2,LucideMicOff:WK,LucideMicVocal:P2,LucideMicrochip:GK,LucideMicroscope:KK,LucideMicrowave:ZK,LucideMilestone:YK,LucideMilk:QK,LucideMilkOff:XK,LucideMinimize:eZ,LucideMinimize2:JK,LucideMinus:P0,LucideMinusCircle:Vw,LucideMinusSquare:Ej,LucideMonitor:iN,LucideMonitorCheck:tZ,LucideMonitorCog:sZ,LucideMonitorDot:rZ,LucideMonitorDown:nZ,LucideMonitorOff:aZ,LucideMonitorPause:iZ,LucideMonitorPlay:oZ,LucideMonitorSmartphone:lZ,LucideMonitorSpeaker:cZ,LucideMonitorStop:dZ,LucideMonitorUp:uZ,LucideMonitorX:hZ,LucideMoon:pZ,LucideMoonStar:mZ,LucideMoreHorizontal:ef,LucideMoreVertical:Jp,LucideMountain:gZ,LucideMountainSnow:fZ,LucideMouse:_Z,LucideMouseOff:xZ,LucideMousePointer:jm,LucideMousePointer2:yZ,LucideMousePointerBan:vZ,LucideMousePointerClick:r_,LucideMousePointerSquareDashed:bj,LucideMove:IZ,LucideMove3D:I2,LucideMove3d:I2,LucideMoveDiagonal:wZ,LucideMoveDiagonal2:bZ,LucideMoveDown:NZ,LucideMoveDownLeft:jZ,LucideMoveDownRight:kZ,LucideMoveHorizontal:SZ,LucideMoveLeft:CZ,LucideMoveRight:MZ,LucideMoveUp:EZ,LucideMoveUpLeft:TZ,LucideMoveUpRight:AZ,LucideMoveVertical:PZ,LucideMusic:RZ,LucideMusic2:LZ,LucideMusic3:DZ,LucideMusic4:OZ,LucideNavigation:yP,LucideNavigation2:zZ,LucideNavigation2Off:FZ,LucideNavigationOff:BZ,LucideNetwork:$Z,LucideNewspaper:I0,LucideNfc:qZ,LucideNotebook:WZ,LucideNotebookPen:UZ,LucideNotebookTabs:VZ,LucideNotebookText:HZ,LucideNotepadText:KZ,LucideNotepadTextDashed:GZ,LucideNut:YZ,LucideNutOff:ZZ,LucideOctagon:QZ,LucideOctagonAlert:o0,LucideOctagonMinus:XZ,LucideOctagonPause:L2,LucideOctagonX:D2,LucideOmega:JZ,LucideOption:eY,LucideOrbit:tY,LucideOrigami:sY,LucideOutdent:C2,LucidePackage:dl,LucidePackage2:rY,LucidePackageCheck:nY,LucidePackageMinus:aY,LucidePackageOpen:iY,LucidePackagePlus:oY,LucidePackageSearch:lY,LucidePackageX:cY,LucidePaintBucket:dY,LucidePaintRoller:uY,LucidePaintbrush:hY,LucidePaintbrush2:O2,LucidePaintbrushVertical:O2,LucidePalette:Bl,LucidePalmtree:Jj,LucidePanelBottom:fY,LucidePanelBottomClose:mY,LucidePanelBottomDashed:R2,LucidePanelBottomInactive:R2,LucidePanelBottomOpen:pY,LucidePanelLeft:$2,LucidePanelLeftClose:F2,LucidePanelLeftDashed:z2,LucidePanelLeftInactive:z2,LucidePanelLeftOpen:B2,LucidePanelRight:yY,LucidePanelRightClose:gY,LucidePanelRightDashed:q2,LucidePanelRightInactive:q2,LucidePanelRightOpen:xY,LucidePanelTop:bY,LucidePanelTopClose:vY,LucidePanelTopDashed:U2,LucidePanelTopInactive:U2,LucidePanelTopOpen:_Y,LucidePanelsLeftBottom:wY,LucidePanelsLeftRight:o2,LucidePanelsRightBottom:jY,LucidePanelsTopBottom:K2,LucidePanelsTopLeft:l0,LucidePaperclip:oN,LucideParentheses:kY,LucideParkingCircle:Ww,LucideParkingCircleOff:Hw,LucideParkingMeter:NY,LucideParkingSquare:Lj,LucideParkingSquareOff:Ij,LucidePartyPopper:Sd,LucidePause:pp,LucidePauseCircle:Gw,LucidePauseOctagon:L2,LucidePawPrint:SY,LucidePcCase:CY,LucidePen:Ix,LucidePenBox:Oc,LucidePenLine:c0,LucidePenOff:MY,LucidePenSquare:Oc,LucidePenTool:n_,LucidePencil:Ra,LucidePencilLine:TY,LucidePencilOff:AY,LucidePencilRuler:EY,LucidePentagon:PY,LucidePercent:v5,LucidePercentCircle:Kw,LucidePercentDiamond:c2,LucidePercentSquare:Dj,LucidePersonStanding:IY,LucidePhilippinePeso:LY,LucidePhone:Zn,LucidePhoneCall:DY,LucidePhoneForwarded:OY,LucidePhoneIncoming:RY,LucidePhoneMissed:FY,LucidePhoneOff:zY,LucidePhoneOutgoing:BY,LucidePi:$Y,LucidePiSquare:Oj,LucidePiano:qY,LucidePickaxe:UY,LucidePictureInPicture:HY,LucidePictureInPicture2:VY,LucidePieChart:Mw,LucidePiggyBank:WY,LucidePilcrow:ZY,LucidePilcrowLeft:GY,LucidePilcrowRight:KY,LucidePilcrowSquare:Rj,LucidePill:XY,LucidePillBottle:YY,LucidePin:a_,LucidePinOff:vP,LucidePipette:QY,LucidePizza:JY,LucidePlane:sX,LucidePlaneLanding:eX,LucidePlaneTakeoff:tX,LucidePlay:ul,LucidePlayCircle:ym,LucidePlaySquare:Fj,LucidePlug:_P,LucidePlug2:rX,LucidePlugZap:V2,LucidePlugZap2:V2,LucidePlus:Zs,LucidePlusCircle:Zw,LucidePlusSquare:zj,LucidePocket:aX,LucidePocketKnife:nX,LucidePodcast:iX,LucidePointer:lX,LucidePointerOff:oX,LucidePopcorn:cX,LucidePopsicle:dX,LucidePoundSterling:uX,LucidePower:bP,LucidePowerCircle:Yw,LucidePowerOff:hX,LucidePowerSquare:Bj,LucidePresentation:Bg,LucidePrinter:wP,LucidePrinterCheck:mX,LucideProjector:pX,LucideProportions:fX,LucidePuzzle:gX,LucidePyramid:xX,LucideQrCode:L0,LucideQuote:_5,LucideRabbit:yX,LucideRadar:vX,LucideRadiation:_X,LucideRadical:bX,LucideRadio:lN,LucideRadioReceiver:wX,LucideRadioTower:jX,LucideRadius:kX,LucideRailSymbol:NX,LucideRainbow:SX,LucideRat:CX,LucideRatio:MX,LucideReceipt:RX,LucideReceiptCent:TX,LucideReceiptEuro:AX,LucideReceiptIndianRupee:EX,LucideReceiptJapaneseYen:PX,LucideReceiptPoundSterling:IX,LucideReceiptRussianRuble:LX,LucideReceiptSwissFranc:DX,LucideReceiptText:OX,LucideRectangleEllipsis:H2,LucideRectangleHorizontal:FX,LucideRectangleVertical:zX,LucideRecycle:BX,LucideRedo:b5,LucideRedo2:$X,LucideRedoDot:qX,LucideRefreshCcw:VX,LucideRefreshCcwDot:UX,LucideRefreshCw:Po,LucideRefreshCwOff:HX,LucideRefrigerator:WX,LucideRegex:GX,LucideRemoveFormatting:KX,LucideRepeat:jP,LucideRepeat1:ZX,LucideRepeat2:YX,LucideReplace:QX,LucideReplaceAll:XX,LucideReply:kP,LucideReplyAll:JX,LucideRewind:eQ,LucideRibbon:tQ,LucideRocket:Gx,LucideRockingChair:sQ,LucideRollerCoaster:rQ,LucideRotate3D:W2,LucideRotate3d:W2,LucideRotateCcw:D0,LucideRotateCcwSquare:nQ,LucideRotateCw:NP,LucideRotateCwSquare:aQ,LucideRoute:oQ,LucideRouteOff:iQ,LucideRouter:lQ,LucideRows:G2,LucideRows2:G2,LucideRows3:K2,LucideRows4:cQ,LucideRss:dQ,LucideRuler:SP,LucideRussianRuble:uQ,LucideSailboat:hQ,LucideSalad:mQ,LucideSandwich:pQ,LucideSatellite:gQ,LucideSatelliteDish:fQ,LucideSave:Bu,LucideSaveAll:xQ,LucideSaveOff:yQ,LucideScale:vQ,LucideScale3D:Z2,LucideScale3d:Z2,LucideScaling:_Q,LucideScan:MQ,LucideScanBarcode:bQ,LucideScanEye:wQ,LucideScanFace:jQ,LucideScanLine:kQ,LucideScanQrCode:NQ,LucideScanSearch:SQ,LucideScanText:CQ,LucideScatterChart:Tw,LucideSchool:TQ,LucideSchool2:tk,LucideScissors:EQ,LucideScissorsLineDashed:AQ,LucideScissorsSquare:$j,LucideScissorsSquareDashedBottom:mj,LucideScreenShare:IQ,LucideScreenShareOff:PQ,LucideScroll:DQ,LucideScrollText:LQ,LucideSearch:fn,LucideSearchCheck:OQ,LucideSearchCode:RQ,LucideSearchSlash:FQ,LucideSearchX:CP,LucideSection:zQ,LucideSend:ka,LucideSendHorizonal:Y2,LucideSendHorizontal:Y2,LucideSendToBack:BQ,LucideSeparatorHorizontal:$Q,LucideSeparatorVertical:qQ,LucideServer:WQ,LucideServerCog:UQ,LucideServerCrash:VQ,LucideServerOff:HQ,LucideSettings:$l,LucideSettings2:MP,LucideShapes:GQ,LucideShare:TP,LucideShare2:cd,LucideSheet:KQ,LucideShell:ZQ,LucideShield:rh,LucideShieldAlert:YQ,LucideShieldBan:XQ,LucideShieldCheck:AP,LucideShieldClose:X2,LucideShieldEllipsis:QQ,LucideShieldHalf:JQ,LucideShieldMinus:eJ,LucideShieldOff:tJ,LucideShieldPlus:sJ,LucideShieldQuestion:rJ,LucideShieldX:X2,LucideShip:aJ,LucideShipWheel:nJ,LucideShirt:iJ,LucideShoppingBag:Kx,LucideShoppingBasket:oJ,LucideShoppingCart:km,LucideShovel:lJ,LucideShowerHead:cJ,LucideShrink:dJ,LucideShrub:uJ,LucideShuffle:cN,LucideSidebar:$2,LucideSidebarClose:F2,LucideSidebarOpen:B2,LucideSigma:hJ,LucideSigmaSquare:qj,LucideSignal:xJ,LucideSignalHigh:mJ,LucideSignalLow:pJ,LucideSignalMedium:fJ,LucideSignalZero:gJ,LucideSignature:yJ,LucideSignpost:_J,LucideSignpostBig:vJ,LucideSiren:bJ,LucideSkipBack:wJ,LucideSkipForward:jJ,LucideSkull:kJ,LucideSlack:NJ,LucideSlash:SJ,LucideSlashSquare:Uj,LucideSlice:CJ,LucideSliders:Q2,LucideSlidersHorizontal:EP,LucideSlidersVertical:Q2,LucideSmartphone:O0,LucideSmartphoneCharging:MJ,LucideSmartphoneNfc:TJ,LucideSmile:EJ,LucideSmilePlus:AJ,LucideSnail:PJ,LucideSnowflake:D1,LucideSofa:IJ,LucideSortAsc:cw,LucideSortDesc:iw,LucideSoup:LJ,LucideSpace:DJ,LucideSpade:OJ,LucideSparkle:RJ,LucideSparkles:hn,LucideSpeaker:FJ,LucideSpeech:zJ,LucideSpellCheck:$J,LucideSpellCheck2:BJ,LucideSpline:qJ,LucideSplit:UJ,LucideSplitSquareHorizontal:Vj,LucideSplitSquareVertical:Hj,LucideSprayCan:VJ,LucideSprout:HJ,LucideSquare:Zx,LucideSquareActivity:J2,LucideSquareArrowDown:sj,LucideSquareArrowDownLeft:ej,LucideSquareArrowDownRight:tj,LucideSquareArrowLeft:rj,LucideSquareArrowOutDownLeft:nj,LucideSquareArrowOutDownRight:aj,LucideSquareArrowOutUpLeft:ij,LucideSquareArrowOutUpRight:oj,LucideSquareArrowRight:lj,LucideSquareArrowUp:uj,LucideSquareArrowUpLeft:cj,LucideSquareArrowUpRight:dj,LucideSquareAsterisk:hj,LucideSquareBottomDashedScissors:mj,LucideSquareChartGantt:jx,LucideSquareCheck:pj,LucideSquareCheckBig:d0,LucideSquareChevronDown:fj,LucideSquareChevronLeft:gj,LucideSquareChevronRight:xj,LucideSquareChevronUp:yj,LucideSquareCode:vj,LucideSquareDashed:wj,LucideSquareDashedBottom:GJ,LucideSquareDashedBottomCode:WJ,LucideSquareDashedKanban:_j,LucideSquareDashedMousePointer:bj,LucideSquareDivide:jj,LucideSquareDot:kj,LucideSquareEqual:Nj,LucideSquareFunction:Sj,LucideSquareGanttChart:jx,LucideSquareKanban:Cj,LucideSquareLibrary:Mj,LucideSquareM:Tj,LucideSquareMenu:Aj,LucideSquareMinus:Ej,LucideSquareMousePointer:Pj,LucideSquareParking:Lj,LucideSquareParkingOff:Ij,LucideSquarePen:Oc,LucideSquarePercent:Dj,LucideSquarePi:Oj,LucideSquarePilcrow:Rj,LucideSquarePlay:Fj,LucideSquarePlus:zj,LucideSquarePower:Bj,LucideSquareRadical:KJ,LucideSquareScissors:$j,LucideSquareSigma:qj,LucideSquareSlash:Uj,LucideSquareSplitHorizontal:Vj,LucideSquareSplitVertical:Hj,LucideSquareSquare:ZJ,LucideSquareStack:YJ,LucideSquareTerminal:Wj,LucideSquareUser:Kj,LucideSquareUserRound:Gj,LucideSquareX:Zj,LucideSquircle:XJ,LucideSquirrel:QJ,LucideStamp:JJ,LucideStar:Gn,LucideStarHalf:eee,LucideStarOff:tee,LucideStars:hn,LucideStepBack:see,LucideStepForward:ree,LucideStethoscope:nee,LucideSticker:aee,LucideStickyNote:iee,LucideStopCircle:Qw,LucideStore:oee,LucideStretchHorizontal:lee,LucideStretchVertical:cee,LucideStrikethrough:dee,LucideSubscript:uee,LucideSubtitles:xw,LucideSun:i_,LucideSunDim:hee,LucideSunMedium:mee,LucideSunMoon:pee,LucideSunSnow:fee,LucideSunrise:gee,LucideSunset:xee,LucideSuperscript:yee,LucideSwatchBook:vee,LucideSwissFranc:_ee,LucideSwitchCamera:bee,LucideSword:wee,LucideSwords:jee,LucideSyringe:kee,LucideTable:PP,LucideTable2:w5,LucideTableCellsMerge:Nee,LucideTableCellsSplit:See,LucideTableColumnsSplit:Cee,LucideTableOfContents:Mee,LucideTableProperties:Tee,LucideTableRowsSplit:Aee,LucideTablet:Pee,LucideTabletSmartphone:Eee,LucideTablets:Iee,LucideTag:Vh,LucideTags:Lee,LucideTally1:Dee,LucideTally2:Oee,LucideTally3:Ree,LucideTally4:Fee,LucideTally5:zee,LucideTangent:Bee,LucideTarget:Hh,LucideTelescope:$ee,LucideTent:Uee,LucideTentTree:qee,LucideTerminal:Vee,LucideTerminalSquare:Wj,LucideTestTube:Hee,LucideTestTube2:Yj,LucideTestTubeDiagonal:Yj,LucideTestTubes:Wee,LucideText:Xee,LucideTextCursor:Kee,LucideTextCursorInput:Gee,LucideTextQuote:Zee,LucideTextSearch:Yee,LucideTextSelect:Xj,LucideTextSelection:Xj,LucideTheater:Qee,LucideThermometer:tte,LucideThermometerSnowflake:Jee,LucideThermometerSun:ete,LucideThumbsDown:IP,LucideThumbsUp:pu,LucideTicket:LP,LucideTicketCheck:ste,LucideTicketMinus:rte,LucideTicketPercent:nte,LucideTicketPlus:ate,LucideTicketSlash:ite,LucideTicketX:ote,LucideTickets:cte,LucideTicketsPlane:lte,LucideTimer:hte,LucideTimerOff:dte,LucideTimerReset:ute,LucideToggleLeft:mte,LucideToggleRight:pte,LucideToilet:fte,LucideTornado:gte,LucideTorus:xte,LucideTouchpad:vte,LucideTouchpadOff:yte,LucideTowerControl:_te,LucideToyBrick:bte,LucideTractor:wte,LucideTrafficCone:jte,LucideTrain:Qj,LucideTrainFront:Nte,LucideTrainFrontTunnel:kte,LucideTrainTrack:Ste,LucideTramFront:Qj,LucideTrash:Cte,LucideTrash2:br,LucideTreeDeciduous:Mte,LucideTreePalm:Jj,LucideTreePine:o_,LucideTrees:Tte,LucideTrello:Ate,LucideTrendingDown:dN,LucideTrendingUp:Cc,LucideTrendingUpDown:Ete,LucideTriangle:Ite,LucideTriangleAlert:Th,LucideTriangleRight:Pte,LucideTrophy:Ki,LucideTruck:DP,LucideTurtle:Lte,LucideTv:Ote,LucideTv2:ek,LucideTvMinimal:ek,LucideTvMinimalPlay:Dte,LucideTwitch:Rte,LucideTwitter:Fte,LucideType:Bte,LucideTypeOutline:zte,LucideUmbrella:qte,LucideUmbrellaOff:$te,LucideUnderline:Ute,LucideUndo:j5,LucideUndo2:Vte,LucideUndoDot:Hte,LucideUnfoldHorizontal:Wte,LucideUnfoldVertical:Gte,LucideUngroup:Kte,LucideUniversity:tk,LucideUnlink:uN,LucideUnlink2:Zte,LucideUnlock:E2,LucideUnlockKeyhole:A2,LucideUnplug:Yte,LucideUpload:Ya,LucideUploadCloud:n2,LucideUsb:Xte,LucideUser:Xi,LucideUser2:ok,LucideUserCheck:l_,LucideUserCheck2:sk,LucideUserCircle:e2,LucideUserCircle2:Jw,LucideUserCog:OP,LucideUserCog2:rk,LucideUserMinus:RP,LucideUserMinus2:nk,LucideUserPen:Qte,LucideUserPlus:xc,LucideUserPlus2:ak,LucideUserRound:ok,LucideUserRoundCheck:sk,LucideUserRoundCog:rk,LucideUserRoundMinus:nk,LucideUserRoundPen:Jte,LucideUserRoundPlus:ak,LucideUserRoundSearch:ese,LucideUserRoundX:ik,LucideUserSearch:tse,LucideUserSquare:Kj,LucideUserSquare2:Gj,LucideUserX:sse,LucideUserX2:ik,LucideUsers:hr,LucideUsers2:lk,LucideUsersRound:lk,LucideUtensils:dk,LucideUtensilsCrossed:ck,LucideUtilityPole:rse,LucideVariable:FP,LucideVault:nse,LucideVegan:ase,LucideVenetianMask:ise,LucideVerified:hw,LucideVibrate:lse,LucideVibrateOff:ose,LucideVideo:kn,LucideVideoOff:cse,LucideVideotape:dse,LucideView:use,LucideVoicemail:hse,LucideVolleyball:mse,LucideVolume:yse,LucideVolume1:pse,LucideVolume2:fse,LucideVolumeOff:gse,LucideVolumeX:xse,LucideVote:vse,LucideWallet:zP,LucideWallet2:uk,LucideWalletCards:_se,LucideWalletMinimal:uk,LucideWallpaper:bse,LucideWand:wse,LucideWand2:u0,LucideWandSparkles:u0,LucideWarehouse:jse,LucideWashingMachine:kse,LucideWatch:Nse,LucideWaves:Sse,LucideWaypoints:Cse,LucideWebcam:Mse,LucideWebhook:Ase,LucideWebhookOff:Tse,LucideWeight:Ese,LucideWheat:Ise,LucideWheatOff:Pse,LucideWholeWord:Lse,LucideWifi:zse,LucideWifiHigh:Dse,LucideWifiLow:Ose,LucideWifiOff:Rse,LucideWifiZero:Fse,LucideWind:$se,LucideWindArrowDown:Bse,LucideWine:Use,LucideWineOff:qse,LucideWorkflow:Vse,LucideWorm:Hse,LucideWrapText:Wse,LucideWrench:$g,LucideX:Ur,LucideXCircle:kc,LucideXOctagon:D2,LucideXSquare:Zj,LucideYoutube:Gse,LucideZap:Dm,LucideZapOff:Kse,LucideZoomIn:c_,LucideZoomOut:k5,Luggage:YG,LuggageIcon:YG,MSquare:Tj,MSquareIcon:Tj,Magnet:XG,MagnetIcon:XG,Mail:_r,MailCheck:QG,MailCheckIcon:QG,MailIcon:_r,MailMinus:JG,MailMinusIcon:JG,MailOpen:eK,MailOpenIcon:eK,MailPlus:tK,MailPlusIcon:tK,MailQuestion:sK,MailQuestionIcon:sK,MailSearch:rK,MailSearchIcon:rK,MailWarning:nK,MailWarningIcon:nK,MailX:uP,MailXIcon:uP,Mailbox:aK,MailboxIcon:aK,Mails:iK,MailsIcon:iK,Map:yK,MapIcon:yK,MapPin:Ai,MapPinCheck:lK,MapPinCheckIcon:lK,MapPinCheckInside:oK,MapPinCheckInsideIcon:oK,MapPinHouse:cK,MapPinHouseIcon:cK,MapPinIcon:Ai,MapPinMinus:uK,MapPinMinusIcon:uK,MapPinMinusInside:dK,MapPinMinusInsideIcon:dK,MapPinOff:hK,MapPinOffIcon:hK,MapPinPlus:pK,MapPinPlusIcon:pK,MapPinPlusInside:mK,MapPinPlusInsideIcon:mK,MapPinX:gK,MapPinXIcon:gK,MapPinXInside:fK,MapPinXInsideIcon:fK,MapPinned:xK,MapPinnedIcon:xK,Martini:vK,MartiniIcon:vK,Maximize:hP,Maximize2:_K,Maximize2Icon:_K,MaximizeIcon:hP,Medal:E0,MedalIcon:E0,Megaphone:zg,MegaphoneIcon:zg,MegaphoneOff:bK,MegaphoneOffIcon:bK,Meh:wK,MehIcon:wK,MemoryStick:jK,MemoryStickIcon:jK,Menu:mP,MenuIcon:mP,MenuSquare:Aj,MenuSquareIcon:Aj,Merge:kK,MergeIcon:kK,MessageCircle:gc,MessageCircleCode:NK,MessageCircleCodeIcon:NK,MessageCircleDashed:SK,MessageCircleDashedIcon:SK,MessageCircleHeart:x5,MessageCircleHeartIcon:x5,MessageCircleIcon:gc,MessageCircleMore:CK,MessageCircleMoreIcon:CK,MessageCircleOff:MK,MessageCircleOffIcon:MK,MessageCirclePlus:TK,MessageCirclePlusIcon:TK,MessageCircleQuestion:pP,MessageCircleQuestionIcon:pP,MessageCircleReply:AK,MessageCircleReplyIcon:AK,MessageCircleWarning:EK,MessageCircleWarningIcon:EK,MessageCircleX:PK,MessageCircleXIcon:PK,MessageSquare:oo,MessageSquareCode:IK,MessageSquareCodeIcon:IK,MessageSquareDashed:LK,MessageSquareDashedIcon:LK,MessageSquareDiff:DK,MessageSquareDiffIcon:DK,MessageSquareDot:OK,MessageSquareDotIcon:OK,MessageSquareHeart:RK,MessageSquareHeartIcon:RK,MessageSquareIcon:oo,MessageSquareLock:FK,MessageSquareLockIcon:FK,MessageSquareMore:fP,MessageSquareMoreIcon:fP,MessageSquareOff:zK,MessageSquareOffIcon:zK,MessageSquarePlus:y5,MessageSquarePlusIcon:y5,MessageSquareQuote:gP,MessageSquareQuoteIcon:gP,MessageSquareReply:BK,MessageSquareReplyIcon:BK,MessageSquareShare:$K,MessageSquareShareIcon:$K,MessageSquareText:qK,MessageSquareTextIcon:qK,MessageSquareWarning:UK,MessageSquareWarningIcon:UK,MessageSquareX:VK,MessageSquareXIcon:VK,MessagesSquare:HK,MessagesSquareIcon:HK,Mic:xP,Mic2:P2,Mic2Icon:P2,MicIcon:xP,MicOff:WK,MicOffIcon:WK,MicVocal:P2,MicVocalIcon:P2,Microchip:GK,MicrochipIcon:GK,Microscope:KK,MicroscopeIcon:KK,Microwave:ZK,MicrowaveIcon:ZK,Milestone:YK,MilestoneIcon:YK,Milk:QK,MilkIcon:QK,MilkOff:XK,MilkOffIcon:XK,Minimize:eZ,Minimize2:JK,Minimize2Icon:JK,MinimizeIcon:eZ,Minus:P0,MinusCircle:Vw,MinusCircleIcon:Vw,MinusIcon:P0,MinusSquare:Ej,MinusSquareIcon:Ej,Monitor:iN,MonitorCheck:tZ,MonitorCheckIcon:tZ,MonitorCog:sZ,MonitorCogIcon:sZ,MonitorDot:rZ,MonitorDotIcon:rZ,MonitorDown:nZ,MonitorDownIcon:nZ,MonitorIcon:iN,MonitorOff:aZ,MonitorOffIcon:aZ,MonitorPause:iZ,MonitorPauseIcon:iZ,MonitorPlay:oZ,MonitorPlayIcon:oZ,MonitorSmartphone:lZ,MonitorSmartphoneIcon:lZ,MonitorSpeaker:cZ,MonitorSpeakerIcon:cZ,MonitorStop:dZ,MonitorStopIcon:dZ,MonitorUp:uZ,MonitorUpIcon:uZ,MonitorX:hZ,MonitorXIcon:hZ,Moon:pZ,MoonIcon:pZ,MoonStar:mZ,MoonStarIcon:mZ,MoreHorizontal:ef,MoreHorizontalIcon:ef,MoreVertical:Jp,MoreVerticalIcon:Jp,Mountain:gZ,MountainIcon:gZ,MountainSnow:fZ,MountainSnowIcon:fZ,Mouse:_Z,MouseIcon:_Z,MouseOff:xZ,MouseOffIcon:xZ,MousePointer:jm,MousePointer2:yZ,MousePointer2Icon:yZ,MousePointerBan:vZ,MousePointerBanIcon:vZ,MousePointerClick:r_,MousePointerClickIcon:r_,MousePointerIcon:jm,MousePointerSquareDashed:bj,MousePointerSquareDashedIcon:bj,Move:IZ,Move3D:I2,Move3DIcon:I2,Move3d:I2,Move3dIcon:I2,MoveDiagonal:wZ,MoveDiagonal2:bZ,MoveDiagonal2Icon:bZ,MoveDiagonalIcon:wZ,MoveDown:NZ,MoveDownIcon:NZ,MoveDownLeft:jZ,MoveDownLeftIcon:jZ,MoveDownRight:kZ,MoveDownRightIcon:kZ,MoveHorizontal:SZ,MoveHorizontalIcon:SZ,MoveIcon:IZ,MoveLeft:CZ,MoveLeftIcon:CZ,MoveRight:MZ,MoveRightIcon:MZ,MoveUp:EZ,MoveUpIcon:EZ,MoveUpLeft:TZ,MoveUpLeftIcon:TZ,MoveUpRight:AZ,MoveUpRightIcon:AZ,MoveVertical:PZ,MoveVerticalIcon:PZ,Music:RZ,Music2:LZ,Music2Icon:LZ,Music3:DZ,Music3Icon:DZ,Music4:OZ,Music4Icon:OZ,MusicIcon:RZ,Navigation:yP,Navigation2:zZ,Navigation2Icon:zZ,Navigation2Off:FZ,Navigation2OffIcon:FZ,NavigationIcon:yP,NavigationOff:BZ,NavigationOffIcon:BZ,Network:$Z,NetworkIcon:$Z,Newspaper:I0,NewspaperIcon:I0,Nfc:qZ,NfcIcon:qZ,Notebook:WZ,NotebookIcon:WZ,NotebookPen:UZ,NotebookPenIcon:UZ,NotebookTabs:VZ,NotebookTabsIcon:VZ,NotebookText:HZ,NotebookTextIcon:HZ,NotepadText:KZ,NotepadTextDashed:GZ,NotepadTextDashedIcon:GZ,NotepadTextIcon:KZ,Nut:YZ,NutIcon:YZ,NutOff:ZZ,NutOffIcon:ZZ,Octagon:QZ,OctagonAlert:o0,OctagonAlertIcon:o0,OctagonIcon:QZ,OctagonMinus:XZ,OctagonMinusIcon:XZ,OctagonPause:L2,OctagonPauseIcon:L2,OctagonX:D2,OctagonXIcon:D2,Omega:JZ,OmegaIcon:JZ,Option:eY,OptionIcon:eY,Orbit:tY,OrbitIcon:tY,Origami:sY,OrigamiIcon:sY,Outdent:C2,OutdentIcon:C2,Package:dl,Package2:rY,Package2Icon:rY,PackageCheck:nY,PackageCheckIcon:nY,PackageIcon:dl,PackageMinus:aY,PackageMinusIcon:aY,PackageOpen:iY,PackageOpenIcon:iY,PackagePlus:oY,PackagePlusIcon:oY,PackageSearch:lY,PackageSearchIcon:lY,PackageX:cY,PackageXIcon:cY,PaintBucket:dY,PaintBucketIcon:dY,PaintRoller:uY,PaintRollerIcon:uY,Paintbrush:hY,Paintbrush2:O2,Paintbrush2Icon:O2,PaintbrushIcon:hY,PaintbrushVertical:O2,PaintbrushVerticalIcon:O2,Palette:Bl,PaletteIcon:Bl,Palmtree:Jj,PalmtreeIcon:Jj,PanelBottom:fY,PanelBottomClose:mY,PanelBottomCloseIcon:mY,PanelBottomDashed:R2,PanelBottomDashedIcon:R2,PanelBottomIcon:fY,PanelBottomInactive:R2,PanelBottomInactiveIcon:R2,PanelBottomOpen:pY,PanelBottomOpenIcon:pY,PanelLeft:$2,PanelLeftClose:F2,PanelLeftCloseIcon:F2,PanelLeftDashed:z2,PanelLeftDashedIcon:z2,PanelLeftIcon:$2,PanelLeftInactive:z2,PanelLeftInactiveIcon:z2,PanelLeftOpen:B2,PanelLeftOpenIcon:B2,PanelRight:yY,PanelRightClose:gY,PanelRightCloseIcon:gY,PanelRightDashed:q2,PanelRightDashedIcon:q2,PanelRightIcon:yY,PanelRightInactive:q2,PanelRightInactiveIcon:q2,PanelRightOpen:xY,PanelRightOpenIcon:xY,PanelTop:bY,PanelTopClose:vY,PanelTopCloseIcon:vY,PanelTopDashed:U2,PanelTopDashedIcon:U2,PanelTopIcon:bY,PanelTopInactive:U2,PanelTopInactiveIcon:U2,PanelTopOpen:_Y,PanelTopOpenIcon:_Y,PanelsLeftBottom:wY,PanelsLeftBottomIcon:wY,PanelsLeftRight:o2,PanelsLeftRightIcon:o2,PanelsRightBottom:jY,PanelsRightBottomIcon:jY,PanelsTopBottom:K2,PanelsTopBottomIcon:K2,PanelsTopLeft:l0,PanelsTopLeftIcon:l0,Paperclip:oN,PaperclipIcon:oN,Parentheses:kY,ParenthesesIcon:kY,ParkingCircle:Ww,ParkingCircleIcon:Ww,ParkingCircleOff:Hw,ParkingCircleOffIcon:Hw,ParkingMeter:NY,ParkingMeterIcon:NY,ParkingSquare:Lj,ParkingSquareIcon:Lj,ParkingSquareOff:Ij,ParkingSquareOffIcon:Ij,PartyPopper:Sd,PartyPopperIcon:Sd,Pause:pp,PauseCircle:Gw,PauseCircleIcon:Gw,PauseIcon:pp,PauseOctagon:L2,PauseOctagonIcon:L2,PawPrint:SY,PawPrintIcon:SY,PcCase:CY,PcCaseIcon:CY,Pen:Ix,PenBox:Oc,PenBoxIcon:Oc,PenIcon:Ix,PenLine:c0,PenLineIcon:c0,PenOff:MY,PenOffIcon:MY,PenSquare:Oc,PenSquareIcon:Oc,PenTool:n_,PenToolIcon:n_,Pencil:Ra,PencilIcon:Ra,PencilLine:TY,PencilLineIcon:TY,PencilOff:AY,PencilOffIcon:AY,PencilRuler:EY,PencilRulerIcon:EY,Pentagon:PY,PentagonIcon:PY,Percent:v5,PercentCircle:Kw,PercentCircleIcon:Kw,PercentDiamond:c2,PercentDiamondIcon:c2,PercentIcon:v5,PercentSquare:Dj,PercentSquareIcon:Dj,PersonStanding:IY,PersonStandingIcon:IY,PhilippinePeso:LY,PhilippinePesoIcon:LY,Phone:Zn,PhoneCall:DY,PhoneCallIcon:DY,PhoneForwarded:OY,PhoneForwardedIcon:OY,PhoneIcon:Zn,PhoneIncoming:RY,PhoneIncomingIcon:RY,PhoneMissed:FY,PhoneMissedIcon:FY,PhoneOff:zY,PhoneOffIcon:zY,PhoneOutgoing:BY,PhoneOutgoingIcon:BY,Pi:$Y,PiIcon:$Y,PiSquare:Oj,PiSquareIcon:Oj,Piano:qY,PianoIcon:qY,Pickaxe:UY,PickaxeIcon:UY,PictureInPicture:HY,PictureInPicture2:VY,PictureInPicture2Icon:VY,PictureInPictureIcon:HY,PieChart:Mw,PieChartIcon:Mw,PiggyBank:WY,PiggyBankIcon:WY,Pilcrow:ZY,PilcrowIcon:ZY,PilcrowLeft:GY,PilcrowLeftIcon:GY,PilcrowRight:KY,PilcrowRightIcon:KY,PilcrowSquare:Rj,PilcrowSquareIcon:Rj,Pill:XY,PillBottle:YY,PillBottleIcon:YY,PillIcon:XY,Pin:a_,PinIcon:a_,PinOff:vP,PinOffIcon:vP,Pipette:QY,PipetteIcon:QY,Pizza:JY,PizzaIcon:JY,Plane:sX,PlaneIcon:sX,PlaneLanding:eX,PlaneLandingIcon:eX,PlaneTakeoff:tX,PlaneTakeoffIcon:tX,Play:ul,PlayCircle:ym,PlayCircleIcon:ym,PlayIcon:ul,PlaySquare:Fj,PlaySquareIcon:Fj,Plug:_P,Plug2:rX,Plug2Icon:rX,PlugIcon:_P,PlugZap:V2,PlugZap2:V2,PlugZap2Icon:V2,PlugZapIcon:V2,Plus:Zs,PlusCircle:Zw,PlusCircleIcon:Zw,PlusIcon:Zs,PlusSquare:zj,PlusSquareIcon:zj,Pocket:aX,PocketIcon:aX,PocketKnife:nX,PocketKnifeIcon:nX,Podcast:iX,PodcastIcon:iX,Pointer:lX,PointerIcon:lX,PointerOff:oX,PointerOffIcon:oX,Popcorn:cX,PopcornIcon:cX,Popsicle:dX,PopsicleIcon:dX,PoundSterling:uX,PoundSterlingIcon:uX,Power:bP,PowerCircle:Yw,PowerCircleIcon:Yw,PowerIcon:bP,PowerOff:hX,PowerOffIcon:hX,PowerSquare:Bj,PowerSquareIcon:Bj,Presentation:Bg,PresentationIcon:Bg,Printer:wP,PrinterCheck:mX,PrinterCheckIcon:mX,PrinterIcon:wP,Projector:pX,ProjectorIcon:pX,Proportions:fX,ProportionsIcon:fX,Puzzle:gX,PuzzleIcon:gX,Pyramid:xX,PyramidIcon:xX,QrCode:L0,QrCodeIcon:L0,Quote:_5,QuoteIcon:_5,Rabbit:yX,RabbitIcon:yX,Radar:vX,RadarIcon:vX,Radiation:_X,RadiationIcon:_X,Radical:bX,RadicalIcon:bX,Radio:lN,RadioIcon:lN,RadioReceiver:wX,RadioReceiverIcon:wX,RadioTower:jX,RadioTowerIcon:jX,Radius:kX,RadiusIcon:kX,RailSymbol:NX,RailSymbolIcon:NX,Rainbow:SX,RainbowIcon:SX,Rat:CX,RatIcon:CX,Ratio:MX,RatioIcon:MX,Receipt:RX,ReceiptCent:TX,ReceiptCentIcon:TX,ReceiptEuro:AX,ReceiptEuroIcon:AX,ReceiptIcon:RX,ReceiptIndianRupee:EX,ReceiptIndianRupeeIcon:EX,ReceiptJapaneseYen:PX,ReceiptJapaneseYenIcon:PX,ReceiptPoundSterling:IX,ReceiptPoundSterlingIcon:IX,ReceiptRussianRuble:LX,ReceiptRussianRubleIcon:LX,ReceiptSwissFranc:DX,ReceiptSwissFrancIcon:DX,ReceiptText:OX,ReceiptTextIcon:OX,RectangleEllipsis:H2,RectangleEllipsisIcon:H2,RectangleHorizontal:FX,RectangleHorizontalIcon:FX,RectangleVertical:zX,RectangleVerticalIcon:zX,Recycle:BX,RecycleIcon:BX,Redo:b5,Redo2:$X,Redo2Icon:$X,RedoDot:qX,RedoDotIcon:qX,RedoIcon:b5,RefreshCcw:VX,RefreshCcwDot:UX,RefreshCcwDotIcon:UX,RefreshCcwIcon:VX,RefreshCw:Po,RefreshCwIcon:Po,RefreshCwOff:HX,RefreshCwOffIcon:HX,Refrigerator:WX,RefrigeratorIcon:WX,Regex:GX,RegexIcon:GX,RemoveFormatting:KX,RemoveFormattingIcon:KX,Repeat:jP,Repeat1:ZX,Repeat1Icon:ZX,Repeat2:YX,Repeat2Icon:YX,RepeatIcon:jP,Replace:QX,ReplaceAll:XX,ReplaceAllIcon:XX,ReplaceIcon:QX,Reply:kP,ReplyAll:JX,ReplyAllIcon:JX,ReplyIcon:kP,Rewind:eQ,RewindIcon:eQ,Ribbon:tQ,RibbonIcon:tQ,Rocket:Gx,RocketIcon:Gx,RockingChair:sQ,RockingChairIcon:sQ,RollerCoaster:rQ,RollerCoasterIcon:rQ,Rotate3D:W2,Rotate3DIcon:W2,Rotate3d:W2,Rotate3dIcon:W2,RotateCcw:D0,RotateCcwIcon:D0,RotateCcwSquare:nQ,RotateCcwSquareIcon:nQ,RotateCw:NP,RotateCwIcon:NP,RotateCwSquare:aQ,RotateCwSquareIcon:aQ,Route:oQ,RouteIcon:oQ,RouteOff:iQ,RouteOffIcon:iQ,Router:lQ,RouterIcon:lQ,Rows:G2,Rows2:G2,Rows2Icon:G2,Rows3:K2,Rows3Icon:K2,Rows4:cQ,Rows4Icon:cQ,RowsIcon:G2,Rss:dQ,RssIcon:dQ,Ruler:SP,RulerIcon:SP,RussianRuble:uQ,RussianRubleIcon:uQ,Sailboat:hQ,SailboatIcon:hQ,Salad:mQ,SaladIcon:mQ,Sandwich:pQ,SandwichIcon:pQ,Satellite:gQ,SatelliteDish:fQ,SatelliteDishIcon:fQ,SatelliteIcon:gQ,Save:Bu,SaveAll:xQ,SaveAllIcon:xQ,SaveIcon:Bu,SaveOff:yQ,SaveOffIcon:yQ,Scale:vQ,Scale3D:Z2,Scale3DIcon:Z2,Scale3d:Z2,Scale3dIcon:Z2,ScaleIcon:vQ,Scaling:_Q,ScalingIcon:_Q,Scan:MQ,ScanBarcode:bQ,ScanBarcodeIcon:bQ,ScanEye:wQ,ScanEyeIcon:wQ,ScanFace:jQ,ScanFaceIcon:jQ,ScanIcon:MQ,ScanLine:kQ,ScanLineIcon:kQ,ScanQrCode:NQ,ScanQrCodeIcon:NQ,ScanSearch:SQ,ScanSearchIcon:SQ,ScanText:CQ,ScanTextIcon:CQ,ScatterChart:Tw,ScatterChartIcon:Tw,School:TQ,School2:tk,School2Icon:tk,SchoolIcon:TQ,Scissors:EQ,ScissorsIcon:EQ,ScissorsLineDashed:AQ,ScissorsLineDashedIcon:AQ,ScissorsSquare:$j,ScissorsSquareDashedBottom:mj,ScissorsSquareDashedBottomIcon:mj,ScissorsSquareIcon:$j,ScreenShare:IQ,ScreenShareIcon:IQ,ScreenShareOff:PQ,ScreenShareOffIcon:PQ,Scroll:DQ,ScrollIcon:DQ,ScrollText:LQ,ScrollTextIcon:LQ,Search:fn,SearchCheck:OQ,SearchCheckIcon:OQ,SearchCode:RQ,SearchCodeIcon:RQ,SearchIcon:fn,SearchSlash:FQ,SearchSlashIcon:FQ,SearchX:CP,SearchXIcon:CP,Section:zQ,SectionIcon:zQ,Send:ka,SendHorizonal:Y2,SendHorizonalIcon:Y2,SendHorizontal:Y2,SendHorizontalIcon:Y2,SendIcon:ka,SendToBack:BQ,SendToBackIcon:BQ,SeparatorHorizontal:$Q,SeparatorHorizontalIcon:$Q,SeparatorVertical:qQ,SeparatorVerticalIcon:qQ,Server:WQ,ServerCog:UQ,ServerCogIcon:UQ,ServerCrash:VQ,ServerCrashIcon:VQ,ServerIcon:WQ,ServerOff:HQ,ServerOffIcon:HQ,Settings:$l,Settings2:MP,Settings2Icon:MP,SettingsIcon:$l,Shapes:GQ,ShapesIcon:GQ,Share:TP,Share2:cd,Share2Icon:cd,ShareIcon:TP,Sheet:KQ,SheetIcon:KQ,Shell:ZQ,ShellIcon:ZQ,Shield:rh,ShieldAlert:YQ,ShieldAlertIcon:YQ,ShieldBan:XQ,ShieldBanIcon:XQ,ShieldCheck:AP,ShieldCheckIcon:AP,ShieldClose:X2,ShieldCloseIcon:X2,ShieldEllipsis:QQ,ShieldEllipsisIcon:QQ,ShieldHalf:JQ,ShieldHalfIcon:JQ,ShieldIcon:rh,ShieldMinus:eJ,ShieldMinusIcon:eJ,ShieldOff:tJ,ShieldOffIcon:tJ,ShieldPlus:sJ,ShieldPlusIcon:sJ,ShieldQuestion:rJ,ShieldQuestionIcon:rJ,ShieldX:X2,ShieldXIcon:X2,Ship:aJ,ShipIcon:aJ,ShipWheel:nJ,ShipWheelIcon:nJ,Shirt:iJ,ShirtIcon:iJ,ShoppingBag:Kx,ShoppingBagIcon:Kx,ShoppingBasket:oJ,ShoppingBasketIcon:oJ,ShoppingCart:km,ShoppingCartIcon:km,Shovel:lJ,ShovelIcon:lJ,ShowerHead:cJ,ShowerHeadIcon:cJ,Shrink:dJ,ShrinkIcon:dJ,Shrub:uJ,ShrubIcon:uJ,Shuffle:cN,ShuffleIcon:cN,Sidebar:$2,SidebarClose:F2,SidebarCloseIcon:F2,SidebarIcon:$2,SidebarOpen:B2,SidebarOpenIcon:B2,Sigma:hJ,SigmaIcon:hJ,SigmaSquare:qj,SigmaSquareIcon:qj,Signal:xJ,SignalHigh:mJ,SignalHighIcon:mJ,SignalIcon:xJ,SignalLow:pJ,SignalLowIcon:pJ,SignalMedium:fJ,SignalMediumIcon:fJ,SignalZero:gJ,SignalZeroIcon:gJ,Signature:yJ,SignatureIcon:yJ,Signpost:_J,SignpostBig:vJ,SignpostBigIcon:vJ,SignpostIcon:_J,Siren:bJ,SirenIcon:bJ,SkipBack:wJ,SkipBackIcon:wJ,SkipForward:jJ,SkipForwardIcon:jJ,Skull:kJ,SkullIcon:kJ,Slack:NJ,SlackIcon:NJ,Slash:SJ,SlashIcon:SJ,SlashSquare:Uj,SlashSquareIcon:Uj,Slice:CJ,SliceIcon:CJ,Sliders:Q2,SlidersHorizontal:EP,SlidersHorizontalIcon:EP,SlidersIcon:Q2,SlidersVertical:Q2,SlidersVerticalIcon:Q2,Smartphone:O0,SmartphoneCharging:MJ,SmartphoneChargingIcon:MJ,SmartphoneIcon:O0,SmartphoneNfc:TJ,SmartphoneNfcIcon:TJ,Smile:EJ,SmileIcon:EJ,SmilePlus:AJ,SmilePlusIcon:AJ,Snail:PJ,SnailIcon:PJ,Snowflake:D1,SnowflakeIcon:D1,Sofa:IJ,SofaIcon:IJ,SortAsc:cw,SortAscIcon:cw,SortDesc:iw,SortDescIcon:iw,Soup:LJ,SoupIcon:LJ,Space:DJ,SpaceIcon:DJ,Spade:OJ,SpadeIcon:OJ,Sparkle:RJ,SparkleIcon:RJ,Sparkles:hn,SparklesIcon:hn,Speaker:FJ,SpeakerIcon:FJ,Speech:zJ,SpeechIcon:zJ,SpellCheck:$J,SpellCheck2:BJ,SpellCheck2Icon:BJ,SpellCheckIcon:$J,Spline:qJ,SplineIcon:qJ,Split:UJ,SplitIcon:UJ,SplitSquareHorizontal:Vj,SplitSquareHorizontalIcon:Vj,SplitSquareVertical:Hj,SplitSquareVerticalIcon:Hj,SprayCan:VJ,SprayCanIcon:VJ,Sprout:HJ,SproutIcon:HJ,Square:Zx,SquareActivity:J2,SquareActivityIcon:J2,SquareArrowDown:sj,SquareArrowDownIcon:sj,SquareArrowDownLeft:ej,SquareArrowDownLeftIcon:ej,SquareArrowDownRight:tj,SquareArrowDownRightIcon:tj,SquareArrowLeft:rj,SquareArrowLeftIcon:rj,SquareArrowOutDownLeft:nj,SquareArrowOutDownLeftIcon:nj,SquareArrowOutDownRight:aj,SquareArrowOutDownRightIcon:aj,SquareArrowOutUpLeft:ij,SquareArrowOutUpLeftIcon:ij,SquareArrowOutUpRight:oj,SquareArrowOutUpRightIcon:oj,SquareArrowRight:lj,SquareArrowRightIcon:lj,SquareArrowUp:uj,SquareArrowUpIcon:uj,SquareArrowUpLeft:cj,SquareArrowUpLeftIcon:cj,SquareArrowUpRight:dj,SquareArrowUpRightIcon:dj,SquareAsterisk:hj,SquareAsteriskIcon:hj,SquareBottomDashedScissors:mj,SquareBottomDashedScissorsIcon:mj,SquareChartGantt:jx,SquareChartGanttIcon:jx,SquareCheck:pj,SquareCheckBig:d0,SquareCheckBigIcon:d0,SquareCheckIcon:pj,SquareChevronDown:fj,SquareChevronDownIcon:fj,SquareChevronLeft:gj,SquareChevronLeftIcon:gj,SquareChevronRight:xj,SquareChevronRightIcon:xj,SquareChevronUp:yj,SquareChevronUpIcon:yj,SquareCode:vj,SquareCodeIcon:vj,SquareDashed:wj,SquareDashedBottom:GJ,SquareDashedBottomCode:WJ,SquareDashedBottomCodeIcon:WJ,SquareDashedBottomIcon:GJ,SquareDashedIcon:wj,SquareDashedKanban:_j,SquareDashedKanbanIcon:_j,SquareDashedMousePointer:bj,SquareDashedMousePointerIcon:bj,SquareDivide:jj,SquareDivideIcon:jj,SquareDot:kj,SquareDotIcon:kj,SquareEqual:Nj,SquareEqualIcon:Nj,SquareFunction:Sj,SquareFunctionIcon:Sj,SquareGanttChart:jx,SquareGanttChartIcon:jx,SquareIcon:Zx,SquareKanban:Cj,SquareKanbanIcon:Cj,SquareLibrary:Mj,SquareLibraryIcon:Mj,SquareM:Tj,SquareMIcon:Tj,SquareMenu:Aj,SquareMenuIcon:Aj,SquareMinus:Ej,SquareMinusIcon:Ej,SquareMousePointer:Pj,SquareMousePointerIcon:Pj,SquareParking:Lj,SquareParkingIcon:Lj,SquareParkingOff:Ij,SquareParkingOffIcon:Ij,SquarePen:Oc,SquarePenIcon:Oc,SquarePercent:Dj,SquarePercentIcon:Dj,SquarePi:Oj,SquarePiIcon:Oj,SquarePilcrow:Rj,SquarePilcrowIcon:Rj,SquarePlay:Fj,SquarePlayIcon:Fj,SquarePlus:zj,SquarePlusIcon:zj,SquarePower:Bj,SquarePowerIcon:Bj,SquareRadical:KJ,SquareRadicalIcon:KJ,SquareScissors:$j,SquareScissorsIcon:$j,SquareSigma:qj,SquareSigmaIcon:qj,SquareSlash:Uj,SquareSlashIcon:Uj,SquareSplitHorizontal:Vj,SquareSplitHorizontalIcon:Vj,SquareSplitVertical:Hj,SquareSplitVerticalIcon:Hj,SquareSquare:ZJ,SquareSquareIcon:ZJ,SquareStack:YJ,SquareStackIcon:YJ,SquareTerminal:Wj,SquareTerminalIcon:Wj,SquareUser:Kj,SquareUserIcon:Kj,SquareUserRound:Gj,SquareUserRoundIcon:Gj,SquareX:Zj,SquareXIcon:Zj,Squircle:XJ,SquircleIcon:XJ,Squirrel:QJ,SquirrelIcon:QJ,Stamp:JJ,StampIcon:JJ,Star:Gn,StarHalf:eee,StarHalfIcon:eee,StarIcon:Gn,StarOff:tee,StarOffIcon:tee,Stars:hn,StarsIcon:hn,StepBack:see,StepBackIcon:see,StepForward:ree,StepForwardIcon:ree,Stethoscope:nee,StethoscopeIcon:nee,Sticker:aee,StickerIcon:aee,StickyNote:iee,StickyNoteIcon:iee,StopCircle:Qw,StopCircleIcon:Qw,Store:oee,StoreIcon:oee,StretchHorizontal:lee,StretchHorizontalIcon:lee,StretchVertical:cee,StretchVerticalIcon:cee,Strikethrough:dee,StrikethroughIcon:dee,Subscript:uee,SubscriptIcon:uee,Subtitles:xw,SubtitlesIcon:xw,Sun:i_,SunDim:hee,SunDimIcon:hee,SunIcon:i_,SunMedium:mee,SunMediumIcon:mee,SunMoon:pee,SunMoonIcon:pee,SunSnow:fee,SunSnowIcon:fee,Sunrise:gee,SunriseIcon:gee,Sunset:xee,SunsetIcon:xee,Superscript:yee,SuperscriptIcon:yee,SwatchBook:vee,SwatchBookIcon:vee,SwissFranc:_ee,SwissFrancIcon:_ee,SwitchCamera:bee,SwitchCameraIcon:bee,Sword:wee,SwordIcon:wee,Swords:jee,SwordsIcon:jee,Syringe:kee,SyringeIcon:kee,Table:PP,Table2:w5,Table2Icon:w5,TableCellsMerge:Nee,TableCellsMergeIcon:Nee,TableCellsSplit:See,TableCellsSplitIcon:See,TableColumnsSplit:Cee,TableColumnsSplitIcon:Cee,TableIcon:PP,TableOfContents:Mee,TableOfContentsIcon:Mee,TableProperties:Tee,TablePropertiesIcon:Tee,TableRowsSplit:Aee,TableRowsSplitIcon:Aee,Tablet:Pee,TabletIcon:Pee,TabletSmartphone:Eee,TabletSmartphoneIcon:Eee,Tablets:Iee,TabletsIcon:Iee,Tag:Vh,TagIcon:Vh,Tags:Lee,TagsIcon:Lee,Tally1:Dee,Tally1Icon:Dee,Tally2:Oee,Tally2Icon:Oee,Tally3:Ree,Tally3Icon:Ree,Tally4:Fee,Tally4Icon:Fee,Tally5:zee,Tally5Icon:zee,Tangent:Bee,TangentIcon:Bee,Target:Hh,TargetIcon:Hh,Telescope:$ee,TelescopeIcon:$ee,Tent:Uee,TentIcon:Uee,TentTree:qee,TentTreeIcon:qee,Terminal:Vee,TerminalIcon:Vee,TerminalSquare:Wj,TerminalSquareIcon:Wj,TestTube:Hee,TestTube2:Yj,TestTube2Icon:Yj,TestTubeDiagonal:Yj,TestTubeDiagonalIcon:Yj,TestTubeIcon:Hee,TestTubes:Wee,TestTubesIcon:Wee,Text:Xee,TextCursor:Kee,TextCursorIcon:Kee,TextCursorInput:Gee,TextCursorInputIcon:Gee,TextIcon:Xee,TextQuote:Zee,TextQuoteIcon:Zee,TextSearch:Yee,TextSearchIcon:Yee,TextSelect:Xj,TextSelectIcon:Xj,TextSelection:Xj,TextSelectionIcon:Xj,Theater:Qee,TheaterIcon:Qee,Thermometer:tte,ThermometerIcon:tte,ThermometerSnowflake:Jee,ThermometerSnowflakeIcon:Jee,ThermometerSun:ete,ThermometerSunIcon:ete,ThumbsDown:IP,ThumbsDownIcon:IP,ThumbsUp:pu,ThumbsUpIcon:pu,Ticket:LP,TicketCheck:ste,TicketCheckIcon:ste,TicketIcon:LP,TicketMinus:rte,TicketMinusIcon:rte,TicketPercent:nte,TicketPercentIcon:nte,TicketPlus:ate,TicketPlusIcon:ate,TicketSlash:ite,TicketSlashIcon:ite,TicketX:ote,TicketXIcon:ote,Tickets:cte,TicketsIcon:cte,TicketsPlane:lte,TicketsPlaneIcon:lte,Timer:hte,TimerIcon:hte,TimerOff:dte,TimerOffIcon:dte,TimerReset:ute,TimerResetIcon:ute,ToggleLeft:mte,ToggleLeftIcon:mte,ToggleRight:pte,ToggleRightIcon:pte,Toilet:fte,ToiletIcon:fte,Tornado:gte,TornadoIcon:gte,Torus:xte,TorusIcon:xte,Touchpad:vte,TouchpadIcon:vte,TouchpadOff:yte,TouchpadOffIcon:yte,TowerControl:_te,TowerControlIcon:_te,ToyBrick:bte,ToyBrickIcon:bte,Tractor:wte,TractorIcon:wte,TrafficCone:jte,TrafficConeIcon:jte,Train:Qj,TrainFront:Nte,TrainFrontIcon:Nte,TrainFrontTunnel:kte,TrainFrontTunnelIcon:kte,TrainIcon:Qj,TrainTrack:Ste,TrainTrackIcon:Ste,TramFront:Qj,TramFrontIcon:Qj,Trash:Cte,Trash2:br,Trash2Icon:br,TrashIcon:Cte,TreeDeciduous:Mte,TreeDeciduousIcon:Mte,TreePalm:Jj,TreePalmIcon:Jj,TreePine:o_,TreePineIcon:o_,Trees:Tte,TreesIcon:Tte,Trello:Ate,TrelloIcon:Ate,TrendingDown:dN,TrendingDownIcon:dN,TrendingUp:Cc,TrendingUpDown:Ete,TrendingUpDownIcon:Ete,TrendingUpIcon:Cc,Triangle:Ite,TriangleAlert:Th,TriangleAlertIcon:Th,TriangleIcon:Ite,TriangleRight:Pte,TriangleRightIcon:Pte,Trophy:Ki,TrophyIcon:Ki,Truck:DP,TruckIcon:DP,Turtle:Lte,TurtleIcon:Lte,Tv:Ote,Tv2:ek,Tv2Icon:ek,TvIcon:Ote,TvMinimal:ek,TvMinimalIcon:ek,TvMinimalPlay:Dte,TvMinimalPlayIcon:Dte,Twitch:Rte,TwitchIcon:Rte,Twitter:Fte,TwitterIcon:Fte,Type:Bte,TypeIcon:Bte,TypeOutline:zte,TypeOutlineIcon:zte,Umbrella:qte,UmbrellaIcon:qte,UmbrellaOff:$te,UmbrellaOffIcon:$te,Underline:Ute,UnderlineIcon:Ute,Undo:j5,Undo2:Vte,Undo2Icon:Vte,UndoDot:Hte,UndoDotIcon:Hte,UndoIcon:j5,UnfoldHorizontal:Wte,UnfoldHorizontalIcon:Wte,UnfoldVertical:Gte,UnfoldVerticalIcon:Gte,Ungroup:Kte,UngroupIcon:Kte,University:tk,UniversityIcon:tk,Unlink:uN,Unlink2:Zte,Unlink2Icon:Zte,UnlinkIcon:uN,Unlock:E2,UnlockIcon:E2,UnlockKeyhole:A2,UnlockKeyholeIcon:A2,Unplug:Yte,UnplugIcon:Yte,Upload:Ya,UploadCloud:n2,UploadCloudIcon:n2,UploadIcon:Ya,Usb:Xte,UsbIcon:Xte,User:Xi,User2:ok,User2Icon:ok,UserCheck:l_,UserCheck2:sk,UserCheck2Icon:sk,UserCheckIcon:l_,UserCircle:e2,UserCircle2:Jw,UserCircle2Icon:Jw,UserCircleIcon:e2,UserCog:OP,UserCog2:rk,UserCog2Icon:rk,UserCogIcon:OP,UserIcon:Xi,UserMinus:RP,UserMinus2:nk,UserMinus2Icon:nk,UserMinusIcon:RP,UserPen:Qte,UserPenIcon:Qte,UserPlus:xc,UserPlus2:ak,UserPlus2Icon:ak,UserPlusIcon:xc,UserRound:ok,UserRoundCheck:sk,UserRoundCheckIcon:sk,UserRoundCog:rk,UserRoundCogIcon:rk,UserRoundIcon:ok,UserRoundMinus:nk,UserRoundMinusIcon:nk,UserRoundPen:Jte,UserRoundPenIcon:Jte,UserRoundPlus:ak,UserRoundPlusIcon:ak,UserRoundSearch:ese,UserRoundSearchIcon:ese,UserRoundX:ik,UserRoundXIcon:ik,UserSearch:tse,UserSearchIcon:tse,UserSquare:Kj,UserSquare2:Gj,UserSquare2Icon:Gj,UserSquareIcon:Kj,UserX:sse,UserX2:ik,UserX2Icon:ik,UserXIcon:sse,Users:hr,Users2:lk,Users2Icon:lk,UsersIcon:hr,UsersRound:lk,UsersRoundIcon:lk,Utensils:dk,UtensilsCrossed:ck,UtensilsCrossedIcon:ck,UtensilsIcon:dk,UtilityPole:rse,UtilityPoleIcon:rse,Variable:FP,VariableIcon:FP,Vault:nse,VaultIcon:nse,Vegan:ase,VeganIcon:ase,VenetianMask:ise,VenetianMaskIcon:ise,Verified:hw,VerifiedIcon:hw,Vibrate:lse,VibrateIcon:lse,VibrateOff:ose,VibrateOffIcon:ose,Video:kn,VideoIcon:kn,VideoOff:cse,VideoOffIcon:cse,Videotape:dse,VideotapeIcon:dse,View:use,ViewIcon:use,Voicemail:hse,VoicemailIcon:hse,Volleyball:mse,VolleyballIcon:mse,Volume:yse,Volume1:pse,Volume1Icon:pse,Volume2:fse,Volume2Icon:fse,VolumeIcon:yse,VolumeOff:gse,VolumeOffIcon:gse,VolumeX:xse,VolumeXIcon:xse,Vote:vse,VoteIcon:vse,Wallet:zP,Wallet2:uk,Wallet2Icon:uk,WalletCards:_se,WalletCardsIcon:_se,WalletIcon:zP,WalletMinimal:uk,WalletMinimalIcon:uk,Wallpaper:bse,WallpaperIcon:bse,Wand:wse,Wand2:u0,Wand2Icon:u0,WandIcon:wse,WandSparkles:u0,WandSparklesIcon:u0,Warehouse:jse,WarehouseIcon:jse,WashingMachine:kse,WashingMachineIcon:kse,Watch:Nse,WatchIcon:Nse,Waves:Sse,WavesIcon:Sse,Waypoints:Cse,WaypointsIcon:Cse,Webcam:Mse,WebcamIcon:Mse,Webhook:Ase,WebhookIcon:Ase,WebhookOff:Tse,WebhookOffIcon:Tse,Weight:Ese,WeightIcon:Ese,Wheat:Ise,WheatIcon:Ise,WheatOff:Pse,WheatOffIcon:Pse,WholeWord:Lse,WholeWordIcon:Lse,Wifi:zse,WifiHigh:Dse,WifiHighIcon:Dse,WifiIcon:zse,WifiLow:Ose,WifiLowIcon:Ose,WifiOff:Rse,WifiOffIcon:Rse,WifiZero:Fse,WifiZeroIcon:Fse,Wind:$se,WindArrowDown:Bse,WindArrowDownIcon:Bse,WindIcon:$se,Wine:Use,WineIcon:Use,WineOff:qse,WineOffIcon:qse,Workflow:Vse,WorkflowIcon:Vse,Worm:Hse,WormIcon:Hse,WrapText:Wse,WrapTextIcon:Wse,Wrench:$g,WrenchIcon:$g,X:Ur,XCircle:kc,XCircleIcon:kc,XIcon:Ur,XOctagon:D2,XOctagonIcon:D2,XSquare:Zj,XSquareIcon:Zj,Youtube:Gse,YoutubeIcon:Gse,Zap:Dm,ZapIcon:Dm,ZapOff:Kse,ZapOffIcon:Kse,ZoomIn:c_,ZoomInIcon:c_,ZoomOut:k5,ZoomOutIcon:k5,createLucideIcon:Z,icons:Pot},Symbol.toStringTag,{value:"Module"})),Qve="-",Iot=t=>{const s=Dot(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:l=>{const i=l.split(Qve);return i[0]===""&&i.length!==1&&i.shift(),pRe(i,s)||Lot(l)},getConflictingClassGroupIds:(l,i)=>{const d=r[l]||[];return i&&n[l]?[...d,...n[l]]:d}}},pRe=(t,s)=>{var l;if(t.length===0)return s.classGroupId;const r=t[0],n=s.nextPart.get(r),a=n?pRe(t.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=t.join(Qve);return(l=s.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},s4e=/^\[(.+)\]$/,Lot=t=>{if(s4e.test(t)){const s=s4e.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},Dot=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return Rot(Object.entries(t.classGroups),r).forEach(([o,l])=>{Pfe(l,n,o,s)}),n},Pfe=(t,s,r,n)=>{t.forEach(a=>{if(typeof a=="string"){const o=a===""?s:r4e(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(Oot(a)){Pfe(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{Pfe(l,r4e(s,o),r,n)})})},r4e=(t,s)=>{let r=t;return s.split(Qve).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},Oot=t=>t.isThemeGetter,Rot=(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,Fot=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)}}},fRe="!",zot=t=>{const{separator:s,experimentalParseClassName:r}=t,n=s.length===1,a=s[0],o=s.length,l=i=>{const d=[];let u=0,p=0,f;for(let w=0;wp?f-p:void 0;return{modifiers:d,hasImportantModifier:_,baseClassName:b,maybePostfixModifierPosition:j}};return r?i=>r({className:i,parseClassName:l}):l},Bot=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:Fot(t.cacheSize),parseClassName:zot(t),...Iot(t)}),qot=/\s+/,Uot=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(qot);let i="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{modifiers:p,hasImportantModifier:f,baseClassName:v,maybePostfixModifierPosition:_}=r(u);let b=!!_,j=n(b?v.substring(0,_):v);if(!j){if(!b){i=u+(i.length>0?" "+i:i);continue}if(j=n(v),!j){i=u+(i.length>0?" "+i:i);continue}b=!1}const w=Bot(p).join(":"),N=f?w+fRe:w,C=N+j;if(o.includes(C))continue;o.push(C);const A=a(j,b);for(let I=0;I0?" "+i:i)}return i};function Vot(){let t=0,s,r,n="";for(;t{if(typeof t=="string")return t;let s,r="";for(let n=0;nf(p),t());return r=$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 p=Uot(d,r);return a(d,p),p}return function(){return o(Vot.apply(null,arguments))}}const Kl=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},xRe=/^\[(?:([a-z-]+):)?(.+)\]$/i,Wot=/^\d+\/\d+$/,Got=new Set(["px","full","screen"]),Kot=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Zot=/\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$/,Yot=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Xot=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Qot=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Vy=t=>N5(t)||Got.has(t)||Wot.test(t),Wv=t=>nM(t,"length",ilt),N5=t=>!!t&&!Number.isNaN(Number(t)),ohe=t=>nM(t,"number",N5),HA=t=>!!t&&Number.isInteger(Number(t)),Jot=t=>t.endsWith("%")&&N5(t.slice(0,-1)),Ri=t=>xRe.test(t),Gv=t=>Kot.test(t),elt=new Set(["length","size","percentage"]),tlt=t=>nM(t,elt,yRe),slt=t=>nM(t,"position",yRe),rlt=new Set(["image","url"]),nlt=t=>nM(t,rlt,llt),alt=t=>nM(t,"",olt),WA=()=>!0,nM=(t,s,r)=>{const n=xRe.exec(t);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},ilt=t=>Zot.test(t)&&!Yot.test(t),yRe=()=>!1,olt=t=>Xot.test(t),llt=t=>Qot.test(t),clt=()=>{const t=Kl("colors"),s=Kl("spacing"),r=Kl("blur"),n=Kl("brightness"),a=Kl("borderColor"),o=Kl("borderRadius"),l=Kl("borderSpacing"),i=Kl("borderWidth"),d=Kl("contrast"),u=Kl("grayscale"),p=Kl("hueRotate"),f=Kl("invert"),v=Kl("gap"),_=Kl("gradientColorStops"),b=Kl("gradientColorStopPositions"),j=Kl("inset"),w=Kl("margin"),N=Kl("opacity"),C=Kl("padding"),A=Kl("saturate"),I=Kl("scale"),L=Kl("sepia"),R=Kl("skew"),$=Kl("space"),q=Kl("translate"),U=()=>["auto","contain","none"],V=()=>["auto","hidden","clip","visible","scroll"],X=()=>["auto",Ri,s],se=()=>[Ri,s],te=()=>["",Vy,Wv],Y=()=>["auto",N5,Ri],de=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ie=()=>["solid","dashed","dotted","double","none"],ae=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>["start","end","center","between","around","evenly","stretch"],pe=()=>["","0",Ri],be=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ye=()=>[N5,Ri];return{cacheSize:500,separator:":",theme:{colors:[WA],spacing:[Vy,Wv],blur:["none","",Gv,Ri],brightness:ye(),borderColor:[t],borderRadius:["none","","full",Gv,Ri],borderSpacing:se(),borderWidth:te(),contrast:ye(),grayscale:pe(),hueRotate:ye(),invert:pe(),gap:se(),gradientColorStops:[t],gradientColorStopPositions:[Jot,Wv],inset:X(),margin:X(),opacity:ye(),padding:se(),saturate:ye(),scale:ye(),sepia:pe(),skew:ye(),space:se(),translate:se()},classGroups:{aspect:[{aspect:["auto","square","video",Ri]}],container:["container"],columns:[{columns:[Gv]}],"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:[...de(),Ri]}],overflow:[{overflow:V()}],"overflow-x":[{"overflow-x":V()}],"overflow-y":[{"overflow-y":V()}],overscroll:[{overscroll:U()}],"overscroll-x":[{"overscroll-x":U()}],"overscroll-y":[{"overscroll-y":U()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[j]}],"inset-x":[{"inset-x":[j]}],"inset-y":[{"inset-y":[j]}],start:[{start:[j]}],end:[{end:[j]}],top:[{top:[j]}],right:[{right:[j]}],bottom:[{bottom:[j]}],left:[{left:[j]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",HA,Ri]}],basis:[{basis:X()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Ri]}],grow:[{grow:pe()}],shrink:[{shrink:pe()}],order:[{order:["first","last","none",HA,Ri]}],"grid-cols":[{"grid-cols":[WA]}],"col-start-end":[{col:["auto",{span:["full",HA,Ri]},Ri]}],"col-start":[{"col-start":Y()}],"col-end":[{"col-end":Y()}],"grid-rows":[{"grid-rows":[WA]}],"row-start-end":[{row:["auto",{span:[HA,Ri]},Ri]}],"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",Ri]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Ri]}],gap:[{gap:[v]}],"gap-x":[{"gap-x":[v]}],"gap-y":[{"gap-y":[v]}],"justify-content":[{justify:["normal",...le()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...le(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...le(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[C]}],px:[{px:[C]}],py:[{py:[C]}],ps:[{ps:[C]}],pe:[{pe:[C]}],pt:[{pt:[C]}],pr:[{pr:[C]}],pb:[{pb:[C]}],pl:[{pl:[C]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[$]}],"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",Ri,s]}],"min-w":[{"min-w":[Ri,s,"min","max","fit"]}],"max-w":[{"max-w":[Ri,s,"none","full","min","max","fit","prose",{screen:[Gv]},Gv]}],h:[{h:[Ri,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Ri,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Ri,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Ri,s,"auto","min","max","fit"]}],"font-size":[{text:["base",Gv,Wv]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",ohe]}],"font-family":[{font:[WA]}],"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",Ri]}],"line-clamp":[{"line-clamp":["none",N5,ohe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Vy,Ri]}],"list-image":[{"list-image":["none",Ri]}],"list-style-type":[{list:["none","disc","decimal",Ri]}],"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:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Vy,Wv]}],"underline-offset":[{"underline-offset":["auto",Vy,Ri]}],"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",Ri]}],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",Ri]}],"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:[...de(),slt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",tlt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},nlt]}],"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:[...ie(),"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:ie()}],"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:["",...ie()]}],"outline-offset":[{"outline-offset":[Vy,Ri]}],"outline-w":[{outline:[Vy,Wv]}],"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":[Vy,Wv]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Gv,alt]}],"shadow-color":[{shadow:[WA]}],opacity:[{opacity:[N]}],"mix-blend":[{"mix-blend":[...ae(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ae()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",Gv,Ri]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[f]}],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":[p]}],"backdrop-invert":[{"backdrop-invert":[f]}],"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",Ri]}],duration:[{duration:ye()}],ease:[{ease:["linear","in","out","in-out",Ri]}],delay:[{delay:ye()}],animate:[{animate:["none","spin","ping","pulse","bounce",Ri]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[I]}],"scale-x":[{"scale-x":[I]}],"scale-y":[{"scale-y":[I]}],rotate:[{rotate:[HA,Ri]}],"translate-x":[{"translate-x":[q]}],"translate-y":[{"translate-y":[q]}],"skew-x":[{"skew-x":[R]}],"skew-y":[{"skew-y":[R]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Ri]}],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",Ri]}],"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",Ri]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Vy,Wv,ohe]}],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"]}}},dlt=Hot(clt);function Pt(...t){return dlt(zi(t))}function Tl(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 n4e(t){const s=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(s)}function Qie(t){return t?t.replace(/<[^>]*>/g,""):""}const ult=Tot,vRe=S.forwardRef(({className:t,...s},r)=>e.jsx(aRe,{ref:r,className:Pt("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...s}));vRe.displayName=aRe.displayName;const hlt=XN("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"}}),_Re=S.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(iRe,{ref:n,className:Pt(hlt({variant:s}),t),...r}));_Re.displayName=iRe.displayName;const mlt=S.forwardRef(({className:t,...s},r)=>e.jsx(cRe,{ref:r,className:Pt("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",t),...s}));mlt.displayName=cRe.displayName;const bRe=S.forwardRef(({className:t,...s},r)=>e.jsx(dRe,{ref:r,className:Pt("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...s,children:e.jsx(Ur,{className:"h-4 w-4"})}));bRe.displayName=dRe.displayName;const wRe=S.forwardRef(({className:t,...s},r)=>e.jsx(oRe,{ref:r,className:Pt("text-sm font-semibold",t),...s}));wRe.displayName=oRe.displayName;const jRe=S.forwardRef(({className:t,...s},r)=>e.jsx(lRe,{ref:r,className:Pt("text-sm opacity-90",t),...s}));jRe.displayName=lRe.displayName;function plt(){const{toasts:t}=Ia();return e.jsxs(ult,{children:[t.map(function({id:s,title:r,description:n,action:a,...o}){return e.jsxs(_Re,{...o,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(wRe,{children:r}),n&&e.jsx(jRe,{children:n})]}),a,e.jsx(bRe,{})]},s)}),e.jsx(vRe,{})]})}var a4e=["light","dark"],flt="(prefers-color-scheme: dark)",glt=S.createContext(void 0),xlt={setTheme:t=>{},themes:[]},ylt=()=>{var t;return(t=S.useContext(glt))!=null?t:xlt};S.memo(({forcedTheme:t,storageKey:s,attribute:r,enableSystem:n,enableColorScheme:a,defaultTheme:o,value:l,attrs:i,nonce:d})=>{let u=o==="system",p=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${i.map(b=>`'${b}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,f=a?a4e.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,j=!1,w=!0)=>{let N=l?l[b]:b,C=j?b+"|| ''":`'${N}'`,A="";return a&&w&&!j&&a4e.includes(b)&&(A+=`d.style.colorScheme = '${b}';`),r==="class"?j||N?A+=`c.add(${C})`:A+="null":N&&(A+=`d[s](n,${C})`),A},_=t?`!function(){${p}${v(t)}}()`:n?`!function(){try{${p}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${u})){var t='${flt}',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)+"}"}${f}}catch(e){}}()`:`!function(){try{${p}var e=localStorage.getItem('${s}');if(e){${l?`var x=${JSON.stringify(l)};`:""}${v(l?"x[e]":"e",!0)}}else{${v(o,!1,!1)};}${f}}catch(t){}}();`;return S.createElement("script",{nonce:d,dangerouslySetInnerHTML:{__html:_}})});var vlt=t=>{switch(t){case"success":return wlt;case"info":return klt;case"warning":return jlt;case"error":return Nlt;default:return null}},_lt=Array(12).fill(0),blt=({visible:t,className:s})=>mt.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},mt.createElement("div",{className:"sonner-spinner"},_lt.map((r,n)=>mt.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),wlt=mt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},mt.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"})),jlt=mt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},mt.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"})),klt=mt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},mt.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=mt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},mt.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"})),Slt=mt.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"},mt.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),mt.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Clt=()=>{let[t,s]=mt.useState(document.hidden);return mt.useEffect(()=>{let r=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},Ife=1,Mlt=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:Ife++,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],mt.isValidElement(d))a=!1,this.create({id:r,type:"default",message:d});else if(Alt(d)&&!d.ok){a=!1;let u=typeof s.error=="function"?await s.error(`HTTP error! status: ${d.status}`):s.error,p=typeof s.description=="function"?await s.description(`HTTP error! status: ${d.status}`):s.description;this.create({id:r,type:"error",message:u,description:p})}else if(s.success!==void 0){a=!1;let u=typeof s.success=="function"?await s.success(d):s.success,p=typeof s.description=="function"?await s.description(d):s.description;this.create({id:r,type:"success",message:u,description:p})}}).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,p=typeof s.description=="function"?await s.description(d):s.description;this.create({id:r,type:"error",message:u,description:p})}}).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)||Ife++;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}},gm=new Mlt,Tlt=(t,s)=>{let r=(s==null?void 0:s.id)||Ife++;return gm.addToast({title:t,...s,id:r}),r},Alt=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",Elt=Tlt,Plt=()=>gm.toasts,Ilt=()=>gm.getActiveToasts(),fe=Object.assign(Elt,{success:gm.success,info:gm.info,warning:gm.warning,error:gm.error,custom:gm.custom,message:gm.message,promise:gm.promise,dismiss:gm.dismiss,loading:gm.loading},{getHistory:Plt,getToasts:Ilt});function Llt(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))}Llt(`: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 g8(t){return t.label!==void 0}var Dlt=3,Olt="32px",Rlt="16px",i4e=4e3,Flt=356,zlt=14,Blt=20,$lt=200;function lg(...t){return t.filter(Boolean).join(" ")}function qlt(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var Ult=t=>{var s,r,n,a,o,l,i,d,u,p,f;let{invert:v,toast:_,unstyled:b,interacting:j,setHeights:w,visibleToasts:N,heights:C,index:A,toasts:I,expanded:L,removeToast:R,defaultRichColors:$,closeButton:q,style:U,cancelButtonStyle:V,actionButtonStyle:X,className:se="",descriptionClassName:te="",duration:Y,position:de,gap:ie,loadingIcon:ae,expandByDefault:le,classNames:pe,icons:be,closeButtonAriaLabel:ye="Close toast",pauseWhenPageIsHidden:we}=t,[ke,Ze]=mt.useState(null),[_e,Ce]=mt.useState(null),[Te,Fe]=mt.useState(!1),[Ae,We]=mt.useState(!1),[ht,De]=mt.useState(!1),[Dt,he]=mt.useState(!1),[Qe,ot]=mt.useState(!1),[rt,Ne]=mt.useState(0),[it,qe]=mt.useState(0),Xe=mt.useRef(_.duration||Y||i4e),$e=mt.useRef(null),Ke=mt.useRef(null),ct=A===0,Ue=A+1<=N,Ve=_.type,Je=_.dismissible!==!1,Rt=_.className||"",$t=_.descriptionClassName||"",ls=mt.useMemo(()=>C.findIndex(Nn=>Nn.toastId===_.id)||0,[C,_.id]),Qt=mt.useMemo(()=>{var Nn;return(Nn=_.closeButton)!=null?Nn:q},[_.closeButton,q]),rs=mt.useMemo(()=>_.duration||Y||i4e,[_.duration,Y]),as=mt.useRef(0),ir=mt.useRef(0),vt=mt.useRef(0),Cs=mt.useRef(null),[or,Ar]=de.split("-"),Wn=mt.useMemo(()=>C.reduce((Nn,ta,Kt)=>Kt>=ls?Nn:Nn+ta.height,0),[C,ls]),ai=Clt(),bo=_.invert||v,Fa=Ve==="loading";ir.current=mt.useMemo(()=>ls*ie+Wn,[ls,Wn]),mt.useEffect(()=>{Xe.current=rs},[rs]),mt.useEffect(()=>{Fe(!0)},[]),mt.useEffect(()=>{let Nn=Ke.current;if(Nn){let ta=Nn.getBoundingClientRect().height;return qe(ta),w(Kt=>[{toastId:_.id,height:ta,position:_.position},...Kt]),()=>w(Kt=>Kt.filter($r=>$r.toastId!==_.id))}},[w,_.id]),mt.useLayoutEffect(()=>{if(!Te)return;let Nn=Ke.current,ta=Nn.style.height;Nn.style.height="auto";let Kt=Nn.getBoundingClientRect().height;Nn.style.height=ta,qe(Kt),w($r=>$r.find(es=>es.toastId===_.id)?$r.map(es=>es.toastId===_.id?{...es,height:Kt}:es):[{toastId:_.id,height:Kt,position:_.position},...$r])},[Te,_.title,_.description,w,_.id]);let yn=mt.useCallback(()=>{We(!0),Ne(ir.current),w(Nn=>Nn.filter(ta=>ta.toastId!==_.id)),setTimeout(()=>{R(_)},$lt)},[_,R,w,ir]);mt.useEffect(()=>{if(_.promise&&Ve==="loading"||_.duration===1/0||_.type==="loading")return;let Nn;return L||j||we&&ai?(()=>{if(vt.current{var ta;(ta=_.onAutoClose)==null||ta.call(_,_),yn()},Xe.current)),()=>clearTimeout(Nn)},[L,j,_,Ve,we,ai,yn]),mt.useEffect(()=>{_.delete&&yn()},[yn,_.delete]);function na(){var Nn,ta,Kt;return be!=null&&be.loading?mt.createElement("div",{className:lg(pe==null?void 0:pe.loader,(Nn=_==null?void 0:_.classNames)==null?void 0:Nn.loader,"sonner-loader"),"data-visible":Ve==="loading"},be.loading):ae?mt.createElement("div",{className:lg(pe==null?void 0:pe.loader,(ta=_==null?void 0:_.classNames)==null?void 0:ta.loader,"sonner-loader"),"data-visible":Ve==="loading"},ae):mt.createElement(blt,{className:lg(pe==null?void 0:pe.loader,(Kt=_==null?void 0:_.classNames)==null?void 0:Kt.loader),visible:Ve==="loading"})}return mt.createElement("li",{tabIndex:0,ref:Ke,className:lg(se,Rt,pe==null?void 0:pe.toast,(s=_==null?void 0:_.classNames)==null?void 0:s.toast,pe==null?void 0:pe.default,pe==null?void 0:pe[Ve],(r=_==null?void 0:_.classNames)==null?void 0:r[Ve]),"data-sonner-toast":"","data-rich-colors":(n=_.richColors)!=null?n:$,"data-styled":!(_.jsx||_.unstyled||b),"data-mounted":Te,"data-promise":!!_.promise,"data-swiped":Qe,"data-removed":Ae,"data-visible":Ue,"data-y-position":or,"data-x-position":Ar,"data-index":A,"data-front":ct,"data-swiping":ht,"data-dismissible":Je,"data-type":Ve,"data-invert":bo,"data-swipe-out":Dt,"data-swipe-direction":_e,"data-expanded":!!(L||le&&Te),style:{"--index":A,"--toasts-before":A,"--z-index":I.length-A,"--offset":`${Ae?rt:ir.current}px`,"--initial-height":le?"auto":`${it}px`,...U,..._.style},onDragEnd:()=>{De(!1),Ze(null),Cs.current=null},onPointerDown:Nn=>{Fa||!Je||($e.current=new Date,Ne(ir.current),Nn.target.setPointerCapture(Nn.pointerId),Nn.target.tagName!=="BUTTON"&&(De(!0),Cs.current={x:Nn.clientX,y:Nn.clientY}))},onPointerUp:()=>{var Nn,ta,Kt,$r;if(Dt||!Je)return;Cs.current=null;let es=Number(((Nn=Ke.current)==null?void 0:Nn.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),nn=Number(((ta=Ke.current)==null?void 0:ta.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),_a=new Date().getTime()-((Kt=$e.current)==null?void 0:Kt.getTime()),aa=ke==="x"?es:nn,Pr=Math.abs(aa)/_a;if(Math.abs(aa)>=Blt||Pr>.11){Ne(ir.current),($r=_.onDismiss)==null||$r.call(_,_),Ce(ke==="x"?es>0?"right":"left":nn>0?"down":"up"),yn(),he(!0),ot(!1);return}De(!1),Ze(null)},onPointerMove:Nn=>{var ta,Kt,$r,es;if(!Cs.current||!Je||((ta=window.getSelection())==null?void 0:ta.toString().length)>0)return;let nn=Nn.clientY-Cs.current.y,_a=Nn.clientX-Cs.current.x,aa=(Kt=t.swipeDirections)!=null?Kt:qlt(de);!ke&&(Math.abs(_a)>1||Math.abs(nn)>1)&&Ze(Math.abs(_a)>Math.abs(nn)?"x":"y");let Pr={x:0,y:0};ke==="y"?(aa.includes("top")||aa.includes("bottom"))&&(aa.includes("top")&&nn<0||aa.includes("bottom")&&nn>0)&&(Pr.y=nn):ke==="x"&&(aa.includes("left")||aa.includes("right"))&&(aa.includes("left")&&_a<0||aa.includes("right")&&_a>0)&&(Pr.x=_a),(Math.abs(Pr.x)>0||Math.abs(Pr.y)>0)&&ot(!0),($r=Ke.current)==null||$r.style.setProperty("--swipe-amount-x",`${Pr.x}px`),(es=Ke.current)==null||es.style.setProperty("--swipe-amount-y",`${Pr.y}px`)}},Qt&&!_.jsx?mt.createElement("button",{"aria-label":ye,"data-disabled":Fa,"data-close-button":!0,onClick:Fa||!Je?()=>{}:()=>{var Nn;yn(),(Nn=_.onDismiss)==null||Nn.call(_,_)},className:lg(pe==null?void 0:pe.closeButton,(a=_==null?void 0:_.classNames)==null?void 0:a.closeButton)},(o=be==null?void 0:be.close)!=null?o:Slt):null,_.jsx||S.isValidElement(_.title)?_.jsx?_.jsx:typeof _.title=="function"?_.title():_.title:mt.createElement(mt.Fragment,null,Ve||_.icon||_.promise?mt.createElement("div",{"data-icon":"",className:lg(pe==null?void 0:pe.icon,(l=_==null?void 0:_.classNames)==null?void 0:l.icon)},_.promise||_.type==="loading"&&!_.icon?_.icon||na():null,_.type!=="loading"?_.icon||(be==null?void 0:be[Ve])||vlt(Ve):null):null,mt.createElement("div",{"data-content":"",className:lg(pe==null?void 0:pe.content,(i=_==null?void 0:_.classNames)==null?void 0:i.content)},mt.createElement("div",{"data-title":"",className:lg(pe==null?void 0:pe.title,(d=_==null?void 0:_.classNames)==null?void 0:d.title)},typeof _.title=="function"?_.title():_.title),_.description?mt.createElement("div",{"data-description":"",className:lg(te,$t,pe==null?void 0:pe.description,(u=_==null?void 0:_.classNames)==null?void 0:u.description)},typeof _.description=="function"?_.description():_.description):null),S.isValidElement(_.cancel)?_.cancel:_.cancel&&g8(_.cancel)?mt.createElement("button",{"data-button":!0,"data-cancel":!0,style:_.cancelButtonStyle||V,onClick:Nn=>{var ta,Kt;g8(_.cancel)&&Je&&((Kt=(ta=_.cancel).onClick)==null||Kt.call(ta,Nn),yn())},className:lg(pe==null?void 0:pe.cancelButton,(p=_==null?void 0:_.classNames)==null?void 0:p.cancelButton)},_.cancel.label):null,S.isValidElement(_.action)?_.action:_.action&&g8(_.action)?mt.createElement("button",{"data-button":!0,"data-action":!0,style:_.actionButtonStyle||X,onClick:Nn=>{var ta,Kt;g8(_.action)&&((Kt=(ta=_.action).onClick)==null||Kt.call(ta,Nn),!Nn.defaultPrevented&&yn())},className:lg(pe==null?void 0:pe.actionButton,(f=_==null?void 0:_.classNames)==null?void 0:f.actionButton)},_.action.label):null))};function o4e(){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 Vlt(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?Rlt:Olt;function d(u){["top","right","bottom","left"].forEach(p=>{r[`${l}-${p}`]=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 Hlt=S.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:p="light",richColors:f,duration:v,style:_,visibleToasts:b=Dlt,toastOptions:j,dir:w=o4e(),gap:N=zlt,loadingIcon:C,icons:A,containerAriaLabel:I="Notifications",pauseWhenPageIsHidden:L}=t,[R,$]=mt.useState([]),q=mt.useMemo(()=>Array.from(new Set([n].concat(R.filter(we=>we.position).map(we=>we.position)))),[R,n]),[U,V]=mt.useState([]),[X,se]=mt.useState(!1),[te,Y]=mt.useState(!1),[de,ie]=mt.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),ae=mt.useRef(null),le=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),pe=mt.useRef(null),be=mt.useRef(!1),ye=mt.useCallback(we=>{$(ke=>{var Ze;return(Ze=ke.find(_e=>_e.id===we.id))!=null&&Ze.delete||gm.dismiss(we.id),ke.filter(({id:_e})=>_e!==we.id)})},[]);return mt.useEffect(()=>gm.subscribe(we=>{if(we.dismiss){$(ke=>ke.map(Ze=>Ze.id===we.id?{...Ze,delete:!0}:Ze));return}setTimeout(()=>{Hve.flushSync(()=>{$(ke=>{let Ze=ke.findIndex(_e=>_e.id===we.id);return Ze!==-1?[...ke.slice(0,Ze),{...ke[Ze],...we},...ke.slice(Ze+1)]:[we,...ke]})})})}),[]),mt.useEffect(()=>{if(p!=="system"){ie(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?ie("dark"):ie("light")),typeof window>"u")return;let we=window.matchMedia("(prefers-color-scheme: dark)");try{we.addEventListener("change",({matches:ke})=>{ie(ke?"dark":"light")})}catch{we.addListener(({matches:Ze})=>{try{ie(Ze?"dark":"light")}catch(_e){console.error(_e)}})}},[p]),mt.useEffect(()=>{R.length<=1&&se(!1)},[R]),mt.useEffect(()=>{let we=ke=>{var Ze,_e;a.every(Ce=>ke[Ce]||ke.code===Ce)&&(se(!0),(Ze=ae.current)==null||Ze.focus()),ke.code==="Escape"&&(document.activeElement===ae.current||(_e=ae.current)!=null&&_e.contains(document.activeElement))&&se(!1)};return document.addEventListener("keydown",we),()=>document.removeEventListener("keydown",we)},[a]),mt.useEffect(()=>{if(ae.current)return()=>{pe.current&&(pe.current.focus({preventScroll:!0}),pe.current=null,be.current=!1)}},[ae.current]),mt.createElement("section",{ref:s,"aria-label":`${I} ${le}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},q.map((we,ke)=>{var Ze;let[_e,Ce]=we.split("-");return R.length?mt.createElement("ol",{key:we,dir:w==="auto"?o4e():w,tabIndex:-1,ref:ae,className:i,"data-sonner-toaster":!0,"data-theme":de,"data-y-position":_e,"data-lifted":X&&R.length>1&&!o,"data-x-position":Ce,style:{"--front-toast-height":`${((Ze=U[0])==null?void 0:Ze.height)||0}px`,"--width":`${Flt}px`,"--gap":`${N}px`,..._,...Vlt(d,u)},onBlur:Te=>{be.current&&!Te.currentTarget.contains(Te.relatedTarget)&&(be.current=!1,pe.current&&(pe.current.focus({preventScroll:!0}),pe.current=null))},onFocus:Te=>{Te.target instanceof HTMLElement&&Te.target.dataset.dismissible==="false"||be.current||(be.current=!0,pe.current=Te.relatedTarget)},onMouseEnter:()=>se(!0),onMouseMove:()=>se(!0),onMouseLeave:()=>{te||se(!1)},onDragEnd:()=>se(!1),onPointerDown:Te=>{Te.target instanceof HTMLElement&&Te.target.dataset.dismissible==="false"||Y(!0)},onPointerUp:()=>Y(!1)},R.filter(Te=>!Te.position&&ke===0||Te.position===we).map((Te,Fe)=>{var Ae,We;return mt.createElement(Ult,{key:Te.id,icons:A,index:Fe,toast:Te,defaultRichColors:f,duration:(Ae=j==null?void 0:j.duration)!=null?Ae:v,className:j==null?void 0:j.className,descriptionClassName:j==null?void 0:j.descriptionClassName,invert:r,visibleToasts:b,closeButton:(We=j==null?void 0:j.closeButton)!=null?We:l,interacting:te,position:we,style:j==null?void 0:j.style,unstyled:j==null?void 0:j.unstyled,classNames:j==null?void 0:j.classNames,cancelButtonStyle:j==null?void 0:j.cancelButtonStyle,actionButtonStyle:j==null?void 0:j.actionButtonStyle,removeToast:ye,toasts:R.filter(ht=>ht.position==Te.position),heights:U.filter(ht=>ht.position==Te.position),setHeights:V,expandByDefault:o,gap:N,loadingIcon:C,expanded:X,pauseWhenPageIsHidden:L,swipeDirections:t.swipeDirections})})):null}))});const Wlt=({...t})=>{const{theme:s="system"}=ylt();return e.jsx(Hlt,{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 Glt=eve[" useId ".trim().toString()]||(()=>{}),Klt=0;function Gd(t){const[s,r]=S.useState(Glt());return Zc(()=>{r(n=>n??String(Klt++))},[t]),s?`radix-${s}`:""}const Zlt=["top","right","bottom","left"],k_=Math.min,np=Math.max,Kre=Math.round,x8=Math.floor,Yx=t=>({x:t,y:t}),Ylt={left:"right",right:"left",bottom:"top",top:"bottom"},Xlt={start:"end",end:"start"};function Lfe(t,s,r){return np(t,k_(s,r))}function K0(t,s){return typeof t=="function"?t(s):t}function Z0(t){return t.split("-")[0]}function aM(t){return t.split("-")[1]}function Jve(t){return t==="x"?"y":"x"}function e1e(t){return t==="y"?"height":"width"}const Qlt=new Set(["top","bottom"]);function Fx(t){return Qlt.has(Z0(t))?"y":"x"}function t1e(t){return Jve(Fx(t))}function Jlt(t,s,r){r===void 0&&(r=!1);const n=aM(t),a=t1e(t),o=e1e(a);let l=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(l=Zre(l)),[l,Zre(l)]}function ect(t){const s=Zre(t);return[Dfe(t),s,Dfe(s)]}function Dfe(t){return t.replace(/start|end/g,s=>Xlt[s])}const l4e=["left","right"],c4e=["right","left"],tct=["top","bottom"],sct=["bottom","top"];function rct(t,s,r){switch(t){case"top":case"bottom":return r?s?c4e:l4e:s?l4e:c4e;case"left":case"right":return s?tct:sct;default:return[]}}function nct(t,s,r,n){const a=aM(t);let o=rct(Z0(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(Dfe)))),o}function Zre(t){return t.replace(/left|right|bottom|top/g,s=>Ylt[s])}function act(t){return{top:0,right:0,bottom:0,left:0,...t}}function kRe(t){return typeof t!="number"?act(t):{top:t,right:t,bottom:t,left:t}}function Yre(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 d4e(t,s,r){let{reference:n,floating:a}=t;const o=Fx(s),l=t1e(s),i=e1e(l),d=Z0(s),u=o==="y",p=n.x+n.width/2-a.width/2,f=n.y+n.height/2-a.height/2,v=n[i]/2-a[i]/2;let _;switch(d){case"top":_={x:p,y:n.y-a.height};break;case"bottom":_={x:p,y:n.y+n.height};break;case"right":_={x:n.x+n.width,y:f};break;case"left":_={x:n.x-a.width,y:f};break;default:_={x:n.x,y:n.y}}switch(aM(s)){case"start":_[l]-=v*(r&&u?-1:1);break;case"end":_[l]+=v*(r&&u?-1:1);break}return _}const ict=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:p,y:f}=d4e(u,n,d),v=n,_={},b=0;for(let j=0;j({name:"arrow",options:t,async fn(s){const{x:r,y:n,placement:a,rects:o,platform:l,elements:i,middlewareData:d}=s,{element:u,padding:p=0}=K0(t,s)||{};if(u==null)return{};const f=kRe(p),v={x:r,y:n},_=t1e(a),b=e1e(_),j=await l.getDimensions(u),w=_==="y",N=w?"top":"left",C=w?"bottom":"right",A=w?"clientHeight":"clientWidth",I=o.reference[b]+o.reference[_]-v[_]-o.floating[b],L=v[_]-o.reference[_],R=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let $=R?R[A]:0;(!$||!await(l.isElement==null?void 0:l.isElement(R)))&&($=i.floating[A]||o.floating[b]);const q=I/2-L/2,U=$/2-j[b]/2-1,V=k_(f[N],U),X=k_(f[C],U),se=V,te=$-j[b]-X,Y=$/2-j[b]/2+q,de=Lfe(se,Y,te),ie=!d.arrow&&aM(a)!=null&&Y!==de&&o.reference[b]/2-(YY<=0)){var X,se;const Y=(((X=o.flip)==null?void 0:X.index)||0)+1,de=$[Y];if(de&&(!(f==="alignment"?C!==Fx(de):!1)||V.every(le=>le.overflows[0]>0&&Fx(le.placement)===C)))return{data:{index:Y,overflows:V},reset:{placement:de}};let ie=(se=V.filter(ae=>ae.overflows[0]<=0).sort((ae,le)=>ae.overflows[1]-le.overflows[1])[0])==null?void 0:se.placement;if(!ie)switch(_){case"bestFit":{var te;const ae=(te=V.filter(le=>{if(R){const pe=Fx(le.placement);return pe===C||pe==="y"}return!0}).map(le=>[le.placement,le.overflows.filter(pe=>pe>0).reduce((pe,be)=>pe+be,0)]).sort((le,pe)=>le[1]-pe[1])[0])==null?void 0:te[0];ae&&(ie=ae);break}case"initialPlacement":ie=i;break}if(a!==ie)return{reset:{placement:ie}}}return{}}}};function u4e(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function h4e(t){return Zlt.some(s=>t[s]>=0)}const cct=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=K0(t,s);switch(n){case"referenceHidden":{const o=await RI(s,{...a,elementContext:"reference"}),l=u4e(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:h4e(l)}}}case"escaped":{const o=await RI(s,{...a,altBoundary:!0}),l=u4e(o,r.floating);return{data:{escapedOffsets:l,escaped:h4e(l)}}}default:return{}}}}},NRe=new Set(["left","top"]);async function dct(t,s){const{placement:r,platform:n,elements:a}=t,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=Z0(r),i=aM(r),d=Fx(r)==="y",u=NRe.has(l)?-1:1,p=o&&d?-1:1,f=K0(s,t);let{mainAxis:v,crossAxis:_,alignmentAxis:b}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return i&&typeof b=="number"&&(_=i==="end"?b*-1:b),d?{x:_*p,y:v*u}:{x:v*u,y:_*p}}const uct=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 dct(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}}}}},hct=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:r,y:n,placement:a}=s,{mainAxis:o=!0,crossAxis:l=!1,limiter:i={fn:w=>{let{x:N,y:C}=w;return{x:N,y:C}}},...d}=K0(t,s),u={x:r,y:n},p=await RI(s,d),f=Fx(Z0(a)),v=Jve(f);let _=u[v],b=u[f];if(o){const w=v==="y"?"top":"left",N=v==="y"?"bottom":"right",C=_+p[w],A=_-p[N];_=Lfe(C,_,A)}if(l){const w=f==="y"?"top":"left",N=f==="y"?"bottom":"right",C=b+p[w],A=b-p[N];b=Lfe(C,b,A)}const j=i.fn({...s,[v]:_,[f]:b});return{...j,data:{x:j.x-r,y:j.y-n,enabled:{[v]:o,[f]:l}}}}}},mct=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}=K0(t,s),p={x:r,y:n},f=Fx(a),v=Jve(f);let _=p[v],b=p[f];const j=K0(i,s),w=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(d){const A=v==="y"?"height":"width",I=o.reference[v]-o.floating[A]+w.mainAxis,L=o.reference[v]+o.reference[A]-w.mainAxis;_L&&(_=L)}if(u){var N,C;const A=v==="y"?"width":"height",I=NRe.has(Z0(a)),L=o.reference[f]-o.floating[A]+(I&&((N=l.offset)==null?void 0:N[f])||0)+(I?0:w.crossAxis),R=o.reference[f]+o.reference[A]+(I?0:((C=l.offset)==null?void 0:C[f])||0)-(I?w.crossAxis:0);bR&&(b=R)}return{[v]:_,[f]:b}}}},pct=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}=K0(t,s),p=await RI(s,u),f=Z0(a),v=aM(a),_=Fx(a)==="y",{width:b,height:j}=o.floating;let w,N;f==="top"||f==="bottom"?(w=f,N=v===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(N=f,w=v==="end"?"top":"bottom");const C=j-p.top-p.bottom,A=b-p.left-p.right,I=k_(j-p[w],C),L=k_(b-p[N],A),R=!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&&($=C),R&&!v){const V=np(p.left,0),X=np(p.right,0),se=np(p.top,0),te=np(p.bottom,0);_?q=b-2*(V!==0||X!==0?V+X:np(p.left,p.right)):$=j-2*(se!==0||te!==0?se+te:np(p.top,p.bottom))}await d({...s,availableWidth:q,availableHeight:$});const U=await l.getDimensions(i.floating);return b!==U.width||j!==U.height?{reset:{rects:!0}}:{}}}};function Jie(){return typeof window<"u"}function iM(t){return SRe(t)?(t.nodeName||"").toLowerCase():"#document"}function fp(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function uy(t){var s;return(s=(SRe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function SRe(t){return Jie()?t instanceof Node||t instanceof fp(t).Node:!1}function Hg(t){return Jie()?t instanceof Element||t instanceof fp(t).Element:!1}function sy(t){return Jie()?t instanceof HTMLElement||t instanceof fp(t).HTMLElement:!1}function m4e(t){return!Jie()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof fp(t).ShadowRoot}const fct=new Set(["inline","contents"]);function uL(t){const{overflow:s,overflowX:r,overflowY:n,display:a}=Wg(t);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!fct.has(a)}const gct=new Set(["table","td","th"]);function xct(t){return gct.has(iM(t))}const yct=[":popover-open",":modal"];function eoe(t){return yct.some(s=>{try{return t.matches(s)}catch{return!1}})}const vct=["transform","translate","scale","rotate","perspective"],_ct=["transform","translate","scale","rotate","perspective","filter"],bct=["paint","layout","strict","content"];function s1e(t){const s=r1e(),r=Hg(t)?Wg(t):t;return vct.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)||_ct.some(n=>(r.willChange||"").includes(n))||bct.some(n=>(r.contain||"").includes(n))}function wct(t){let s=N_(t);for(;sy(s)&&!o3(s);){if(s1e(s))return s;if(eoe(s))return null;s=N_(s)}return null}function r1e(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const jct=new Set(["html","body","#document"]);function o3(t){return jct.has(iM(t))}function Wg(t){return fp(t).getComputedStyle(t)}function toe(t){return Hg(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function N_(t){if(iM(t)==="html")return t;const s=t.assignedSlot||t.parentNode||m4e(t)&&t.host||uy(t);return m4e(s)?s.host:s}function CRe(t){const s=N_(t);return o3(s)?t.ownerDocument?t.ownerDocument.body:t.body:sy(s)&&uL(s)?s:CRe(s)}function FI(t,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=CRe(t),o=a===((n=t.ownerDocument)==null?void 0:n.body),l=fp(a);if(o){const i=Ofe(l);return s.concat(l,l.visualViewport||[],uL(a)?a:[],i&&r?FI(i):[])}return s.concat(a,FI(a,[],r))}function Ofe(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function MRe(t){const s=Wg(t);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=sy(t),o=a?t.offsetWidth:r,l=a?t.offsetHeight:n,i=Kre(r)!==o||Kre(n)!==l;return i&&(r=o,n=l),{width:r,height:n,$:i}}function n1e(t){return Hg(t)?t:t.contextElement}function S5(t){const s=n1e(t);if(!sy(s))return Yx(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:o}=MRe(s);let l=(o?Kre(r.width):r.width)/n,i=(o?Kre(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const kct=Yx(0);function TRe(t){const s=fp(t);return!r1e()||!s.visualViewport?kct:{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 SN(t,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=t.getBoundingClientRect(),o=n1e(t);let l=Yx(1);s&&(n?Hg(n)&&(l=S5(n)):l=S5(t));const i=Nct(o,r,n)?TRe(o):Yx(0);let d=(a.left+i.x)/l.x,u=(a.top+i.y)/l.y,p=a.width/l.x,f=a.height/l.y;if(o){const v=fp(o),_=n&&Hg(n)?fp(n):n;let b=v,j=Ofe(b);for(;j&&n&&_!==b;){const w=S5(j),N=j.getBoundingClientRect(),C=Wg(j),A=N.left+(j.clientLeft+parseFloat(C.paddingLeft))*w.x,I=N.top+(j.clientTop+parseFloat(C.paddingTop))*w.y;d*=w.x,u*=w.y,p*=w.x,f*=w.y,d+=A,u+=I,b=fp(j),j=Ofe(b)}}return Yre({width:p,height:f,x:d,y:u})}function a1e(t,s){const r=toe(t).scrollLeft;return s?s.left+r:SN(uy(t)).left+r}function ARe(t,s,r){r===void 0&&(r=!1);const n=t.getBoundingClientRect(),a=n.left+s.scrollLeft-(r?0:a1e(t,n)),o=n.top+s.scrollTop;return{x:a,y:o}}function Sct(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=uy(n),i=s?eoe(s.floating):!1;if(n===l||i&&o)return r;let d={scrollLeft:0,scrollTop:0},u=Yx(1);const p=Yx(0),f=sy(n);if((f||!f&&!o)&&((iM(n)!=="body"||uL(l))&&(d=toe(n)),sy(n))){const _=SN(n);u=S5(n),p.x=_.x+n.clientLeft,p.y=_.y+n.clientTop}const v=l&&!f&&!o?ARe(l,d,!0):Yx(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-d.scrollLeft*u.x+p.x+v.x,y:r.y*u.y-d.scrollTop*u.y+p.y+v.y}}function Cct(t){return Array.from(t.getClientRects())}function Mct(t){const s=uy(t),r=toe(t),n=t.ownerDocument.body,a=np(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),o=np(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let l=-r.scrollLeft+a1e(t);const i=-r.scrollTop;return Wg(n).direction==="rtl"&&(l+=np(s.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}function Tct(t,s){const r=fp(t),n=uy(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=r1e();(!u||u&&s==="fixed")&&(i=a.offsetLeft,d=a.offsetTop)}return{width:o,height:l,x:i,y:d}}const Act=new Set(["absolute","fixed"]);function Ect(t,s){const r=SN(t,!0,s==="fixed"),n=r.top+t.clientTop,a=r.left+t.clientLeft,o=sy(t)?S5(t):Yx(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 p4e(t,s,r){let n;if(s==="viewport")n=Tct(t,r);else if(s==="document")n=Mct(uy(t));else if(Hg(s))n=Ect(s,r);else{const a=TRe(t);n={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return Yre(n)}function ERe(t,s){const r=N_(t);return r===s||!Hg(r)||o3(r)?!1:Wg(r).position==="fixed"||ERe(r,s)}function Pct(t,s){const r=s.get(t);if(r)return r;let n=FI(t,[],!1).filter(i=>Hg(i)&&iM(i)!=="body"),a=null;const o=Wg(t).position==="fixed";let l=o?N_(t):t;for(;Hg(l)&&!o3(l);){const i=Wg(l),d=s1e(l);!d&&i.position==="fixed"&&(a=null),(o?!d&&!a:!d&&i.position==="static"&&!!a&&Act.has(a.position)||uL(l)&&!d&&ERe(t,l))?n=n.filter(p=>p!==l):a=i,l=N_(l)}return s.set(t,n),n}function Ict(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?eoe(s)?[]:Pct(s,this._c):[].concat(r),n],i=l[0],d=l.reduce((u,p)=>{const f=p4e(s,p,a);return u.top=np(f.top,u.top),u.right=k_(f.right,u.right),u.bottom=k_(f.bottom,u.bottom),u.left=np(f.left,u.left),u},p4e(s,i,a));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function Lct(t){const{width:s,height:r}=MRe(t);return{width:s,height:r}}function Dct(t,s,r){const n=sy(s),a=uy(s),o=r==="fixed",l=SN(t,!0,o,s);let i={scrollLeft:0,scrollTop:0};const d=Yx(0);function u(){d.x=a1e(a)}if(n||!n&&!o)if((iM(s)!=="body"||uL(a))&&(i=toe(s)),n){const _=SN(s,!0,o,s);d.x=_.x+s.clientLeft,d.y=_.y+s.clientTop}else a&&u();o&&!n&&a&&u();const p=a&&!n&&!o?ARe(a,i):Yx(0),f=l.left+i.scrollLeft-d.x-p.x,v=l.top+i.scrollTop-d.y-p.y;return{x:f,y:v,width:l.width,height:l.height}}function lhe(t){return Wg(t).position==="static"}function f4e(t,s){if(!sy(t)||Wg(t).position==="fixed")return null;if(s)return s(t);let r=t.offsetParent;return uy(t)===r&&(r=r.ownerDocument.body),r}function PRe(t,s){const r=fp(t);if(eoe(t))return r;if(!sy(t)){let a=N_(t);for(;a&&!o3(a);){if(Hg(a)&&!lhe(a))return a;a=N_(a)}return r}let n=f4e(t,s);for(;n&&xct(n)&&lhe(n);)n=f4e(n,s);return n&&o3(n)&&lhe(n)&&!s1e(n)?r:n||wct(t)||r}const Oct=async function(t){const s=this.getOffsetParent||PRe,r=this.getDimensions,n=await r(t.floating);return{reference:Dct(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Rct(t){return Wg(t).direction==="rtl"}const Fct={convertOffsetParentRelativeRectToViewportRelativeRect:Sct,getDocumentElement:uy,getClippingRect:Ict,getOffsetParent:PRe,getElementRects:Oct,getClientRects:Cct,getDimensions:Lct,getScale:S5,isElement:Hg,isRTL:Rct};function IRe(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function zct(t,s){let r=null,n;const a=uy(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:p,top:f,width:v,height:_}=u;if(i||s(),!v||!_)return;const b=x8(f),j=x8(a.clientWidth-(p+v)),w=x8(a.clientHeight-(f+_)),N=x8(p),A={rootMargin:-b+"px "+-j+"px "+-w+"px "+-N+"px",threshold:np(0,k_(1,d))||1};let I=!0;function L(R){const $=R[0].intersectionRatio;if($!==d){if(!I)return l();$?l(!1,$):n=setTimeout(()=>{l(!1,1e-7)},1e3)}$===1&&!IRe(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 Bct(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=n1e(t),p=a||o?[...u?FI(u):[],...FI(s)]:[];p.forEach(N=>{a&&N.addEventListener("scroll",r,{passive:!0}),o&&N.addEventListener("resize",r)});const f=u&&i?zct(u,r):null;let v=-1,_=null;l&&(_=new ResizeObserver(N=>{let[C]=N;C&&C.target===u&&_&&(_.unobserve(s),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var A;(A=_)==null||A.observe(s)})),r()}),u&&!d&&_.observe(u),_.observe(s));let b,j=d?SN(t):null;d&&w();function w(){const N=SN(t);j&&!IRe(j,N)&&r(),j=N,b=requestAnimationFrame(w)}return r(),()=>{var N;p.forEach(C=>{a&&C.removeEventListener("scroll",r),o&&C.removeEventListener("resize",r)}),f==null||f(),(N=_)==null||N.disconnect(),_=null,d&&cancelAnimationFrame(b)}}const $ct=uct,qct=hct,Uct=lct,Vct=pct,Hct=cct,g4e=oct,Wct=mct,Gct=(t,s,r)=>{const n=new Map,a={platform:Fct,...r},o={...a.platform,_c:n};return ict(t,s,{...a,platform:o})};var Kct=typeof document<"u",Zct=function(){},Zse=Kct?S.useLayoutEffect:Zct;function Xre(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(!Xre(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)&&!Xre(t[o],s[o]))return!1}return!0}return t!==t&&s!==s}function LRe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function x4e(t,s){const r=LRe(t);return Math.round(s*r)/r}function che(t){const s=S.useRef(t);return Zse(()=>{s.current=t}),s}function Yct(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,[p,f]=S.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[v,_]=S.useState(n);Xre(v,n)||_(n);const[b,j]=S.useState(null),[w,N]=S.useState(null),C=S.useCallback(le=>{le!==R.current&&(R.current=le,j(le))},[]),A=S.useCallback(le=>{le!==$.current&&($.current=le,N(le))},[]),I=o||b,L=l||w,R=S.useRef(null),$=S.useRef(null),q=S.useRef(p),U=d!=null,V=che(d),X=che(a),se=che(u),te=S.useCallback(()=>{if(!R.current||!$.current)return;const le={placement:s,strategy:r,middleware:v};X.current&&(le.platform=X.current),Gct(R.current,$.current,le).then(pe=>{const be={...pe,isPositioned:se.current!==!1};Y.current&&!Xre(q.current,be)&&(q.current=be,wm.flushSync(()=>{f(be)}))})},[v,s,r,X,se]);Zse(()=>{u===!1&&q.current.isPositioned&&(q.current.isPositioned=!1,f(le=>({...le,isPositioned:!1})))},[u]);const Y=S.useRef(!1);Zse(()=>(Y.current=!0,()=>{Y.current=!1}),[]),Zse(()=>{if(I&&(R.current=I),L&&($.current=L),I&&L){if(V.current)return V.current(I,L,te);te()}},[I,L,te,V,U]);const de=S.useMemo(()=>({reference:R,floating:$,setReference:C,setFloating:A}),[C,A]),ie=S.useMemo(()=>({reference:I,floating:L}),[I,L]),ae=S.useMemo(()=>{const le={position:r,left:0,top:0};if(!ie.floating)return le;const pe=x4e(ie.floating,p.x),be=x4e(ie.floating,p.y);return i?{...le,transform:"translate("+pe+"px, "+be+"px)",...LRe(ie.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:pe,top:be}},[r,i,ie.floating,p.x,p.y]);return S.useMemo(()=>({...p,update:te,refs:de,elements:ie,floatingStyles:ae}),[p,te,de,ie,ae])}const Xct=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?g4e({element:n.current,padding:a}).fn(r):{}:n?g4e({element:n,padding:a}).fn(r):{}}}},Qct=(t,s)=>({...$ct(t),options:[t,s]}),Jct=(t,s)=>({...qct(t),options:[t,s]}),edt=(t,s)=>({...Wct(t),options:[t,s]}),tdt=(t,s)=>({...Uct(t),options:[t,s]}),sdt=(t,s)=>({...Vct(t),options:[t,s]}),rdt=(t,s)=>({...Hct(t),options:[t,s]}),ndt=(t,s)=>({...Xct(t),options:[t,s]});var adt="Arrow",DRe=S.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"})})});DRe.displayName=adt;var idt=DRe;function hL(t){const[s,r]=S.useState(void 0);return Zc(()=>{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 i1e="Popper",[ORe,hy]=Ac(i1e),[odt,RRe]=ORe(i1e),FRe=t=>{const{__scopePopper:s,children:r}=t,[n,a]=S.useState(null);return e.jsx(odt,{scope:s,anchor:n,onAnchorChange:a,children:r})};FRe.displayName=i1e;var zRe="PopperAnchor",BRe=S.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=RRe(zRe,r),l=S.useRef(null),i=Pa(s,l);return S.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||l.current)}),n?null:e.jsx(Qr.div,{...a,ref:i})});BRe.displayName=zRe;var o1e="PopperContent",[ldt,cdt]=ORe(o1e),$Re=S.forwardRef((t,s)=>{var Te,Fe,Ae,We,ht,De;const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:i=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:p=0,sticky:f="partial",hideWhenDetached:v=!1,updatePositionStrategy:_="optimized",onPlaced:b,...j}=t,w=RRe(o1e,r),[N,C]=S.useState(null),A=Pa(s,Dt=>C(Dt)),[I,L]=S.useState(null),R=hL(I),$=(R==null?void 0:R.width)??0,q=(R==null?void 0:R.height)??0,U=n+(o!=="center"?"-"+o:""),V=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},X=Array.isArray(u)?u:[u],se=X.length>0,te={padding:V,boundary:X.filter(udt),altBoundary:se},{refs:Y,floatingStyles:de,placement:ie,isPositioned:ae,middlewareData:le}=Yct({strategy:"fixed",placement:U,whileElementsMounted:(...Dt)=>Bct(...Dt,{animationFrame:_==="always"}),elements:{reference:w.anchor},middleware:[Qct({mainAxis:a+q,alignmentAxis:l}),d&&Jct({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?edt():void 0,...te}),d&&tdt({...te}),sdt({...te,apply:({elements:Dt,rects:he,availableWidth:Qe,availableHeight:ot})=>{const{width:rt,height:Ne}=he.reference,it=Dt.floating.style;it.setProperty("--radix-popper-available-width",`${Qe}px`),it.setProperty("--radix-popper-available-height",`${ot}px`),it.setProperty("--radix-popper-anchor-width",`${rt}px`),it.setProperty("--radix-popper-anchor-height",`${Ne}px`)}}),I&&ndt({element:I,padding:i}),hdt({arrowWidth:$,arrowHeight:q}),v&&rdt({strategy:"referenceHidden",...te})]}),[pe,be]=VRe(ie),ye=Vc(b);Zc(()=>{ae&&(ye==null||ye())},[ae,ye]);const we=(Te=le.arrow)==null?void 0:Te.x,ke=(Fe=le.arrow)==null?void 0:Fe.y,Ze=((Ae=le.arrow)==null?void 0:Ae.centerOffset)!==0,[_e,Ce]=S.useState();return Zc(()=>{N&&Ce(window.getComputedStyle(N).zIndex)},[N]),e.jsx("div",{ref:Y.setFloating,"data-radix-popper-content-wrapper":"",style:{...de,transform:ae?de.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:_e,"--radix-popper-transform-origin":[(We=le.transformOrigin)==null?void 0:We.x,(ht=le.transformOrigin)==null?void 0:ht.y].join(" "),...((De=le.hide)==null?void 0:De.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(ldt,{scope:r,placedSide:pe,onArrowChange:L,arrowX:we,arrowY:ke,shouldHideArrow:Ze,children:e.jsx(Qr.div,{"data-side":pe,"data-align":be,...j,ref:A,style:{...j.style,animation:ae?void 0:"none"}})})})});$Re.displayName=o1e;var qRe="PopperArrow",ddt={top:"bottom",right:"left",bottom:"top",left:"right"},URe=S.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=cdt(qRe,n),l=ddt[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(idt,{...a,ref:r,style:{...a.style,display:"block"}})})});URe.displayName=qRe;function udt(t){return t!==null}var hdt=t=>({name:"transformOrigin",options:t,fn(s){var w,N,C;const{placement:r,rects:n,middlewareData:a}=s,l=((w=a.arrow)==null?void 0:w.centerOffset)!==0,i=l?0:t.arrowWidth,d=l?0:t.arrowHeight,[u,p]=VRe(r),f={start:"0%",center:"50%",end:"100%"}[p],v=(((N=a.arrow)==null?void 0:N.x)??0)+i/2,_=(((C=a.arrow)==null?void 0:C.y)??0)+d/2;let b="",j="";return u==="bottom"?(b=l?f:`${v}px`,j=`${-d}px`):u==="top"?(b=l?f:`${v}px`,j=`${n.floating.height+d}px`):u==="right"?(b=`${-d}px`,j=l?f:`${_}px`):u==="left"&&(b=`${n.floating.width+d}px`,j=l?f:`${_}px`),{data:{x:b,y:j}}}});function VRe(t){const[s,r="center"]=t.split("-");return[s,r]}var mL=FRe,oM=BRe,pL=$Re,fL=URe,[soe]=Ac("Tooltip",[hy]),roe=hy(),HRe="TooltipProvider",mdt=700,Rfe="tooltip.open",[pdt,l1e]=soe(HRe),WRe=t=>{const{__scopeTooltip:s,delayDuration:r=mdt,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,l=S.useRef(!0),i=S.useRef(!1),d=S.useRef(0);return S.useEffect(()=>{const u=d.current;return()=>window.clearTimeout(u)},[]),e.jsx(pdt,{scope:s,isOpenDelayedRef:l,delayDuration:r,onOpen:S.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:S.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:S.useCallback(u=>{i.current=u},[]),disableHoverableContent:a,children:o})};WRe.displayName=HRe;var zI="Tooltip",[fdt,noe]=soe(zI),GRe=t=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,d=l1e(zI,t.__scopeTooltip),u=roe(s),[p,f]=S.useState(null),v=Gd(),_=S.useRef(0),b=l??d.disableHoverableContent,j=i??d.delayDuration,w=S.useRef(!1),[N,C]=xu({prop:n,defaultProp:a??!1,onChange:$=>{$?(d.onOpen(),document.dispatchEvent(new CustomEvent(Rfe))):d.onClose(),o==null||o($)},caller:zI}),A=S.useMemo(()=>N?w.current?"delayed-open":"instant-open":"closed",[N]),I=S.useCallback(()=>{window.clearTimeout(_.current),_.current=0,w.current=!1,C(!0)},[C]),L=S.useCallback(()=>{window.clearTimeout(_.current),_.current=0,C(!1)},[C]),R=S.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{w.current=!0,C(!0),_.current=0},j)},[j,C]);return S.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),e.jsx(mL,{...u,children:e.jsx(fdt,{scope:s,contentId:v,open:N,stateAttribute:A,trigger:p,onTriggerChange:f,onTriggerEnter:S.useCallback(()=>{d.isOpenDelayedRef.current?R():I()},[d.isOpenDelayedRef,R,I]),onTriggerLeave:S.useCallback(()=>{b?L():(window.clearTimeout(_.current),_.current=0)},[L,b]),onOpen:I,onClose:L,disableHoverableContent:b,children:r})})};GRe.displayName=zI;var Ffe="TooltipTrigger",KRe=S.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=noe(Ffe,r),o=l1e(Ffe,r),l=roe(r),i=S.useRef(null),d=Pa(s,i,a.onTriggerChange),u=S.useRef(!1),p=S.useRef(!1),f=S.useCallback(()=>u.current=!1,[]);return S.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),e.jsx(oM,{asChild:!0,...l,children:e.jsx(Qr.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:d,onPointerMove:Cr(t.onPointerMove,v=>{v.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Cr(t.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Cr(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Cr(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Cr(t.onBlur,a.onClose),onClick:Cr(t.onClick,a.onClose)})})});KRe.displayName=Ffe;var gdt="TooltipPortal",[E1s,xdt]=soe(gdt,{forceMount:void 0}),l3="TooltipContent",ZRe=S.forwardRef((t,s)=>{const r=xdt(l3,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=noe(l3,t.__scopeTooltip);return e.jsx(hd,{present:n||l.open,children:l.disableHoverableContent?e.jsx(YRe,{side:a,...o,ref:s}):e.jsx(ydt,{side:a,...o,ref:s})})}),ydt=S.forwardRef((t,s)=>{const r=noe(l3,t.__scopeTooltip),n=l1e(l3,t.__scopeTooltip),a=S.useRef(null),o=Pa(s,a),[l,i]=S.useState(null),{trigger:d,onClose:u}=r,p=a.current,{onPointerInTransitChange:f}=n,v=S.useCallback(()=>{i(null),f(!1)},[f]),_=S.useCallback((b,j)=>{const w=b.currentTarget,N={x:b.clientX,y:b.clientY},C=jdt(N,w.getBoundingClientRect()),A=kdt(N,C),I=Ndt(j.getBoundingClientRect()),L=Cdt([...A,...I]);i(L),f(!0)},[f]);return S.useEffect(()=>()=>v(),[v]),S.useEffect(()=>{if(d&&p){const b=w=>_(w,p),j=w=>_(w,d);return d.addEventListener("pointerleave",b),p.addEventListener("pointerleave",j),()=>{d.removeEventListener("pointerleave",b),p.removeEventListener("pointerleave",j)}}},[d,p,_,v]),S.useEffect(()=>{if(l){const b=j=>{const w=j.target,N={x:j.clientX,y:j.clientY},C=(d==null?void 0:d.contains(w))||(p==null?void 0:p.contains(w)),A=!Sdt(N,l);C?v():A&&(v(),u())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[d,p,l,u,v]),e.jsx(YRe,{...t,ref:o})}),[vdt,_dt]=soe(zI,{isInside:!1}),bdt=$8e("TooltipContent"),YRe=S.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,d=noe(l3,r),u=roe(r),{onClose:p}=d;return S.useEffect(()=>(document.addEventListener(Rfe,p),()=>document.removeEventListener(Rfe,p)),[p]),S.useEffect(()=>{if(d.trigger){const f=v=>{const _=v.target;_!=null&&_.contains(d.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[d.trigger,p]),e.jsx(R_,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:e.jsxs(pL,{"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(bdt,{children:n}),e.jsx(vdt,{scope:r,isInside:!0,children:e.jsx(uot,{id:d.contentId,role:"tooltip",children:a||n})})]})})});ZRe.displayName=l3;var XRe="TooltipArrow",wdt=S.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=roe(r);return _dt(XRe,r).isInside?null:e.jsx(fL,{...a,...n,ref:s})});wdt.displayName=XRe;function jdt(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 kdt(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 Sdt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=v>n&&r<(f-u)*(n-p)/(v-p)+u&&(a=!a)}return a}function Cdt(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),Mdt(s)}function Mdt(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 Tdt=WRe,Adt=GRe,Edt=KRe,QRe=ZRe;const QN=Tdt,nd=Adt,ad=Edt,Wc=S.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(QRe,{ref:n,sideOffset:s,className:Pt("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));Wc.displayName=QRe.displayName;var lM=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(){}},CN=typeof window>"u"||"Deno"in globalThis;function Ch(){}function Pdt(t,s){return typeof t=="function"?t(s):t}function zfe(t){return typeof t=="number"&&t>=0&&t!==1/0}function JRe(t,s){return Math.max(t+(s||0)-Date.now(),0)}function d_(t,s){return typeof t=="function"?t(s):t}function Gp(t,s){return typeof t=="function"?t(s):t}function y4e(t,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=t;if(l){if(n){if(s.queryHash!==c1e(l,s.options))return!1}else if(!BI(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 v4e(t,s){const{exact:r,status:n,predicate:a,mutationKey:o}=t;if(o){if(!s.options.mutationKey)return!1;if(r){if(MN(s.options.mutationKey)!==MN(o))return!1}else if(!BI(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function c1e(t,s){return((s==null?void 0:s.queryKeyHashFn)||MN)(t)}function MN(t){return JSON.stringify(t,(s,r)=>Bfe(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function BI(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?Object.keys(s).every(r=>BI(t[r],s[r])):!1}function eFe(t,s){if(t===s)return t;const r=_4e(t)&&_4e(s);if(r||Bfe(t)&&Bfe(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 p=0;p{setTimeout(s,t)})}function $fe(t,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,s):r.structuralSharing!==!1?eFe(t,s):s}function Ldt(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function Ddt(t,s,r=0){const n=[s,...t];return r&&n.length>r?n.slice(0,-1):n}var d1e=Symbol();function tFe(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===d1e?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function sFe(t,s){return typeof t=="function"?t(...s):!!t}var Bk,j1,q5,gDe,Odt=(gDe=class extends lM{constructor(){super();qa(this,Bk);qa(this,j1);qa(this,q5);$n(this,q5,s=>{if(!CN&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){us(this,j1)||this.setEventListener(us(this,q5))}onUnsubscribe(){var s;this.hasListeners()||((s=us(this,j1))==null||s.call(this),$n(this,j1,void 0))}setEventListener(s){var r;$n(this,q5,s),(r=us(this,j1))==null||r.call(this),$n(this,j1,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){us(this,Bk)!==s&&($n(this,Bk,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof us(this,Bk)=="boolean"?us(this,Bk):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},Bk=new WeakMap,j1=new WeakMap,q5=new WeakMap,gDe),u1e=new Odt,U5,k1,V5,xDe,Rdt=(xDe=class extends lM{constructor(){super();qa(this,U5,!0);qa(this,k1);qa(this,V5);$n(this,V5,s=>{if(!CN&&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(){us(this,k1)||this.setEventListener(us(this,V5))}onUnsubscribe(){var s;this.hasListeners()||((s=us(this,k1))==null||s.call(this),$n(this,k1,void 0))}setEventListener(s){var r;$n(this,V5,s),(r=us(this,k1))==null||r.call(this),$n(this,k1,s(this.setOnline.bind(this)))}setOnline(s){us(this,U5)!==s&&($n(this,U5,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return us(this,U5)}},U5=new WeakMap,k1=new WeakMap,V5=new WeakMap,xDe),Jre=new Rdt;function qfe(){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 Fdt(t){return Math.min(1e3*2**t,3e4)}function rFe(t){return(t??"online")==="online"?Jre.isOnline():!0}var nFe=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function dhe(t){return t instanceof nFe}function aFe(t){let s=!1,r=0,n=!1,a;const o=qfe(),l=j=>{var w;n||(v(new nFe(j)),(w=t.abort)==null||w.call(t))},i=()=>{s=!0},d=()=>{s=!1},u=()=>u1e.isFocused()&&(t.networkMode==="always"||Jre.isOnline())&&t.canRun(),p=()=>rFe(t.networkMode)&&t.canRun(),f=j=>{var w;n||(n=!0,(w=t.onSuccess)==null||w.call(t,j),a==null||a(),o.resolve(j))},v=j=>{var w;n||(n=!0,(w=t.onError)==null||w.call(t,j),a==null||a(),o.reject(j))},_=()=>new Promise(j=>{var w;a=N=>{(n||u())&&j(N)},(w=t.onPause)==null||w.call(t)}).then(()=>{var j;a=void 0,n||(j=t.onContinue)==null||j.call(t)}),b=()=>{if(n)return;let j;const w=r===0?t.initialPromise:void 0;try{j=w??t.fn()}catch(N){j=Promise.reject(N)}Promise.resolve(j).then(f).catch(N=>{var R;if(n)return;const C=t.retry??(CN?0:3),A=t.retryDelay??Fdt,I=typeof A=="function"?A(r,N):A,L=C===!0||typeof C=="number"&&ru()?void 0:_()).then(()=>{s?v(N):b()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:d,canStart:p,start:()=>(p()?b():_().then(b),o)}}var zdt=t=>setTimeout(t,0);function Bdt(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=zdt;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 Bd=Bdt(),$k,yDe,iFe=(yDe=class{constructor(){qa(this,$k)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),zfe(this.gcTime)&&$n(this,$k,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(CN?1/0:5*60*1e3))}clearGcTimeout(){us(this,$k)&&(clearTimeout(us(this,$k)),$n(this,$k,void 0))}},$k=new WeakMap,yDe),H5,qk,Wp,Uk,Ku,eL,Vk,yg,Qy,vDe,$dt=(vDe=class extends iFe{constructor(s){super();qa(this,yg);qa(this,H5);qa(this,qk);qa(this,Wp);qa(this,Uk);qa(this,Ku);qa(this,eL);qa(this,Vk);$n(this,Vk,!1),$n(this,eL,s.defaultOptions),this.setOptions(s.options),this.observers=[],$n(this,Uk,s.client),$n(this,Wp,us(this,Uk).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,$n(this,H5,qdt(this.options)),this.state=s.state??us(this,H5),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=us(this,Ku))==null?void 0:s.promise}setOptions(s){this.options={...us(this,eL),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&us(this,Wp).remove(this)}setData(s,r){const n=$fe(this.state.data,s,this.options);return qi(this,yg,Qy).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(s,r){qi(this,yg,Qy).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=us(this,Ku))==null?void 0:n.promise;return(a=us(this,Ku))==null||a.cancel(s),r?r.then(Ch).catch(Ch):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(us(this,H5))}isActive(){return this.observers.some(s=>Gp(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===d1e||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>d_(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:!JRe(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=us(this,Ku))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=us(this,Ku))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),us(this,Wp).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(r=>r!==s),this.observers.length||(us(this,Ku)&&(us(this,Vk)?us(this,Ku).cancel({revert:!0}):us(this,Ku).cancelRetry()),this.scheduleGc()),us(this,Wp).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||qi(this,yg,Qy).call(this,{type:"invalidate"})}fetch(s,r){var u,p,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(us(this,Ku))return us(this,Ku).continueRetry(),us(this,Ku).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:()=>($n(this,Vk,!0),n.signal)})},o=()=>{const v=tFe(this.options,r),b=(()=>{const j={client:us(this,Uk),queryKey:this.queryKey,meta:this.meta};return a(j),j})();return $n(this,Vk,!1),this.options.persister?this.options.persister(v,b,this):v(b)},i=(()=>{const v={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:us(this,Uk),state:this.state,fetchFn:o};return a(v),v})();(u=this.options.behavior)==null||u.onFetch(i,this),$n(this,qk,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=i.fetchOptions)==null?void 0:p.meta))&&qi(this,yg,Qy).call(this,{type:"fetch",meta:(f=i.fetchOptions)==null?void 0:f.meta});const d=v=>{var _,b,j,w;dhe(v)&&v.silent||qi(this,yg,Qy).call(this,{type:"error",error:v}),dhe(v)||((b=(_=us(this,Wp).config).onError)==null||b.call(_,v,this),(w=(j=us(this,Wp).config).onSettled)==null||w.call(j,this.state.data,v,this)),this.scheduleGc()};return $n(this,Ku,aFe({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:v=>{var _,b,j,w;if(v===void 0){d(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(v)}catch(N){d(N);return}(b=(_=us(this,Wp).config).onSuccess)==null||b.call(_,v,this),(w=(j=us(this,Wp).config).onSettled)==null||w.call(j,v,this.state.error,this),this.scheduleGc()},onError:d,onFail:(v,_)=>{qi(this,yg,Qy).call(this,{type:"failed",failureCount:v,error:_})},onPause:()=>{qi(this,yg,Qy).call(this,{type:"pause"})},onContinue:()=>{qi(this,yg,Qy).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),us(this,Ku).start()}},H5=new WeakMap,qk=new WeakMap,Wp=new WeakMap,Uk=new WeakMap,Ku=new WeakMap,eL=new WeakMap,Vk=new WeakMap,yg=new WeakSet,Qy=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,...oFe(n.data,this.options),fetchMeta:s.meta??null};case"success":return $n(this,qk,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 dhe(a)&&a.revert&&us(this,qk)?{...us(this,qk),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),Bd.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),us(this,Wp).notify({query:this,type:"updated",action:s})})},vDe);function oFe(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:rFe(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function qdt(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 Ax,_De,Udt=(_De=class extends lM{constructor(s={}){super();qa(this,Ax);this.config=s,$n(this,Ax,new Map)}build(s,r,n){const a=r.queryKey,o=r.queryHash??c1e(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){us(this,Ax).has(s.queryHash)||(us(this,Ax).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=us(this,Ax).get(s.queryHash);r&&(s.destroy(),r===s&&us(this,Ax).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){Bd.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return us(this,Ax).get(s)}getAll(){return[...us(this,Ax).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>y4e(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>y4e(s,n)):r}notify(s){Bd.batch(()=>{this.listeners.forEach(r=>{r(s)})})}onFocus(){Bd.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){Bd.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},Ax=new WeakMap,_De),Ex,kh,Hk,Px,Jv,bDe,Vdt=(bDe=class extends iFe{constructor(s){super();qa(this,Px);qa(this,Ex);qa(this,kh);qa(this,Hk);this.mutationId=s.mutationId,$n(this,kh,s.mutationCache),$n(this,Ex,[]),this.state=s.state||lFe(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){us(this,Ex).includes(s)||(us(this,Ex).push(s),this.clearGcTimeout(),us(this,kh).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){$n(this,Ex,us(this,Ex).filter(r=>r!==s)),this.scheduleGc(),us(this,kh).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){us(this,Ex).length||(this.state.status==="pending"?this.scheduleGc():us(this,kh).remove(this))}continue(){var s;return((s=us(this,Hk))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var o,l,i,d,u,p,f,v,_,b,j,w,N,C,A,I,L,R,$,q;const r=()=>{qi(this,Px,Jv).call(this,{type:"continue"})};$n(this,Hk,aFe({fn:()=>this.options.mutationFn?this.options.mutationFn(s):Promise.reject(new Error("No mutationFn found")),onFail:(U,V)=>{qi(this,Px,Jv).call(this,{type:"failed",failureCount:U,error:V})},onPause:()=>{qi(this,Px,Jv).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>us(this,kh).canRun(this)}));const n=this.state.status==="pending",a=!us(this,Hk).canStart();try{if(n)r();else{qi(this,Px,Jv).call(this,{type:"pending",variables:s,isPaused:a}),await((l=(o=us(this,kh).config).onMutate)==null?void 0:l.call(o,s,this));const V=await((d=(i=this.options).onMutate)==null?void 0:d.call(i,s));V!==this.state.context&&qi(this,Px,Jv).call(this,{type:"pending",context:V,variables:s,isPaused:a})}const U=await us(this,Hk).start();return await((p=(u=us(this,kh).config).onSuccess)==null?void 0:p.call(u,U,s,this.state.context,this)),await((v=(f=this.options).onSuccess)==null?void 0:v.call(f,U,s,this.state.context)),await((b=(_=us(this,kh).config).onSettled)==null?void 0:b.call(_,U,null,this.state.variables,this.state.context,this)),await((w=(j=this.options).onSettled)==null?void 0:w.call(j,U,null,s,this.state.context)),qi(this,Px,Jv).call(this,{type:"success",data:U}),U}catch(U){try{throw await((C=(N=us(this,kh).config).onError)==null?void 0:C.call(N,U,s,this.state.context,this)),await((I=(A=this.options).onError)==null?void 0:I.call(A,U,s,this.state.context)),await((R=(L=us(this,kh).config).onSettled)==null?void 0:R.call(L,void 0,U,this.state.variables,this.state.context,this)),await((q=($=this.options).onSettled)==null?void 0:q.call($,void 0,U,s,this.state.context)),U}finally{qi(this,Px,Jv).call(this,{type:"error",error:U})}}finally{us(this,kh).runNext(this)}}},Ex=new WeakMap,kh=new WeakMap,Hk=new WeakMap,Px=new WeakSet,Jv=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),Bd.batch(()=>{us(this,Ex).forEach(n=>{n.onMutationUpdate(s)}),us(this,kh).notify({mutation:this,type:"updated",action:s})})},bDe);function lFe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var h0,vg,tL,wDe,Hdt=(wDe=class extends lM{constructor(s={}){super();qa(this,h0);qa(this,vg);qa(this,tL);this.config=s,$n(this,h0,new Set),$n(this,vg,new Map),$n(this,tL,0)}build(s,r,n){const a=new Vdt({mutationCache:this,mutationId:++YO(this,tL)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){us(this,h0).add(s);const r=y8(s);if(typeof r=="string"){const n=us(this,vg).get(r);n?n.push(s):us(this,vg).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(us(this,h0).delete(s)){const r=y8(s);if(typeof r=="string"){const n=us(this,vg).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&us(this,vg).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=y8(s);if(typeof r=="string"){const n=us(this,vg).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=y8(s);if(typeof r=="string"){const a=(n=us(this,vg).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(){Bd.batch(()=>{us(this,h0).forEach(s=>{this.notify({type:"removed",mutation:s})}),us(this,h0).clear(),us(this,vg).clear()})}getAll(){return Array.from(us(this,h0))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>v4e(r,n))}findAll(s={}){return this.getAll().filter(r=>v4e(s,r))}notify(s){Bd.batch(()=>{this.listeners.forEach(r=>{r(s)})})}resumePausedMutations(){const s=this.getAll().filter(r=>r.state.isPaused);return Bd.batch(()=>Promise.all(s.map(r=>r.continue().catch(Ch))))}},h0=new WeakMap,vg=new WeakMap,tL=new WeakMap,wDe);function y8(t){var s;return(s=t.options.scope)==null?void 0:s.id}function ene(t){return{onFetch:(s,r)=>{var p,f,v,_,b;const n=s.options,a=(v=(f=(p=s.fetchOptions)==null?void 0:p.meta)==null?void 0:f.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 j=!1;const w=A=>{Object.defineProperty(A,"signal",{enumerable:!0,get:()=>(s.signal.aborted?j=!0:s.signal.addEventListener("abort",()=>{j=!0}),s.signal)})},N=tFe(s.options,s.fetchOptions),C=async(A,I,L)=>{if(j)return Promise.reject();if(I==null&&A.pages.length)return Promise.resolve(A);const $=(()=>{const X={client:s.client,queryKey:s.queryKey,pageParam:I,direction:L?"backward":"forward",meta:s.options.meta};return w(X),X})(),q=await N($),{maxPages:U}=s.options,V=L?Ddt:Ldt;return{pages:V(A.pages,q,U),pageParams:V(A.pageParams,I,U)}};if(a&&o.length){const A=a==="backward",I=A?cFe:Ufe,L={pages:o,pageParams:l},R=I(n,L);i=await C(L,R,A)}else{const A=t??o.length;do{const I=d===0?l[0]??n.initialPageParam:Ufe(n,i);if(d>0&&I==null)break;i=await C(i,I),d++}while(d{var j,w;return(w=(j=s.options).persister)==null?void 0:w.call(j,u,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r)}:s.fetchFn=u}}}function Ufe(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 cFe(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 Wdt(t,s){return s?Ufe(t,s)!=null:!1}function Gdt(t,s){return!s||!t.getPreviousPageParam?!1:cFe(t,s)!=null}var Dc,N1,S1,W5,G5,C1,K5,Z5,jDe,Kdt=(jDe=class{constructor(t={}){qa(this,Dc);qa(this,N1);qa(this,S1);qa(this,W5);qa(this,G5);qa(this,C1);qa(this,K5);qa(this,Z5);$n(this,Dc,t.queryCache||new Udt),$n(this,N1,t.mutationCache||new Hdt),$n(this,S1,t.defaultOptions||{}),$n(this,W5,new Map),$n(this,G5,new Map),$n(this,C1,0)}mount(){YO(this,C1)._++,us(this,C1)===1&&($n(this,K5,u1e.subscribe(async t=>{t&&(await this.resumePausedMutations(),us(this,Dc).onFocus())})),$n(this,Z5,Jre.subscribe(async t=>{t&&(await this.resumePausedMutations(),us(this,Dc).onOnline())})))}unmount(){var t,s;YO(this,C1)._--,us(this,C1)===0&&((t=us(this,K5))==null||t.call(this),$n(this,K5,void 0),(s=us(this,Z5))==null||s.call(this),$n(this,Z5,void 0))}isFetching(t){return us(this,Dc).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return us(this,N1).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=us(this,Dc).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=us(this,Dc).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(d_(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(t){return us(this,Dc).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=us(this,Dc).get(n.queryHash),o=a==null?void 0:a.state.data,l=Pdt(s,o);if(l!==void 0)return us(this,Dc).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return Bd.batch(()=>us(this,Dc).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=us(this,Dc).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=us(this,Dc);Bd.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=us(this,Dc);return Bd.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},s)))}cancelQueries(t,s={}){const r={revert:!0,...s},n=Bd.batch(()=>us(this,Dc).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(Ch).catch(Ch)}invalidateQueries(t,s={}){return Bd.batch(()=>(us(this,Dc).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=Bd.batch(()=>us(this,Dc).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(Ch)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(Ch)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const r=us(this,Dc).build(this,s);return r.isStaleByTime(d_(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ch).catch(Ch)}fetchInfiniteQuery(t){return t.behavior=ene(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ch).catch(Ch)}ensureInfiniteQueryData(t){return t.behavior=ene(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Jre.isOnline()?us(this,N1).resumePausedMutations():Promise.resolve()}getQueryCache(){return us(this,Dc)}getMutationCache(){return us(this,N1)}getDefaultOptions(){return us(this,S1)}setDefaultOptions(t){$n(this,S1,t)}setQueryDefaults(t,s){us(this,W5).set(MN(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...us(this,W5).values()],r={};return s.forEach(n=>{BI(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){us(this,G5).set(MN(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...us(this,G5).values()],r={};return s.forEach(n=>{BI(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const s={...us(this,S1).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=c1e(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===d1e&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...us(this,S1).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){us(this,Dc).clear(),us(this,N1).clear()}},Dc=new WeakMap,N1=new WeakMap,S1=new WeakMap,W5=new WeakMap,G5=new WeakMap,C1=new WeakMap,K5=new WeakMap,Z5=new WeakMap,jDe),mm,xo,sL,Nh,Wk,Y5,M1,T1,rL,X5,Q5,Gk,Kk,A1,J5,Uo,kE,Vfe,Hfe,Wfe,Gfe,Kfe,Zfe,Yfe,uFe,kDe,dFe=(kDe=class extends lM{constructor(s,r){super();qa(this,Uo);qa(this,mm);qa(this,xo);qa(this,sL);qa(this,Nh);qa(this,Wk);qa(this,Y5);qa(this,M1);qa(this,T1);qa(this,rL);qa(this,X5);qa(this,Q5);qa(this,Gk);qa(this,Kk);qa(this,A1);qa(this,J5,new Set);this.options=r,$n(this,mm,s),$n(this,T1,null),$n(this,M1,qfe()),this.options.experimental_prefetchInRender||us(this,M1).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&&(us(this,xo).addObserver(this),w4e(us(this,xo),this.options)?qi(this,Uo,kE).call(this):this.updateResult(),qi(this,Uo,Gfe).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Xfe(us(this,xo),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Xfe(us(this,xo),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,qi(this,Uo,Kfe).call(this),qi(this,Uo,Zfe).call(this),us(this,xo).removeObserver(this)}setOptions(s){const r=this.options,n=us(this,xo);if(this.options=us(this,mm).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Gp(this.options.enabled,us(this,xo))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");qi(this,Uo,Yfe).call(this),us(this,xo).setOptions(this.options),r._defaulted&&!Qre(this.options,r)&&us(this,mm).getQueryCache().notify({type:"observerOptionsUpdated",query:us(this,xo),observer:this});const a=this.hasListeners();a&&j4e(us(this,xo),n,this.options,r)&&qi(this,Uo,kE).call(this),this.updateResult(),a&&(us(this,xo)!==n||Gp(this.options.enabled,us(this,xo))!==Gp(r.enabled,us(this,xo))||d_(this.options.staleTime,us(this,xo))!==d_(r.staleTime,us(this,xo)))&&qi(this,Uo,Vfe).call(this);const o=qi(this,Uo,Hfe).call(this);a&&(us(this,xo)!==n||Gp(this.options.enabled,us(this,xo))!==Gp(r.enabled,us(this,xo))||o!==us(this,A1))&&qi(this,Uo,Wfe).call(this,o)}getOptimisticResult(s){const r=us(this,mm).getQueryCache().build(us(this,mm),s),n=this.createResult(r,s);return Ydt(this,n)&&($n(this,Nh,n),$n(this,Y5,this.options),$n(this,Wk,us(this,xo).state)),n}getCurrentResult(){return us(this,Nh)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(n,a))})}trackProp(s){us(this,J5).add(s)}getCurrentQuery(){return us(this,xo)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=us(this,mm).defaultQueryOptions(s),n=us(this,mm).getQueryCache().build(us(this,mm),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return qi(this,Uo,kE).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),us(this,Nh)))}createResult(s,r){var U;const n=us(this,xo),a=this.options,o=us(this,Nh),l=us(this,Wk),i=us(this,Y5),u=s!==n?s.state:us(this,sL),{state:p}=s;let f={...p},v=!1,_;if(r._optimisticResults){const V=this.hasListeners(),X=!V&&w4e(s,r),se=V&&j4e(s,n,r,a);(X||se)&&(f={...f,...oFe(p.data,s.options)}),r._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:b,errorUpdatedAt:j,status:w}=f;_=f.data;let N=!1;if(r.placeholderData!==void 0&&_===void 0&&w==="pending"){let V;o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(V=o.data,N=!0):V=typeof r.placeholderData=="function"?r.placeholderData((U=us(this,Q5))==null?void 0:U.state.data,us(this,Q5)):r.placeholderData,V!==void 0&&(w="success",_=$fe(o==null?void 0:o.data,V,r),v=!0)}if(r.select&&_!==void 0&&!N)if(o&&_===(l==null?void 0:l.data)&&r.select===us(this,rL))_=us(this,X5);else try{$n(this,rL,r.select),_=r.select(_),_=$fe(o==null?void 0:o.data,_,r),$n(this,X5,_),$n(this,T1,null)}catch(V){$n(this,T1,V)}us(this,T1)&&(b=us(this,T1),_=us(this,X5),j=Date.now(),w="error");const C=f.fetchStatus==="fetching",A=w==="pending",I=w==="error",L=A&&C,R=_!==void 0,q={status:w,fetchStatus:f.fetchStatus,isPending:A,isSuccess:w==="success",isError:I,isInitialLoading:L,isLoading:L,data:_,dataUpdatedAt:f.dataUpdatedAt,error:b,errorUpdatedAt:j,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:C,isRefetching:C&&!A,isLoadingError:I&&!R,isPaused:f.fetchStatus==="paused",isPlaceholderData:v,isRefetchError:I&&R,isStale:h1e(s,r),refetch:this.refetch,promise:us(this,M1),isEnabled:Gp(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const V=te=>{q.status==="error"?te.reject(q.error):q.data!==void 0&&te.resolve(q.data)},X=()=>{const te=$n(this,M1,q.promise=qfe());V(te)},se=us(this,M1);switch(se.status){case"pending":s.queryHash===n.queryHash&&V(se);break;case"fulfilled":(q.status==="error"||q.data!==se.value)&&X();break;case"rejected":(q.status!=="error"||q.error!==se.reason)&&X();break}}return q}updateResult(){const s=us(this,Nh),r=this.createResult(us(this,xo),this.options);if($n(this,Wk,us(this,xo).state),$n(this,Y5,this.options),us(this,Wk).data!==void 0&&$n(this,Q5,us(this,xo)),Qre(r,s))return;$n(this,Nh,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!us(this,J5).size)return!0;const l=new Set(o??us(this,J5));return this.options.throwOnError&&l.add("error"),Object.keys(us(this,Nh)).some(i=>{const d=i;return us(this,Nh)[d]!==s[d]&&l.has(d)})};qi(this,Uo,uFe).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&qi(this,Uo,Gfe).call(this)}},mm=new WeakMap,xo=new WeakMap,sL=new WeakMap,Nh=new WeakMap,Wk=new WeakMap,Y5=new WeakMap,M1=new WeakMap,T1=new WeakMap,rL=new WeakMap,X5=new WeakMap,Q5=new WeakMap,Gk=new WeakMap,Kk=new WeakMap,A1=new WeakMap,J5=new WeakMap,Uo=new WeakSet,kE=function(s){qi(this,Uo,Yfe).call(this);let r=us(this,xo).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(Ch)),r},Vfe=function(){qi(this,Uo,Kfe).call(this);const s=d_(this.options.staleTime,us(this,xo));if(CN||us(this,Nh).isStale||!zfe(s))return;const n=JRe(us(this,Nh).dataUpdatedAt,s)+1;$n(this,Gk,setTimeout(()=>{us(this,Nh).isStale||this.updateResult()},n))},Hfe=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(us(this,xo)):this.options.refetchInterval)??!1},Wfe=function(s){qi(this,Uo,Zfe).call(this),$n(this,A1,s),!(CN||Gp(this.options.enabled,us(this,xo))===!1||!zfe(us(this,A1))||us(this,A1)===0)&&$n(this,Kk,setInterval(()=>{(this.options.refetchIntervalInBackground||u1e.isFocused())&&qi(this,Uo,kE).call(this)},us(this,A1)))},Gfe=function(){qi(this,Uo,Vfe).call(this),qi(this,Uo,Wfe).call(this,qi(this,Uo,Hfe).call(this))},Kfe=function(){us(this,Gk)&&(clearTimeout(us(this,Gk)),$n(this,Gk,void 0))},Zfe=function(){us(this,Kk)&&(clearInterval(us(this,Kk)),$n(this,Kk,void 0))},Yfe=function(){const s=us(this,mm).getQueryCache().build(us(this,mm),this.options);if(s===us(this,xo))return;const r=us(this,xo);$n(this,xo,s),$n(this,sL,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},uFe=function(s){Bd.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(us(this,Nh))}),us(this,mm).getQueryCache().notify({query:us(this,xo),type:"observerResultsUpdated"})})},kDe);function Zdt(t,s){return Gp(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function w4e(t,s){return Zdt(t,s)||t.state.data!==void 0&&Xfe(t,s,s.refetchOnMount)}function Xfe(t,s,r){if(Gp(s.enabled,t)!==!1&&d_(s.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&h1e(t,s)}return!1}function j4e(t,s,r,n){return(t!==s||Gp(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&h1e(t,r)}function h1e(t,s){return Gp(s.enabled,t)!==!1&&t.isStaleByTime(d_(s.staleTime,t))}function Ydt(t,s){return!Qre(t.getCurrentResult(),s)}var Xdt=class extends dFe{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:ene()})}getOptimisticResult(t){return t.behavior=ene(),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,j;const{state:r}=t,n=super.createResult(t,s),{isFetching:a,isRefetching:o,isError:l,isRefetchError:i}=n,d=(j=(b=r.fetchMeta)==null?void 0:b.fetchMore)==null?void 0:j.direction,u=l&&d==="forward",p=a&&d==="forward",f=l&&d==="backward",v=a&&d==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Wdt(s,r.data),hasPreviousPage:Gdt(s,r.data),isFetchNextPageError:u,isFetchingNextPage:p,isFetchPreviousPageError:f,isFetchingPreviousPage:v,isRefetchError:i&&!u&&!f,isRefetching:o&&!p&&!v}}},E1,P1,pm,m0,q0,Yse,Qfe,NDe,Qdt=(NDe=class extends lM{constructor(r,n){super();qa(this,q0);qa(this,E1);qa(this,P1);qa(this,pm);qa(this,m0);$n(this,E1,r),this.setOptions(n),this.bindMethods(),qi(this,q0,Yse).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=us(this,E1).defaultMutationOptions(r),Qre(this.options,n)||us(this,E1).getMutationCache().notify({type:"observerOptionsUpdated",mutation:us(this,pm),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&MN(n.mutationKey)!==MN(this.options.mutationKey)?this.reset():((a=us(this,pm))==null?void 0:a.state.status)==="pending"&&us(this,pm).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=us(this,pm))==null||r.removeObserver(this)}onMutationUpdate(r){qi(this,q0,Yse).call(this),qi(this,q0,Qfe).call(this,r)}getCurrentResult(){return us(this,P1)}reset(){var r;(r=us(this,pm))==null||r.removeObserver(this),$n(this,pm,void 0),qi(this,q0,Yse).call(this),qi(this,q0,Qfe).call(this)}mutate(r,n){var a;return $n(this,m0,n),(a=us(this,pm))==null||a.removeObserver(this),$n(this,pm,us(this,E1).getMutationCache().build(us(this,E1),this.options)),us(this,pm).addObserver(this),us(this,pm).execute(r)}},E1=new WeakMap,P1=new WeakMap,pm=new WeakMap,m0=new WeakMap,q0=new WeakSet,Yse=function(){var n;const r=((n=us(this,pm))==null?void 0:n.state)??lFe();$n(this,P1,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},Qfe=function(r){Bd.batch(()=>{var n,a,o,l,i,d,u,p;if(us(this,m0)&&this.hasListeners()){const f=us(this,P1).variables,v=us(this,P1).context;(r==null?void 0:r.type)==="success"?((a=(n=us(this,m0)).onSuccess)==null||a.call(n,r.data,f,v),(l=(o=us(this,m0)).onSettled)==null||l.call(o,r.data,null,f,v)):(r==null?void 0:r.type)==="error"&&((d=(i=us(this,m0)).onError)==null||d.call(i,r.error,f,v),(p=(u=us(this,m0)).onSettled)==null||p.call(u,void 0,r.error,f,v))}this.listeners.forEach(f=>{f(us(this,P1))})})},NDe),hFe=S.createContext(void 0),ns=t=>{const s=S.useContext(hFe);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},Jdt=({client:t,children:s})=>(S.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(hFe.Provider,{value:t,children:s})),mFe=S.createContext(!1),eut=()=>S.useContext(mFe);mFe.Provider;function tut(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var sut=S.createContext(tut()),rut=()=>S.useContext(sut),nut=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},aut=t=>{S.useEffect(()=>{t.clearReset()},[t])},iut=({result:t,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>t.isError&&!s.isReset()&&!t.isFetching&&n&&(a&&t.data===void 0||sFe(r,[t.error,n])),out=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))}},lut=(t,s)=>t.isLoading&&t.isFetching&&!s,cut=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,k4e=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function pFe(t,s,r){var f,v,_,b,j;const n=eut(),a=rut(),o=ns(),l=o.defaultQueryOptions(t);(v=(f=o.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||v.call(f,l),l._optimisticResults=n?"isRestoring":"optimistic",out(l),nut(l,a),aut(a);const i=!o.getQueryCache().get(l.queryHash),[d]=S.useState(()=>new s(o,l)),u=d.getOptimisticResult(l),p=!n&&t.subscribed!==!1;if(S.useSyncExternalStore(S.useCallback(w=>{const N=p?d.subscribe(Bd.batchCalls(w)):Ch;return d.updateResult(),N},[d,p]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),S.useEffect(()=>{d.setOptions(l)},[l,d]),cut(l,u))throw k4e(l,d,a);if(iut({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&&!CN&&lut(u,n)){const w=i?k4e(l,d,a):(j=o.getQueryCache().get(l.queryHash))==null?void 0:j.promise;w==null||w.catch(Ch).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?u:d.trackResult(u)}function Ct(t,s){return pFe(t,dFe)}function Ot(t,s){const r=ns(),[n]=S.useState(()=>new Qdt(r,t));S.useEffect(()=>{n.setOptions(t)},[n,t]);const a=S.useSyncExternalStore(S.useCallback(l=>n.subscribe(Bd.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=S.useCallback((l,i)=>{n.mutate(l,i).catch(Ch)},[n]);if(a.error&&sFe(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function dut(t,s){return pFe(t,Xdt)}/** * @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 $I(){return $I=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function fFe(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function hut(){return Math.random().toString(36).substr(2,8)}function S4e(t,s){return{usr:t.state,key:t.key,idx:s}}function Jfe(t,s,r,n){return r===void 0&&(r=null),$I({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?cM(s):s,{state:r,key:s&&s.key||n||hut()})}function tne(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 cM(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 mut(t,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,i=O1.Pop,d=null,u=p();u==null&&(u=0,l.replaceState($I({},l.state,{idx:u}),""));function p(){return(l.state||{idx:null}).idx}function f(){i=O1.Pop;let w=p(),N=w==null?null:w-u;u=w,d&&d({action:i,location:j.location,delta:N})}function v(w,N){i=O1.Push;let C=Jfe(j.location,w,N);u=p()+1;let A=S4e(C,u),I=j.createHref(C);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:j.location,delta:1})}function _(w,N){i=O1.Replace;let C=Jfe(j.location,w,N);u=p();let A=S4e(C,u),I=j.createHref(C);l.replaceState(A,"",I),o&&d&&d({action:i,location:j.location,delta:0})}function b(w){let N=a.location.origin!=="null"?a.location.origin:a.location.href,C=typeof w=="string"?w:tne(w);return C=C.replace(/ $/,"%20"),dd(N,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,N)}let j={get action(){return i},get location(){return t(a,l)},listen(w){if(d)throw new Error("A history only accepts one active listener");return a.addEventListener(N4e,f),d=w,()=>{a.removeEventListener(N4e,f),d=null}},createHref(w){return s(a,w)},createURL:b,encodeLocation(w){let N=b(w);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:v,replace:_,go(w){return l.go(w)}};return j}var C4e;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(C4e||(C4e={}));function put(t,s,r){return r===void 0&&(r="/"),fut(t,s,r)}function fut(t,s,r,n){let a=typeof s=="string"?cM(s):s,o=m1e(a.pathname||"/",r);if(o==null)return null;let l=gFe(t);gut(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("/")&&(dd(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=u_([n,d.relativePath]),p=r.concat(d);o.children&&o.children.length>0&&(dd(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),gFe(o.children,s,p,u)),!(o.path==null&&!o.index)&&s.push({path:u,score:jut(u,o.index),routesMeta:p})};return t.forEach((o,l)=>{var i;if(o.path===""||!((i=o.path)!=null&&i.includes("?")))a(o,l);else for(let d of xFe(o.path))a(o,l,d)}),s}function xFe(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=xFe(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 gut(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:kut(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const xut=/^:[\w-]+$/,yut=3,vut=2,_ut=1,but=10,wut=-2,M4e=t=>t==="*";function jut(t,s){let r=t.split("/"),n=r.length;return r.some(M4e)&&(n+=wut),s&&(n+=vut),r.filter(a=>!M4e(a)).reduce((a,o)=>a+(xut.test(o)?yut:o===""?_ut:but),n)}function kut(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:_}=p;if(v==="*"){let j=i[f]||"";l=o.slice(0,o.length-j.length).replace(/(.)\/+$/,"$1")}const b=i[f];return _&&!b?u[v]=void 0:u[v]=(b||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:l,pattern:t}}function Cut(t,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),fFe(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 Mut(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return fFe(!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 m1e(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 Tut(t,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof t=="string"?cM(t):t;return{pathname:r?r.startsWith("/")?r:Aut(r,s):s,search:Iut(n),hash:Lut(a)}}function Aut(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 uhe(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 Eut(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function p1e(t,s){let r=Eut(t);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function f1e(t,s,r,n){n===void 0&&(n=!1);let a;typeof t=="string"?a=cM(t):(a=$I({},t),dd(!a.pathname||!a.pathname.includes("?"),uhe("?","pathname","search",a)),dd(!a.pathname||!a.pathname.includes("#"),uhe("#","pathname","hash",a)),dd(!a.search||!a.search.includes("#"),uhe("#","search","hash",a)));let o=t===""||a.pathname==="",l=o?"/":a.pathname,i;if(l==null)i=r;else{let f=s.length-1;if(!n&&l.startsWith("..")){let v=l.split("/");for(;v[0]==="..";)v.shift(),f-=1;a.pathname=v.join("/")}i=f>=0?s[f]:"/"}let d=Tut(a,i),u=l&&l!=="/"&&l.endsWith("/"),p=(o||l===".")&&r.endsWith("/");return!d.pathname.endsWith("/")&&(u||p)&&(d.pathname+="/"),d}const u_=t=>t.join("/").replace(/\/\/+/g,"/"),Put=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Iut=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Lut=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function Dut(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const yFe=["post","put","patch","delete"];new Set(yFe);const Out=["get",...yFe];new Set(Out);/** * 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 qI(){return qI=Object.assign?Object.assign.bind():function(t){for(var s=1;s{i.current=!0}),S.useCallback(function(u,p){if(p===void 0&&(p={}),!i.current)return;if(typeof u=="number"){n.go(u);return}let f=f1e(u,JSON.parse(l),o,p.relative==="path");t==null&&s!=="/"&&(f.pathname=f.pathname==="/"?s:u_([s,f.pathname])),(p.replace?n.replace:n.push)(f,p.state,p)},[s,n,l,o,t])}const But=S.createContext(null);function $ut(t){let s=S.useContext(my).outlet;return s&&S.createElement(But.Provider,{value:t},s)}function Mo(){let{matches:t}=S.useContext(my),s=t[t.length-1];return s?s.params:{}}function bFe(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=S.useContext(F_),{matches:a}=S.useContext(my),{pathname:o}=vu(),l=JSON.stringify(p1e(a,n.v7_relativeSplatPath));return S.useMemo(()=>f1e(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function qut(t,s){return Uut(t,s)}function Uut(t,s,r,n){dM()||dd(!1);let{navigator:a}=S.useContext(F_),{matches:o}=S.useContext(my),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let d=l?l.pathnameBase:"/";l&&l.route;let u=vu(),p;if(s){var f;let w=typeof s=="string"?cM(s):s;d==="/"||(f=w.pathname)!=null&&f.startsWith(d)||dd(!1),p=w}else p=u;let v=p.pathname||"/",_=v;if(d!=="/"){let w=d.replace(/^\//,"").split("/");_="/"+v.replace(/^\//,"").split("/").slice(w.length).join("/")}let b=put(t,{pathname:_}),j=Kut(b&&b.map(w=>Object.assign({},w,{params:Object.assign({},i,w.params),pathname:u_([d,a.encodeLocation?a.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?d:u_([d,a.encodeLocation?a.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),o,r,n);return s&&j?S.createElement(aoe.Provider,{value:{location:qI({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:O1.Pop}},j):j}function Vut(){let t=Qut(),s=Dut(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 S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},s),r?S.createElement("pre",{style:a},r):null,null)}const Hut=S.createElement(Vut,null);class Wut extends S.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?S.createElement(my.Provider,{value:this.props.routeContext},S.createElement(vFe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Gut(t){let{routeContext:s,match:r,children:n}=t,a=S.useContext(g1e);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),S.createElement(my.Provider,{value:s},n)}function Kut(t,s,r,n){var a;if(s===void 0&&(s=[]),r===void 0&&(r=null),n===void 0&&(n=null),t==null){var o;if(!r)return null;if(r.errors)t=r.matches;else if((o=n)!=null&&o.v7_partialHydration&&s.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let l=t,i=(a=r)==null?void 0:a.errors;if(i!=null){let p=l.findIndex(f=>f.route.id&&(i==null?void 0:i[f.route.id])!==void 0);p>=0||dd(!1),l=l.slice(0,Math.min(l.length,p+1))}let d=!1,u=-1;if(r&&n&&n.v7_partialHydration)for(let p=0;p=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((p,f,v)=>{let _,b=!1,j=null,w=null;r&&(_=i&&f.route.id?i[f.route.id]:void 0,j=f.route.errorElement||Hut,d&&(u<0&&v===0?(eht("route-fallback"),b=!0,w=null):u===v&&(b=!0,w=f.route.hydrateFallbackElement||null)));let N=s.concat(l.slice(0,v+1)),C=()=>{let A;return _?A=j:b?A=w:f.route.Component?A=S.createElement(f.route.Component,null):f.route.element?A=f.route.element:A=p,S.createElement(Gut,{match:f,routeContext:{outlet:p,matches:N,isDataRoute:r!=null},children:A})};return r&&(f.route.ErrorBoundary||f.route.errorElement||v===0)?S.createElement(Wut,{location:r.location,revalidation:r.revalidation,component:j,error:_,children:C(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):C()},null)}var wFe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(wFe||{}),jFe=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}(jFe||{});function Zut(t){let s=S.useContext(g1e);return s||dd(!1),s}function Yut(t){let s=S.useContext(Rut);return s||dd(!1),s}function Xut(t){let s=S.useContext(my);return s||dd(!1),s}function kFe(t){let s=Xut(),r=s.matches[s.matches.length-1];return r.route.id||dd(!1),r.route.id}function Qut(){var t;let s=S.useContext(vFe),r=Yut(),n=kFe();return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function Jut(){let{router:t}=Zut(wFe.UseNavigateStable),s=kFe(jFe.UseNavigateStable),r=S.useRef(!1);return _Fe(()=>{r.current=!0}),S.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,qI({fromRouteId:s},o)))},[t,s])}const T4e={};function eht(t,s,r){T4e[t]||(T4e[t]=!0)}function tht(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function hhe(t){let{to:s,replace:r,state:n,relative:a}=t;dM()||dd(!1);let{future:o,static:l}=S.useContext(F_),{matches:i}=S.useContext(my),{pathname:d}=vu(),u=Dr(),p=f1e(s,p1e(i,o.v7_relativeSplatPath),d,a==="path"),f=JSON.stringify(p);return S.useEffect(()=>u(JSON.parse(f),{replace:r,state:n,relative:a}),[u,f,a,r,n]),null}function sht(t){return $ut(t.context)}function Vs(t){dd(!1)}function rht(t){let{basename:s="/",children:r=null,location:n,navigationType:a=O1.Pop,navigator:o,static:l=!1,future:i}=t;dM()&&dd(!1);let d=s.replace(/^\/*/,"/"),u=S.useMemo(()=>({basename:d,navigator:o,static:l,future:qI({v7_relativeSplatPath:!1},i)}),[d,i,o,l]);typeof n=="string"&&(n=cM(n));let{pathname:p="/",search:f="",hash:v="",state:_=null,key:b="default"}=n,j=S.useMemo(()=>{let w=m1e(p,d);return w==null?null:{location:{pathname:w,search:f,hash:v,state:_,key:b},navigationType:a}},[d,p,f,v,_,b,a]);return j==null?null:S.createElement(F_.Provider,{value:u},S.createElement(aoe.Provider,{children:r,value:j}))}function NFe(t){let{children:s,location:r}=t;return qut(ege(s),r)}new Promise(()=>{});function ege(t,s){s===void 0&&(s=[]);let r=[];return S.Children.forEach(t,(n,a)=>{if(!S.isValidElement(n))return;let o=[...s,a];if(n.type===S.Fragment){r.push.apply(r,ege(n.props.children,o));return}n.type!==Vs&&dd(!1),!n.props.index||!n.props.children||dd(!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=ege(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 tge(){return tge=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&(r[a]=t[a]);return r}function aht(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function iht(t,s){return t.button===0&&(!s||s==="_self")&&!aht(t)}function sge(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 oht(t,s){let r=sge(t);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const lht=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],cht="6";try{window.__reactRouterVersion=cht}catch{}const dht="startTransition",A4e=eve[dht];function uht(t){let{basename:s,children:r,future:n,window:a}=t,o=S.useRef();o.current==null&&(o.current=uut({window:a,v5Compat:!0}));let l=o.current,[i,d]=S.useState({action:l.action,location:l.location}),{v7_startTransition:u}=n||{},p=S.useCallback(f=>{u&&A4e?A4e(()=>d(f)):d(f)},[d,u]);return S.useLayoutEffect(()=>l.listen(p),[l,p]),S.useEffect(()=>tht(n),[n]),S.createElement(rht,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const hht=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",mht=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,vo=S.forwardRef(function(s,r){let{onClick:n,relative:a,reloadDocument:o,replace:l,state:i,target:d,to:u,preventScrollReset:p,viewTransition:f}=s,v=nht(s,lht),{basename:_}=S.useContext(F_),b,j=!1;if(typeof u=="string"&&mht.test(u)&&(b=u,hht))try{let A=new URL(window.location.href),I=u.startsWith("//")?new URL(A.protocol+u):new URL(u),L=m1e(I.pathname,_);I.origin===A.origin&&L!=null?u=L+I.search+I.hash:j=!0}catch{}let w=Fut(u,{relative:a}),N=pht(u,{replace:l,state:i,target:d,preventScrollReset:p,relative:a,viewTransition:f});function C(A){n&&n(A),A.defaultPrevented||N(A)}return S.createElement("a",tge({},v,{href:b||w,onClick:j||o?n:C,ref:r,target:d}))});var E4e;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(E4e||(E4e={}));var P4e;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(P4e||(P4e={}));function pht(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,d=Dr(),u=vu(),p=bFe(t,{relative:l});return S.useCallback(f=>{if(iht(f,r)){f.preventDefault();let v=n!==void 0?n:tne(u)===tne(p);d(t,{replace:v,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[u,d,p,n,a,r,t,o,l,i])}function Ec(t){let s=S.useRef(sge(t)),r=S.useRef(!1),n=vu(),a=S.useMemo(()=>oht(n.search,r.current?null:s.current),[n.search]),o=Dr(),l=S.useCallback((i,d)=>{const u=sge(typeof i=="function"?i(a):i);r.current=!0,o("?"+u,d)},[o,a]);return[a,l]}var fht=typeof Element<"u",ght=typeof Map=="function",xht=typeof Set=="function",yht=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function Xse(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(!Xse(t[n],s[n]))return!1;return!0}var o;if(ght&&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(!Xse(n.value[1],s.get(n.value[0])))return!1;return!0}if(xht&&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(yht&&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(fht&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&t.$$typeof)&&!Xse(t[a[n]],s[a[n]]))return!1;return!0}return t!==t&&s!==s}var vht=function(s,r){try{return Xse(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 _ht=_o(vht);var bht=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],p=0;d=new Error(s.replace(/%s/g,function(){return u[p++]})),d.name="Invariant Violation"}throw d.framesToPop=1,d}},wht=bht;const I4e=_o(wht);var jht=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))(SFe||{}),mhe={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"]}},L4e=Object.values(SFe),x1e={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},Nht=Object.entries(x1e).reduce((t,[s,r])=>(t[r]=s,t),{}),Eg="data-rh",C5={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},M5=(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},Sht=t=>{let s=M5(t,"title");const r=M5(t,C5.TITLE_TEMPLATE);if(Array.isArray(s)&&(s=s.join("")),r&&s)return r.replace(/%s/g,()=>s);const n=M5(t,C5.DEFAULT_TITLE);return s||n||void 0},Cht=t=>M5(t,C5.ON_CHANGE_CLIENT_STATE)||(()=>{}),phe=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),Mht=(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),GA=(t,s,r)=>{const n={};return r.filter(a=>Array.isArray(a[t])?!0:(typeof a[t]<"u"&&Tht(`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 p=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:Mht(["href"],t),bodyAttributes:phe("bodyAttributes",t),defer:M5(t,C5.DEFER),encode:M5(t,C5.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:phe("htmlAttributes",t),linkTags:GA("link",["rel","href"],t),metaTags:GA("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:GA("noscript",["innerHTML"],t),onChangeClientState:Cht(t),scriptTags:GA("script",["src","innerHTML"],t),styleTags:GA("style",["cssText"],t),title:Sht(t),titleAttributes:phe("titleAttributes",t),prioritizeSeoTags:Aht(t,C5.PRIORITIZE_SEO_TAGS)}),CFe=t=>Array.isArray(t)?t.join(""):t,Pht=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(Pht(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},D4e=(t,s)=>({...t,[s]:void 0}),Iht=["noscript","script","style"],rge=(t,s=!0)=>s===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),MFe=t=>Object.keys(t).reduce((s,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return s?`${s} ${n}`:n},""),Lht=(t,s,r,n)=>{const a=MFe(r),o=CFe(s);return a?`<${t} ${Eg}="true" ${a}>${rge(o,n)}`:`<${t} ${Eg}="true">${rge(o,n)}`},Dht=(t,s,r=!0)=>s.reduce((n,a)=>{const o=a,l=Object.keys(o).filter(u=>!(u==="innerHTML"||u==="cssText")).reduce((u,p)=>{const f=typeof o[p]>"u"?p:`${p}="${rge(o[p],r)}"`;return u?`${u} ${f}`:f},""),i=o.innerHTML||o.cssText||"",d=Iht.indexOf(t)===-1;return`${n}<${t} ${Eg}="true" ${l}${d?"/>":`>${i}`}`},""),TFe=(t,s={})=>Object.keys(t).reduce((r,n)=>{const a=x1e[n];return r[a||n]=t[n],r},s),Oht=(t,s,r)=>{const n={key:s,[Eg]:!0},a=TFe(r,n);return[mt.createElement("title",a,s)]},Qse=(t,s)=>s.map((r,n)=>{const a={key:n,[Eg]:!0};return Object.keys(r).forEach(o=>{const i=x1e[o]||o;if(i==="innerHTML"||i==="cssText"){const d=r.innerHTML||r.cssText;a.dangerouslySetInnerHTML={__html:d}}else a[i]=r[o]}),mt.createElement(t,a)}),Hp=(t,s,r=!0)=>{switch(t){case"title":return{toComponent:()=>Oht(t,s.title,s.titleAttributes),toString:()=>Lht(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>TFe(s),toString:()=>MFe(s)};default:return{toComponent:()=>Qse(t,s),toString:()=>Dht(t,s,r)}}},Rht=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=fhe(t,mhe.meta),o=fhe(s,mhe.link),l=fhe(r,mhe.script);return{priorityMethods:{toComponent:()=>[...Qse("meta",a.priority),...Qse("link",o.priority),...Qse("script",l.priority)],toString:()=>`${Hp("meta",a.priority,n)} ${Hp("link",o.priority,n)} ${Hp("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},Fht=t=>{const{baseTag:s,bodyAttributes:r,encode:n=!0,htmlAttributes:a,noscriptTags:o,styleTags:l,title:i="",titleAttributes:d,prioritizeSeoTags:u}=t;let{linkTags:p,metaTags:f,scriptTags:v}=t,_={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:_,linkTags:p,metaTags:f,scriptTags:v}=Rht(t)),{priority:_,base:Hp("base",s,n),bodyAttributes:Hp("bodyAttributes",r,n),htmlAttributes:Hp("htmlAttributes",a,n),link:Hp("link",p,n),meta:Hp("meta",f,n),noscript:Hp("noscript",o,n),script:Hp("script",v,n),style:Hp("style",l,n),title:Hp("title",{title:i,titleAttributes:d},n)}},nge=Fht,v8=[],AFe=!!(typeof window<"u"&&window.document&&window.document.createElement),age=class{constructor(t,s){_n(this,"instances",[]);_n(this,"canUseDOM",AFe);_n(this,"context");_n(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?v8:this.instances,add:t=>{(this.canUseDOM?v8:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?v8:this.instances).indexOf(t);(this.canUseDOM?v8:this.instances).splice(s,1)}}});this.context=t,this.canUseDOM=s||!1,s||(t.helmet=nge({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},zht={},EFe=mt.createContext(zht),Zk,PFe=(Zk=class extends S.Component{constructor(r){super(r);_n(this,"helmetData");this.helmetData=new age(this.props.context||{},Zk.canUseDOM)}render(){return mt.createElement(EFe.Provider,{value:this.helmetData.value},this.props.children)}},_n(Zk,"canUseDOM",AFe),Zk),WC=(t,s)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${Eg}]`),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 p=u,f=typeof i[p]>"u"?"":i[p];d.setAttribute(u,f)}d.setAttribute(Eg,"true"),a.some((u,p)=>(l=p,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}},ige=(t,s)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(Eg),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(Eg):r.getAttribute(Eg)!==l.join(",")&&r.setAttribute(Eg,l.join(","))},Bht=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=CFe(t)),ige("title",s)},O4e=(t,s)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:a,linkTags:o,metaTags:l,noscriptTags:i,onChangeClientState:d,scriptTags:u,styleTags:p,title:f,titleAttributes:v}=t;ige("body",n),ige("html",a),Bht(f,v);const _={baseTag:WC("base",r),linkTags:WC("link",o),metaTags:WC("meta",l),noscriptTags:WC("noscript",i),scriptTags:WC("script",u),styleTags:WC("style",p)},b={},j={};Object.keys(_).forEach(w=>{const{newTags:N,oldTags:C}=_[w];N.length&&(b[w]=N),C.length&&(j[w]=_[w].oldTags)}),s&&s(),d(t,b,j)},KA=null,$ht=t=>{KA&&cancelAnimationFrame(KA),t.defer?KA=requestAnimationFrame(()=>{O4e(t,()=>{KA=null})}):(O4e(t),KA=null)},qht=$ht,R4e=class extends S.Component{constructor(){super(...arguments);_n(this,"rendered",!1)}shouldComponentUpdate(s){return!kht(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=Eht(s.get().map(o=>{const l={...o.props};return delete l.context,l}));PFe.canUseDOM?qht(a):nge&&(n=nge(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}},Dpe,ah=(Dpe=class extends S.Component{shouldComponentUpdate(t){return!_ht(D4e(this.props,"helmetData"),D4e(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 I4e(L4e.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 ${L4e.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),I4e(!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 mt.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 age)){const a=n;n=new age(a.context,!0),delete r.helmetData}return n?mt.createElement(R4e,{...r,context:n.value}):mt.createElement(EFe.Consumer,null,a=>mt.createElement(R4e,{...r,context:a}))}},_n(Dpe,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),Dpe),oge=function(t,s){return oge=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])},oge(t,s)};function IFe(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");oge(t,s);function r(){this.constructor=t}t.prototype=s===null?Object.create(s):(r.prototype=s.prototype,new r)}var tf=function(){return tf=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 DFe(t,s){return function(r,n){s(r,n,t)}}function OFe(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,p=s||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),f,v=!1,_=r.length-1;_>=0;_--){var b={};for(var j in n)b[j]=j==="access"?{}:n[j];for(var j in n.access)b.access[j]=n.access[j];b.addInitializer=function(N){if(v)throw new TypeError("Cannot add initializers after decoration has completed");o.push(l(N||null))};var w=(0,r[_])(i==="accessor"?{get:p.get,set:p.set}:p[d],b);if(i==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(f=l(w.get))&&(p.get=f),(f=l(w.set))&&(p.set=f),(f=l(w.init))&&a.unshift(f)}else(f=l(w))&&(i==="field"?a.unshift(f):p[d]=f)}u&&Object.defineProperty(u,n.name,p),v=!0}function RFe(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 y1e(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 UFe(){for(var t=[],s=0;s1||d(_,j)})},b&&(a[_]=b(a[_])))}function d(_,b){try{u(n[_](b))}catch(j){v(o[0][3],j)}}function u(_){_.value instanceof c3?Promise.resolve(_.value.v).then(p,f):v(o[0][2],_)}function p(_){d("next",_)}function f(_){d("throw",_)}function v(_,b){_(b),o.shift(),o.length&&d(o[0][0],o[0][1])}}function WFe(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:c3(t[a](l)),done:!1}:o?o(l):l}:o}}function GFe(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 sne=="function"?sne(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 KFe(t,s){return Object.defineProperty?Object.defineProperty(t,"raw",{value:s}):t.raw=s,t}var Uht=Object.create?function(t,s){Object.defineProperty(t,"default",{enumerable:!0,value:s})}:function(t,s){t.default=s},lge=function(t){return lge=Object.getOwnPropertyNames||function(s){var r=[];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[r.length]=n);return r},lge(t)};function ZFe(t){if(t&&t.__esModule)return t;var s={};if(t!=null)for(var r=lge(t),n=0;n{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>dy(async()=>{const{default:n}=await Promise.resolve().then(()=>JN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class _1e extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class F4e extends _1e{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class z4e extends _1e{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class B4e extends _1e{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var cge;(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"})(cge||(cge={}));class Kht{constructor(s,{headers:r={},customFetch:n,region:a=cge.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=Ght(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s){return ca(this,arguments,void 0,function*(r,n={}){var a;try{const{headers:o,method:l,body:i,signal:d}=n;let u={},{region:p}=n;p||(p=this.region);const f=new URL(`${this.url}/${r}`);p&&p!=="any"&&(u["x-region"]=p,f.searchParams.set("forceFunctionRegion",p));let 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(f.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 F4e(N)}),b=_.headers.get("x-relay-error");if(b&&b==="true")throw new z4e(_);if(!_.ok)throw new B4e(_);let j=((a=_.headers.get("Content-Type"))!==null&&a!==void 0?a:"text/plain").split(";")[0].trim(),w;return j==="application/json"?w=yield _.json():j==="application/octet-stream"||j==="application/pdf"?w=yield _.blob():j==="text/event-stream"?w=_:j==="multipart/form-data"?w=yield _.formData():w=yield _.text(),{data:w,error:null,response:_}}catch(o){return o instanceof Error&&o.name==="AbortError"?{data:null,error:new F4e(o)}:{data:null,error:o,response:o instanceof B4e||o instanceof z4e?o.context:void 0}}})}}var vm={};const uM=SDe(Wht);var _8={},b8={},w8={},j8={},k8={},Zht=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")},d3=Zht();const Yht=d3.fetch,rze=d3.fetch.bind(d3),nze=d3.Headers,Xht=d3.Request,Qht=d3.Response,JN=Object.freeze(Object.defineProperty({__proto__:null,Headers:nze,Request:Xht,Response:Qht,default:rze,fetch:Yht},Symbol.toStringTag,{value:"Module"})),Jht=SDe(JN);var N8={},$4e;function aze(){if($4e)return N8;$4e=1,Object.defineProperty(N8,"__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 N8.default=t,N8}var q4e;function ize(){if(q4e)return k8;q4e=1,Object.defineProperty(k8,"__esModule",{value:!0});const t=uM,s=t.__importDefault(Jht),r=t.__importDefault(aze());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 p,f,v,_;let b=null,j=null,w=null,N=u.status,C=u.statusText;if(u.ok){if(this.method!=="HEAD"){const R=await u.text();R===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((p=this.headers.get("Accept"))===null||p===void 0)&&p.includes("application/vnd.pgrst.plan+text"))?j=R:j=JSON.parse(R))}const I=(f=this.headers.get("Prefer"))===null||f===void 0?void 0:f.match(/count=(exact|planned|estimated)/),L=(v=u.headers.get("content-range"))===null||v===void 0?void 0:v.split("/");I&&L&&L.length>1&&(w=parseInt(L[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(j)&&(j.length>1?(b={code:"PGRST116",details:`Results contain ${j.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},j=null,w=null,N=406,C="Not Acceptable"):j.length===1?j=j[0]:j=null)}else{const I=await u.text();try{b=JSON.parse(I),Array.isArray(b)&&u.status===404&&(j=[],b=null,N=200,C="OK")}catch{u.status===404&&I===""?(N=204,C="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,C="OK"),b&&this.shouldThrowOnError)throw new r.default(b)}return{error:b,data:j,count:w,status:N,statusText:C}});return this.shouldThrowOnError||(d=d.catch(u=>{var p,f,v;return{error:{message:`${(p=u==null?void 0:u.name)!==null&&p!==void 0?p:"FetchError"}: ${u==null?void 0:u.message}`,details:`${(f=u==null?void 0:u.stack)!==null&&f!==void 0?f:""}`,hint:"",code:`${(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 k8.default=n,k8}var U4e;function oze(){if(U4e)return j8;U4e=1,Object.defineProperty(j8,"__esModule",{value:!0});const s=uM.__importDefault(ize());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",p=this.url.searchParams.get(u);return this.url.searchParams.set(u,`${p?`${p},`:""}${a}.${o?"asc":"desc"}${l===void 0?"":l?".nullsfirst":".nullslast"}`),this}limit(a,{foreignTable:o,referencedTable:l=o}={}){const i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(i,`${a}`),this}range(a,o,{foreignTable:l,referencedTable:i=l}={}){const 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 p;const f=[a?"analyze":null,o?"verbose":null,l?"settings":null,i?"buffers":null,d?"wal":null].filter(Boolean).join("|"),v=(p=this.headers.get("Accept"))!==null&&p!==void 0?p:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${u}; for="${v}"; options=${f};`),u==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(a){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${a}`),this}}return j8.default=r,j8}var V4e;function b1e(){if(V4e)return w8;V4e=1,Object.defineProperty(w8,"__esModule",{value:!0});const s=uM.__importDefault(oze()),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 p=i===void 0?"":`(${i})`;return this.url.searchParams.append(o,`${u}fts${p}.${l}`),this}match(o){return Object.entries(o).forEach(([l,i])=>{this.url.searchParams.append(l,`eq.${i}`)}),this}not(o,l,i){return this.url.searchParams.append(o,`not.${l}.${i}`),this}or(o,{foreignTable:l,referencedTable:i=l}={}){const 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 w8.default=n,w8}var H4e;function lze(){if(H4e)return b8;H4e=1,Object.defineProperty(b8,"__esModule",{value:!0});const s=uM.__importDefault(b1e());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 p=(a??"*").split("").map(f=>/\s/.test(f)&&!u?"":(f==='"'&&(u=!u),f)).join("");return this.url.searchParams.set("select",p),i&&this.headers.append("Prefer",`count=${i}`),new s.default({method: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((p,f)=>p.concat(Object.keys(f)),[]);if(u.length>0){const p=[...new Set(u)].map(f=>`"${f}"`);this.url.searchParams.set("columns",p.join(","))}}return new s.default({method: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 p="POST";if(this.headers.append("Prefer",`resolution=${l?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),i&&this.headers.append("Prefer",`count=${i}`),d||this.headers.append("Prefer","missing=default"),Array.isArray(a)){const f=a.reduce((v,_)=>v.concat(Object.keys(_)),[]);if(f.length>0){const v=[...new Set(f)].map(_=>`"${_}"`);this.url.searchParams.set("columns",v.join(","))}}return new s.default({method:p,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}update(a,{count:o}={}){var l;const i="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new s.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}delete({count:a}={}){var o;const l="DELETE";return a&&this.headers.append("Prefer",`count=${a}`),new s.default({method:l,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}}return b8.default=r,b8}var W4e;function emt(){if(W4e)return _8;W4e=1,Object.defineProperty(_8,"__esModule",{value:!0});const t=uM,s=t.__importDefault(lze()),r=t.__importDefault(b1e());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 p;let f;const v=new URL(`${this.url}/rpc/${o}`);let _;i||d?(f=i?"HEAD":"GET",Object.entries(l).filter(([j,w])=>w!==void 0).map(([j,w])=>[j,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([j,w])=>{v.searchParams.append(j,w)})):(f="POST",_=l);const b=new Headers(this.headers);return u&&b.set("Prefer",`count=${u}`),new r.default({method:f,url:v,headers:b,schema:this.schemaName,body:_,fetch:(p=this.fetch)!==null&&p!==void 0?p:fetch})}}return _8.default=n,_8}Object.defineProperty(vm,"__esModule",{value:!0});var cze=vm.PostgrestError=vze=vm.PostgrestBuilder=xze=vm.PostgrestTransformBuilder=fze=vm.PostgrestFilterBuilder=mze=vm.PostgrestQueryBuilder=uze=vm.PostgrestClient=void 0;const hM=uM,dze=hM.__importDefault(emt());var uze=vm.PostgrestClient=dze.default;const hze=hM.__importDefault(lze());var mze=vm.PostgrestQueryBuilder=hze.default;const pze=hM.__importDefault(b1e());var fze=vm.PostgrestFilterBuilder=pze.default;const gze=hM.__importDefault(oze());var xze=vm.PostgrestTransformBuilder=gze.default;const yze=hM.__importDefault(ize());var vze=vm.PostgrestBuilder=yze.default;const _ze=hM.__importDefault(aze());cze=vm.PostgrestError=_ze.default;var bze=vm.default={PostgrestClient:dze.default,PostgrestQueryBuilder:hze.default,PostgrestFilterBuilder:pze.default,PostgrestTransformBuilder:gze.default,PostgrestBuilder:yze.default,PostgrestError:_ze.default};const tmt=Object.freeze(Object.defineProperty({__proto__:null,get PostgrestBuilder(){return vze},get PostgrestClient(){return uze},get PostgrestError(){return cze},get PostgrestFilterBuilder(){return fze},get PostgrestQueryBuilder(){return mze},get PostgrestTransformBuilder(){return xze},default:bze},Symbol.toStringTag,{value:"Module"})),{PostgrestClient:smt,PostgrestQueryBuilder:I1s,PostgrestFilterBuilder:L1s,PostgrestTransformBuilder:D1s,PostgrestBuilder:O1s,PostgrestError:R1s}=bze||tmt;class rmt{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 nmt="2.78.0",amt=`realtime-js/${nmt}`,imt="1.0.0",dge=1e4,omt=1e3,lmt=100;var BP;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(BP||(BP={}));var Dd;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(Dd||(Dd={}));var bg;(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"})(bg||(bg={}));var uge;(function(t){t.websocket="websocket"})(uge||(uge={}));var yk;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(yk||(yk={}));class cmt{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 wze{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 Sl;(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"})(Sl||(Sl={}));const G4e=(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]=dmt(l,t,s,a),o),{}):{}},dmt=(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)?jze(o,l):hge(l)},jze=(t,s)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return pmt(s,r)}switch(t){case Sl.bool:return umt(s);case Sl.float4:case Sl.float8:case Sl.int2:case Sl.int4:case Sl.int8:case Sl.numeric:case Sl.oid:return hmt(s);case Sl.json:case Sl.jsonb:return mmt(s);case Sl.timestamp:return fmt(s);case Sl.abstime:case Sl.date:case Sl.daterange:case Sl.int4range:case Sl.int8range:case Sl.money:case Sl.reltime:case Sl.text:case Sl.time:case Sl.timestamptz:case Sl.timetz:case Sl.tsrange:case Sl.tstzrange:return hge(s);default:return hge(s)}},hge=t=>t,umt=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},hmt=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},mmt=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},pmt=(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=>jze(s,i))}return t},fmt=t=>typeof t=="string"?t.replace(" ","T"):t,kze=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 ghe{constructor(s,r,n={},a=dge){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 K4e;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(K4e||(K4e={}));class $P{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=$P.syncState(this.state,a,o,l),this.pendingDiffs.forEach(d=>{this.state=$P.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=$P.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,p)=>{l[u]||(d[u]=p)}),this.map(l,(u,p)=>{const f=o[u];if(f){const v=p.map(w=>w.presence_ref),_=f.map(w=>w.presence_ref),b=p.filter(w=>_.indexOf(w.presence_ref)<0),j=f.filter(w=>v.indexOf(w.presence_ref)<0);b.length>0&&(i[u]=b),j.length>0&&(d[u]=j)}else i[u]=p}),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 p=(u=s[i])!==null&&u!==void 0?u:[];if(s[i]=this.cloneDeep(d),p.length>0){const f=s[i].map(_=>_.presence_ref),v=p.filter(_=>f.indexOf(_.presence_ref)<0);s[i].unshift(...v)}n(i,p,d)}),this.map(l,(i,d)=>{let u=s[i];if(!u)return;const p=d.map(f=>f.presence_ref);u=u.filter(f=>p.indexOf(f.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 Z4e;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(Z4e||(Z4e={}));var qP;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(qP||(qP={}));var s0;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(s0||(s0={}));class w1e{constructor(s,r={config:{}},n){var a,o;if(this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=Dd.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 ghe(this,bg.join,this.params,this.timeout),this.rejoinTimer=new wze(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Dd.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=Dd.closed,this.socket._remove(this)}),this._onError(l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=Dd.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Dd.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=Dd.errored,this.rejoinTimer.scheduleTimeout())}),this._on(bg.reply,{},(l,i)=>{this._trigger(this._replyEventName(i),l)}),this.presence=new $P(this),this.broadcastEndpointURL=kze(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==Dd.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:[],p=!!this.bindings[qP.PRESENCE]&&this.bindings[qP.PRESENCE].length>0||((o=this.params.config.presence)===null||o===void 0?void 0:o.enabled)===!0,f={},v={broadcast:l,presence:Object.assign(Object.assign({},i),{enabled:p}),postgres_changes:u,private:d};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this._onError(_=>s==null?void 0:s(s0.CHANNEL_ERROR,_)),this._onClose(()=>s==null?void 0:s(s0.CLOSED)),this.updateJoinPayload(Object.assign({config:v},f)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:_})=>{var b;if(this.socket.setAuth(),_===void 0){s==null||s(s0.SUBSCRIBED);return}else{const j=this.bindings.postgres_changes,w=(b=j==null?void 0:j.length)!==null&&b!==void 0?b:0,N=[];for(let C=0;C{this.state=Dd.errored,s==null||s(s0.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(_).join(", ")||"error")))}).receive("timeout",()=>{s==null||s(s0.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===Dd.joined&&s===qP.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=Dd.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(bg.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(a=>{n=new ghe(this,bg.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=Dd.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 ghe(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>lmt){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:p}=bg;if(n&&[i,d,u,p].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,j,w;return((b=_.filter)===null||b===void 0?void 0:b.event)==="*"||((w=(j=_.filter)===null||j===void 0?void 0:j.event)===null||w===void 0?void 0:w.toLocaleLowerCase())===l}).map(_=>_.callback(v,n)):(o=this.bindings[l])===null||o===void 0||o.filter(_=>{var b,j,w,N,C,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&&((j=r.ids)===null||j===void 0?void 0:j.includes(I))&&(L==="*"||(L==null?void 0:L.toLocaleLowerCase())===((w=r.data)===null||w===void 0?void 0:w.type.toLocaleLowerCase()))}else{const I=(C=(N=_==null?void 0:_.filter)===null||N===void 0?void 0:N.event)===null||C===void 0?void 0:C.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:j,table:w,commit_timestamp:N,type:C,errors:A}=b;v=Object.assign(Object.assign({},{schema:j,table:w,commit_timestamp:N,eventType:C,new:{},old:{},errors:A}),this._getPayloadRecords(b))}_.callback(v,n)})}_isClosed(){return this.state===Dd.closed}_isJoined(){return this.state===Dd.joined}_isJoining(){return this.state===Dd.joining}_isLeaving(){return this.state===Dd.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&&w1e.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(bg.close,{},s)}_onError(s){this._on(bg.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Dd.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=G4e(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=G4e(s.columns,s.old_record)),r}}const xhe=()=>{},S8={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},gmt=[1e3,2e3,5e3,1e4],xmt=1e4,ymt=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class vmt{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=dge,this.transport=null,this.heartbeatIntervalMs=S8.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=xhe,this.ref=0,this.reconnectTimer=null,this.logger=xhe,this.conn=null,this.sendBuffer=[],this.serializer=new cmt,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)=>dy(async()=>{const{default:i}=await Promise.resolve().then(()=>JN);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}/${uge.websocket}`,this.httpEndpoint=kze(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=rmt.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:imt}))}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 BP.connecting:return yk.Connecting;case BP.open:return yk.Open;case BP.closing:return yk.Closing;default:return yk.Closed}}isConnected(){return this.connectionState()===yk.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 w1e(`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(omt,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},S8.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(bg.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([ymt],{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:amt};r&&n.updateJoinPayload(a),n.joinedOnce&&n._isJoined()&&n._push(bg.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 wze(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},S8.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(s){var r,n,a,o,l,i,d,u,p;if(this.transport=(r=s==null?void 0:s.transport)!==null&&r!==void 0?r:null,this.timeout=(n=s==null?void 0:s.timeout)!==null&&n!==void 0?n:dge,this.heartbeatIntervalMs=(a=s==null?void 0:s.heartbeatIntervalMs)!==null&&a!==void 0?a:S8.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:xhe,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:f=>gmt[f-1]||xmt,this.encode=(u=s==null?void 0:s.encode)!==null&&u!==void 0?u:(f,v)=>v(JSON.stringify(f)),this.decode=(p=s==null?void 0:s.decode)!==null&&p!==void 0?p:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=s==null?void 0:s.workerUrl}}}class j1e extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function wc(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class _mt extends j1e{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 mge extends j1e{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}const k1e=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>dy(async()=>{const{default:n}=await Promise.resolve().then(()=>JN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},bmt=()=>ca(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield dy(()=>Promise.resolve().then(()=>JN),void 0)).Response:Response}),pge=t=>{if(Array.isArray(t))return t.map(r=>pge(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]=pge(n)}),s},wmt=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)},yhe=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)},jmt=(t,s,r)=>ca(void 0,void 0,void 0,function*(){const n=yield bmt();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 _mt(yhe(a),o,l))}).catch(a=>{s(new mge(yhe(a),a))}):s(new mge(yhe(t),t))}),kmt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"||!n?a:(wmt(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 gL(t,s,r,n,a,o){return ca(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,kmt(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=>jmt(d,i,n))})})}function UI(t,s,r,n){return ca(this,void 0,void 0,function*(){return gL(t,"GET",s,r,n)})}function xg(t,s,r,n,a){return ca(this,void 0,void 0,function*(){return gL(t,"POST",s,n,a,r)})}function fge(t,s,r,n,a){return ca(this,void 0,void 0,function*(){return gL(t,"PUT",s,n,a,r)})}function Nmt(t,s,r,n){return ca(this,void 0,void 0,function*(){return gL(t,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function N1e(t,s,r,n,a){return ca(this,void 0,void 0,function*(){return gL(t,"DELETE",s,n,a,r)})}class Smt{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r}then(s,r){return this.execute().then(s,r)}execute(){return ca(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(wc(s))return{data:null,error:s};throw s}})}}var Nze;class Cmt{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r,this[Nze]="BlobDownloadBuilder",this.promise=null}asStream(){return new Smt(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 ca(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(wc(s))return{data:null,error:s};throw s}})}}Nze=Symbol.toStringTag;const Mmt={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},Y4e={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class Tmt{constructor(s,r={},n,a){this.shouldThrowOnError=!1,this.url=s,this.headers=r,this.bucketId=n,this.fetch=k1e(a)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(s,r,n,a){return ca(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},Y4e),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),p=this._getFinalPath(u),f=yield(s=="PUT"?fge:xg)(this.fetch,`${this.url}/object/${p}`,o,Object.assign({headers:i},l!=null&&l.duplex?{duplex:l.duplex}:{}));return{data:{path:u,id:f.Id,fullPath:f.Key},error:null}}catch(o){if(this.shouldThrowOnError)throw o;if(wc(o))return{data:null,error:o};throw o}})}upload(s,r,n){return ca(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return ca(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:Y4e.upsert},a),p=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,p["cache-control"]=`max-age=${u.cacheControl}`,p["content-type"]=u.contentType);const f=yield fge(this.fetch,i.toString(),d,{headers:p});return{data:{path:o,fullPath:f.Key},error:null}}catch(d){if(this.shouldThrowOnError)throw d;if(wc(d))return{data:null,error:d};throw d}})}createSignedUploadUrl(s,r){return ca(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 xg(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 j1e("No token returned by API");return{data:{signedUrl:l.toString(),path:s,token:i},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(wc(n))return{data:null,error:n};throw n}})}update(s,r,n){return ca(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return ca(this,void 0,void 0,function*(){try{return{data:yield xg(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(wc(a))return{data:null,error:a};throw a}})}copy(s,r,n){return ca(this,void 0,void 0,function*(){try{return{data:{path:(yield xg(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(wc(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return ca(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),o=yield xg(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(wc(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return ca(this,void 0,void 0,function*(){try{const a=yield xg(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(wc(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=()=>UI(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0});return new Cmt(d,this.shouldThrowOnError)}info(s){return ca(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield UI(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:pge(n),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(wc(n))return{data:null,error:n};throw n}})}exists(s){return ca(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(wc(n)&&n instanceof mge){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 ca(this,void 0,void 0,function*(){try{return{data:yield N1e(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(wc(r))return{data:null,error:r};throw r}})}list(s,r,n){return ca(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},Mmt),r),{prefix:s||""});return{data:yield xg(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(wc(a))return{data:null,error:a};throw a}})}listV2(s,r){return ca(this,void 0,void 0,function*(){try{const n=Object.assign({},s);return{data:yield xg(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(wc(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 Sze="2.78.0",Cze={"X-Client-Info":`storage-js/${Sze}`};class Amt{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({},Cze),r),this.fetch=k1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(s){return ca(this,void 0,void 0,function*(){try{const r=this.listBucketOptionsToQueryString(s);return{data:yield UI(this.fetch,`${this.url}/bucket${r}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(wc(r))return{data:null,error:r};throw r}})}getBucket(s){return ca(this,void 0,void 0,function*(){try{return{data:yield UI(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(wc(r))return{data:null,error:r};throw r}})}createBucket(s){return ca(this,arguments,void 0,function*(r,n={public:!1}){try{return{data:yield xg(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(wc(a))return{data:null,error:a};throw a}})}updateBucket(s,r){return ca(this,void 0,void 0,function*(){try{return{data:yield fge(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(wc(n))return{data:null,error:n};throw n}})}emptyBucket(s){return ca(this,void 0,void 0,function*(){try{return{data:yield xg(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(wc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ca(this,void 0,void 0,function*(){try{return{data:yield N1e(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(wc(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 Emt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Cze),r),this.fetch=k1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return ca(this,void 0,void 0,function*(){try{return{data:yield xg(this.fetch,`${this.url}/bucket`,{name:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(wc(r))return{data:null,error:r};throw r}})}listBuckets(s){return ca(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 UI(this.fetch,a,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(wc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ca(this,void 0,void 0,function*(){try{return{data:yield N1e(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(wc(r))return{data:null,error:r};throw r}})}}const S1e={"X-Client-Info":`storage-js/${Sze}`,"Content-Type":"application/json"};class Mze extends Error{constructor(s){super(s),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function ap(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}class vhe extends Mze{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 Pmt extends Mze{constructor(s,r){super(s),this.name="StorageVectorsUnknownError",this.originalError=r}}var X4e;(function(t){t.InternalError="InternalError",t.S3VectorConflictException="S3VectorConflictException",t.S3VectorNotFoundException="S3VectorNotFoundException",t.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",t.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",t.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(X4e||(X4e={}));const C1e=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>dy(async()=>{const{default:n}=await Promise.resolve().then(()=>JN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},Imt=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)},Q4e=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Lmt=(t,s,r)=>ca(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 vhe(Q4e(l),a,i))}).catch(()=>{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new vhe(i,a,l))});else{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new vhe(i,a,l))}}else s(new Pmt(Q4e(t),t))}),Dmt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return n?(Imt(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 Omt(t,s,r,n,a,o){return ca(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,Dmt(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=>Lmt(d,i,n))})})}function ip(t,s,r,n,a){return ca(this,void 0,void 0,function*(){return Omt(t,"POST",s,n,a,r)})}class Rmt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},S1e),r),this.fetch=C1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(s){return ca(this,void 0,void 0,function*(){try{return{data:(yield ip(this.fetch,`${this.url}/CreateIndex`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}getIndex(s,r){return ca(this,void 0,void 0,function*(){try{return{data:yield ip(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(ap(n))return{data:null,error:n};throw n}})}listIndexes(s){return ca(this,void 0,void 0,function*(){try{return{data:yield ip(this.fetch,`${this.url}/ListIndexes`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}deleteIndex(s,r){return ca(this,void 0,void 0,function*(){try{return{data:(yield ip(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(ap(n))return{data:null,error:n};throw n}})}}class Fmt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},S1e),r),this.fetch=C1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(s){return ca(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 ip(this.fetch,`${this.url}/PutVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}getVectors(s){return ca(this,void 0,void 0,function*(){try{return{data:yield ip(this.fetch,`${this.url}/GetVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}listVectors(s){return ca(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 ip(this.fetch,`${this.url}/ListVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}queryVectors(s){return ca(this,void 0,void 0,function*(){try{return{data:yield ip(this.fetch,`${this.url}/QueryVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}deleteVectors(s){return ca(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 ip(this.fetch,`${this.url}/DeleteVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}}class zmt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},S1e),r),this.fetch=C1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return ca(this,void 0,void 0,function*(){try{return{data:(yield ip(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}getBucket(s){return ca(this,void 0,void 0,function*(){try{return{data:yield ip(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}listBuckets(){return ca(this,arguments,void 0,function*(s={}){try{return{data:yield ip(this.fetch,`${this.url}/ListVectorBuckets`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ca(this,void 0,void 0,function*(){try{return{data:(yield ip(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}}class Bmt extends zmt{constructor(s,r={}){super(s,r.headers||{},r.fetch)}from(s){return new $mt(this.url,this.headers,s,this.fetch)}}class $mt extends Rmt{constructor(s,r,n,a){super(s,r,a),this.vectorBucketName=n}createIndex(s){const r=Object.create(null,{createIndex:{get:()=>super.createIndex}});return ca(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 ca(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 ca(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 ca(this,void 0,void 0,function*(){return r.deleteIndex.call(this,this.vectorBucketName,s)})}index(s){return new qmt(this.url,this.headers,this.vectorBucketName,s,this.fetch)}}class qmt extends Fmt{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 ca(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 ca(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 ca(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 ca(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 ca(this,void 0,void 0,function*(){return r.deleteVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class Umt extends Amt{constructor(s,r={},n,a){super(s,r,n,a)}from(s){return new Tmt(this.url,this.headers,s,this.fetch)}get vectors(){return new Bmt(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new Emt(this.url+"/iceberg",this.headers,this.fetch)}}const Vmt="2.78.0";let NE="";typeof Deno<"u"?NE="deno":typeof document<"u"?NE="web":typeof navigator<"u"&&navigator.product==="ReactNative"?NE="react-native":NE="node";const Hmt={"X-Client-Info":`supabase-js-${NE}/${Vmt}`},Wmt={headers:Hmt},Gmt={schema:"public"},Kmt={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Zmt={},Ymt=t=>{let s;return t?s=t:typeof fetch>"u"?s=rze:s=fetch,(...r)=>s(...r)},Xmt=()=>typeof Headers>"u"?nze:Headers,Qmt=(t,s,r)=>{const n=Ymt(r),a=Xmt();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 Jmt(t){return t.endsWith("/")?t:t+"/"}function ept(t,s){var r,n;const{db:a,auth:o,realtime:l,global:i}=t,{db:d,auth:u,realtime:p,global:f}=s,v={db:Object.assign(Object.assign({},d),a),auth:Object.assign(Object.assign({},u),o),realtime:Object.assign(Object.assign({},p),l),storage:{},global:Object.assign(Object.assign(Object.assign({},f),i),{headers:Object.assign(Object.assign({},(r=f==null?void 0:f.headers)!==null&&r!==void 0?r:{}),(n=i==null?void 0:i.headers)!==null&&n!==void 0?n:{})}),accessToken:async()=>""};return t.accessToken?v.accessToken=t.accessToken:delete v.accessToken,v}function tpt(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(Jmt(s))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const Tze="2.78.0",f4=30*1e3,gge=3,_he=gge*f4,spt="http://localhost:9999",rpt="supabase.auth.token",npt={"X-Client-Info":`gotrue-js/${Tze}`},xge="X-Supabase-Api-Version",Aze={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},apt=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,ipt=10*60*1e3;class VI extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Ma(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class opt extends VI{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function lpt(t){return Ma(t)&&t.name==="AuthApiError"}class vk extends VI{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class B_ extends VI{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class ug extends B_{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function cpt(t){return Ma(t)&&t.name==="AuthSessionMissingError"}class GC extends B_{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class C8 extends B_{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class M8 extends B_{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 dpt(t){return Ma(t)&&t.name==="AuthImplicitGrantRedirectError"}class J4e extends B_{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 yge extends B_{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function bhe(t){return Ma(t)&&t.name==="AuthRetryableFetchError"}class e5e extends B_{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class vge extends B_{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const rne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),t5e=` \r=`.split(""),upt=(()=>{const t=new Array(128);for(let s=0;s=6;){const n=s.queue>>s.queuedBits-6&63;r(rne[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(rne[n]),s.queuedBits-=6}}function Eze(t,s,r){const n=upt[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 r5e(t){const s=[],r=l=>{s.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{ppt(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 mpt(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}hpt(n,s)}}function ppt(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 T5(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function Sk(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};return t.forEach(a=>s5e(a,r,n)),s5e(null,r,n),s.join("")}function gpt(t){return Math.round(Date.now()/1e3)+t}function xpt(){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 jh=()=>typeof window<"u"&&typeof document<"u",Wb={tested:!1,writable:!1},Pze=()=>{if(!jh())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Wb.tested)return Wb.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Wb.tested=!0,Wb.writable=!0}catch{Wb.tested=!0,Wb.writable=!1}return Wb.writable};function ypt(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 Ize=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>dy(async()=>{const{default:n}=await Promise.resolve().then(()=>JN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},vpt=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",g4=async(t,s,r)=>{await t.setItem(s,JSON.stringify(r))},Gb=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},Kv=async(t,s)=>{await t.removeItem(s)};class ooe{constructor(){this.promise=new ooe.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}ooe.promiseConstructor=Promise;function whe(t){const s=t.split(".");if(s.length!==3)throw new vge("Invalid JWT structure");for(let n=0;n{setTimeout(()=>s(null),t)})}function bpt(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 wpt(t){return("0"+t.toString(16)).substr(-2)}function jpt(){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,wpt).join("")}async function kpt(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 kpt(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function KC(t,s,r=!1){const n=jpt();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await g4(t,`${s}-code-verifier`,a);const o=await Npt(n);return[o,n===o?"plain":"s256"]}const Spt=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function Cpt(t){const s=t.headers.get(xge);if(!s||!s.match(Spt))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function Mpt(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 Tpt(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 Apt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function ZC(t){if(!Apt.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function jhe(){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 Ept(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 n5e(t){return JSON.parse(JSON.stringify(t))}const hk=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Ppt=[502,503,504];async function a5e(t){var s;if(!vpt(t))throw new yge(hk(t),0);if(Ppt.includes(t.status))throw new yge(hk(t),t.status);let r;try{r=await t.json()}catch(o){throw new vk(hk(o),o)}let n;const a=Cpt(t);if(a&&a.getTime()>=Aze["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 e5e(hk(r),t.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new ug}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 e5e(hk(r),t.status,r.weak_password.reasons);throw new opt(hk(r),t.status||500,n)}const Ipt=(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 di(t,s,r,n){var a;const o=Object.assign({},n==null?void 0:n.headers);o[xge]||(o[xge]=Aze["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 Lpt(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 Lpt(t,s,r,n,a,o){const l=Ipt(s,n,a,o);let i;try{i=await t(r,Object.assign({},l))}catch(d){throw console.error(d),new yge(hk(d),0)}if(i.ok||await a5e(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(d){await a5e(d)}}function hg(t){var s;let r=null;Rpt(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=gpt(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function i5e(t){const s=hg(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 y1(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function Dpt(t){return{data:t,error:null}}function Opt(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=z_(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 o5e(t){return t}function Rpt(t){return t.access_token&&t.refresh_token&&t.expires_in}const khe=["global","local","others"];class Fpt{constructor({url:s="",headers:r={},fetch:n}){this.url=s,this.headers=r,this.fetch=Ize(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=khe[0]){if(khe.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${khe.join(", ")}`);try{return await di(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:s,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Ma(n))return{data:null,error:n};throw n}}async inviteUserByEmail(s,r={}){try{return await di(this.fetch,"POST",`${this.url}/invite`,{body:{email:s,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:y1})}catch(n){if(Ma(n))return{data:{user:null},error:n};throw n}}async generateLink(s){try{const{options:r}=s,n=z_(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 di(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:a,headers:this.headers,xform:Opt,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(Ma(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(s){try{return await di(this.fetch,"POST",`${this.url}/admin/users`,{body:s,headers:this.headers,xform:y1})}catch(r){if(Ma(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},p=await di(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:o5e});if(p.error)throw p.error;const f=await p.json(),v=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,_=(d=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&d!==void 0?d:[];return _.length>0&&(_.forEach(b=>{const j=parseInt(b.split(";")[0].split("=")[1].substring(0,1)),w=JSON.parse(b.split(";")[1].split("=")[1]);u[`${w}Page`]=j}),u.total=parseInt(v)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Ma(u))return{data:{users:[]},error:u};throw u}}async getUserById(s){ZC(s);try{return await di(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:y1})}catch(r){if(Ma(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){ZC(s);try{return await di(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:y1})}catch(n){if(Ma(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){ZC(s);try{return await di(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:y1})}catch(n){if(Ma(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){ZC(s.userId);try{const{data:r,error:n}=await di(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(Ma(r))return{data:null,error:r};throw r}}async _deleteFactor(s){ZC(s.userId),ZC(s.id);try{return{data:await di(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(r){if(Ma(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},p=await di(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:o5e});if(p.error)throw p.error;const f=await p.json(),v=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,_=(d=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&d!==void 0?d:[];return _.length>0&&(_.forEach(b=>{const j=parseInt(b.split(";")[0].split("=")[1].substring(0,1)),w=JSON.parse(b.split(";")[1].split("=")[1]);u[`${w}Page`]=j}),u.total=parseInt(v)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Ma(u))return{data:{clients:[]},error:u};throw u}}async _createOAuthClient(s){try{return await di(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ma(r))return{data:null,error:r};throw r}}async _getOAuthClient(s){try{return await di(this.fetch,"GET",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ma(r))return{data:null,error:r};throw r}}async _updateOAuthClient(s,r){try{return await di(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${s}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Ma(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(s){try{return await di(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(Ma(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(s){try{return await di(this.fetch,"POST",`${this.url}/admin/oauth/clients/${s}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ma(r))return{data:null,error:r};throw r}}}function l5e(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}const YC={debug:!!(globalThis&&Pze()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class Lze extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class zpt extends Lze{}async function Bpt(t,s,r){YC.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),YC.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){YC.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,a.name);try{return await r()}finally{YC.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,a.name)}}else{if(s===0)throw YC.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new zpt(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(YC.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 Dze(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function qpt(t){return parseInt(t,16)}function Upt(t){const s=new TextEncoder().encode(t);return"0x"+Array.from(s,n=>n.toString(16).padStart(2,"0")).join("")}function Vpt(t){var s;const{chainId:r,domain:n,expirationTime:a,issuedAt:o=new Date,nonce:l,notBefore:i,requestId:d,resources:u,scheme:p,uri:f,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(!f)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 _=Dze(t.address),b=p?`${p}://${n}`:n,j=t.statement?`${t.statement} `:"",w=`${b} wants you to sign in with your Ethereum account: ${_} ${j}`;let N=`URI: ${f} 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 C=` 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}`);C+=` - ${A}`}N+=C}return`${w} ${N}`}class bd 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 nne extends bd{constructor(s,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:s}),this.name="WebAuthnUnknownError",this.originalError=r}}function Hpt({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 bd({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 bd({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 bd({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 bd({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 bd({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new bd({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 bd({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new bd({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(Oze(l)){if(o.rp.id!==l)return new bd({message:`The RP ID "${o.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new bd({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 bd({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 bd({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 bd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function Wpt({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 bd({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new bd({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(Oze(n)){if(r.rpId!==n)return new bd({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new bd({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new bd({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 bd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class Gpt{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 Kpt=new Gpt;function Zpt(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=z_(t,["challenge","user","excludeCredentials"]),o=T5(s).buffer,l=Object.assign(Object.assign({},r),{id:T5(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]=ane(i,l):n[o]=ane(l)}else n[o]=l}return n}function rft(t,s){return ane(tft,t,s||{})}function nft(t,s){return ane(sft,t,s||{})}class aft{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??Kpt.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=rft(l.webauthn.credential_options.publicKey,o==null?void 0:o.create),{data:p,error:f}=await Jpt({publicKey:u,signal:d});return p?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:p}},error:null}:{data:null,error:f}}case"request":{const u=nft(l.webauthn.credential_options.publicKey,o==null?void 0:o.request),{data:p,error:f}=await eft(Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:u,signal:d}));return p?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:p}},error:null}:{data:null,error:f}}}}catch(l){return Ma(l)?{data:null,error:l}:{data:null,error:new vk("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 VI("rpId is required for WebAuthn authentication")};try{if(!c5e())return{data:null,error:new vk("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 Ma(l)?{data:null,error:l}:{data:null,error:new vk("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 VI("rpId is required for WebAuthn registration")};try{if(!c5e())return{data:null,error:new vk("Browser does not support WebAuthn",null)};const{data:l,error:i}=await this._enroll({friendlyName:s});if(!l)return await this.client.mfa.listFactors().then(p=>{var f;return(f=p.data)===null||f===void 0?void 0:f.all.find(v=>v.factor_type==="webauthn"&&v.friendly_name===s&&v.status!=="unverified")}).then(p=>p?this.client.mfa.unenroll({factorId:p==null?void 0:p.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 Ma(l)?{data:null,error:l}:{data:null,error:new vk("Unexpected error in register",l)}}}}$pt();const ift={url:spt,storageKey:rpt,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:npt,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function d5e(t,s,r){return await r()}const XC={};class HI{get jwks(){var s,r;return(r=(s=XC[this.storageKey])===null||s===void 0?void 0:s.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(s){XC[this.storageKey]=Object.assign(Object.assign({},XC[this.storageKey]),{jwks:s})}get jwks_cached_at(){var s,r;return(r=(s=XC[this.storageKey])===null||s===void 0?void 0:s.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(s){XC[this.storageKey]=Object.assign(Object.assign({},XC[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=HI.nextInstanceID,HI.nextInstanceID+=1,this.instanceID>0&&jh()&&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({},ift),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 Fpt({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=Ize(a.fetch),this.lock=a.lock||d5e,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:jh()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=Bpt:this.lock=d5e,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 aft(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:Pze()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=l5e(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=l5e(this.memoryStorage)),jh()&&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} (${Tze}) ${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=ypt(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),jh()&&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),dpt(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 Ma(r)?{error:r}:{error:new vk("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var r,n,a;try{const o=await di(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:hg}),{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(Ma(o))return{data:{user:null,session:null},error:o};throw o}}async signUp(s){var r,n,a;try{let o;if("email"in s){const{email:p,password:f,options:v}=s;let _=null,b=null;this.flowType==="pkce"&&([_,b]=await KC(this.storage,this.storageKey)),o=await di(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:v==null?void 0:v.emailRedirectTo,body:{email:p,password:f,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:hg})}else if("phone"in s){const{phone:p,password:f,options:v}=s;o=await di(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:p,password:f,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:hg})}else throw new C8("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(Ma(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 di(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:i5e})}else if("phone"in s){const{phone:o,password:l,options:i}=s;r=await di(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:i5e})}else throw new C8("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 GC}:(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(Ma(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,p,f,v;let _,b;if("message"in s)_=s.message,b=s.signature;else{const{chain:j,wallet:w,statement:N,options:C}=s;let A;if(jh())if(typeof w=="object")A=w;else{const U=window;if("ethereum"in U&&typeof U.ethereum=="object"&&"request"in U.ethereum&&typeof U.ethereum.request=="function")A=U.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof w!="object"||!(C!=null&&C.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");A=w}const I=new URL((r=C==null?void 0:C.url)!==null&&r!==void 0?r:window.location.href),L=await A.request({method:"eth_requestAccounts"}).then(U=>U).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!L||L.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const R=Dze(L[0]);let $=(n=C==null?void 0:C.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!$){const U=await A.request({method:"eth_chainId"});$=qpt(U)}const q={domain:I.host,address:R,statement:N,uri:I.href,version:"1",chainId:$,nonce:(a=C==null?void 0:C.signInWithEthereum)===null||a===void 0?void 0:a.nonce,issuedAt:(l=(o=C==null?void 0:C.signInWithEthereum)===null||o===void 0?void 0:o.issuedAt)!==null&&l!==void 0?l:new Date,expirationTime:(i=C==null?void 0:C.signInWithEthereum)===null||i===void 0?void 0:i.expirationTime,notBefore:(d=C==null?void 0:C.signInWithEthereum)===null||d===void 0?void 0:d.notBefore,requestId:(u=C==null?void 0:C.signInWithEthereum)===null||u===void 0?void 0:u.requestId,resources:(p=C==null?void 0:C.signInWithEthereum)===null||p===void 0?void 0:p.resources};_=Vpt(q),b=await A.request({method:"personal_sign",params:[Upt(_),R]})}try{const{data:j,error:w}=await di(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:_,signature:b},!((f=s.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(v=s.options)===null||v===void 0?void 0:v.captchaToken}}:null),xform:hg});if(w)throw w;return!j||!j.session||!j.user?{data:{user:null,session:null},error:new GC}:(j.session&&(await this._saveSession(j.session),await this._notifyAllSubscribers("SIGNED_IN",j.session)),{data:Object.assign({},j),error:w})}catch(j){if(Ma(j))return{data:{user:null,session:null},error:j};throw j}}async signInWithSolana(s){var r,n,a,o,l,i,d,u,p,f,v,_;let b,j;if("message"in s)b=s.message,j=s.signature;else{const{chain:w,wallet:N,statement:C,options:A}=s;let I;if(jh())if(typeof N=="object")I=N;else{const R=window;if("solana"in R&&typeof R.solana=="object"&&("signIn"in R.solana&&typeof R.solana.signIn=="function"||"signMessage"in R.solana&&typeof R.solana.signMessage=="function"))I=R.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof N!="object"||!(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 R=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}),C?{statement:C}:null));let $;if(Array.isArray(R)&&R[0]&&typeof R[0]=="object")$=R[0];else if(R&&typeof R=="object"&&"signedMessage"in R&&"signature"in R)$=R;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),j=$.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(),...C?["",C,""]:[""],"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}`]:[],...!((f=(p=A==null?void 0:A.signInWithSolana)===null||p===void 0?void 0:p.resources)===null||f===void 0)&&f.length?["Resources",...A.signInWithSolana.resources.map($=>`- ${$}`)]:[]].join(` `);const R=await I.signMessage(new TextEncoder().encode(b),"utf8");if(!R||!(R instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");j=R}}try{const{data:w,error:N}=await di(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:b,signature:Sk(j)},!((v=s.options)===null||v===void 0)&&v.captchaToken?{gotrue_meta_security:{captcha_token:(_=s.options)===null||_===void 0?void 0:_.captchaToken}}:null),xform:hg});if(N)throw N;return!w||!w.session||!w.user?{data:{user:null,session:null},error:new GC}:(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),{data:Object.assign({},w),error:N})}catch(w){if(Ma(w))return{data:{user:null,session:null},error:w};throw w}}async _exchangeCodeForSession(s){const r=await Gb(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(r??"").split("/");try{const{data:o,error:l}=await di(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:n},xform:hg});if(await Kv(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new GC}:(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(Ma(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 di(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:hg}),{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 GC}:(d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",d.session)),{data:d,error:u})}catch(r){if(Ma(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,p=null;this.flowType==="pkce"&&([u,p]=await KC(this.storage,this.storageKey));const{error:f}=await di(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:p},redirectTo:d==null?void 0:d.emailRedirectTo});return{data:{user:null,session:null},error:f}}if("phone"in s){const{phone:i,options:d}=s,{data:u,error:p}=await di(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:p}}throw new C8("You must provide either an email or phone number.")}catch(i){if(Ma(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 di(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:o}}),redirectTo:a,xform:hg});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(Ma(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 KC(this.storage,this.storageKey)),await di(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:Dpt})}catch(o){if(Ma(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 ug;const{error:a}=await di(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(s){if(Ma(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 di(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 di(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 C8("You must provide either an email or phone number and a type")}catch(r){if(Ma(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 Gb(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()<_he:!1;if(this._debug("#__loadSession()",`session has${n?"":" not"} expired`,"expires_at",s.expires_at),!n){if(this.userStorage){const l=await Gb(this.userStorage,this.storageKey+"-user");l!=null&&l.user?s.user=l.user:s.user=jhe()}if(this.storage.isServer&&s.user&&!s.user.__isUserNotAvailableProxy){const l={value:this.suppressGetSessionWarning};s.user=Ept(s.user,l),l.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:s},error:null}}const{data:a,error:o}=await this._callRefreshToken(s.refresh_token);return o?{data:{session:null},error:o}:{data:{session:a},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(s){return s?await this._getUser(s):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(s){try{return s?await di(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:y1}):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 ug}:await di(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:y1})})}catch(r){if(Ma(r))return cpt(r)&&(await this._removeSession(),await Kv(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 ug;const l=a.session;let i=null,d=null;this.flowType==="pkce"&&s.email!=null&&([i,d]=await KC(this.storage,this.storageKey));const{data:u,error:p}=await di(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:y1});if(p)throw p;return l.user=u.user,await this._saveSession(l),await this._notifyAllSubscribers("USER_UPDATED",l),{data:{user:l.user},error:null}})}catch(n){if(Ma(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 ug;const r=Date.now()/1e3;let n=r,a=!0,o=null;const{payload:l}=whe(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(Ma(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 ug;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(Ma(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!jh())throw new M8("No browser detected.");if(s.error||s.error_description||s.error_code)throw new M8(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 J4e("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new M8("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 J4e("No code detected.");const{data:C,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:C.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:o,refresh_token:l,expires_in:i,expires_at:d,token_type:u}=s;if(!o||!i||!l||!u)throw new M8("No session defined in URL");const p=Math.round(Date.now()/1e3),f=parseInt(i);let v=p+f;d&&(v=parseInt(d));const _=v-p;_*1e3<=f4&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${_}s, should have been closer to ${f}s`);const b=v-f;p-b>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",b,v,p):p-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,p);const{data:j,error:w}=await this._getUser(o);if(w)throw w;const N={provider_token:n,provider_refresh_token:a,access_token:o,expires_in:f,expires_at:v,refresh_token:l,token_type:u,user:j.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:N,redirectType:s.type},error:null}}catch(n){if(Ma(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 Gb(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&&!(lpt(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await Kv(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=xpt(),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 KC(this.storage,this.storageKey,!0));try{return await di(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(Ma(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(Ma(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,p;const{data:f,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 di(this.fetch,"GET",_,{headers:this.headers,jwt:(p=(u=f.session)===null||u===void 0?void 0:u.access_token)!==null&&p!==void 0?p:void 0})});if(a)throw a;return jh()&&!(!((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(Ma(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:p}=s,f=await di(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:p,link_identity:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:hg}),{data:v,error:_}=f;return _?{data:{user:null,session:null},error:_}:!v||!v.session||!v.user?{data:{user:null,session:null},error:new GC}:(v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("USER_UPDATED",v.session)),{data:v,error:_})}catch(a){if(Ma(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 di(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(Ma(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 bpt(async a=>(a>0&&await _pt(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await di(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:hg})),(a,o)=>{const l=200*Math.pow(2,a);return o&&bhe(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(),f4);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)/f4);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${f4}ms, refresh threshold is ${gge} ticks`),a<=gge&&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 Lze)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!jh()||!(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 KC(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 di(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(Ma(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 di(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(Ma(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"?Xpt(s.webauthn.credential_response):Qpt(s.webauthn.credential_response)})}:{code:s.code}),{data:i,error:d}=await di(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(Ma(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 di(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:Zpt(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:Ypt(i.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(Ma(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}=whe(n.access_token);let l=null;o.aal&&(l=o.aal);let i=l;((r=(s=n.user.factors)===null||s===void 0?void 0:s.filter(p=>p.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(i="aal2");const u=o.amr||[];return{data:{currentLevel:l,nextLevel:i,currentAuthenticationMethods:u},error:null}}async _getAuthorizationDetails(s){try{return await this._useSession(async r=>{const{data:{session:n},error:a}=r;return a?{data:null,error:a}:n?await di(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 ug}})}catch(r){if(Ma(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 ug};const l=await di(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&&jh()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Ma(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 ug};const l=await di(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&&jh()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Ma(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+ipt>a)return n;const{data:o,error:l}=await di(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}}=whe(n);r!=null&&r.allowExpired||Mpt(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 p=Tpt(a.alg),f=await crypto.subtle.importKey("jwk",u,p,!0,["verify"]);if(!await crypto.subtle.verify(p,f,l,fpt(`${i}.${d}`)))throw new vge("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(Ma(n))return{data:null,error:n};throw n}}}HI.nextInstanceID=0;const oft=HI;class lft extends oft{constructor(s){super(s)}}class cft{constructor(s,r,n){var a,o,l;this.supabaseUrl=s,this.supabaseKey=r;const i=tpt(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:Gmt,realtime:Zmt,auth:Object.assign(Object.assign({},Kmt),{storageKey:d}),global:Wmt},p=ept(n??{},u);this.storageKey=(a=p.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(o=p.global.headers)!==null&&o!==void 0?o:{},p.accessToken?(this.accessToken=p.accessToken,this.auth=new Proxy({},{get:(f,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=p.auth)!==null&&l!==void 0?l:{},this.headers,p.global.fetch),this.fetch=Qmt(r,this._getAccessToken.bind(this),p.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},p.realtime)),this.rest=new smt(new URL("rest/v1",i).href,{headers:this.headers,schema:p.db.schema,fetch:this.fetch}),this.storage=new Umt(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),p.accessToken||this._listenForAuthEvents()}get functions(){return new Kht(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},p,f){const v={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new lft({url:this.authUrl.href,headers:Object.assign(Object.assign({},v),p),storageKey:l,autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,userStorage:o,flowType:i,lock:d,debug:u,fetch:f,hasCustomAuthorizationHeader:Object.keys(this.headers).some(_=>_.toLowerCase()==="authorization")})}_initRealtimeClient(s){return new vmt(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 dft=(t,s,r)=>new cft(t,s,r);function uft(){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}uft()&&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 hft="https://relzejiswnotikjgvjhz.supabase.co",mft="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",G=dft(hft,mft,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),Rze=S.createContext(void 0),pft=({children:t})=>{const[s,r]=S.useState(null),[n,a]=S.useState(null),[o,l]=S.useState(!0),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[f,v]=S.useState(null),[_,b]=S.useState([]),[j,w]=S.useState(null),N=Dr(),C=()=>{d(!1),p(!1),v(null),b([]),w(null)},A=async $=>{try{console.log("Checking roles via RPC for user:",$);const[{data:q,error:U},{data:V,error:X}]=await Promise.all([G.rpc("has_role",{_user_id:$,_role:"admin"}),G.rpc("has_role",{_user_id:$,_role:"brokerage_manager"})]);if(U||X)console.error("Role RPC errors:",{isAdminError:U,isBrokerError:X}),d(!1),p(!1);else{const Y=!!q,de=!!V;console.log("RPC roles result:",{adminValue:Y,brokerValue:de}),d(Y),p(de)}const{data:se,error:te}=await G.from("profiles").select("brokerage_id").eq("id",$).single();if(v(!te&&se?se.brokerage_id:null),V){console.log("Fetching managed brokerages for user:",$);const{data:Y,error:de}=await G.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",$);if(console.log("Managed brokerage assignments result:",{assignments:Y,assignmentsError:de}),de||!Y){console.error("Error fetching managed brokerage assignments:",de),b([]);return}const ie=Array.from(new Set(Y.map(be=>be.brokerage_id).filter(Boolean)));if(ie.length===0){b([]);return}const{data:ae,error:le}=await G.from("brokerages").select("id, name").in("id",ie);if(console.log("Managed brokerages details result:",{brokeragesData:ae,brokeragesError:le}),le||!ae){console.error("Error fetching managed brokerages details:",le),b([]);return}const pe=ae.map(be=>({id:be.id,name:be.name})).sort((be,ye)=>ie.indexOf(be.id)-ie.indexOf(ye.id));console.log("Parsed managed brokerages:",pe),b(pe),pe.length>0&&w(be=>be??pe[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),C()}};S.useEffect(()=>{let $=!0,q=!1;const U=()=>{!$||q||(q=!0,l(!1))},{data:{subscription:V}}=G.auth.onAuthStateChange((te,Y)=>{console.log("Auth event:",te),$&&(a(Y),r((Y==null?void 0:Y.user)??null),U(),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):C())}),X=window.setTimeout(()=>{console.warn("Auth initialization timeout reached. Continuing without blocking UI."),U()},4e3);return(async()=>{try{const{data:{session:te}}=await G.auth.getSession();if(!$)return;a(te),r((te==null?void 0:te.user)??null),te!=null&&te.user?await A(te.user.id):C()}catch(te){console.error("Error restoring auth session:",te),$&&(a(null),r(null),C())}finally{U()}})(),()=>{$=!1,window.clearTimeout(X),V.unsubscribe()}},[]);const I=async($,q)=>{const{error:U}=await G.auth.signInWithPassword({email:$,password:q});if(U)throw fe.error(U.message),U;fe.success("Welcome back!"),N("/dashboard")},L=async($,q,U)=>{const V=`${window.location.origin}/dashboard`,{error:X}=await G.auth.signUp({email:$,password:q,options:{emailRedirectTo:V,data:{name:U}}});if(X)throw fe.error(X.message),X;fe.success("Account created! Welcome to LevelUp."),N("/dashboard")},R=async()=>{try{const{data:{session:$}}=await G.auth.getSession();if($){const{error:q}=await G.auth.signOut();q?q.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",q.message):(console.error("Sign out error:",q),fe.error(q.message)):fe.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");r(null),a(null),d(!1),p(!1),v(null),b([]),w(null),N("/auth")}catch($){console.error("Unexpected sign out error:",$),N("/auth")}};return e.jsx(Rze.Provider,{value:{user:s,session:n,loading:o,signIn:I,signUp:L,signOut:R,isAdmin:i,isBrokerageManager:u,brokerageId:f,managedBrokerages:_,selectedBrokerageId:j,setSelectedBrokerageId:w},children:t})},Gs=()=>{const t=S.useContext(Rze);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},Fze=S.createContext(void 0),Kb="levelup_admin_session",Zv="levelup_impersonation",fft=({children:t})=>{const[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState(!1);S.useEffect(()=>{const u=sessionStorage.getItem(Zv);if(u)try{const p=JSON.parse(u);r(!0),a(p)}catch{sessionStorage.removeItem(Zv)}},[]);const i=async u=>{l(!0);try{const{data:{session:p}}=await G.auth.getSession();if(!p)return fe.error("No active session found"),!1;const f={access_token:p.access_token,refresh_token:p.refresh_token};sessionStorage.setItem(Kb,JSON.stringify(f));const v=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/impersonate-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${p.access_token}`},body:JSON.stringify({targetUserId:u})}),_=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(Zv,JSON.stringify(b)),_.method==="session"){const{error:j}=await G.auth.setSession({access_token:_.access_token,refresh_token:_.refresh_token});if(j)throw console.error("Set session error:",j),sessionStorage.removeItem(Kb),sessionStorage.removeItem(Zv),new Error("Failed to establish impersonation session")}else{const j=_.type||"recovery",{error:w}=await G.auth.verifyOtp({token_hash:_.token_hash,type:j});if(w)throw console.error("Verify OTP error:",w),sessionStorage.removeItem(Kb),sessionStorage.removeItem(Zv),new Error("Failed to establish impersonation session")}return r(!0),a(b),fe.success(`Now viewing as ${b.name}`),window.location.href="/dashboard",!0}catch(p){return console.error("Impersonation error:",p),fe.error(p.message||"Failed to impersonate user"),sessionStorage.removeItem(Kb),sessionStorage.removeItem(Zv),!1}finally{l(!1)}},d=async()=>{l(!0);try{const u=sessionStorage.getItem(Kb);if(!u){await G.auth.signOut(),window.location.href="/auth";return}const p=JSON.parse(u);await G.auth.signOut();const{error:f}=await G.auth.setSession({access_token:p.access_token,refresh_token:p.refresh_token});if(sessionStorage.removeItem(Kb),sessionStorage.removeItem(Zv),f){console.error("Failed to restore admin session:",f),fe.error("Admin session expired, please sign in again"),window.location.href="/auth";return}r(!1),a(null),fe.success("Returned to admin account"),window.location.href="/admin/members"}catch(u){console.error("Stop impersonation error:",u),fe.error("Failed to restore admin session"),sessionStorage.removeItem(Kb),sessionStorage.removeItem(Zv),window.location.href="/auth"}finally{l(!1)}};return e.jsx(Fze.Provider,{value:{isImpersonating:s,impersonatedUser:n,startImpersonation:i,stopImpersonation:d,isLoading:o},children:t})},M1e=()=>{const t=S.useContext(Fze);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},WI=XN("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-full px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),K=S.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?Wve:"button";return e.jsx(l,{className:Pt(WI({variant:s,size:r,className:t})),ref:o,...a})});K.displayName="Button";const gft=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=M1e();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(Th,{className:"h-5 w-5 flex-shrink-0"}),e.jsxs("span",{className:"font-medium text-sm md:text-base",children:[e.jsx("span",{className:"hidden sm:inline",children:"You are viewing as "}),e.jsx("strong",{children:s.name}),e.jsxs("span",{className:"hidden md:inline text-amber-800",children:[" (",s.email,")"]})]})]}),e.jsx(K,{size:"sm",variant:"secondary",onClick:r,disabled:n,className:"bg-amber-100 hover:bg-amber-200 text-amber-950 border-0",children:n?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Ur,{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"})]})})]})})},zze=S.createContext(void 0),QC="levelup_acting_as",T8="levelup_acting_as_self",xft=({children:t})=>{const{user:s}=Gs(),[r,n]=S.useState(!1),[a,o]=S.useState([]),[l,i]=S.useState(null),[d,u]=S.useState({}),[p,f]=S.useState(!0),[v,_]=S.useState(()=>sessionStorage.getItem(T8)==="true");S.useEffect(()=>{if(!(s!=null&&s.id)){n(!1),o([]),i(null),u({}),f(!1);return}(async()=>{f(!0);try{const{data:A}=await G.rpc("has_role",{_user_id:s.id,_role:"assistant"});if(!A){n(!1),o([]),i(null),u({}),f(!1);return}n(!0);const{data:I,error:L}=await G.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",s.id);if(L||!I||I.length===0){o([]),f(!1);return}const R=I.map(U=>U.agent_id),{data:$}=await G.from("profiles").select("id, name, email, avatar_url").in("id",R),q=($||[]).map(U=>({id:U.id,name:U.name||U.email||"Unknown",email:U.email||"",avatar_url:U.avatar_url}));if(o(q),sessionStorage.getItem(T8)==="true")_(!0),i(null),u({});else{const U=sessionStorage.getItem(QC);if(U){const V=q.find(X=>X.id===U);if(V){i(V);const X=I.find(se=>se.agent_id===U);u((X==null?void 0:X.permissions)||{})}else if(q.length>0){i(q[0]);const X=I.find(se=>se.agent_id===q[0].id);u((X==null?void 0:X.permissions)||{}),sessionStorage.setItem(QC,q[0].id)}}else if(q.length>0){i(q[0]);const V=I.find(X=>X.agent_id===q[0].id);u((V==null?void 0:V.permissions)||{}),sessionStorage.setItem(QC,q[0].id)}}}catch(A){console.error("Error loading assistant data:",A)}finally{f(!1)}})()},[s==null?void 0:s.id]);const b=C=>{i(C),_(!1),sessionStorage.removeItem(T8),C?(sessionStorage.setItem(QC,C.id),G.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(s==null?void 0:s.id)||"").eq("agent_id",C.id).single().then(({data:A})=>{u((A==null?void 0:A.permissions)||{})})):(sessionStorage.removeItem(QC),u({}))},j=()=>{_(!0),i(null),u({}),sessionStorage.setItem(T8,"true"),sessionStorage.removeItem(QC)},w=C=>!r||v?!0:d[C]===!0,N=r&&l&&!v?l.id:(s==null?void 0:s.id)||null;return e.jsx(zze.Provider,{value:{isAssistant:r,assignedAgents:a,actingAsAgent:l,setActingAsAgent:b,effectiveUserId:N,permissions:d,hasPermission:w,isLoading:p,isActingAsSelf:v,setActingAsSelf:j},children:t})},T1e=()=>{const t=S.useContext(zze);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},ti=()=>{const{effectiveUserId:t}=T1e();return t};var Bze={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 u3=S;function yft(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var vft=typeof Object.is=="function"?Object.is:yft,_ft=u3.useState,bft=u3.useEffect,wft=u3.useLayoutEffect,jft=u3.useDebugValue;function kft(t,s){var r=s(),n=_ft({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return wft(function(){a.value=r,a.getSnapshot=s,Nhe(a)&&o({inst:a})},[t,r,s]),bft(function(){return Nhe(a)&&o({inst:a}),t(function(){Nhe(a)&&o({inst:a})})},[t]),jft(r),r}function Nhe(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!vft(t,r)}catch{return!0}}function Nft(t,s){return s()}var Sft=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Nft:kft;$ze.useSyncExternalStore=u3.useSyncExternalStore!==void 0?u3.useSyncExternalStore:Sft;Bze.exports=$ze;var Cft=Bze.exports;function Mft(){return Cft.useSyncExternalStore(Tft,()=>!0,()=>!1)}function Tft(){return()=>{}}var A1e="Avatar",[Aft]=Ac(A1e),[Eft,qze]=Aft(A1e),Uze=S.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=S.useState("idle");return e.jsx(Eft,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(Qr.span,{...n,ref:s})})});Uze.displayName=A1e;var Vze="AvatarImage",Hze=S.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=qze(Vze,r),i=Pft(n,o),d=Vc(u=>{a(u),l.onImageLoadingStatusChange(u)});return Zc(()=>{i!=="idle"&&d(i)},[i,d]),i==="loaded"?e.jsx(Qr.img,{...o,ref:s,src:n}):null});Hze.displayName=Vze;var Wze="AvatarFallback",Gze=S.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=qze(Wze,r),[l,i]=S.useState(n===void 0);return S.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});Gze.displayName=Wze;function u5e(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Pft(t,{referrerPolicy:s,crossOrigin:r}){const n=Mft(),a=S.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=S.useState(()=>u5e(o,t));return Zc(()=>{i(u5e(o,t))},[o,t]),Zc(()=>{const d=f=>()=>{i(f)};if(!o)return;const u=d("loaded"),p=d("error");return o.addEventListener("load",u),o.addEventListener("error",p),s&&(o.referrerPolicy=s),typeof r=="string"&&(o.crossOrigin=r),()=>{o.removeEventListener("load",u),o.removeEventListener("error",p)}},[o,r,s]),l}var Kze=Uze,Zze=Hze,Yze=Gze;const gn=S.forwardRef(({className:t,...s},r)=>e.jsx(Kze,{ref:r,className:Pt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));gn.displayName=Kze.displayName;const Ea=S.forwardRef(({className:t,...s},r)=>e.jsx(Zze,{ref:r,className:Pt("aspect-square h-full w-full",t),...s}));Ea.displayName=Zze.displayName;const xn=S.forwardRef(({className:t,...s},r)=>e.jsx(Yze,{ref:r,className:Pt("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));xn.displayName=Yze.displayName;const Ift=XN("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 at({className:t,variant:s,...r}){return e.jsx("div",{className:Pt(Ift({variant:s}),t),...r})}var Lft=S.createContext(void 0);function $_(t){const s=S.useContext(Lft);return t||s||"ltr"}var She=0;function loe(){S.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??h5e()),document.body.insertAdjacentElement("beforeend",t[1]??h5e()),She++,()=>{She===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),She--}},[])}function h5e(){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 Che="focusScope.autoFocusOnMount",Mhe="focusScope.autoFocusOnUnmount",m5e={bubbles:!1,cancelable:!0},Dft="FocusScope",xL=S.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,d]=S.useState(null),u=Vc(a),p=Vc(o),f=S.useRef(null),v=Pa(s,j=>d(j)),_=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.useEffect(()=>{if(n){let j=function(A){if(_.paused||!i)return;const I=A.target;i.contains(I)?f.current=I:e1(f.current,{select:!0})},w=function(A){if(_.paused||!i)return;const I=A.relatedTarget;I!==null&&(i.contains(I)||e1(f.current,{select:!0}))},N=function(A){if(document.activeElement===document.body)for(const L of A)L.removedNodes.length>0&&e1(i)};document.addEventListener("focusin",j),document.addEventListener("focusout",w);const C=new MutationObserver(N);return i&&C.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",w),C.disconnect()}}},[n,i,_.paused]),S.useEffect(()=>{if(i){f5e.add(_);const j=document.activeElement;if(!i.contains(j)){const N=new CustomEvent(Che,m5e);i.addEventListener(Che,u),i.dispatchEvent(N),N.defaultPrevented||(Oft($ft(Xze(i)),{select:!0}),document.activeElement===j&&e1(i))}return()=>{i.removeEventListener(Che,u),setTimeout(()=>{const N=new CustomEvent(Mhe,m5e);i.addEventListener(Mhe,p),i.dispatchEvent(N),N.defaultPrevented||e1(j??document.body,{select:!0}),i.removeEventListener(Mhe,p),f5e.remove(_)},0)}}},[i,u,p,_]);const b=S.useCallback(j=>{if(!r&&!n||_.paused)return;const w=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,N=document.activeElement;if(w&&N){const C=j.currentTarget,[A,I]=Rft(C);A&&I?!j.shiftKey&&N===I?(j.preventDefault(),r&&e1(A,{select:!0})):j.shiftKey&&N===A&&(j.preventDefault(),r&&e1(I,{select:!0})):N===C&&j.preventDefault()}},[r,n,_.paused]);return e.jsx(Qr.div,{tabIndex:-1,...l,ref:v,onKeyDown:b})});xL.displayName=Dft;function Oft(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(e1(n,{select:s}),document.activeElement!==r)return}function Rft(t){const s=Xze(t),r=p5e(s,t),n=p5e(s.reverse(),t);return[r,n]}function Xze(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 p5e(t,s){for(const r of t)if(!Fft(r,{upTo:s}))return r}function Fft(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 zft(t){return t instanceof HTMLInputElement&&"select"in t}function e1(t,{select:s=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&zft(t)&&s&&t.select()}}var f5e=Bft();function Bft(){let t=[];return{add(s){const r=t[0];s!==r&&(r==null||r.pause()),t=g5e(t,s),t.unshift(s)},remove(s){var r;t=g5e(t,s),(r=t[0])==null||r.resume()}}}function g5e(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 The="rovingFocusGroup.onEntryFocus",qft={bubbles:!1,cancelable:!0},yL="RovingFocusGroup",[_ge,Qze,Uft]=cL(yL),[Vft,q_]=Ac(yL,[Uft]),[Hft,Wft]=Vft(yL),Jze=S.forwardRef((t,s)=>e.jsx(_ge.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(_ge.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Gft,{...t,ref:s})})}));Jze.displayName=yL;var Gft=S.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...f}=t,v=S.useRef(null),_=Pa(s,v),b=$_(o),[j,w]=xu({prop:l,defaultProp:i??null,onChange:d,caller:yL}),[N,C]=S.useState(!1),A=Vc(u),I=Qze(r),L=S.useRef(!1),[R,$]=S.useState(0);return S.useEffect(()=>{const q=v.current;if(q)return q.addEventListener(The,A),()=>q.removeEventListener(The,A)},[A]),e.jsx(Hft,{scope:r,orientation:n,dir:b,loop:a,currentTabStopId:j,onItemFocus:S.useCallback(q=>w(q),[w]),onItemShiftTab:S.useCallback(()=>C(!0),[]),onFocusableItemAdd:S.useCallback(()=>$(q=>q+1),[]),onFocusableItemRemove:S.useCallback(()=>$(q=>q-1),[]),children:e.jsx(Qr.div,{tabIndex:N||R===0?-1:0,"data-orientation":n,...f,ref:_,style:{outline:"none",...t.style},onMouseDown:Cr(t.onMouseDown,()=>{L.current=!0}),onFocus:Cr(t.onFocus,q=>{const U=!L.current;if(q.target===q.currentTarget&&U&&!N){const V=new CustomEvent(The,qft);if(q.currentTarget.dispatchEvent(V),!V.defaultPrevented){const X=I().filter(ie=>ie.focusable),se=X.find(ie=>ie.active),te=X.find(ie=>ie.id===j),de=[se,te,...X].filter(Boolean).map(ie=>ie.ref.current);s7e(de,p)}}L.current=!1}),onBlur:Cr(t.onBlur,()=>C(!1))})})}),e7e="RovingFocusGroupItem",t7e=S.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,d=Gd(),u=o||d,p=Wft(e7e,r),f=p.currentTabStopId===u,v=Qze(r),{onFocusableItemAdd:_,onFocusableItemRemove:b,currentTabStopId:j}=p;return S.useEffect(()=>{if(n)return _(),()=>b()},[n,_,b]),e.jsx(_ge.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:e.jsx(Qr.span,{tabIndex:f?0:-1,"data-orientation":p.orientation,...i,ref:s,onMouseDown:Cr(t.onMouseDown,w=>{n?p.onItemFocus(u):w.preventDefault()}),onFocus:Cr(t.onFocus,()=>p.onItemFocus(u)),onKeyDown:Cr(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const N=Yft(w,p.orientation,p.dir);if(N!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.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(w.currentTarget);A=p.loop?Xft(A,I+1):A.slice(I+1)}setTimeout(()=>s7e(A))}}),children:typeof l=="function"?l({isCurrentTabStop:f,hasTabStop:j!=null}):l})})});t7e.displayName=e7e;var Kft={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Zft(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Yft(t,s,r){const n=Zft(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return Kft[n]}function s7e(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function Xft(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var coe=Jze,doe=t7e,Qft=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},JC=new WeakMap,A8=new WeakMap,E8={},Ahe=0,r7e=function(t){return t&&(t.host||r7e(t.parentNode))},Jft=function(t,s){return s.map(function(r){if(t.contains(r))return r;var n=r7e(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})},egt=function(t,s,r,n){var a=Jft(s,Array.isArray(t)?t:[t]);E8[r]||(E8[r]=new WeakMap);var o=E8[r],l=[],i=new Set,d=new Set(a),u=function(f){!f||i.has(f)||(i.add(f),u(f.parentNode))};a.forEach(u);var p=function(f){!f||d.has(f)||Array.prototype.forEach.call(f.children,function(v){if(i.has(v))p(v);else try{var _=v.getAttribute(n),b=_!==null&&_!=="false",j=(JC.get(v)||0)+1,w=(o.get(v)||0)+1;JC.set(v,j),o.set(v,w),l.push(v),j===1&&b&&A8.set(v,!0),w===1&&v.setAttribute(r,"true"),b||v.setAttribute(n,"true")}catch(N){console.error("aria-hidden: cannot operate on ",v,N)}})};return p(s),i.clear(),Ahe++,function(){l.forEach(function(f){var v=JC.get(f)-1,_=o.get(f)-1;JC.set(f,v),o.set(f,_),v||(A8.has(f)||f.removeAttribute(n),A8.delete(f)),_||f.removeAttribute(r)}),Ahe--,Ahe||(JC=new WeakMap,JC=new WeakMap,A8=new WeakMap,E8={})}},uoe=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=Qft(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),egt(n,a,r,"aria-hidden")):function(){return null}},Jse="right-scroll-bar-position",ere="width-before-scroll-bar",tgt="with-scroll-bars-hidden",sgt="--removed-body-scroll-bar-size";function Ehe(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function rgt(t,s){var r=S.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 ngt=typeof window<"u"?S.useLayoutEffect:S.useEffect,x5e=new WeakMap;function agt(t,s){var r=rgt(null,function(n){return t.forEach(function(a){return Ehe(a,n)})});return ngt(function(){var n=x5e.get(r);if(n){var a=new Set(n),o=new Set(t),l=r.current;a.forEach(function(i){o.has(i)||Ehe(i,null)}),o.forEach(function(i){a.has(i)||Ehe(i,l)})}x5e.set(r,t)},[t]),r}function igt(t){return t}function ogt(t,s){s===void 0&&(s=igt);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 p=l;l=[],p.forEach(o)},u=function(){return Promise.resolve().then(d)};u(),r={push:function(p){l.push(p),u()},filter:function(p){return l=l.filter(p),r}}}};return a}function lgt(t){t===void 0&&(t={});var s=ogt(null);return s.options=tf({async:!0,ssr:!1},t),s}var n7e=function(t){var s=t.sideCar,r=z_(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 S.createElement(n,tf({},r))};n7e.isSideCarExport=!0;function cgt(t,s){return t.useMedium(s),n7e}var a7e=lgt(),Phe=function(){},hoe=S.forwardRef(function(t,s){var r=S.useRef(null),n=S.useState({onScrollCapture:Phe,onWheelCapture:Phe,onTouchMoveCapture:Phe}),a=n[0],o=n[1],l=t.forwardProps,i=t.children,d=t.className,u=t.removeScrollBar,p=t.enabled,f=t.shards,v=t.sideCar,_=t.noRelative,b=t.noIsolation,j=t.inert,w=t.allowPinchZoom,N=t.as,C=N===void 0?"div":N,A=t.gapMode,I=z_(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),L=v,R=agt([r,s]),$=tf(tf({},I),a);return S.createElement(S.Fragment,null,p&&S.createElement(L,{sideCar:a7e,removeScrollBar:u,shards:f,noRelative:_,noIsolation:b,inert:j,setCallbacks:o,allowPinchZoom:!!w,lockRef:r,gapMode:A}),l?S.cloneElement(S.Children.only(i),tf(tf({},$),{ref:R})):S.createElement(C,tf({},$,{className:d,ref:R}),i))});hoe.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};hoe.classNames={fullWidth:ere,zeroRight:Jse};var dgt=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ugt(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=dgt();return s&&t.setAttribute("nonce",s),t}function hgt(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function mgt(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var pgt=function(){var t=0,s=null;return{add:function(r){t==0&&(s=ugt())&&(hgt(s,r),mgt(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},fgt=function(){var t=pgt();return function(s,r){S.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&r])}},i7e=function(){var t=fgt(),s=function(r){var n=r.styles,a=r.dynamic;return t(n,a),null};return s},ggt={left:0,top:0,right:0,gap:0},Ihe=function(t){return parseInt(t||"",10)||0},xgt=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[Ihe(r),Ihe(n),Ihe(a)]},ygt=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return ggt;var s=xgt(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])}},vgt=i7e(),A5="data-scroll-locked",_gt=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(tgt,` { overflow: hidden `).concat(n,`; padding-right: `).concat(i,"px ").concat(n,`; } body[`).concat(A5,`] { 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(Jse,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(ere,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(Jse," .").concat(Jse,` { right: 0 `).concat(n,`; } .`).concat(ere," .").concat(ere,` { margin-right: 0 `).concat(n,`; } body[`).concat(A5,`] { `).concat(sgt,": ").concat(i,`px; } `)},y5e=function(){var t=parseInt(document.body.getAttribute(A5)||"0",10);return isFinite(t)?t:0},bgt=function(){S.useEffect(function(){return document.body.setAttribute(A5,(y5e()+1).toString()),function(){var t=y5e()-1;t<=0?document.body.removeAttribute(A5):document.body.setAttribute(A5,t.toString())}},[])},wgt=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;bgt();var o=S.useMemo(function(){return ygt(a)},[a]);return S.createElement(vgt,{styles:_gt(o,!s,a,r?"":"!important")})},bge=!1;if(typeof window<"u")try{var P8=Object.defineProperty({},"passive",{get:function(){return bge=!0,!0}});window.addEventListener("test",P8,P8),window.removeEventListener("test",P8,P8)}catch{bge=!1}var e4=bge?{passive:!1}:!1,jgt=function(t){return t.tagName==="TEXTAREA"},o7e=function(t,s){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!jgt(t)&&r[s]==="visible")},kgt=function(t){return o7e(t,"overflowY")},Ngt=function(t){return o7e(t,"overflowX")},v5e=function(t,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=l7e(t,n);if(a){var o=c7e(t,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},Sgt=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},Cgt=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},l7e=function(t,s){return t==="v"?kgt(s):Ngt(s)},c7e=function(t,s){return t==="v"?Sgt(s):Cgt(s)},Mgt=function(t,s){return t==="h"&&s==="rtl"?-1:1},Tgt=function(t,s,r,n,a){var o=Mgt(t,window.getComputedStyle(s).direction),l=o*n,i=r.target,d=s.contains(i),u=!1,p=l>0,f=0,v=0;do{if(!i)break;var _=c7e(t,i),b=_[0],j=_[1],w=_[2],N=j-w-o*b;(b||N)&&l7e(t,i)&&(f+=N,v+=b);var C=i.parentNode;i=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!d&&i!==document.body||d&&(s.contains(i)||s===i));return(p&&Math.abs(f)<1||!p&&Math.abs(v)<1)&&(u=!0),u},I8=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},_5e=function(t){return[t.deltaX,t.deltaY]},b5e=function(t){return t&&"current"in t?t.current:t},Agt=function(t,s){return t[0]===s[0]&&t[1]===s[1]},Egt=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},Pgt=0,t4=[];function Igt(t){var s=S.useRef([]),r=S.useRef([0,0]),n=S.useRef(),a=S.useState(Pgt++)[0],o=S.useState(i7e)[0],l=S.useRef(t);S.useEffect(function(){l.current=t},[t]),S.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var j=v1e([t.lockRef.current],(t.shards||[]).map(b5e),!0).filter(Boolean);return j.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),j.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var i=S.useCallback(function(j,w){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!l.current.allowPinchZoom;var N=I8(j),C=r.current,A="deltaX"in j?j.deltaX:C[0]-N[0],I="deltaY"in j?j.deltaY:C[1]-N[1],L,R=j.target,$=Math.abs(A)>Math.abs(I)?"h":"v";if("touches"in j&&$==="h"&&R.type==="range")return!1;var q=v5e($,R);if(!q)return!0;if(q?L=$:(L=$==="v"?"h":"v",q=v5e($,R)),!q)return!1;if(!n.current&&"changedTouches"in j&&(A||I)&&(n.current=L),!L)return!0;var U=n.current||L;return Tgt(U,w,j,U==="h"?A:I)},[]),d=S.useCallback(function(j){var w=j;if(!(!t4.length||t4[t4.length-1]!==o)){var N="deltaY"in w?_5e(w):I8(w),C=s.current.filter(function(L){return L.name===w.type&&(L.target===w.target||w.target===L.shadowParent)&&Agt(L.delta,N)})[0];if(C&&C.should){w.cancelable&&w.preventDefault();return}if(!C){var A=(l.current.shards||[]).map(b5e).filter(Boolean).filter(function(L){return L.contains(w.target)}),I=A.length>0?i(w,A[0]):!l.current.noIsolation;I&&w.cancelable&&w.preventDefault()}}},[]),u=S.useCallback(function(j,w,N,C){var A={name:j,delta:w,target:N,should:C,shadowParent:Lgt(N)};s.current.push(A),setTimeout(function(){s.current=s.current.filter(function(I){return I!==A})},1)},[]),p=S.useCallback(function(j){r.current=I8(j),n.current=void 0},[]),f=S.useCallback(function(j){u(j.type,_5e(j),j.target,i(j,t.lockRef.current))},[]),v=S.useCallback(function(j){u(j.type,I8(j),j.target,i(j,t.lockRef.current))},[]);S.useEffect(function(){return t4.push(o),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:v}),document.addEventListener("wheel",d,e4),document.addEventListener("touchmove",d,e4),document.addEventListener("touchstart",p,e4),function(){t4=t4.filter(function(j){return j!==o}),document.removeEventListener("wheel",d,e4),document.removeEventListener("touchmove",d,e4),document.removeEventListener("touchstart",p,e4)}},[]);var _=t.removeScrollBar,b=t.inert;return S.createElement(S.Fragment,null,b?S.createElement(o,{styles:Egt(a)}):null,_?S.createElement(wgt,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function Lgt(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const Dgt=cgt(a7e,Igt);var vL=S.forwardRef(function(t,s){return S.createElement(hoe,tf({},t,{ref:s,sideCar:Dgt}))});vL.classNames=hoe.classNames;var wge=["Enter"," "],Ogt=["ArrowDown","PageUp","Home"],d7e=["ArrowUp","PageDown","End"],Rgt=[...Ogt,...d7e],Fgt={ltr:[...wge,"ArrowRight"],rtl:[...wge,"ArrowLeft"]},zgt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},_L="Menu",[GI,Bgt,$gt]=cL(_L),[eS,u7e]=Ac(_L,[$gt,hy,q_]),moe=hy(),h7e=q_(),[qgt,tS]=eS(_L),[Ugt,bL]=eS(_L),m7e=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=moe(s),[d,u]=S.useState(null),p=S.useRef(!1),f=Vc(o),v=$_(a);return S.useEffect(()=>{const _=()=>{p.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>p.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(mL,{...i,children:e.jsx(qgt,{scope:s,open:r,onOpenChange:f,content:d,onContentChange:u,children:e.jsx(Ugt,{scope:s,onClose:S.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:p,dir:v,modal:l,children:n})})})};m7e.displayName=_L;var Vgt="MenuAnchor",E1e=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=moe(r);return e.jsx(oM,{...a,...n,ref:s})});E1e.displayName=Vgt;var P1e="MenuPortal",[Hgt,p7e]=eS(P1e,{forceMount:void 0}),f7e=t=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=t,o=tS(P1e,s);return e.jsx(Hgt,{scope:s,forceMount:r,children:e.jsx(hd,{present:r||o.open,children:e.jsx(rM,{asChild:!0,container:a,children:n})})})};f7e.displayName=P1e;var hf="MenuContent",[Wgt,I1e]=eS(hf),g7e=S.forwardRef((t,s)=>{const r=p7e(hf,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=tS(hf,t.__scopeMenu),l=bL(hf,t.__scopeMenu);return e.jsx(GI.Provider,{scope:t.__scopeMenu,children:e.jsx(hd,{present:n||o.open,children:e.jsx(GI.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(Ggt,{...a,ref:s}):e.jsx(Kgt,{...a,ref:s})})})})}),Ggt=S.forwardRef((t,s)=>{const r=tS(hf,t.__scopeMenu),n=S.useRef(null),a=Pa(s,n);return S.useEffect(()=>{const o=n.current;if(o)return uoe(o)},[]),e.jsx(L1e,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Cr(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),Kgt=S.forwardRef((t,s)=>{const r=tS(hf,t.__scopeMenu);return e.jsx(L1e,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),Zgt=j_("MenuContent.ScrollLock"),L1e=S.forwardRef((t,s)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:i,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:v,onDismiss:_,disableOutsideScroll:b,...j}=t,w=tS(hf,r),N=bL(hf,r),C=moe(r),A=h7e(r),I=Bgt(r),[L,R]=S.useState(null),$=S.useRef(null),q=Pa(s,$,w.onContentChange),U=S.useRef(0),V=S.useRef(""),X=S.useRef(0),se=S.useRef(null),te=S.useRef("right"),Y=S.useRef(0),de=b?vL:S.Fragment,ie=b?{as:Zgt,allowPinchZoom:!0}:void 0,ae=pe=>{var Te,Fe;const be=V.current+pe,ye=I().filter(Ae=>!Ae.disabled),we=document.activeElement,ke=(Te=ye.find(Ae=>Ae.ref.current===we))==null?void 0:Te.textValue,Ze=ye.map(Ae=>Ae.textValue),_e=oxt(Ze,be,ke),Ce=(Fe=ye.find(Ae=>Ae.textValue===_e))==null?void 0:Fe.ref.current;(function Ae(We){V.current=We,window.clearTimeout(U.current),We!==""&&(U.current=window.setTimeout(()=>Ae(""),1e3))})(be),Ce&&setTimeout(()=>Ce.focus())};S.useEffect(()=>()=>window.clearTimeout(U.current),[]),loe();const le=S.useCallback(pe=>{var ye,we;return te.current===((ye=se.current)==null?void 0:ye.side)&&cxt(pe,(we=se.current)==null?void 0:we.area)},[]);return e.jsx(Wgt,{scope:r,searchRef:V,onItemEnter:S.useCallback(pe=>{le(pe)&&pe.preventDefault()},[le]),onItemLeave:S.useCallback(pe=>{var be;le(pe)||((be=$.current)==null||be.focus(),R(null))},[le]),onTriggerLeave:S.useCallback(pe=>{le(pe)&&pe.preventDefault()},[le]),pointerGraceTimerRef:X,onPointerGraceIntentChange:S.useCallback(pe=>{se.current=pe},[]),children:e.jsx(de,{...ie,children:e.jsx(xL,{asChild:!0,trapped:a,onMountAutoFocus:Cr(o,pe=>{var be;pe.preventDefault(),(be=$.current)==null||be.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(R_,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:v,onDismiss:_,children:e.jsx(coe,{asChild:!0,...A,dir:N.dir,orientation:"vertical",loop:n,currentTabStopId:L,onCurrentTabStopIdChange:R,onEntryFocus:Cr(d,pe=>{N.isUsingKeyboardRef.current||pe.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(pL,{role:"menu","aria-orientation":"vertical","data-state":P7e(w.open),"data-radix-menu-content":"",dir:N.dir,...C,...j,ref:q,style:{outline:"none",...j.style},onKeyDown:Cr(j.onKeyDown,pe=>{const ye=pe.target.closest("[data-radix-menu-content]")===pe.currentTarget,we=pe.ctrlKey||pe.altKey||pe.metaKey,ke=pe.key.length===1;ye&&(pe.key==="Tab"&&pe.preventDefault(),!we&&ke&&ae(pe.key));const Ze=$.current;if(pe.target!==Ze||!Rgt.includes(pe.key))return;pe.preventDefault();const Ce=I().filter(Te=>!Te.disabled).map(Te=>Te.ref.current);d7e.includes(pe.key)&&Ce.reverse(),axt(Ce)}),onBlur:Cr(t.onBlur,pe=>{pe.currentTarget.contains(pe.target)||(window.clearTimeout(U.current),V.current="")}),onPointerMove:Cr(t.onPointerMove,KI(pe=>{const be=pe.target,ye=Y.current!==pe.clientX;if(pe.currentTarget.contains(be)&&ye){const we=pe.clientX>Y.current?"right":"left";te.current=we,Y.current=pe.clientX}}))})})})})})})});g7e.displayName=hf;var Ygt="MenuGroup",D1e=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{role:"group",...n,ref:s})});D1e.displayName=Ygt;var Xgt="MenuLabel",x7e=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});x7e.displayName=Xgt;var ine="MenuItem",w5e="menu.itemSelect",poe=S.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=S.useRef(null),l=bL(ine,t.__scopeMenu),i=I1e(ine,t.__scopeMenu),d=Pa(s,o),u=S.useRef(!1),p=()=>{const f=o.current;if(!r&&f){const v=new CustomEvent(w5e,{bubbles:!0,cancelable:!0});f.addEventListener(w5e,_=>n==null?void 0:n(_),{once:!0}),Gve(f,v),v.defaultPrevented?u.current=!1:l.onClose()}};return e.jsx(y7e,{...a,ref:d,disabled:r,onClick:Cr(t.onClick,p),onPointerDown:f=>{var v;(v=t.onPointerDown)==null||v.call(t,f),u.current=!0},onPointerUp:Cr(t.onPointerUp,f=>{var v;u.current||(v=f.currentTarget)==null||v.click()}),onKeyDown:Cr(t.onKeyDown,f=>{const v=i.searchRef.current!=="";r||v&&f.key===" "||wge.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});poe.displayName=ine;var y7e=S.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=I1e(ine,r),i=h7e(r),d=S.useRef(null),u=Pa(s,d),[p,f]=S.useState(!1),[v,_]=S.useState("");return S.useEffect(()=>{const b=d.current;b&&_((b.textContent??"").trim())},[o.children]),e.jsx(GI.ItemSlot,{scope:r,disabled:n,textValue:a??v,children:e.jsx(doe,{asChild:!0,...i,focusable:!n,children:e.jsx(Qr.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:u,onPointerMove:Cr(t.onPointerMove,KI(b=>{n?l.onItemLeave(b):(l.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Cr(t.onPointerLeave,KI(b=>l.onItemLeave(b))),onFocus:Cr(t.onFocus,()=>f(!0)),onBlur:Cr(t.onBlur,()=>f(!1))})})})}),Qgt="MenuCheckboxItem",v7e=S.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(k7e,{scope:t.__scopeMenu,checked:r,children:e.jsx(poe,{role:"menuitemcheckbox","aria-checked":one(r)?"mixed":r,...a,ref:s,"data-state":R1e(r),onSelect:Cr(a.onSelect,()=>n==null?void 0:n(one(r)?!0:!r),{checkForDefaultPrevented:!1})})})});v7e.displayName=Qgt;var _7e="MenuRadioGroup",[Jgt,ext]=eS(_7e,{value:void 0,onValueChange:()=>{}}),b7e=S.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=Vc(n);return e.jsx(Jgt,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(D1e,{...a,ref:s})})});b7e.displayName=_7e;var w7e="MenuRadioItem",j7e=S.forwardRef((t,s)=>{const{value:r,...n}=t,a=ext(w7e,t.__scopeMenu),o=r===a.value;return e.jsx(k7e,{scope:t.__scopeMenu,checked:o,children:e.jsx(poe,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":R1e(o),onSelect:Cr(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});j7e.displayName=w7e;var O1e="MenuItemIndicator",[k7e,txt]=eS(O1e,{checked:!1}),N7e=S.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=txt(O1e,r);return e.jsx(hd,{present:n||one(o.checked)||o.checked===!0,children:e.jsx(Qr.span,{...a,ref:s,"data-state":R1e(o.checked)})})});N7e.displayName=O1e;var sxt="MenuSeparator",S7e=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});S7e.displayName=sxt;var rxt="MenuArrow",C7e=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=moe(r);return e.jsx(fL,{...a,...n,ref:s})});C7e.displayName=rxt;var nxt="MenuSub",[F1s,M7e]=eS(nxt),SE="MenuSubTrigger",T7e=S.forwardRef((t,s)=>{const r=tS(SE,t.__scopeMenu),n=bL(SE,t.__scopeMenu),a=M7e(SE,t.__scopeMenu),o=I1e(SE,t.__scopeMenu),l=S.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:d}=o,u={__scopeMenu:t.__scopeMenu},p=S.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return S.useEffect(()=>p,[p]),S.useEffect(()=>{const f=i.current;return()=>{window.clearTimeout(f),d(null)}},[i,d]),e.jsx(E1e,{asChild:!0,...u,children:e.jsx(y7e,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":P7e(r.open),...t,ref:G0(s,a.onTriggerChange),onClick:f=>{var v;(v=t.onClick)==null||v.call(t,f),!(t.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Cr(t.onPointerMove,KI(f=>{o.onItemEnter(f),!f.defaultPrevented&&!t.disabled&&!r.open&&!l.current&&(o.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),p()},100))})),onPointerLeave:Cr(t.onPointerLeave,KI(f=>{var _,b;p();const v=(_=r.content)==null?void 0:_.getBoundingClientRect();if(v){const j=(b=r.content)==null?void 0:b.dataset.side,w=j==="right",N=w?-5:5,C=v[w?"left":"right"],A=v[w?"right":"left"];o.onPointerGraceIntentChange({area:[{x:f.clientX+N,y:f.clientY},{x:C,y:v.top},{x:A,y:v.top},{x:A,y:v.bottom},{x:C,y:v.bottom}],side:j}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(f),f.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Cr(t.onKeyDown,f=>{var _;const v=o.searchRef.current!=="";t.disabled||v&&f.key===" "||Fgt[n.dir].includes(f.key)&&(r.onOpenChange(!0),(_=r.content)==null||_.focus(),f.preventDefault())})})})});T7e.displayName=SE;var A7e="MenuSubContent",E7e=S.forwardRef((t,s)=>{const r=p7e(hf,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=tS(hf,t.__scopeMenu),l=bL(hf,t.__scopeMenu),i=M7e(A7e,t.__scopeMenu),d=S.useRef(null),u=Pa(s,d);return e.jsx(GI.Provider,{scope:t.__scopeMenu,children:e.jsx(hd,{present:n||o.open,children:e.jsx(GI.Slot,{scope:t.__scopeMenu,children:e.jsx(L1e,{id:i.contentId,"aria-labelledby":i.triggerId,...a,ref:u,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{var f;l.isUsingKeyboardRef.current&&((f=d.current)==null||f.focus()),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Cr(t.onFocusOutside,p=>{p.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Cr(t.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:Cr(t.onKeyDown,p=>{var _;const f=p.currentTarget.contains(p.target),v=zgt[l.dir].includes(p.key);f&&v&&(o.onOpenChange(!1),(_=i.trigger)==null||_.focus(),p.preventDefault())})})})})})});E7e.displayName=A7e;function P7e(t){return t?"open":"closed"}function one(t){return t==="indeterminate"}function R1e(t){return one(t)?"indeterminate":t?"checked":"unchecked"}function axt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function ixt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function oxt(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=ixt(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 lxt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=v>n&&r<(f-u)*(n-p)/(v-p)+u&&(a=!a)}return a}function cxt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return lxt(r,s)}function KI(t){return s=>s.pointerType==="mouse"?t(s):void 0}var dxt=m7e,uxt=E1e,hxt=f7e,mxt=g7e,pxt=D1e,fxt=x7e,gxt=poe,xxt=v7e,yxt=b7e,vxt=j7e,_xt=N7e,bxt=S7e,wxt=C7e,jxt=T7e,kxt=E7e,foe="DropdownMenu",[Nxt]=Ac(foe,[u7e]),Qh=u7e(),[Sxt,I7e]=Nxt(foe),L7e=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,d=Qh(s),u=S.useRef(null),[p,f]=xu({prop:a,defaultProp:o??!1,onChange:l,caller:foe});return e.jsx(Sxt,{scope:s,triggerId:Gd(),triggerRef:u,contentId:Gd(),open:p,onOpenChange:f,onOpenToggle:S.useCallback(()=>f(v=>!v),[f]),modal:i,children:e.jsx(dxt,{...d,open:p,onOpenChange:f,dir:n,modal:i,children:r})})};L7e.displayName=foe;var D7e="DropdownMenuTrigger",O7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=I7e(D7e,r),l=Qh(r);return e.jsx(uxt,{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:G0(s,o.triggerRef),onPointerDown:Cr(t.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:Cr(t.onKeyDown,i=>{n||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});O7e.displayName=D7e;var Cxt="DropdownMenuPortal",R7e=t=>{const{__scopeDropdownMenu:s,...r}=t,n=Qh(s);return e.jsx(hxt,{...n,...r})};R7e.displayName=Cxt;var F7e="DropdownMenuContent",z7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=I7e(F7e,r),o=Qh(r),l=S.useRef(!1);return e.jsx(mxt,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:s,onCloseAutoFocus:Cr(t.onCloseAutoFocus,i=>{var d;l.current||(d=a.triggerRef.current)==null||d.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:Cr(t.onInteractOutside,i=>{const d=i.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,p=d.button===2||u;(!a.modal||p)&&(l.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});z7e.displayName=F7e;var Mxt="DropdownMenuGroup",Txt=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Qh(r);return e.jsx(pxt,{...a,...n,ref:s})});Txt.displayName=Mxt;var Axt="DropdownMenuLabel",B7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Qh(r);return e.jsx(fxt,{...a,...n,ref:s})});B7e.displayName=Axt;var Ext="DropdownMenuItem",$7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Qh(r);return e.jsx(gxt,{...a,...n,ref:s})});$7e.displayName=Ext;var Pxt="DropdownMenuCheckboxItem",q7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Qh(r);return e.jsx(xxt,{...a,...n,ref:s})});q7e.displayName=Pxt;var Ixt="DropdownMenuRadioGroup",Lxt=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Qh(r);return e.jsx(yxt,{...a,...n,ref:s})});Lxt.displayName=Ixt;var Dxt="DropdownMenuRadioItem",U7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Qh(r);return e.jsx(vxt,{...a,...n,ref:s})});U7e.displayName=Dxt;var Oxt="DropdownMenuItemIndicator",V7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Qh(r);return e.jsx(_xt,{...a,...n,ref:s})});V7e.displayName=Oxt;var Rxt="DropdownMenuSeparator",H7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Qh(r);return e.jsx(bxt,{...a,...n,ref:s})});H7e.displayName=Rxt;var Fxt="DropdownMenuArrow",zxt=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Qh(r);return e.jsx(wxt,{...a,...n,ref:s})});zxt.displayName=Fxt;var Bxt="DropdownMenuSubTrigger",W7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Qh(r);return e.jsx(jxt,{...a,...n,ref:s})});W7e.displayName=Bxt;var $xt="DropdownMenuSubContent",G7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Qh(r);return e.jsx(kxt,{...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)"}})});G7e.displayName=$xt;var qxt=L7e,Uxt=O7e,Vxt=R7e,K7e=z7e,Z7e=B7e,Y7e=$7e,X7e=q7e,Q7e=U7e,J7e=V7e,eBe=H7e,tBe=W7e,sBe=G7e;const Kd=qxt,Zd=Uxt,Hxt=S.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(tBe,{ref:a,className:Pt("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",s&&"pl-8",t),...n,children:[r,e.jsx(Ha,{className:"ml-auto h-4 w-4"})]}));Hxt.displayName=tBe.displayName;const Wxt=S.forwardRef(({className:t,...s},r)=>e.jsx(sBe,{ref:r,className:Pt("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s}));Wxt.displayName=sBe.displayName;const Td=S.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(Vxt,{children:e.jsx(K7e,{ref:n,sideOffset:s,className:Pt("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})}));Td.displayName=K7e.displayName;const Ta=S.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(Y7e,{ref:n,className:Pt("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",s&&"pl-8",t),...r}));Ta.displayName=Y7e.displayName;const Gxt=S.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(X7e,{ref:a,className:Pt("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),checked:r,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(J7e,{children:e.jsx(ua,{className:"h-4 w-4"})})}),s]}));Gxt.displayName=X7e.displayName;const Kxt=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(Q7e,{ref:n,className:Pt("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(J7e,{children:e.jsx(Gc,{className:"h-2 w-2 fill-current"})})}),s]}));Kxt.displayName=Q7e.displayName;const jge=S.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(Z7e,{ref:n,className:Pt("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));jge.displayName=Z7e.displayName;const S_=S.forwardRef(({className:t,...s},r)=>e.jsx(eBe,{ref:r,className:Pt("-mx-1 my-1 h-px bg-muted",t),...s}));S_.displayName=eBe.displayName;const Zxt=()=>{const{isAssistant:t,actingAsAgent:s,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:a,setActingAsSelf:o}=T1e();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(Xi,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"My Account"})]}):e.jsxs(e.Fragment,{children:[e.jsx(hr,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"Acting as"})]}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{variant:"secondary",size:"sm",className:"gap-2 bg-primary-foreground/20 hover:bg-primary-foreground/30 text-primary-foreground border-0",children:[a?e.jsxs(e.Fragment,{children:[e.jsx(Xi,{className:"h-4 w-4"}),e.jsx("strong",{children:"My Account"})]}):s?e.jsxs(e.Fragment,{children:[e.jsxs(gn,{className:"h-5 w-5",children:[e.jsx(Ea,{src:s.avatar_url||void 0}),e.jsx(xn,{className:"text-[10px] bg-primary-foreground/30",children:l(s.name)})]}),e.jsx("strong",{children:s.name})]}):e.jsx("strong",{children:"Select..."}),e.jsx(Vo,{className:"h-3 w-3"})]})}),e.jsxs(Td,{align:"start",className:"z-[2147483647]",children:[e.jsxs(Ta,{onClick:o,className:"gap-2",children:[e.jsx(Xi,{className:"h-4 w-4"}),e.jsx("span",{children:"My Account"}),a&&e.jsx(at,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),e.jsx(S_,{}),r.map(i=>e.jsxs(Ta,{onClick:()=>n(i),className:"gap-2",children:[e.jsxs(gn,{className:"h-6 w-6",children:[e.jsx(Ea,{src:i.avatar_url||void 0}),e.jsx(xn,{className:"text-[10px]",children:l(i.name)})]}),e.jsx("span",{children:i.name}),!a&&i.id===(s==null?void 0:s.id)&&e.jsx(at,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},i.id))]})]})]}),e.jsx(at,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:a?"Personal Mode":"Assistant Mode"})]})})},ur=({children:t,requireAdmin:s=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:a,isAdmin:o,isBrokerageManager:l}=Gs();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(hhe,{to:"/dashboard",replace:!0}):r&&!l&&!o?e.jsx(hhe,{to:"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t}):e.jsx(hhe,{to:"/auth",replace:!0})};var F1e={};(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 we=be.transferToImageBitmap();ye.createPattern(we,"no-repeat")}catch{return!1}return!0}();function d(){}function u(be){var ye=r.exports.Promise,we=ye!==void 0?ye:s.Promise;return typeof we=="function"?new we(be):(be(d,d),null)}var p=function(be,ye){return{transform:function(we){if(be)return we;if(ye.has(we))return ye.get(we);var ke=new OffscreenCanvas(we.width,we.height),Ze=ke.getContext("2d");return Ze.drawImage(we,0,0),ye.set(we,ke),ke},clear:function(){ye.clear()}}}(i,new Map),f=function(){var be=Math.floor(16.666666666666668),ye,we,ke={},Ze=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(ye=function(_e){var Ce=Math.random();return ke[Ce]=requestAnimationFrame(function Te(Fe){Ze===Fe||Ze+be-1{const{data:s,error:r}=await G.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 Xxt(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("celebration_queue").update({seen_at:new Date().toISOString()}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}function Qxt(){const t=ns(),{user:s}=Gs();return Ot({mutationFn:async r=>{const{error:n}=await G.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 goe="Dialog",[rBe,nBe]=Ac(goe),[Jxt,Yg]=rBe(goe),aBe=t=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=t,i=S.useRef(null),d=S.useRef(null),[u,p]=xu({prop:n,defaultProp:a??!1,onChange:o,caller:goe});return e.jsx(Jxt,{scope:s,triggerRef:i,contentRef:d,contentId:Gd(),titleId:Gd(),descriptionId:Gd(),open:u,onOpenChange:p,onOpenToggle:S.useCallback(()=>p(f=>!f),[p]),modal:l,children:r})};aBe.displayName=goe;var iBe="DialogTrigger",oBe=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Yg(iBe,r),o=Pa(s,a.triggerRef);return e.jsx(Qr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":$1e(a.open),...n,ref:o,onClick:Cr(t.onClick,a.onOpenToggle)})});oBe.displayName=iBe;var z1e="DialogPortal",[eyt,lBe]=rBe(z1e,{forceMount:void 0}),cBe=t=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=t,o=Yg(z1e,s);return e.jsx(eyt,{scope:s,forceMount:r,children:S.Children.map(n,l=>e.jsx(hd,{present:r||o.open,children:e.jsx(rM,{asChild:!0,container:a,children:l})}))})};cBe.displayName=z1e;var lne="DialogOverlay",dBe=S.forwardRef((t,s)=>{const r=lBe(lne,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=Yg(lne,t.__scopeDialog);return o.modal?e.jsx(hd,{present:n||o.open,children:e.jsx(syt,{...a,ref:s})}):null});dBe.displayName=lne;var tyt=j_("DialogOverlay.RemoveScroll"),syt=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Yg(lne,r);return e.jsx(vL,{as:tyt,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(Qr.div,{"data-state":$1e(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),TN="DialogContent",uBe=S.forwardRef((t,s)=>{const r=lBe(TN,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=Yg(TN,t.__scopeDialog);return e.jsx(hd,{present:n||o.open,children:o.modal?e.jsx(ryt,{...a,ref:s}):e.jsx(nyt,{...a,ref:s})})});uBe.displayName=TN;var ryt=S.forwardRef((t,s)=>{const r=Yg(TN,t.__scopeDialog),n=S.useRef(null),a=Pa(s,r.contentRef,n);return S.useEffect(()=>{const o=n.current;if(o)return uoe(o)},[]),e.jsx(hBe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Cr(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Cr(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:Cr(t.onFocusOutside,o=>o.preventDefault())})}),nyt=S.forwardRef((t,s)=>{const r=Yg(TN,t.__scopeDialog),n=S.useRef(!1),a=S.useRef(!1);return e.jsx(hBe,{...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()}})}),hBe=S.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=Yg(TN,r),d=S.useRef(null),u=Pa(s,d);return loe(),e.jsxs(e.Fragment,{children:[e.jsx(xL,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(R_,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":$1e(i.open),...l,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(iyt,{titleId:i.titleId}),e.jsx(lyt,{contentRef:d,descriptionId:i.descriptionId})]})]})}),B1e="DialogTitle",mBe=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Yg(B1e,r);return e.jsx(Qr.h2,{id:a.titleId,...n,ref:s})});mBe.displayName=B1e;var pBe="DialogDescription",fBe=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Yg(pBe,r);return e.jsx(Qr.p,{id:a.descriptionId,...n,ref:s})});fBe.displayName=pBe;var gBe="DialogClose",xBe=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Yg(gBe,r);return e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:Cr(t.onClick,()=>a.onOpenChange(!1))})});xBe.displayName=gBe;function $1e(t){return t?"open":"closed"}var yBe="DialogTitleWarning",[ayt,vBe]=$it(yBe,{contentName:TN,titleName:B1e,docsSlug:"dialog"}),iyt=({titleId:t})=>{const s=vBe(yBe),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 S.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},oyt="DialogDescriptionWarning",lyt=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${vBe(oyt).contentName}}.`;return S.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},xoe=aBe,q1e=oBe,yoe=cBe,mM=dBe,pM=uBe,wL=mBe,jL=fBe,kL=xBe;const vs=xoe,Ei=q1e,cyt=yoe,z1s=kL,_Be=S.forwardRef(({className:t,...s},r)=>e.jsx(mM,{ref:r,className:Pt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));_Be.displayName=mM.displayName;const ys=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(cyt,{children:[e.jsx(_Be,{}),e.jsxs(pM,{ref:n,className:Pt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...r,children:[s,e.jsxs(kL,{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(Ur,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ys.displayName=pM.displayName;const Ss=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});Ss.displayName="DialogHeader";const On=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});On.displayName="DialogFooter";const Ns=S.forwardRef(({className:t,...s},r)=>e.jsx(wL,{ref:r,className:Pt("text-lg font-semibold leading-none tracking-tight",t),...s}));Ns.displayName=wL.displayName;const Kr=S.forwardRef(({className:t,...s},r)=>e.jsx(jL,{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));Kr.displayName=jL.displayName;const dyt={points_earned:Ki,listing_created:Un,deal_closed:Kc,custom:Gn},k5e={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"},N5e=()=>{const t=window.location.hostname;return t.startsWith("cards.")||t.startsWith("cardstudio.")||t.startsWith("listings.")||t.startsWith("presentations.")||t.startsWith("guestbook.")||t.startsWith("clients.")||t.startsWith("booking.")||t.startsWith("contacts.")};function uyt(){const{user:t}=Gs(),s=ns(),{data:r}=Yxt(),n=Xxt(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=S.useCallback(()=>{const _=Date.now()+3e3,b={startVelocity:30,spread:360,ticks:60,zIndex:9999},j=(N,C)=>Math.random()*(C-N)+N,w=setInterval(()=>{const N=_-Date.now();if(N<=0){clearInterval(w);return}const C=50*(N/3e3);j5e({...b,particleCount:C,origin:{x:j(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),j5e({...b,particleCount:C,origin:{x:j(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);S.useEffect(()=>{N5e()||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(N5e()||!a)return null;const p=dyt[a.celebration_type]||Gn,f=k5e[a.celebration_type]||k5e.custom;return e.jsx(vs,{open:l,onOpenChange:v=>!v&&u(),children:e.jsxs(ys,{className:"sm:max-w-md text-center border-0 overflow-hidden",children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${f} opacity-10`}),e.jsxs("div",{className:"relative z-10 py-6",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:`w-20 h-20 rounded-full bg-gradient-to-br ${f} flex items-center justify-center animate-bounce`,children:e.jsx(p,{className:"w-10 h-10 text-white"})})}),e.jsxs("div",{className:"flex justify-center gap-1 mb-4",children:[e.jsx(hn,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),e.jsx(hn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),e.jsx(hn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-150"})]}),e.jsxs("h2",{className:"text-2xl font-bold mb-2 bg-gradient-to-r from-primary to-secondary bg-clip-text text-transparent",children:["🎉 ",a.title]}),a.points_amount&&a.points_amount>0&&e.jsxs("div",{className:"text-4xl font-bold text-primary mb-2",children:["+",a.points_amount," points!"]}),a.message&&e.jsx("p",{className:"text-muted-foreground mb-6",children:a.message}),e.jsx(K,{onClick:u,className:"w-full",size:"lg",children:"Awesome! 🙌"}),r&&r.length>1&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-3",children:["+",r.length-1," more celebration",r.length>2?"s":""," waiting"]})]})]})})}const bBe="/assets/levelup-logo-horizontal-DEFNc0ms.png",U1e="/assets/levelup-logo-white-C2RAgAoG.png",hyt="/assets/listings-hero-BI9Ki9Dq.jpg",Re=S.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:Pt("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...r}));Re.displayName="Input";var wBe={exports:{}};(function(t,s){(function(r,n){t.exports=n()})(f0,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;",p={};r(p),a=d(p),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(a.workerUrl=window.URL.createObjectURL(new Blob([u],{type:"text/javascript"})))}}o(["exports"],function(i){var d=1e-6,u=typeof Float32Array<"u"?Float32Array:Array;function p(g,c){var m=c[0],y=c[1],k=c[2],E=c[3],P=m*E-k*y;return P?(g[0]=E*(P=1/P),g[1]=-y*P,g[2]=-k*P,g[3]=m*P,g):null}function f(){var g=new u(9);return u!=Float32Array&&(g[1]=0,g[2]=0,g[3]=0,g[5]=0,g[6]=0,g[7]=0),g[0]=1,g[4]=1,g[8]=1,g}function v(g,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 g[0]=P*J-O*W,g[1]=k*W-y*J,g[2]=y*O-k*P,g[3]=O*B-E*J,g[4]=m*J-k*B,g[5]=k*E-m*O,g[6]=E*W-P*B,g[7]=y*B-m*W,g[8]=m*P-y*E,g}function _(g,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],ce=m[1],ue=m[2],je=m[3],Le=m[4],Ie=m[5],Ge=m[6],Ye=m[7],nt=m[8];return g[0]=ne*y+ce*P+ue*W,g[1]=ne*k+ce*O+ue*J,g[2]=ne*E+ce*B+ue*ee,g[3]=je*y+Le*P+Ie*W,g[4]=je*k+Le*O+Ie*J,g[5]=je*E+Le*B+Ie*ee,g[6]=Ge*y+Ye*P+nt*W,g[7]=Ge*k+Ye*O+nt*J,g[8]=Ge*E+Ye*B+nt*ee,g}function b(){var g=new u(16);return u!=Float32Array&&(g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[11]=0,g[12]=0,g[13]=0,g[14]=0),g[0]=1,g[5]=1,g[10]=1,g[15]=1,g}function j(g){var c=new u(16);return c[0]=g[0],c[1]=g[1],c[2]=g[2],c[3]=g[3],c[4]=g[4],c[5]=g[5],c[6]=g[6],c[7]=g[7],c[8]=g[8],c[9]=g[9],c[10]=g[10],c[11]=g[11],c[12]=g[12],c[13]=g[13],c[14]=g[14],c[15]=g[15],c}function w(g){return g[0]=1,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=1,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=1,g[11]=0,g[12]=0,g[13]=0,g[14]=0,g[15]=1,g}function N(g,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],ce=c[11],ue=c[12],je=c[13],Le=c[14],Ie=c[15],Ge=m*O-y*P,Ye=m*B-k*P,nt=m*W-E*P,bt=y*B-k*O,ft=y*W-E*O,St=k*W-E*B,It=J*je-ee*ue,qt=J*Le-ne*ue,is=J*Ie-ce*ue,Wt=ee*Le-ne*je,ms=ee*Ie-ce*je,_s=ne*Ie-ce*Le,bs=Ge*_s-Ye*ms+nt*Wt+bt*is-ft*qt+St*It;return bs?(g[0]=(O*_s-B*ms+W*Wt)*(bs=1/bs),g[1]=(k*ms-y*_s-E*Wt)*bs,g[2]=(je*St-Le*ft+Ie*bt)*bs,g[3]=(ne*ft-ee*St-ce*bt)*bs,g[4]=(B*is-P*_s-W*qt)*bs,g[5]=(m*_s-k*is+E*qt)*bs,g[6]=(Le*nt-ue*St-Ie*Ye)*bs,g[7]=(J*St-ne*nt+ce*Ye)*bs,g[8]=(P*ms-O*is+W*It)*bs,g[9]=(y*is-m*ms-E*It)*bs,g[10]=(ue*ft-je*nt+Ie*Ge)*bs,g[11]=(ee*nt-J*ft-ce*Ge)*bs,g[12]=(O*qt-P*Wt-B*It)*bs,g[13]=(m*Wt-y*qt+k*It)*bs,g[14]=(je*Ye-ue*bt-Le*Ge)*bs,g[15]=(J*bt-ee*Ye+ne*Ge)*bs,g):null}function C(g,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],ce=c[10],ue=c[11],je=c[12],Le=c[13],Ie=c[14],Ge=c[15],Ye=m[0],nt=m[1],bt=m[2],ft=m[3];return g[0]=Ye*y+nt*O+bt*ee+ft*je,g[1]=Ye*k+nt*B+bt*ne+ft*Le,g[2]=Ye*E+nt*W+bt*ce+ft*Ie,g[3]=Ye*P+nt*J+bt*ue+ft*Ge,g[4]=(Ye=m[4])*y+(nt=m[5])*O+(bt=m[6])*ee+(ft=m[7])*je,g[5]=Ye*k+nt*B+bt*ne+ft*Le,g[6]=Ye*E+nt*W+bt*ce+ft*Ie,g[7]=Ye*P+nt*J+bt*ue+ft*Ge,g[8]=(Ye=m[8])*y+(nt=m[9])*O+(bt=m[10])*ee+(ft=m[11])*je,g[9]=Ye*k+nt*B+bt*ne+ft*Le,g[10]=Ye*E+nt*W+bt*ce+ft*Ie,g[11]=Ye*P+nt*J+bt*ue+ft*Ge,g[12]=(Ye=m[12])*y+(nt=m[13])*O+(bt=m[14])*ee+(ft=m[15])*je,g[13]=Ye*k+nt*B+bt*ne+ft*Le,g[14]=Ye*E+nt*W+bt*ce+ft*Ie,g[15]=Ye*P+nt*J+bt*ue+ft*Ge,g}function A(g,c,m){var y,k,E,P,O,B,W,J,ee,ne,ce,ue,je=m[0],Le=m[1],Ie=m[2];return c===g?(g[12]=c[0]*je+c[4]*Le+c[8]*Ie+c[12],g[13]=c[1]*je+c[5]*Le+c[9]*Ie+c[13],g[14]=c[2]*je+c[6]*Le+c[10]*Ie+c[14],g[15]=c[3]*je+c[7]*Le+c[11]*Ie+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],ce=c[10],ue=c[11],g[0]=y=c[0],g[1]=k,g[2]=E,g[3]=P,g[4]=O,g[5]=B,g[6]=W,g[7]=J,g[8]=ee,g[9]=ne,g[10]=ce,g[11]=ue,g[12]=y*je+O*Le+ee*Ie+c[12],g[13]=k*je+B*Le+ne*Ie+c[13],g[14]=E*je+W*Le+ce*Ie+c[14],g[15]=P*je+J*Le+ue*Ie+c[15]),g}function I(g,c,m){var y=m[0],k=m[1],E=m[2];return g[0]=c[0]*y,g[1]=c[1]*y,g[2]=c[2]*y,g[3]=c[3]*y,g[4]=c[4]*k,g[5]=c[5]*k,g[6]=c[6]*k,g[7]=c[7]*k,g[8]=c[8]*E,g[9]=c[9]*E,g[10]=c[10]*E,g[11]=c[11]*E,g[12]=c[12],g[13]=c[13],g[14]=c[14],g[15]=c[15],g}function L(g,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!==g&&(g[0]=c[0],g[1]=c[1],g[2]=c[2],g[3]=c[3],g[12]=c[12],g[13]=c[13],g[14]=c[14],g[15]=c[15]),g[4]=E*k+W*y,g[5]=P*k+J*y,g[6]=O*k+ee*y,g[7]=B*k+ne*y,g[8]=W*k-E*y,g[9]=J*k-P*y,g[10]=ee*k-O*y,g[11]=ne*k-B*y,g}function R(g,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!==g&&(g[4]=c[4],g[5]=c[5],g[6]=c[6],g[7]=c[7],g[12]=c[12],g[13]=c[13],g[14]=c[14],g[15]=c[15]),g[0]=E*k-W*y,g[1]=P*k-J*y,g[2]=O*k-ee*y,g[3]=B*k-ne*y,g[8]=E*y+W*k,g[9]=P*y+J*k,g[10]=O*y+ee*k,g[11]=B*y+ne*k,g}function $(g,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!==g&&(g[8]=c[8],g[9]=c[9],g[10]=c[10],g[11]=c[11],g[12]=c[12],g[13]=c[13],g[14]=c[14],g[15]=c[15]),g[0]=E*k+W*y,g[1]=P*k+J*y,g[2]=O*k+ee*y,g[3]=B*k+ne*y,g[4]=W*k-E*y,g[5]=J*k-P*y,g[6]=ee*k-O*y,g[7]=ne*k-B*y,g}function q(g,c){return g[0]=c[0],g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=c[1],g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=c[2],g[11]=0,g[12]=0,g[13]=0,g[14]=0,g[15]=1,g}function U(g,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)),g[0]=c[0]*E,g[1]=c[1]*E,g[2]=c[2]*E,g}function We(g,c){return g[0]*c[0]+g[1]*c[1]+g[2]*c[2]}function ht(g,c,m){var y=c[0],k=c[1],E=c[2],P=m[0],O=m[1],B=m[2];return g[0]=k*B-E*O,g[1]=E*P-y*B,g[2]=y*O-k*P,g}function De(g,c,m,y){var k=c[0],E=c[1],P=c[2];return g[0]=k+y*(m[0]-k),g[1]=E+y*(m[1]-E),g[2]=P+y*(m[2]-P),g}function Dt(g,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 g[0]=(m[0]*y+m[4]*k+m[8]*E+m[12])/(P=P||1),g[1]=(m[1]*y+m[5]*k+m[9]*E+m[13])/P,g[2]=(m[2]*y+m[6]*k+m[10]*E+m[14])/P,g}function he(g,c,m){var y=c[0],k=c[1],E=c[2];return g[0]=y*m[0]+k*m[3]+E*m[6],g[1]=y*m[1]+k*m[4]+E*m[7],g[2]=y*m[2]+k*m[5]+E*m[8],g}function Qe(g,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 g[0]=O+P*(J+=J)+k*(ne+=ne)-E*(ee+=ee),g[1]=B+P*ee+E*J-y*ne,g[2]=W+P*ne+y*ee-k*J,g}function ot(g){return g[0]=0,g[1]=0,g[2]=0,g}function rt(g,c){return g[0]===c[0]&&g[1]===c[1]&&g[2]===c[2]}var Ne=pe,it=be,qe=de;function Xe(){var g=new u(4);return u!=Float32Array&&(g[0]=0,g[1]=0,g[2]=0,g[3]=0),g}function $e(g,c,m){return g[0]=c[0]*m,g[1]=c[1]*m,g[2]=c[2]*m,g[3]=c[3]*m,g}function Ke(g,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)),g[0]=m*P,g[1]=y*P,g[2]=k*P,g[3]=E*P,g}function ct(g,c,m){var y=c[0],k=c[1],E=c[2],P=c[3];return g[0]=m[0]*y+m[4]*k+m[8]*E+m[12]*P,g[1]=m[1]*y+m[5]*k+m[9]*E+m[13]*P,g[2]=m[2]*y+m[6]*k+m[10]*E+m[14]*P,g[3]=m[3]*y+m[7]*k+m[11]*E+m[15]*P,g}function Ue(){var g=new u(4);return u!=Float32Array&&(g[0]=0,g[1]=0,g[2]=0),g[3]=1,g}function Ve(g){return g[0]=0,g[1]=0,g[2]=0,g[3]=1,g}function Je(g,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 g[0]=y*B+P*O,g[1]=k*B+E*O,g[2]=E*B-k*O,g[3]=P*B-y*O,g}function Rt(g,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 g[0]=y*B-E*O,g[1]=k*B+P*O,g[2]=E*B+y*O,g[3]=P*B-k*O,g}te(),Xe();var $t,ls,Qt,rs=Ke,as=($t=te(),ls=ie(1,0,0),Qt=ie(0,1,0),function(g,c,m){var y=We(c,m);return y<-.999999?(ht($t,ls,c),qe($t)<1e-6&&ht($t,Qt,c),Ae($t,$t),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)}(g,$t,Math.PI),g):y>.999999?(g[0]=0,g[1]=0,g[2]=0,g[3]=1,g):(ht($t,c,m),g[0]=$t[0],g[1]=$t[1],g[2]=$t[2],g[3]=1+y,rs(g,g))});function ir(){var g=new u(2);return u!=Float32Array&&(g[0]=0,g[1]=0),g}function vt(g,c){var m=new u(2);return m[0]=g,m[1]=c,m}function Cs(g,c,m){return g[0]=c,g[1]=m,g}function or(g,c,m){return g[0]=c[0]+m[0],g[1]=c[1]+m[1],g}function Ar(g,c,m){return g[0]=c[0]-m[0],g[1]=c[1]-m[1],g}function Wn(g,c,m){return g[0]=c[0]*m,g[1]=c[1]*m,g}function ai(g){var c=g[0],m=g[1];return Math.sqrt(c*c+m*m)}function bo(g,c){var m=c[0],y=c[1],k=m*m+y*y;return k>0&&(k=1/Math.sqrt(k)),g[0]=c[0]*k,g[1]=c[1]*k,g}function Fa(g,c){return g[0]*c[0]+g[1]*c[1]}Ue(),Ue(),f();var yn,na,Nn=Ar;function ta(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}ir();var Kt=function(){if(na)return yn;function g(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 na=1,yn=g,g.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}(),$r=ta(Kt);function es(g,c){this.x=g,this.y=c}function nn(g,c){if(Array.isArray(g)){if(!Array.isArray(c)||g.length!==c.length)return!1;for(let m=0;m=1)return 1;const c=g*g,m=c*g;return 4*(g<.5?m:3*(g-c)+m-.75)}function Vl(g,c,m,y){const k=new $r(g,c,m,y);return function(E){return k.solve(E)}}const dt=Vl(.25,.1,.25,1);function Se(g,c,m){return Math.min(m,Math.max(c,g))}function ze(g,c,m){return(m=Se((m-g)/(c-g),0,1))*m*(3-2*m)}function st(g,c,m){const y=m-c,k=((g-c)%y+y)%y+c;return k===c?m:k}function Tt(g,c,m){if(!g.length)return m(null,[]);let y=g.length;const k=new Array(g.length);let E=null;g.forEach((P,O)=>{c(P,(B,W)=>{B&&(E=B),k[O]=W,--y==0&&m(E,k)})})}let Nt=1;function Bt(){return Nt++}function Zt(g){return g<=1?1:Math.pow(2,Math.ceil(Math.log2(g)))}function Ut(g,c){g.forEach(m=>{c[m]&&(c[m]=c[m].bind(c))})}function Xt(g,c,m){const y={};for(const k in g)y[k]=c.call(this,g[k],k,g);return y}function Is(g,c,m){const y={};for(const k in g)c.call(this,g[k],k,g)&&(y[k]=g[k]);return y}function xs(g){return Array.isArray(g)?g.map(xs):typeof g=="object"&&g?Xt(g,xs):g}function pr(g,c){for(let m=0;m=0)return!0;return!1}const qr={};function dr(g){qr[g]||(typeof console<"u"&&console.warn(g),qr[g]=!0)}function Cn(g,c,m){return(m.y-g.y)*(c.x-g.x)>(c.y-g.y)*(m.x-g.x)}function Mn(g){let c=0;for(let m,y,k=0,E=g.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 $o=null;function Wa(g,c){return[g[4*c],g[4*c+1],g[4*c+2],g[4*c+3]]}function Wo(g,c,m,y){for(;c>1;g[k]>1;g[k]<=y?c=k+1:m=k}return c}function ba(g){return g>0?1/(1.001-g):1+g}function Ji(g){return g>0?1-1/(1.001-g):-g}function yi(g,c,m){return(g-c.min)*(m.max-m.min)/(c.max-c.min)+m.min}const sa={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(!sa.API_URL)return null;try{const g=new URL(sa.API_URL);return g.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":g.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 eo(g){return sa.API_URL_REGEX.test(g)}function ac(g){return sa.API_SPRITE_REGEX.test(g)}let yc,Ad,kp,vl,wu,Xc;function em(){return yc==null&&(yc=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),yc}const _l={now:()=>vl!==void 0?vl:performance.now(),setNow(g){vl=g},restoreNow(){vl=void 0},frame(g){const c=requestAnimationFrame(g);return{cancel:()=>cancelAnimationFrame(c)}},getImageData(g,c=0){const{width:m,height:y}=g;wu||(wu=document.createElement("canvas"));const k=wu.getContext("2d",{willReadFrequently:!0});if(!k)throw new Error("failed to create canvas 2d context");return(m>wu.width||y>wu.height)&&(wu.width=m,wu.height=y),k.clearRect(-c,-c,m+2*c,y+2*c),k.drawImage(g,0,0,m,y),k.getImageData(-c,-c,m+2*c,y+2*c)},resolveURL:g=>(Ad||(Ad=document.createElement("a")),Ad.href=g,Ad.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(kp==null&&(kp=window.matchMedia("(prefers-reduced-motion: reduce)")),kp.matches)},hasCanvasFingerprintNoise(){if(Xc!==void 0)return Xc;if(!em())return Xc=!1,!1;const g=new OffscreenCanvas(85,1),c=g.getContext("2d",{willReadFrequently:!0});let m=0;for(let k=0;k0?`?${E}`:""}`}const ov="mapbox-tiles";let lv=500,cv=50;const $m=["language","worldview","jobid"];let hh,Ed;function mh(){try{return caches}catch{}}function md(){const g=mh();g&&hh==null&&(hh=g.open(ov))}let Qc=1/0;const Pd={supported:!1,testSupport:function(g){!tm&&Sp&&(sm?vy(g):Np=g)}};let Np,Sp,tm=!1,sm=!1;const Jc=typeof self<"u"?self:{};function vy(g){const c=g.createTexture();g.bindTexture(g.TEXTURE_2D,c);try{if(g.texImage2D(g.TEXTURE_2D,0,g.RGBA,g.RGBA,g.UNSIGNED_BYTE,Sp),g.isContextLost())return;Pd.supported=!0}catch{}g.deleteTexture(c),tm=!0}Jc.document&&(Sp=Jc.document.createElement("img"),Sp.onload=function(){Np&&vy(Np),Np=null,sm=!0},Sp.onerror=function(){tm=!0,Np=null},Sp.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Df={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(Df);class hl extends Error{constructor(c,m,y){m===401&&eo(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 dv=ha()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,Of=function(g,c){if(!(/^file:/.test(m=g.url)||/^file:/.test(dv())&&!/^\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:dv(),referrerPolicy:y.referrerPolicy,signal:E.signal});let O=!1,B=!1;const W=(J=P.url).indexOf("sku=")>0&&eo(J);var J;y.type==="json"&&P.headers.set("Accept","application/json");const ee=(ce,ue,je)=>{if(B)return;if(ce&&ce.message!=="SecurityError"&&dr(ce.toString()),ue&&je)return ne(ue);const Le=Date.now();fetch(P).then(Ie=>{if(Ie.ok){const Ge=W?Ie.clone():null;return ne(Ie,Ge,Le)}return k(new hl(Ie.statusText,Ie.status,y.url))}).catch(Ie=>{Ie.name!=="AbortError"&&k(new Error(`${Ie.message} ${y.url}`))})},ne=(ce,ue,je)=>{(y.type==="arrayBuffer"?ce.arrayBuffer():y.type==="json"?ce.json():ce.text()).then(Le=>{B||(ue&&je&&function(Ie,Ge,Ye){if(md(),hh==null)return;const nt=co(Ge.headers.get("Cache-Control")||"");if(nt["no-store"])return;const bt={status:Ge.status,statusText:Ge.statusText,headers:new Headers};Ge.headers.forEach((It,qt)=>bt.headers.set(qt,It)),nt["max-age"]&&bt.headers.set("Expires",new Date(Ye+1e3*nt["max-age"]).toUTCString());const ft=bt.headers.get("Expires");if(!ft||new Date(ft).getTime()-Ye<42e4)return;let St=ex(Ie.url,{persistentParams:$m});if(Ge.status===206){const It=Ie.headers.get("Range");if(!It)return;bt.status=200,St=Lf(St,{range:It})}(function(It,qt){if(Ed===void 0)try{new Response(new ReadableStream),Ed=!0}catch{Ed=!1}Ed?qt(It.body):It.blob().then(qt).catch(is=>dr(is.message))})(Ge,It=>{const qt=new Response((is=Ge.status)!==200&&is!==404&&[101,103,204,205,304].includes(is)?null:It,bt);var is;md(),hh!=null&&hh.then(Wt=>Wt.put(St,qt)).catch(Wt=>dr(Wt.message))})}(P,ue,je),O=!0,k(null,Le,ce.headers))}).catch(Le=>{B||k(new Error(Le.message))})};return W?function(ce,ue){if(md(),hh==null)return ue(null);hh.then(je=>{let Le=ex(ce.url,{persistentParams:$m});const Ie=ce.headers.get("Range");Ie&&(Le=Lf(Le,{range:Ie})),je.match(Le).then(Ge=>{const Ye=function(nt){if(!nt)return!1;const bt=new Date(nt.headers.get("Expires")||0),ft=co(nt.headers.get("Cache-Control")||"");return Number(bt)>Date.now()&&!ft["no-cache"]}(Ge);je.delete(Le).catch(ue),Ye&&je.put(Le,Ge.clone()).catch(ue),ue(null,Ge,Ye)}).catch(ue)}).catch(ue)}(P,ee):ee(null,null),{cancel:()=>{B=!0,O||E.abort()}}}(g,c);if(ha(self)&&self.worker.actor)return self.worker.actor.send("getResource",g,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 hl(E.statusText,E.status,y.url))},E.send(y.body),{cancel:()=>E.abort()}}(g,c)},Uu=function(g,c){return Of(Object.assign(g,{type:"arrayBuffer"}),c)};function sb(g){const c=document.createElement("a");return c.href=g,c.protocol===location.protocol&&c.host===location.host}const hS="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let _y,wa;_y=[],wa=0;const tx=function(g,c){if(Pd.supported&&(g.headers||(g.headers={}),g.headers.accept="image/webp,*/*"),wa>=sa.MAX_PARALLEL_IMAGE_REQUESTS){const E={requestParameters:g,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return _y.push(E),E}wa++;let m=!1;const y=()=>{if(!m)for(m=!0,wa--;_y.length&&wa{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=hS})},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):hS}(P,(B,W)=>c(B,W,O)))});return{cancel:()=>{k.cancel(),y()}}};var rb,mS,pS,ph={exports:{}},by={exports:{}},wy={exports:{}},nb=function(){if(pS)return ph.exports;pS=1;var g=(rb||(rb=1,by.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}),by.exports),c=(mS||(mS=1,wy.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}),wy.exports);return ph.exports=g,ph.exports.murmur3=g,ph.exports.murmur2=c,ph.exports}(),uv=ta(nb);class rm{constructor(c,...m){Object.assign(this,m[0]||{}),this.type=c}}class sx extends rm{constructor(c,m={}){super("error",Object.assign({error:c},m))}}function ab(g,c,m){m[g]&&m[g].indexOf(c)!==-1||(m[g]=m[g]||[],m[g].push(c))}function yt(g,c,m){if(m&&m[g]){const y=m[g].indexOf(c);y!==-1&&m[g].splice(y,1)}}class Ts{on(c,m){return this._listeners=this._listeners||{},ab(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||{},ab(c,m,this._oneTimeListeners),this):new Promise(y=>{this.once(c,y)})}fire(c,m){const y=typeof c=="string"?new rm(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 sx&&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 Ws{constructor(c){typeof c=="string"?this.name=c:(this.name=c.name,this.iconsetId=c.iconsetId)}static from(c){return new Ws(c)}static toString(c){return c.iconsetId?`${c.name}${c.iconsetId}`:c.name}static parse(c){const[m,y]=c.split("");return new Ws({name:m,iconsetId:y})}static isEqual(c,m){return c.name===m.name&&c.iconsetId===m.iconsetId}toString(){return Ws.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var ln,cn={},ea=function(){if(ln)return cn;ln=1;var g={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{cn.parseCSSColor=function(E){var P,O=E.replace(/ /g,"").toLowerCase();if(O in g)return g[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 ce=(parseFloat(ee[0])%360+360)%360/360,ue=y(ee[1]),je=y(ee[2]),Le=je<=.5?je*(ue+1):je+ue-je*ue,Ie=2*je-Le;return[c(255*k(Ie,Le,ce+1/3)),c(255*k(Ie,Le,ce)),c(255*k(Ie,Le,ce-1/3)),ne];default:return null}}return null}}catch{}return cn}();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=ea.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 Rf(c,m,y,k,E)}toPremultipliedRenderColor(c){const{r:m,g:y,b:k,a:E}=this;return new qm(c,m*E,y*E,k*E,E)}clone(){return new Fr(this.r,this.g,this.b,this.a)}}class to{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),ce=Math.ceil(y),ue=Math.ceil(k),je=m-W,Le=y-J,Ie=k-ee,Ge=c.image.data,Ye=4*(W+J*B+ee*O),nt=4*(W+J*B+ue*O),bt=4*(W+ce*B+ee*O),ft=4*(W+ce*B+ue*O),St=4*(ne+J*B+ee*O),It=4*(ne+J*B+ue*O),qt=4*(ne+ce*B+ee*O),is=4*(ne+ce*B+ue*O);if(Ye<0||is>=Ge.length)throw new Error("out of range");this.r=Hr(Hr(Hr(Ge[Ye],Ge[nt],Ie),Hr(Ge[bt],Ge[ft],Ie),Le),Hr(Hr(Ge[St],Ge[It],Ie),Hr(Ge[qt],Ge[is],Ie),Le),je)/255*(this.premultiplied?E:1),this.g=Hr(Hr(Hr(Ge[Ye+1],Ge[nt+1],Ie),Hr(Ge[bt+1],Ge[ft+1],Ie),Le),Hr(Hr(Ge[St+1],Ge[It+1],Ie),Hr(Ge[qt+1],Ge[is+1],Ie),Le),je)/255*(this.premultiplied?E:1),this.b=Hr(Hr(Hr(Ge[Ye+2],Ge[nt+2],Ie),Hr(Ge[bt+2],Ge[ft+2],Ie),Le),Hr(Hr(Ge[St+2],Ge[It+2],Ie),Hr(Ge[qt+2],Ge[is+2],Ie),Le),je)/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 ce;switch(W){case E:ce=60*((P-O)/J+(PHr(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 ky=Object.freeze({__proto__:null,array:jy,color:function(g,c,m){return new Fr(Hr(g.r,c.r,m),Hr(g.g,c.g,m),Hr(g.b,c.b,m),Hr(g.a,c.a,m))},number:Hr});class nm extends Error{constructor(c,m){super(m),this.message=m,this.key=c}}class hv{constructor(c,m=[]){this.parent=c,this.bindings={};for(const[y,k]of m)this.bindings[y]=k}concat(c){return new hv(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 Um={kind:"null"},Rr={kind:"number"},ja={kind:"string"},pi={kind:"boolean"},ju={kind:"color"},Cp={kind:"object"},si={kind:"value"},fS={kind:"collator"},ib={kind:"formatted"},ob={kind:"resolvedImage"};function pd(g,c){return{kind:"array",itemType:g,N:c}}function al(g){if(g.kind==="array"){const c=al(g.itemType);return typeof g.N=="number"?`array<${c}, ${g.N}>`:g.itemType.kind==="value"?"array":`array<${c}>`}return g.kind}const Ice=[Um,Rr,ja,pi,ju,ib,Cp,pd(si),ob];function rx(g,c){if(c.kind==="error")return null;if(g.kind==="array"){if(c.kind==="array"&&(c.N===0&&c.itemType.kind==="value"||!rx(g.itemType,c.itemType))&&(typeof g.N!="number"||g.N===c.N))return null}else{if(g.kind===c.kind)return null;if(g.kind==="value"){for(const m of Ice)if(!rx(m,c))return null}}return`Expected ${al(g)} but found ${al(c)} instead.`}function GM(g,c){return c.some(m=>m.kind===g.kind)}function lb(g,c){return c.some(m=>m==="null"?g===null:m==="array"?Array.isArray(g):m==="object"?g&&!Array.isArray(g)&&typeof g=="object":m===typeof g)}function gS(g,c){return g.kind==="array"&&c.kind==="array"?g.N===c.N&&gS(g.itemType,c.itemType):g.kind===c.kind}class KM{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 xS{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 Qd{constructor(c){this.sections=c}static fromString(c){return new Qd([new xS(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 Qd?c:Qd.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 Ff{constructor(c,m={}){this.id=Ws.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 Ff(m,{params:y,sx:k,sy:E}):null}scaleSelf(c,m=c){return this.sx*=c,this.sy*=m,this}}class Jd{constructor(c,m,y,k,E=!1){this.primaryId=Ws.from(c),this.primaryOptions=m,y&&(this.secondaryId=Ws.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 Ff(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new Ff(this.secondaryId,this.secondaryOptions):null}static from(c){return typeof c=="string"?Jd.build({name:c}):c}static build(c,m,y,k){return!c||typeof c=="object"&&!("name"in c)?null:new Jd(c,y,m,k)}}function Ny(g,c,m,y){return typeof g=="number"&&g>=0&&g<=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 [${[g,c,m,y].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof y=="number"?[g,c,m,y]:[g,c,m]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function mv(g){if(g===null||typeof g=="string"||typeof g=="boolean"||typeof g=="number"||g instanceof Fr||g instanceof KM||g instanceof Qd||g instanceof Jd)return!0;if(Array.isArray(g)){for(const c of g)if(!mv(c))return!1;return!0}if(typeof g=="object"){for(const c in g)if(!mv(g[c]))return!1;return!0}return!1}function ic(g){if(g===null)return Um;if(typeof g=="string")return ja;if(typeof g=="boolean")return pi;if(typeof g=="number")return Rr;if(g instanceof Fr)return ju;if(g instanceof KM)return fS;if(g instanceof Qd)return ib;if(g instanceof Jd)return ob;if(Array.isArray(g)){const c=g.length;let m;for(const y of g){const k=ic(y);if(m){if(m===k)continue;m=si;break}m=k}return pd(m||si,c)}return Cp}function am(g){const c=typeof g;return g===null?"":c==="string"||c==="number"||c==="boolean"?String(g):g instanceof Qd||g instanceof Jd||g instanceof Fr?g.toString():JSON.stringify(g)}class zf{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(!mv(c[1]))return m.error("invalid value");const y=c[1];let k=ic(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 zf(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 Qd?this.value.serialize():this.value}}class Hl{constructor(c){this.name="ExpressionEvaluationError",this.message=c}toJSON(){return this.message}}const ZM={string:ja,number:Rr,boolean:pi,object:Cp};class Vm{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 ZM)||W==="object")return m.error('The item type argument of "array" must be one of string, number, boolean',1);O=ZM[W],k++}else O=si;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=pd(O,B)}else y=ZM[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=ib,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",Rr),!B))return null;let W=null;if(O["text-font"]&&(W=m.parseObjectValue(O["text-font"],P,"text-font",pd(ja)),!W))return null;let J=null;if(O["text-color"]&&(J=m.parseObjectValue(O["text-color"],P,"text-color",ju),!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,si);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 Qd(this.sections.map(m=>{const y=m.content.evaluate(c);return gS(ic(y),ob)?new xS("",y,null,null,null):new xS(am(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 Dn{constructor(c,m,y,k){this._imageWarnHistory={},this.type=ob,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(yWs.isEqual(P,E)),k.available){const P=k.getSecondary()?k.getSecondary().id:null;P&&(k.available=c.availableImages.some(O=>Ws.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 Ir(g){return dn(g)?"string":pv(g)?"number":vS(g)?"boolean":Array.isArray(g)?"array":g===null?"null":yS(g)?"object":typeof g}function yS(g){return g!=null&&!Array.isArray(g)&&typeof g!="function"&&!(g instanceof String||g instanceof Number||g instanceof Boolean)&&typeof g=="object"}function dn(g){return typeof g=="string"||g instanceof String}function pv(g){return typeof g=="number"||g instanceof Number}function vS(g){return typeof g=="boolean"||g instanceof Boolean}const rn={"to-boolean":pi,"to-color":ju,"to-number":Rr,"to-string":ja};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=Um;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=pd(m.expectedType.itemType,P)}else{if(!(P>0&&mv(c[1][0])))return null;E=pd(ic(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.`:Ny(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 Hl(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 Hl(`Could not convert ${JSON.stringify(m)} to number.`)}return this.type.kind==="formatted"?Qd.fromString(am(this.args[0].evaluate(c))):this.type.kind==="resolvedImage"?Jd.build(am(this.args[0].evaluate(c))):this.type.kind==="array"?this.args.map(m=>m.evaluate(c)):am(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 Dn(this.args[0]).serialize();const c=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(m=>{c.push(m.serialize())}),c}}const YM=["Unknown","Point","LineString","Polygon"];class _S{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"?YM[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 eu{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=eu.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=eu.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 PS(m.registry,m.path,null,m.scope,void 0,m._scope,m.options,m.iconImageUseTheme);const ne=[];let ce=!1;for(let ue=1;uene)).map(bS).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);wS(g,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=g[c];let P=m,O=y;for(Hm(g,m,c),k(g[y],E)>0&&Hm(g,m,y);P0;)O--}k(g[m],E)===0?Hm(g,m,O):(O++,Hm(g,O,y)),O<=c&&(m=O+1),c<=O&&(y=O-1)}}function Hm(g,c,m){const y=g[c];g[c]=g[m],g[m]=y}function XM(g,c){return gc?1:0}function nx(g){let c=0;for(let m,y,k=0,E=g.length,P=E-1;k=c[2]||g[1]<=c[1]||g[3]>=c[3])}function Lce(g,c,m){const y=g[0]-c[0],k=g[1]-c[1],E=g[0]-m[0],P=g[1]-m[1];return y*P-E*k==0&&y*E<=0&&k*P<=0}function fv(g,c,m=!1){let y=!1;for(let O=0,B=c.length;O(k=g)[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 db(g,c,m,y){const k=y[0]-m[0],E=y[1]-m[1],P=(g[0]-m[0])*E-k*(g[1]-m[1]),O=(c[0]-m[0])*E-k*(c[1]-m[1]);return P>0&&O<0||P<0&&O>0}function ub(g,c,m,y){return(k=[y[0]-m[0],y[1]-m[1]])[0]*(E=[c[0]-g[0],c[1]-g[1]])[1]-k[1]*E[0]!=0&&!(!db(g,c,m,y)||!db(m,y,g,c));var k,E}function Bf(g){const c=new es(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),m=new es(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const y of g[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=g[0]-m[0]>k?-y:m[0]-g[0]>k?y:0;E===0&&(E=g[0]-m[2]>k?-y:m[2]-g[0]>k?y:0),g[0]+=E}im(c,g)}function cD(g,c,m,y){const k=Math.pow(2,y.z)*ax,E=[y.x*ax,y.y*ax],P=[];if(!g)return P;for(const O of g)for(const B of O){const W=[B.x+E[0],B.y+E[1]];lD(W,c,m,k),P.push(W)}return P}function jS(g,c,m,y){const k=Math.pow(2,y.z)*ax,E=[y.x*ax,y.y*ax],P=[];if(!g)return P;for(const B of g){const W=[];for(const J of B){const ee=[J.x+E[0],J.y+E[1]];im(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)lD(W,c,m,k)}var O;return P}class ox{constructor(c,m){this.type=pi,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(mv(c[1])){const y=c[1];if(y.type==="FeatureCollection")for(let k=0;km)return kS(E,P,(m-(y-O))/O)}return c[c.length-1]}pointToSegmentDistance(c,m,y){let[k,E]=m,P=fh(y[0]-k)*this.kx,O=(y[1]-E)*this.ky;if(P!==0||O!==0){const B=(fh(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=fh(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]):ce>0&&(W+=ee/this.kx*ce,J+=ne/this.ky*ce)),ee=fh(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;!eT(y[O],P[0])&&O<=B&&P.push(y[O]);for(let W=O+1;W<=B;W++)P.push(y[W]);return eT(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(kS(O,B,(c-(k-W))/W)),k>=m)return E.push(kS(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 fh(c[0]-m[0])>=0&&fh(c[0]-m[2])<=0&&c[1]>=m[1]&&c[1]<=m[3]}}function eT(g,c){return g[0]===c[0]&&g[1]===c[1]}function kS(g,c,m){const y=fh(c[0]-g[0]);return[g[0]+y*m,g[1]+(c[1]-g[1])*m]}function fh(g){for(;g<-180;)g+=360;for(;g>180;)g-=360;return g}class NS{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 Ys=8192;function tT(g,c){return c.dist-g.dist}const SS=100,CS=50;function sT(g){const c=[1/0,1/0,-1/0,-1/0];if(c.length!==g.length)return!1;for(let m=0;m=g[0]&&g[1]g[1])return[null,null];const m=mb(g);if(c){if(m===2)return[g,null];const y=Math.floor(m/2);return[[g[0],g[0]+y],[g[0]+y,g[1]]]}{if(m===1)return[g,null];const y=Math.floor(m/2)-1;return[[g[0],g[0]+y],[g[0]+y+1,g[1]]]}}function Sy(g,c){const m=[1/0,1/0,-1/0,-1/0];if(!Ap(c,g.length))return m;for(let y=c[0];y<=c[1];++y)im(m,g[y]);return m}function Cy(g){const c=[1/0,1/0,-1/0,-1/0];for(let m=0;mc[2]&&(y=g[0]-c[2]),g[1]>c[3]&&(k=g[1]-c[3]),g[3]=y)return y;if(cb(k,E)){if(aT(g,c))return 0}else if(aT(c,g))return 0;let P=y;for(const O of g)for(let B=0,W=O.length,J=W-1;B=E)continue;const J=W.range1;if(mb(J)<=O){if(!Ap(J,g.length))return NaN;if(c){const ee=Bce(g,J,m,y);if((E=Math.min(E,ee))===0)return E}else for(let ee=J[0];ee<=J[1];++ee){const ne=zce(g[ee],m,y);if((E=Math.min(E,ne))===0)return E}}else{const ee=rT(J,c);if(ee[0]!==null){const ne=lx(Sy(g,ee[0]),B,y);ne=P)continue;const ee=J.range1,ne=J.range2;if(mb(ee)<=B&&mb(ne)<=W){if(!Ap(ee,g.length)||!Ap(ne,m.length))return NaN;if(c&&y?P=Math.min(P,Sa(g,ee,m,ne,k)):c||y?c&&!y?P=Math.min(P,nT(m,ne,g,ee,k)):!c&&y&&(P=Math.min(P,nT(g,ee,m,ne,k))):P=Math.min(P,Fce(g,ee,m,ne,k)),P===0)return P}else{const ce=rT(ee,c),ue=rT(ne,y);so(O,P,k,g,m,ce[0],ue[0]),so(O,P,k,g,m,ce[0],ue[1]),so(O,P,k,g,m,ce[1],ue[0]),so(O,P,k,g,m,ce[1],ue[1])}}return P}function iT(g,c,m,y,k=1/0){let E=k;const P=Sy(g,[0,g.length-1]);for(const O of m)if(!(E!==1/0&&lx(P,Sy(O,[0,O.length-1]),y)>=E)&&(E=Math.min(E,mD(g,c,O,!0,y,E)),E===0))return E;return E}function AS(g,c,m,y,k=1/0){let E=k;const P=Sy(g,[0,g.length-1]);for(const O of m){if(E!==1/0&&lx(P,Cy(O),y)>=E)continue;const B=qce(g,c,O,y,E);if(isNaN(B))return B;if((E=Math.min(E,B))===0)return E}return E}function oT(g){return g==="Point"||g==="MultiPoint"||g==="LineString"||g==="MultiLineString"||g==="Polygon"||g==="MultiPolygon"}class My{constructor(c,m){this.type=Rr,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(mv(c[1])){const y=c[1];if(y.type==="FeatureCollection"){for(let k=0;k{c&&!yv(m)&&(c=!1)}),c}function pb(g){if(g instanceof eu&&g.name==="feature-state")return!1;let c=!0;return g.eachChild(m=>{c&&!pb(m)&&(c=!1)}),c}function vv(g,c){if(g instanceof eu&&c.indexOf(g.name)>=0)return!1;let m=!0;return g.eachChild(y=>{m&&!vv(y,c)&&(m=!1)}),m}function pD(g,c,m){return[g,c,m].filter(Boolean).join("")}function lT(g,c){switch(g){case"string":return am(c);case"number":return+c;case"boolean":return!!c;case"color":return Fr.parse(c);case"formatted":return Qd.fromString(am(c));case"resolvedImage":return Jd.build(am(c))}return c}function fD(g,c,m,y){return y!==void 0&&(g=y*Math.round(g/y)),c!==void 0&&gm&&(g=m),g}class _v{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=si),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 zf))return m.error("Key name of 'config' expression must be a string literal.");let E,P=!0;const O=am(k.value);if(c.length>=3){const B=m.parse(c[2],2);if(!(B instanceof zf))return m.error("Scope of 'config' expression must be a string literal.");E=am(B.value)}if(m.options){const B=pD(O,E,m._scope),W=m.options.get(B);W&&(P=yv(W.value||W.default))}return new _v(y,O,E,P)}evaluate(c){const m=pD(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=lT(k,ee)),ee===void 0||O===void 0&&B===void 0&&W===void 0||(typeof ee=="number"?ee=fD(ee,O,B,W):Array.isArray(ee)&&(ee=ee.map(ne=>typeof ne=="number"?fD(ne,O,B,W):ne))),E!==void 0&&ee!==void 0&&P&&!P.includes(ee)&&(ee=J,k&&(ee=lT(k,ee))),(k&&k!==this.type||ee!==void 0&&!gS(ic(ee),this.type))&&(ee=lT(this.type.kind,ee)),ee}eachChild(){}outputDefined(){return!1}serialize(){const c=["config",this.key];return this.scope&&c.concat(this.scope),c}}class ES{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 ES(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 PS{constructor(c,m=[],y,k=new hv,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 Vm(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 zf)&&E.type.kind!=="resolvedImage"&&cT(E)){const P=new _S(this._scope,this.options,this.iconImageUseTheme);try{E=new zf(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 PS(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 nm(y,c))}checkSubtype(c,m){const y=rx(c,m);return y&&this.error(y),y}}function cT(g){if(g instanceof ES)return cT(g.boundExpression);if(g instanceof eu&&g.name==="error"||g instanceof vc||g instanceof ox||g instanceof My||g instanceof _v)return!1;const c=g instanceof Tp||g instanceof Vm;let m=!0;return g.eachChild(y=>{m=c?m&&cT(y):m&&y instanceof zf}),!!m&&yv(g)&&vv(g,["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 IS(g,c){const m=g.length-1;let y,k,E=0,P=m,O=0;for(;E<=P;)if(O=Math.floor((E+P)/2),y=g[O],k=g[O+1],y<=c){if(O===m||cc))throw new Hl("Input is not a number.");P=O-1}return 0}class fb{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,Rr);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 fb(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[IS(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 gD=.95047,xD=1.08883,yD=4/29,bv=6/29,vD=3*bv*bv,Uce=bv*bv*bv,Vce=Math.PI/180,Hce=180/Math.PI;function dT(g){return g>Uce?Math.pow(g,1/3):g/vD+yD}function uT(g){return g>bv?g*g*g:vD*(g-yD)}function hT(g){return 255*(g<=.0031308?12.92*g:1.055*Math.pow(g,1/2.4)-.055)}function mT(g){return(g/=255)<=.04045?g/12.92:Math.pow((g+.055)/1.055,2.4)}function _D(g){const c=mT(g.r),m=mT(g.g),y=mT(g.b),k=dT((.4124564*c+.3575761*m+.1804375*y)/gD),E=dT((.2126729*c+.7151522*m+.072175*y)/1);return{l:116*E-16,a:500*(k-E),b:200*(E-dT((.0193339*c+.119192*m+.9503041*y)/xD)),alpha:g.a}}function LS(g){let c=(g.l+16)/116,m=isNaN(g.a)?c:c+g.a/500,y=isNaN(g.b)?c:c-g.b/200;return c=1*uT(c),m=gD*uT(m),y=xD*uT(y),new Fr(hT(3.2404542*m-1.5371385*c-.4985314*y),hT(-.969266*m+1.8760108*c+.041556*y),hT(.0556434*m-.2040259*c+1.0572252*y),g.alpha)}function DS(g,c,m){const y=c-g;return g+m*(y>180||y<-180?y-360*Math.round(y/360):y)}const wv={forward:_D,reverse:LS,interpolate:function(g,c,m){return{l:Hr(g.l,c.l,m),a:Hr(g.a,c.a,m),b:Hr(g.b,c.b,m),alpha:Hr(g.alpha,c.alpha,m)}}},gb={forward:function(g){const{l:c,a:m,b:y}=_D(g),k=Math.atan2(y,m)*Hce;return{h:k<0?k+360:k,c:Math.sqrt(m*m+y*y),l:c,alpha:g.a}},reverse:function(g){const c=g.h*Vce,m=g.c;return LS({l:g.l,a:Math.cos(c)*m,b:Math.sin(c)*m,alpha:g.alpha})},interpolate:function(g,c,m){return{h:DS(g.h,c.h,m),c:Hr(g.c,c.c,m),l:Hr(g.l,c.l,m),alpha:Hr(g.alpha,c.alpha,m)}}};var bD=Object.freeze({__proto__:null,hcl:gb,lab:wv});class gh{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=OS(m,c.base,y,k);else if(c.name==="linear")E=OS(m,1,y,k);else if(c.name==="cubic-bezier"){const P=c.controlPoints;E=new $r(P[0],P[1],P[2],P[3]).solve(OS(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,Rr),!E)return null;const O=[];let B=null;y==="interpolate-hcl"||y==="interpolate-lab"?B=ju: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,ce,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 gh(B,y,k,E,O):m.error(`Type ${al(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=IS(m,k),O=gh.interpolationFactor(this.interpolation,k,m[P],m[P+1]),B=y[P].evaluate(c),W=y[P+1].evaluate(c);return this.operator==="interpolate"?ky[this.type.kind.toLowerCase()](B,W,O):this.operator==="interpolate-hcl"?gb.reverse(gb.interpolate(gb.forward(B),gb.forward(W),O)):wv.reverse(wv.interpolate(wv.forward(B),wv.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;yrx(k,O.type));return new xb(P?si: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 Jd&&!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 $f{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 Hl("Array index out of bounds: index exceeds array size");if(m!==Math.floor(m))throw new Hl("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 FS{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,Rr),k=m.parse(c[2],2,pd(m.expectedType||si));return y&&k?new FS(k.type.itemType,y,k):null}evaluate(c){const m=this.index.evaluate(c),y=this.input.evaluate(c);if(m<0)throw new Hl(`Array index out of bounds: ${m} < 0.`);if(m>y.length-1)throw new Hl(`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 Hl(`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 pT{constructor(c,m){this.type=pi,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,si),k=m.parse(c[2],2,si);return y&&k?GM(y.type,[pi,ja,Rr,Um,si])?new pT(y,k):m.error(`Expected first argument to be of type boolean, string, number or null, but found ${al(y.type)} instead`):null}evaluate(c){const m=this.needle.evaluate(c),y=this.haystack.evaluate(c);if(y==null)return!1;if(!lb(m,["boolean","string","number","null"]))throw new Hl(`Expected first argument to be of type boolean, string, number or null, but found ${al(ic(m))} instead.`);if(!lb(y,["string","array"]))throw new Hl(`Expected second argument to be of type array or string, but found ${al(ic(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 jv{constructor(c,m,y){this.type=Rr,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,si),k=m.parse(c[2],2,si);if(!y||!k)return null;if(!GM(y.type,[pi,ja,Rr,Um,si]))return m.error(`Expected first argument to be of type boolean, string, number or null, but found ${al(y.type)} instead`);if(c.length===4){const E=m.parse(c[3],3,Rr);return E?new jv(y,k,E):null}return new jv(y,k)}evaluate(c){const m=this.needle.evaluate(c),y=this.haystack.evaluate(c);if(!lb(m,["boolean","string","number","null"]))throw new Hl(`Expected first argument to be of type boolean, string, number or null, but found ${al(ic(m))} instead.`);if(!lb(y,["string","array"]))throw new Hl(`Expected second argument to be of type array or string, but found ${al(ic(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 yb{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,ic(ue)))return null}else y=ic(ue);if(E[String(ue)]!==void 0)return ne.error("Branch labels must be unique.");E[String(ue)]=P.length}const ce=m.parse(ee,W,k);if(!ce)return null;k=k||ce.type,P.push(ce)}const O=m.parse(c[1],1,si);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 yb(y,k,O,E,P,B):null}evaluate(c){const m=this.input.evaluate(c);return(gS(ic(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 vb{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 zS{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,si),k=m.parse(c[2],2,Rr);if(!y||!k)return null;if(!GM(y.type,[pd(si),ja,si]))return m.error(`Expected first argument to be of type array or string, but found ${al(y.type)} instead`);if(c.length===4){const E=m.parse(c[3],3,Rr);return E?new zS(y.type,y,k,E):null}return new zS(y.type,y,k)}evaluate(c){const m=this.input.evaluate(c),y=this.beginIndex.evaluate(c);if(!lb(m,["string","array"]))throw new Hl(`Expected first argument to be of type array or string, but found ${al(ic(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 fT{constructor(c,m){this.type=pd(ja),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,ja),k=m.parse(c[2],2,ja);return y&&k?new fT(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 gT(g,c){return g==="=="||g==="!="?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 xT(g,c,m,y){return y.compare(c,m)===0}function kv(g,c,m){const y=g!=="=="&&g!=="!=";return class jBe{constructor(E,P,O){this.type=pi,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,si);if(!B)return null;if(!gT(O,B.type))return P.concat(1).error(`"${O}" comparisons are not supported for type '${al(B.type)}'.`);let W=P.parse(E[2],2,si);if(!W)return null;if(!gT(O,W.type))return P.concat(2).error(`"${O}" comparisons are not supported for type '${al(W.type)}'.`);if(B.type.kind!==W.type.kind&&B.type.kind!=="value"&&W.type.kind!=="value")return P.error(`Cannot compare types '${al(B.type)}' and '${al(W.type)}'.`);y&&(B.type.kind==="value"&&W.type.kind!=="value"?B=new Vm(W.type,[B]):B.type.kind!=="value"&&W.type.kind==="value"&&(W=new Vm(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,fS),!J)return null}return new jBe(B,W,J)}evaluate(E){const P=this.lhs.evaluate(E),O=this.rhs.evaluate(E);if(y&&this.hasUntypedArgument){const B=ic(P),W=ic(O);if(B.kind!==W.kind||B.kind!=="string"&&B.kind!=="number")throw new Hl(`Expected arguments for "${g}" to be (string, string) or (number, number), but found (${B.kind}, ${W.kind}) instead.`)}if(this.collator&&!y&&this.hasUntypedArgument){const B=ic(P),W=ic(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=[g];return this.eachChild(P=>{E.push(P.serialize())}),E}}}const Wce=kv("==",function(g,c,m){return c===m},xT),Gce=kv("!=",function(g,c,m){return c!==m},function(g,c,m,y){return!xT(0,c,m,y)}),wD=kv("<",function(g,c,m){return c",function(g,c,m){return c>m},function(g,c,m,y){return y.compare(c,m)>0}),BS=kv("<=",function(g,c,m){return c<=m},function(g,c,m,y){return y.compare(c,m)<=0}),Kce=kv(">=",function(g,c,m){return c>=m},function(g,c,m,y){return y.compare(c,m)>=0});class $S{constructor(c,m,y,k,E,P){this.type=ja,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,Rr);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",ja),!E))return null;let P=null;if(k.currency&&(P=m.parseObjectValue(k.currency,2,"currency",ja),!P))return null;let O=null;if(k.unit&&(O=m.parseObjectValue(k.unit,2,"unit",ja),!O))return null;let B=null;if(k["min-fraction-digits"]&&(B=m.parseObjectValue(k["min-fraction-digits"],2,"min-fraction-digits",Rr),!B))return null;let W=null;return k["max-fraction-digits"]&&(W=m.parseObjectValue(k["max-fraction-digits"],2,"max-fraction-digits",Rr),!W)?null:new $S(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 yT{constructor(c){this.type=Rr,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 ${al(y.type)} instead.`):new yT(y):null}evaluate(c){const m=this.input.evaluate(c);if(typeof m=="string"||Array.isArray(m))return m.length;throw new Hl(`Expected value to be of type string or array, but found ${al(ic(m))} instead.`)}eachChild(c){c(this.input)}outputDefined(){return!1}serialize(){const c=["length"];return this.eachChild(m=>{c.push(m.serialize())}),c}}function kD(g){return function(){g=1831565813+(g|=0)|0;let c=Math.imul(g^g>>>15,1|g);return c=c+Math.imul(c^c>>>7,61|c)^c,((c^c>>>14)>>>0)/4294967296}}const Nv={"==":Wce,"!=":Gce,">":jD,"<":wD,">=":Kce,"<=":BS,array:Vm,at:RS,"at-interpolated":FS,boolean:Vm,case:vb,coalesce:xb,collator:vc,format:Mp,image:Dn,in:pT,"index-of":jv,interpolate:gh,"interpolate-hcl":gh,"interpolate-lab":gh,length:yT,let:$f,literal:zf,match:yb,number:Vm,"number-format":$S,object:Vm,slice:zS,step:fb,string:Vm,"to-boolean":Tp,"to-color":Tp,"to-number":Tp,"to-string":Tp,var:ES,within:ox,distance:My,config:_v,split:fT};function vT(g,[c,m,y,k]){c=c.evaluate(g),m=m.evaluate(g),y=y.evaluate(g);const E=k?k.evaluate(g):1,P=Ny(c,m,y,E);if(P)throw new Hl(P);return new Fr(c/255,m/255,y/255,E)}function _T(g,[c,m,y,k]){c=c.evaluate(g),m=m.evaluate(g),y=y.evaluate(g);const E=k?k.evaluate(g):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 Hl(P);const O=`hsla(${c}, ${m}%, ${y}%, ${E})`,B=Fr.parse(O);if(!B)throw new Hl(`Failed to parse HSLA color: ${O}`);return B}function ND(g,c){return g in c}function bT(g,c){const m=c[g];return m===void 0?null:m}function dx(g){return{type:g}}function Ty(g){if(g instanceof _v)return new Set([g.key]);let c=new Set;return g.eachChild(m=>{c=new Set([...c,...Ty(m)])}),c}function qS(g){if(g instanceof eu&&g.name==="is-active-floor")return!0;let c=!1;return g.eachChild(m=>{!c&&qS(m)&&(c=!0)}),c}function SD(g){return{result:"success",value:g}}function ux(g){return{result:"error",value:g}}function wT(g,c){return!!g&&!!g.parameters&&g.parameters.indexOf(c)>-1}function _b(g){return g["property-type"]==="data-driven"}function CD(g){return wT(g.expression,"measure-light")}function MD(g){return wT(g.expression,"zoom")}function US(g){return!!g.expression&&g.expression.interpolated}function VS(g){return typeof g=="object"&&g!==null&&!Array.isArray(g)}function TD(g){return g}function AD(g,c){const m=c.type==="color",y=g.stops&&typeof g.stops[0][0]=="object",k=y||!(y||g.property!==void 0),E=g.type||(US(c)?"exponential":"interval");if(m&&((g=Object.assign({},g)).stops&&(g.stops=g.stops.map(W=>[W[0],Fr.parse(W[1])])),g.default=Fr.parse(g.default?g.default:c.default)),g.colorSpace&&g.colorSpace!=="rgb"&&!bD[g.colorSpace])throw new Error(`Unknown color space: ${g.colorSpace}`);let P,O,B;if(E==="exponential")P=ED;else if(E==="interval")P=Yce;else if(E==="categorical"){P=Zce,O=Object.create(null);for(const W of g.stops)O[W[0]]=W[1];B=typeof g.stops[0][0]}else{if(E!=="identity")throw new Error(`Unknown function type "${E}"`);P=PD}if(y){const W={},J=[];for(let ce=0;cece[0]),evaluate:({zoom:ce},ue)=>ED({stops:ee,base:g.base},c,ce).evaluate(ce,ue)}}if(k){const W=E==="exponential"?{name:"exponential",base:g.base!==void 0?g.base:1}:null;return{kind:"camera",interpolationType:W,interpolationFactor:gh.interpolationFactor.bind(void 0,W),zoomStops:g.stops.map(J=>J[0]),evaluate:({zoom:J})=>P(g,c,J,O,B)}}return{kind:"source",evaluate(W,J){const ee=J&&J.properties?J.properties[g.property]:void 0;return ee===void 0?Ep(g.default,c.default):P(g,c,ee,O,B)}}}function Ep(g,c,m){return g!==void 0?g:c!==void 0?c:m!==void 0?m:void 0}function Zce(g,c,m,y,k){return Ep(typeof m===k?y[m]:void 0,g.default,c.default)}function Yce(g,c,m){if(!pv(m))return Ep(g.default,c.default);const y=g.stops.length;if(y===1||m<=g.stops[0][0])return g.stops[0][1];if(m>=g.stops[y-1][0])return g.stops[y-1][1];const k=IS(g.stops.map(E=>E[0]),m);return g.stops[k][1]}function ED(g,c,m){const y=g.base!==void 0?g.base:1;if(!pv(m))return Ep(g.default,c.default);const k=g.stops.length;if(k===1||m<=g.stops[0][0])return g.stops[0][1];if(m>=g.stops[k-1][0])return g.stops[k-1][1];const E=IS(g.stops.map(J=>J[0]),m),P=function(J,ee,ne,ce){const ue=ce-ne,je=J-ne;return ue===0?0:ee===1?je/ue:(Math.pow(ee,je)-1)/(Math.pow(ee,ue)-1)}(m,y,g.stops[E][0],g.stops[E+1][0]),O=g.stops[E][1],B=g.stops[E+1][1];let W=ky[c.type]||TD;if(g.colorSpace&&g.colorSpace!=="rgb"){const J=bD[g.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 PD(g,c,m){return c.type==="color"?m=Fr.parse(m):c.type==="formatted"?m=Qd.fromString(m.toString()):c.type==="resolvedImage"?m=Jd.build(m.toString()):Ir(m)===c.type||c.type==="enum"&&c.values[m]||(m=void 0),Ep(m,g.default,c.default)}eu.register(Nv,{error:[{kind:"error"},[ja],(g,[c])=>{throw new Hl(c.evaluate(g))}],typeof:[ja,[si],(g,[c])=>al(ic(c.evaluate(g)))],"to-rgba":[pd(Rr,4),[ju],(g,[c])=>c.evaluate(g).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[pd(Rr,4),[ju],(g,[c])=>c.evaluate(g).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[ju,[Rr,Rr,Rr],vT],rgba:[ju,[Rr,Rr,Rr,Rr],vT],hsl:[ju,[Rr,Rr,Rr],_T],hsla:[ju,[Rr,Rr,Rr,Rr],_T],has:{type:pi,overloads:[[[ja],(g,[c])=>ND(c.evaluate(g),g.properties())],[[ja,Cp],(g,[c,m])=>ND(c.evaluate(g),m.evaluate(g))]]},get:{type:si,overloads:[[[ja],(g,[c])=>bT(c.evaluate(g),g.properties())],[[ja,Cp],(g,[c,m])=>bT(c.evaluate(g),m.evaluate(g))]]},"feature-state":[si,[ja],(g,[c])=>bT(c.evaluate(g),g.featureState||{})],properties:[Cp,[],g=>g.properties()],"geometry-type":[ja,[],g=>g.geometryType()],worldview:[ja,[],g=>g.globals.worldview||""],"is-active-floor":[pi,dx(ja),(g,c)=>{if(!(g.globals.activeFloors&&g.globals.activeFloors.size>0))return!1;const m=g.globals.activeFloors;return c.some(y=>{const k=y.evaluate(g);return m.has(k)})}],id:[si,[],g=>g.id()],zoom:[Rr,[],g=>g.globals.zoom],pitch:[Rr,[],g=>g.globals.pitch||0],"distance-from-center":[Rr,[],g=>g.distanceFromCenter()],"measure-light":[Rr,[ja],(g,[c])=>g.measureLight(c.evaluate(g))],"heatmap-density":[Rr,[],g=>g.globals.heatmapDensity||0],"line-progress":[Rr,[],g=>g.globals.lineProgress||0],"raster-value":[Rr,[],g=>g.globals.rasterValue||0],"raster-particle-speed":[Rr,[],g=>g.globals.rasterParticleSpeed||0],"sky-radial-progress":[Rr,[],g=>g.globals.skyRadialProgress||0],accumulated:[si,[],g=>g.globals.accumulated===void 0?null:g.globals.accumulated],"+":[Rr,dx(Rr),(g,c)=>{let m=0;for(const y of c)m+=y.evaluate(g);return m}],"*":[Rr,dx(Rr),(g,c)=>{let m=1;for(const y of c)m*=y.evaluate(g);return m}],"-":{type:Rr,overloads:[[[Rr,Rr],(g,[c,m])=>c.evaluate(g)-m.evaluate(g)],[[Rr],(g,[c])=>-c.evaluate(g)]]},"/":[Rr,[Rr,Rr],(g,[c,m])=>c.evaluate(g)/m.evaluate(g)],"%":[Rr,[Rr,Rr],(g,[c,m])=>c.evaluate(g)%m.evaluate(g)],ln2:[Rr,[],()=>Math.LN2],pi:[Rr,[],()=>Math.PI],e:[Rr,[],()=>Math.E],"^":[Rr,[Rr,Rr],(g,[c,m])=>Math.pow(c.evaluate(g),m.evaluate(g))],sqrt:[Rr,[Rr],(g,[c])=>Math.sqrt(c.evaluate(g))],log10:[Rr,[Rr],(g,[c])=>Math.log(c.evaluate(g))/Math.LN10],ln:[Rr,[Rr],(g,[c])=>Math.log(c.evaluate(g))],log2:[Rr,[Rr],(g,[c])=>Math.log2(c.evaluate(g))],sin:[Rr,[Rr],(g,[c])=>Math.sin(c.evaluate(g))],cos:[Rr,[Rr],(g,[c])=>Math.cos(c.evaluate(g))],tan:[Rr,[Rr],(g,[c])=>Math.tan(c.evaluate(g))],asin:[Rr,[Rr],(g,[c])=>Math.asin(c.evaluate(g))],acos:[Rr,[Rr],(g,[c])=>Math.acos(c.evaluate(g))],atan:[Rr,[Rr],(g,[c])=>Math.atan(c.evaluate(g))],min:[Rr,dx(Rr),(g,c)=>Math.min(...c.map(m=>m.evaluate(g)))],max:[Rr,dx(Rr),(g,c)=>Math.max(...c.map(m=>m.evaluate(g)))],abs:[Rr,[Rr],(g,[c])=>Math.abs(c.evaluate(g))],round:[Rr,[Rr],(g,[c])=>{const m=c.evaluate(g);return m<0?-Math.round(-m):Math.round(m)}],floor:[Rr,[Rr],(g,[c])=>Math.floor(c.evaluate(g))],ceil:[Rr,[Rr],(g,[c])=>Math.ceil(c.evaluate(g))],"filter-==":[pi,[ja,si],(g,[c,m])=>g.properties()[c.value]===m.value],"filter-id-==":[pi,[si],(g,[c])=>g.id()===c.value],"filter-type-==":[pi,[ja],(g,[c])=>g.geometryType()===c.value],"filter-<":[pi,[ja,si],(g,[c,m])=>{const y=g.properties()[c.value],k=m.value;return typeof y==typeof k&&y{const m=g.id(),y=c.value;return typeof m==typeof y&&m":[pi,[ja,si],(g,[c,m])=>{const y=g.properties()[c.value],k=m.value;return typeof y==typeof k&&y>k}],"filter-id->":[pi,[si],(g,[c])=>{const m=g.id(),y=c.value;return typeof m==typeof y&&m>y}],"filter-<=":[pi,[ja,si],(g,[c,m])=>{const y=g.properties()[c.value],k=m.value;return typeof y==typeof k&&y<=k}],"filter-id-<=":[pi,[si],(g,[c])=>{const m=g.id(),y=c.value;return typeof m==typeof y&&m<=y}],"filter->=":[pi,[ja,si],(g,[c,m])=>{const y=g.properties()[c.value],k=m.value;return typeof y==typeof k&&y>=k}],"filter-id->=":[pi,[si],(g,[c])=>{const m=g.id(),y=c.value;return typeof m==typeof y&&m>=y}],"filter-has":[pi,[si],(g,[c])=>c.value in g.properties()],"filter-has-id":[pi,[],g=>g.id()!==null&&g.id()!==void 0],"filter-type-in":[pi,[pd(ja)],(g,[c])=>c.value.indexOf(g.geometryType())>=0],"filter-id-in":[pi,[pd(si)],(g,[c])=>c.value.indexOf(g.id())>=0],"filter-in-small":[pi,[ja,pd(si)],(g,[c,m])=>m.value.indexOf(g.properties()[c.value])>=0],"filter-in-large":[pi,[ja,pd(si)],(g,[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}(g.properties()[c.value],m.value,0,m.value.length-1)],all:{type:pi,overloads:[[[pi,pi],(g,[c,m])=>c.evaluate(g)&&m.evaluate(g)],[dx(pi),(g,c)=>{for(const m of c)if(!m.evaluate(g))return!1;return!0}]]},any:{type:pi,overloads:[[[pi,pi],(g,[c,m])=>c.evaluate(g)||m.evaluate(g)],[dx(pi),(g,c)=>{for(const m of c)if(m.evaluate(g))return!0;return!1}]]},"!":[pi,[pi],(g,[c])=>!c.evaluate(g)],"is-supported-script":[pi,[ja],(g,[c])=>{const m=g.globals&&g.globals.isSupportedScript;return!m||m(c.evaluate(g))}],upcase:[ja,[ja],(g,[c])=>c.evaluate(g).toUpperCase()],downcase:[ja,[ja],(g,[c])=>c.evaluate(g).toLowerCase()],concat:[ja,dx(si),(g,c)=>c.map(m=>am(m.evaluate(g))).join("")],"resolved-locale":[ja,[fS],(g,[c])=>c.evaluate(g).resolvedLocale()],random:[Rr,[Rr,Rr,si],(g,c)=>{const[m,y,k]=c.map(P=>P.evaluate(g));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 bb(g){return Array.isArray(g)&&g.length>0&&typeof g[0]=="string"&&g[0]in Nv}function hx(g,c,m,y,k){const E=new PS(Nv,[],c?function(O){const B={color:ju,string:ja,number:Rr,enum:ja,boolean:pi,formatted:ib,resolvedImage:ob};return O.type==="array"?pd(B[O.value]||si,O.length):B[O.type]}(c):void 0,void 0,void 0,m,y,k),P=E.parse(g,void 0,void 0,void 0,c&&c.type==="string"?{typeAnnotation:"coerce"}:void 0);return P?SD(new HS(P,c,m,y,k)):ux(E.errors)}class Sv{constructor(c,m,y,k){this.kind=c,this._styleExpression=m,this.isLightConstant=y,this.isLineProgressConstant=k,this.isStateDependent=c!=="constant"&&!pb(m.expression),this.configDependencies=Ty(m.expression),this.isIndoorDependent=qS(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 Ay{constructor(c,m,y,k,E,P){this.kind=c,this.zoomStops=y,this._styleExpression=m,this.isStateDependent=c!=="camera"&&!pb(m.expression),this.isIndoorDependent=qS(m.expression),this.isLightConstant=E,this.isLineProgressConstant=P,this.configDependencies=Ty(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?gh.interpolationFactor(this.interpolationType,c,m,y):0}}function jT(g,c,m,y,k){if((g=hx(g,c,m,y,k)).result==="error")return g;const E=g.value.expression,P=yv(E);if(!P&&!_b(c))return ux([new nm("","data expressions not supported")]);const O=vv(E,["zoom","pitch","distance-from-center"]);if(!O&&!MD(c))return ux([new nm("","zoom expressions not supported")]);const B=vv(E,["measure-light"]);if(!B&&!CD(c))return ux([new nm("","measure-light expression not supported")]);const W=vv(E,["line-progress"]);if(!W&&!function(ne){return wT(ne.expression,"line-progress")}(c))return ux([new nm("","line-progress expression not supported")]);const J=c.expression&&c.expression.relaxZoomRestriction,ee=Wm(E);return ee||O||J?ee instanceof nm?ux([ee]):ee instanceof gh&&!US(c)?ux([new nm("",'"interpolate" expressions cannot be used with this property')]):SD(ee?new Ay(P&&W?"camera":"composite",g.value,ee.labels,ee instanceof gh?ee.interpolation:void 0,B,W):new Sv(P&&W?"constant":"source",g.value,B,W)):ux([new nm("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class WS{constructor(c,m){this._parameters=c,this._specification=m,Object.assign(this,AD(this._parameters,this._specification))}static deserialize(c){return new WS(c._parameters,c._specification)}static serialize(c){return{_parameters:c._parameters,_specification:c._specification}}}function Wm(g){let c=null;if(g instanceof $f)c=Wm(g.result);else if(g instanceof xb){for(const m of g.args)if(c=Wm(m),c)break}else(g instanceof fb||g instanceof gh)&&g.input instanceof eu&&g.input.name==="zoom"&&(c=g);return c instanceof nm||g.eachChild(m=>{const y=Wm(m);y instanceof nm?c=y:c&&y&&c!==y&&(c=new nm("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),c}var kT,ID,LD=function(){if(ID)return kT;ID=1,kT=c;var g=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[je+0]&&E>=ne[je+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),ce=this._convertToCellCoord(E),ue=J;ue<=ne;ue++)for(var je=ee;je<=ce;je++){var Le=this.d*je+ue;if((!W||W(this._convertFromCellCoord(ue),this._convertFromCellCoord(je),this._convertFromCellCoord(ue+1),this._convertFromCellCoord(je+1)))&&P.call(this,m,y,k,E,Le,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=g+this.cells.length+1+1,k=0,E=0;E=0||(k[E]=qf(g[E],c)));g instanceof Error&&(k.message=g.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 g)}function mx(g){if(g==null||typeof g=="boolean"||typeof g=="number"||typeof g=="string"||g instanceof Boolean||g instanceof Number||g instanceof String||g instanceof Date||g instanceof RegExp||wb(g)||g instanceof ImageBitmap||ArrayBuffer.isView(g)||g instanceof ImageData)return g;if(Array.isArray(g))return g.map(mx);if(typeof g=="object"){const c=g.$name||"Object";if(c==="Map"){const k=g.entries||[],E=new Map;for(let P=0;Pg>=128&&g<=255,Arabic:g=>g>=1536&&g<=1791,"Arabic Supplement":g=>g>=1872&&g<=1919,"Arabic Extended-A":g=>g>=2208&&g<=2303,"Hangul Jamo":g=>g>=4352&&g<=4607,"Unified Canadian Aboriginal Syllabics":g=>g>=5120&&g<=5759,Khmer:g=>g>=6016&&g<=6143,"Unified Canadian Aboriginal Syllabics Extended":g=>g>=6320&&g<=6399,"General Punctuation":g=>g>=8192&&g<=8303,"Letterlike Symbols":g=>g>=8448&&g<=8527,"Number Forms":g=>g>=8528&&g<=8591,"Miscellaneous Technical":g=>g>=8960&&g<=9215,"Control Pictures":g=>g>=9216&&g<=9279,"Optical Character Recognition":g=>g>=9280&&g<=9311,"Enclosed Alphanumerics":g=>g>=9312&&g<=9471,"Geometric Shapes":g=>g>=9632&&g<=9727,"Miscellaneous Symbols":g=>g>=9728&&g<=9983,"Miscellaneous Symbols and Arrows":g=>g>=11008&&g<=11263,"CJK Radicals Supplement":g=>g>=11904&&g<=12031,"Kangxi Radicals":g=>g>=12032&&g<=12255,"Ideographic Description Characters":g=>g>=12272&&g<=12287,"CJK Symbols and Punctuation":g=>g>=12288&&g<=12351,Hiragana:g=>g>=12352&&g<=12447,Katakana:g=>g>=12448&&g<=12543,Bopomofo:g=>g>=12544&&g<=12591,"Hangul Compatibility Jamo":g=>g>=12592&&g<=12687,Kanbun:g=>g>=12688&&g<=12703,"Bopomofo Extended":g=>g>=12704&&g<=12735,"CJK Strokes":g=>g>=12736&&g<=12783,"Katakana Phonetic Extensions":g=>g>=12784&&g<=12799,"Enclosed CJK Letters and Months":g=>g>=12800&&g<=13055,"CJK Compatibility":g=>g>=13056&&g<=13311,"CJK Unified Ideographs Extension A":g=>g>=13312&&g<=19903,"Yijing Hexagram Symbols":g=>g>=19904&&g<=19967,"CJK Unified Ideographs":g=>g>=19968&&g<=40959,"Yi Syllables":g=>g>=40960&&g<=42127,"Yi Radicals":g=>g>=42128&&g<=42191,"Hangul Jamo Extended-A":g=>g>=43360&&g<=43391,"Hangul Syllables":g=>g>=44032&&g<=55215,"Hangul Jamo Extended-B":g=>g>=55216&&g<=55295,"Private Use Area":g=>g>=57344&&g<=63743,"CJK Compatibility Ideographs":g=>g>=63744&&g<=64255,"Arabic Presentation Forms-A":g=>g>=64336&&g<=65023,"Vertical Forms":g=>g>=65040&&g<=65055,"CJK Compatibility Forms":g=>g>=65072&&g<=65103,"Small Form Variants":g=>g>=65104&&g<=65135,"Arabic Presentation Forms-B":g=>g>=65136&&g<=65279,"Halfwidth and Fullwidth Forms":g=>g>=65280&&g<=65519,Osage:g=>g>=66736&&g<=66815,"CJK Unified Ideographs Extension B":g=>g>=131072&&g<=173791};function jb(g){for(const c of g)if(GS(c.charCodeAt(0)))return!0;return!1}function NT(g){for(const c of g)if(!DD(c.charCodeAt(0)))return!1;return!0}function DD(g){return!(Zr.Arabic(g)||Zr["Arabic Supplement"](g)||Zr["Arabic Extended-A"](g)||Zr["Arabic Presentation Forms-A"](g)||Zr["Arabic Presentation Forms-B"](g))}function GS(g){return!(g!==746&&g!==747&&(g<4352||!(Zr["Bopomofo Extended"](g)||Zr.Bopomofo(g)||Zr["CJK Compatibility Forms"](g)&&!(g>=65097&&g<=65103)||Zr["CJK Compatibility Ideographs"](g)||Zr["CJK Compatibility"](g)||Zr["CJK Radicals Supplement"](g)||Zr["CJK Strokes"](g)||!(!Zr["CJK Symbols and Punctuation"](g)||g>=12296&&g<=12305||g>=12308&&g<=12319||g===12336)||Zr["CJK Unified Ideographs Extension A"](g)||Zr["CJK Unified Ideographs"](g)||Zr["Enclosed CJK Letters and Months"](g)||Zr["Hangul Compatibility Jamo"](g)||Zr["Hangul Jamo Extended-A"](g)||Zr["Hangul Jamo Extended-B"](g)||Zr["Hangul Jamo"](g)||Zr["Hangul Syllables"](g)||Zr.Hiragana(g)||Zr["Ideographic Description Characters"](g)||Zr.Kanbun(g)||Zr["Kangxi Radicals"](g)||Zr["Katakana Phonetic Extensions"](g)||Zr.Katakana(g)&&g!==12540||!(!Zr["Halfwidth and Fullwidth Forms"](g)||g===65288||g===65289||g===65293||g>=65306&&g<=65310||g===65339||g===65341||g===65343||g>=65371&&g<=65503||g===65507||g>=65512&&g<=65519)||!(!Zr["Small Form Variants"](g)||g>=65112&&g<=65118||g>=65123&&g<=65126)||Zr["Unified Canadian Aboriginal Syllabics"](g)||Zr["Unified Canadian Aboriginal Syllabics Extended"](g)||Zr["Vertical Forms"](g)||Zr["Yijing Hexagram Symbols"](g)||Zr["Yi Syllables"](g)||Zr["Yi Radicals"](g))))}function KS(g){return!(GS(g)||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)}(g))}function ZS(g){return Zr.Arabic(g)||Zr["Arabic Supplement"](g)||Zr["Arabic Extended-A"](g)||Zr["Arabic Presentation Forms-A"](g)||Zr["Arabic Presentation Forms-B"](g)}function ST(g){return g>=1424&&g<=2303||Zr["Arabic Presentation Forms-A"](g)||Zr["Arabic Presentation Forms-B"](g)}function Uf(g,c){return!(!c&&ST(g)||g>=2304&&g<=3583||g>=3840&&g<=4255||Zr.Khmer(g))}function Xce(g){for(const c of g)if(ST(c.charCodeAt(0)))return!0;return!1}const Vu={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let CT=null,tu=Vu.unavailable,Vf=null;const kb=function(g){g&&typeof g=="string"&&g.indexOf("NetworkError")>-1&&(tu=Vu.error),CT&&CT(g)};function YS(){XS.fire(new rm("pluginStateChange",{pluginStatus:tu,pluginURL:Vf}))}const XS=new Ts,Nb=function(){return tu},OD=function(){if(tu!==Vu.deferred||!Vf)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");tu=Vu.loading,YS(),Vf&&Uu({url:Vf},g=>{g?kb(g):(tu=Vu.loaded,YS())})},Hf={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>tu===Vu.loaded||Hf.applyArabicShaping!=null,isLoading:()=>tu===Vu.loading,setState(g){tu=g.pluginStatus,Vf=g.pluginURL},isParsing:()=>tu===Vu.parsing,isParsed:()=>tu===Vu.parsed,getPluginURL:()=>Vf};class Di{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(!Uf(k.charCodeAt(0),y))return!1;return!0}(c,Hf.isLoaded())}}class QS{constructor(c,m,y,k,E){this.property=c,this.value=m,this.expression=function(P,O,B,W,J){if(VS(P))return new WS(P,O);if(bb(P)||Array.isArray(P)&&P.length>0){const ee=jT(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 MT{constructor(c,m,y,k){this.property=c,this.value=new QS(c,void 0,m,y,k)}transitioned(c,m){return new FD(this.property,this.value,m,Object.assign({},c.transition,this.transition),c.now)}untransitioned(){return new FD(this.property,this.value,null,{},0)}}class RD{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 MT(this._values[c].property,this._scope,this._options,this._iconImageUseTheme)),this._values[c].value=new QS(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 MT(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 zD(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 zD(this._properties);for(const m of Object.keys(this._values))c._values[m]=this._values[m].untransitioned();return c}isIndoorDependent(){return this._isIndoorDependent}}class FD{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 $D(g){return g instanceof Number||g instanceof String||g instanceof Boolean?g.valueOf():g}function JS(g){if(Array.isArray(g))return g.map(JS);if(g instanceof Object&&!(g instanceof Number||g instanceof String||g instanceof Boolean)){const c={};for(const m in g)c[m]=JS(g[m]);return c}return $D(g)}function Pp(g){if(g===!0||g===!1)return!0;if(!Array.isArray(g)||g.length===0)return!1;switch(g[0]){case"has":return g.length>=2&&g[1]!=="$id"&&g[1]!=="$type";case"in":return g.length>=3&&(typeof g[1]!="string"||Array.isArray(g[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return g.length!==3||Array.isArray(g[1])||Array.isArray(g[2]);case"any":case"all":for(const c of g.slice(1))if(!Pp(c)&&typeof c!="boolean")return!1;return!0;default:return!0}}function eC(g,c="",m=null,y="fill"){if(g==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Pp(g)||(g=tC(g));const k=g;let E=!0;try{E=function(J){if(!Mv(J))return J;let ee=JS(J);return qD(ee),ee=Dy(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=hx(E,O,c,m);if(J.result==="error")throw new Error(J.value.map(ee=>`${ee.key}: ${ee.message}`).join(", "));P=(ee,ne,ce)=>J.value.evaluate(ee,ne,{},ce)}let B=null,W=null;if(E!==k){const J=hx(k,O,c,m);if(J.result==="error")throw new Error(J.value.map(ee=>`${ee.key}: ${ee.message}`).join(", "));B=(ee,ne,ce,ue,je)=>J.value.evaluate(ee,ne,{},ce,void 0,void 0,ue,je),W=!yv(J.value.expression)}return{filter:P,dynamicFilter:B||void 0,needGeometry:UD(E),needFeature:!!W}}function Dy(g){if(!Array.isArray(g))return g;const c=function(m){if(Qce.has(m[0])){for(let y=1;yDy(m))}function qD(g){let c=!1;const m=[];if(g[0]==="case"){for(let y=1;y",">=","<","<=","to-boolean"]);function Jce(g,c){return gc?1:0}function UD(g){if(!Array.isArray(g))return!1;if(g[0]==="within"||g[0]==="distance")return!0;for(let c=1;c"||c==="<="||c===">="?sC(g[1],g[2],c):c==="any"?(m=g.slice(1),["any"].concat(m.map(tC))):c==="all"?["all"].concat(g.slice(1).map(tC)):c==="none"?["all"].concat(g.slice(1).map(tC).map(Sb)):c==="in"?rC(g[1],g.slice(2)):c==="!in"?Sb(rC(g[1],g.slice(2))):c==="has"?nC(g[1]):c!=="!has"||Sb(nC(g[1]));var m}function sC(g,c,m){switch(g){case"$type":return[`filter-type-${m}`,c];case"$id":return[`filter-id-${m}`,c];default:return[`filter-${m}`,g,c]}}function rC(g,c){if(c.length===0)return!1;switch(g){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",g,["literal",c.sort(Jce)]]:["filter-in-small",g,["literal",c]]}}function nC(g){switch(g){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",g]}}function Sb(g){return["!",g]}const Oy="";function Gm(g,c){return c?`${g}${Oy}${c}`:g}let VD;const HD=()=>VD||(VD=new wo({"icon-size":new rr(Gt.layout_symbol["icon-size"]),"icon-image":new rr(Gt.layout_symbol["icon-image"]),"icon-rotate":new rr(Gt.layout_symbol["icon-rotate"]),"icon-offset":new rr(Gt.layout_symbol["icon-offset"]),"text-size":new rr(Gt.layout_symbol["text-size"]),"text-rotate":new rr(Gt.layout_symbol["text-rotate"]),"text-offset":new rr(Gt.layout_symbol["text-offset"])}));class WD{constructor(c,m,y,k,E,P){const O=hx(c,Gt.appearance.condition);if(O.result==="success"&&(this.condition=O.value),this.name=m,y){this.properties=new Iy(HD()),this.unevaluatedLayout=new BD(HD(),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 GD="-transition",Ip=new Set(["fill","line","background","hillshade","raster"]);class su extends Ts{constructor(c,m,y,k,E,P){if(super(),this.id=c.id,this.fqid=Gm(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=hx(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 BD(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 RD(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 Iy(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 WD(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(GD)?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(GD)){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())),Is(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 Py&&_b(m.property.specification)&&(m.value.kind==="source"||m.value.kind==="composite")&&m.value.isStateDependent)return!0}for(const c of this.appearances)if(!pb(c.condition.expression))return!0;return!1}compileFilter(c){this._filterCompiled||(this._featureFilter=eC(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 KD={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Cb{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 ede=new ArrayBuffer(0);class Hi{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=ede),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 ia(g,c=1){let m=0,y=0;return{members:g.map(k=>{const E=KD[k.type].BYTES_PER_ELEMENT,P=m=ZD(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:ZD(m,Math.max(y,c)),alignment:c}}function ZD(g,c){return Math.ceil(g/c)*c}class px extends Hi{_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}}px.prototype.bytesPerElement=4,vr(px,"StructArrayLayout2i4");class Tv extends Hi{_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}}Tv.prototype.bytesPerElement=6,vr(Tv,"StructArrayLayout3i6");class Av extends Hi{_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}}Av.prototype.bytesPerElement=8,vr(Av,"StructArrayLayout4i8");class Wf extends Hi{_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}}Wf.prototype.bytesPerElement=4,vr(Wf,"StructArrayLayout1f4");class TT extends Hi{_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}}TT.prototype.bytesPerElement=8,vr(TT,"StructArrayLayout2i1f8");class AT extends Hi{_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}}AT.prototype.bytesPerElement=8,vr(AT,"StructArrayLayout3i8");class ET extends Hi{_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}}ET.prototype.bytesPerElement=10,vr(ET,"StructArrayLayout5i10");class aC extends Hi{_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}}aC.prototype.bytesPerElement=12,vr(aC,"StructArrayLayout2i4ub1f12");class xh extends Hi{_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}}xh.prototype.bytesPerElement=12,vr(xh,"StructArrayLayout3f12");class ku extends Hi{_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}}ku.prototype.bytesPerElement=12,vr(ku,"StructArrayLayout4ui1f12");class Ry extends Hi{_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}}Ry.prototype.bytesPerElement=8,vr(Ry,"StructArrayLayout4ui8");class iC extends Hi{_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}}iC.prototype.bytesPerElement=12,vr(iC,"StructArrayLayout6i12");class PT extends Hi{_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 ce=this.length;return this.resize(ce+1),this.emplace(ce,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,ce){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]=ce,c}}PT.prototype.bytesPerElement=24,vr(PT,"StructArrayLayout4i4ui4i24");class IT extends Hi{_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}}IT.prototype.bytesPerElement=20,vr(IT,"StructArrayLayout3i3f20");class fx extends Hi{_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}}fx.prototype.bytesPerElement=16,vr(fx,"StructArrayLayout4f16");class oC extends Hi{_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}}oC.prototype.bytesPerElement=4,vr(oC,"StructArrayLayout1ul4");class yh extends Hi{_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}}yh.prototype.bytesPerElement=4,vr(yh,"StructArrayLayout2ui4");class lC extends Hi{_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,ce){const ue=this.length;return this.resize(ue+1),this.emplace(ue,c,m,y,k,E,P,O,B,W,J,ee,ne,ce)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue){const je=20*c,Le=10*c;return this.int16[je+0]=m,this.int16[je+1]=y,this.int16[je+2]=k,this.int16[je+3]=E,this.int16[je+4]=P,this.float32[Le+3]=O,this.float32[Le+4]=B,this.float32[Le+5]=W,this.float32[Le+6]=J,this.int16[je+14]=ee,this.uint32[Le+8]=ne,this.uint16[je+18]=ce,this.uint16[je+19]=ue,c}}lC.prototype.bytesPerElement=40,vr(lC,"StructArrayLayout5i4f1i1ul2ui40");class cC extends Hi{_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}}cC.prototype.bytesPerElement=16,vr(cC,"StructArrayLayout3i2i2i16");class dC extends Hi{_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}}dC.prototype.bytesPerElement=16,vr(dC,"StructArrayLayout2f1f2i16");class LT extends Hi{_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}}LT.prototype.bytesPerElement=20,vr(LT,"StructArrayLayout2ub4f20");class bl extends Hi{_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}}bl.prototype.bytesPerElement=6,vr(bl,"StructArrayLayout3ui6");class Ev extends Hi{_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,ce,ue,je,Le,Ie,Ge,Ye,nt,bt){const ft=this.length;return this.resize(ft+1),this.emplace(ft,c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge,Ye,nt,bt)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge,Ye,nt,bt,ft){const St=30*c,It=15*c,qt=60*c;return this.int16[St+0]=m,this.int16[St+1]=y,this.int16[St+2]=k,this.float32[It+2]=E,this.float32[It+3]=P,this.uint16[St+8]=O,this.uint16[St+9]=B,this.uint32[It+5]=W,this.uint32[It+6]=J,this.uint32[It+7]=ee,this.uint16[St+16]=ne,this.uint16[St+17]=ce,this.uint16[St+18]=ue,this.float32[It+10]=je,this.float32[It+11]=Le,this.uint8[qt+48]=Ie,this.uint8[qt+49]=Ge,this.uint8[qt+50]=Ye,this.uint32[It+13]=nt,this.int16[St+28]=bt,this.uint8[qt+58]=ft,c}}Ev.prototype.bytesPerElement=60,vr(Ev,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class DT extends Hi{_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,ce,ue,je,Le,Ie,Ge,Ye,nt,bt,ft,St,It,qt,is,Wt,ms,_s,bs,Os,Fs,Ps){const Ls=this.length;return this.resize(Ls+1),this.emplace(Ls,c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge,Ye,nt,bt,ft,St,It,qt,is,Wt,ms,_s,bs,Os,Fs,Ps)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge,Ye,nt,bt,ft,St,It,qt,is,Wt,ms,_s,bs,Os,Fs,Ps,Ls){const hs=20*c,cs=40*c,Ds=80*c;return this.float32[hs+0]=m,this.float32[hs+1]=y,this.int16[cs+4]=k,this.int16[cs+5]=E,this.int16[cs+6]=P,this.int16[cs+7]=O,this.int16[cs+8]=B,this.int16[cs+9]=W,this.int16[cs+10]=J,this.int16[cs+11]=ee,this.int16[cs+12]=ne,this.uint16[cs+13]=ce,this.uint16[cs+14]=ue,this.uint16[cs+15]=je,this.uint16[cs+16]=Le,this.uint16[cs+17]=Ie,this.uint16[cs+18]=Ge,this.uint16[cs+19]=Ye,this.uint16[cs+20]=nt,this.uint16[cs+21]=bt,this.uint16[cs+22]=ft,this.uint16[cs+23]=St,this.uint16[cs+24]=It,this.uint16[cs+25]=qt,this.uint16[cs+26]=is,this.uint16[cs+27]=Wt,this.uint32[hs+14]=ms,this.float32[hs+15]=_s,this.float32[hs+16]=bs,this.float32[hs+17]=Os,this.float32[hs+18]=Fs,this.uint8[Ds+76]=Ps,this.uint16[cs+39]=Ls,c}}DT.prototype.bytesPerElement=80,vr(DT,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class OT extends Hi{_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}}OT.prototype.bytesPerElement=24,vr(OT,"StructArrayLayout6f24");class Fy extends Hi{_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}}Fy.prototype.bytesPerElement=20,vr(Fy,"StructArrayLayout5f20");class RT extends Hi{_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}}RT.prototype.bytesPerElement=28,vr(RT,"StructArrayLayout7f28");class FT extends Hi{_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 ce=11*c;return this.float32[ce+0]=m,this.float32[ce+1]=y,this.float32[ce+2]=k,this.float32[ce+3]=E,this.float32[ce+4]=P,this.float32[ce+5]=O,this.float32[ce+6]=B,this.float32[ce+7]=W,this.float32[ce+8]=J,this.float32[ce+9]=ee,this.float32[ce+10]=ne,c}}FT.prototype.bytesPerElement=44,vr(FT,"StructArrayLayout11f44");class Pv extends Hi{_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}}Pv.prototype.bytesPerElement=36,vr(Pv,"StructArrayLayout9f36");class Lp extends Hi{_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 Nu extends Hi{_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}}Nu.prototype.bytesPerElement=12,vr(Nu,"StructArrayLayout1ul3ui12");class gx extends Hi{_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}}gx.prototype.bytesPerElement=2,vr(gx,"StructArrayLayout1ui2");class zT extends Hi{_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,ce,ue,je,Le){const Ie=this.length;return this.resize(Ie+1),this.emplace(Ie,c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie){const Ge=16*c;return this.float32[Ge+0]=m,this.float32[Ge+1]=y,this.float32[Ge+2]=k,this.float32[Ge+3]=E,this.float32[Ge+4]=P,this.float32[Ge+5]=O,this.float32[Ge+6]=B,this.float32[Ge+7]=W,this.float32[Ge+8]=J,this.float32[Ge+9]=ee,this.float32[Ge+10]=ne,this.float32[Ge+11]=ce,this.float32[Ge+12]=ue,this.float32[Ge+13]=je,this.float32[Ge+14]=Le,this.float32[Ge+15]=Ie,c}}zT.prototype.bytesPerElement=64,vr(zT,"StructArrayLayout16f64");class uC extends Hi{_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}}uC.prototype.bytesPerElement=20,vr(uC,"StructArrayLayout4ui3f20");class BT extends Hi{_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}}BT.prototype.bytesPerElement=2,vr(BT,"StructArrayLayout1i2");class hC extends Hi{_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}}hC.prototype.bytesPerElement=1,vr(hC,"StructArrayLayout1ub1");class mC extends Cb{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]}}mC.prototype.size=40;class YD extends lC{get(c){return new mC(this,c)}}vr(YD,"CollisionBoxArray");class pC extends Cb{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}}pC.prototype.size=60;class XD extends Ev{get(c){return new pC(this,c)}}vr(XD,"PlacedSymbolArray");class QD extends Cb{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]}}QD.prototype.size=80;class $T extends DT{get(c){return new QD(this,c)}}vr($T,"SymbolInstanceArray");class fC extends Wf{getoffsetX(c){return this.float32[1*c+0]}}vr(fC,"GlyphOffsetArray");class JD extends px{getx(c){return this.int16[2*c+0]}gety(c){return this.int16[2*c+1]}}vr(JD,"SymbolLineVertexArray");class qT extends Cb{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]}}qT.prototype.size=12;class UT extends Nu{get(c){return new qT(this,c)}}vr(UT,"FeatureIndexArray");class eO extends yh{geta_centroid_pos0(c){return this.uint16[2*c+0]}geta_centroid_pos1(c){return this.uint16[2*c+1]}}vr(eO,"FillExtrusionCentroidArray");class gC extends Cb{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]}}gC.prototype.size=6;class Mb extends Tv{get(c){return new gC(this,c)}}vr(Mb,"FillExtrusionWallArray");const tO=ia([{name:"a_pos",components:2,type:"Int16"}],4),tde=ia([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),sO=ia([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class uo{constructor(c=[]){this.segments=c}_prepareSegment(c,m,y,k){let E=this.segments[this.segments.length-1];return c>uo.MAX_VERTEX_ARRAY_LENGTH&&dr(`Max vertices per segment is ${uo.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${c}`),(!E||E.vertexLength+c>uo.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 uo([{vertexOffset:c,primitiveOffset:m,vertexLength:y,primitiveLength:k,vaos:{},sortKey:0}])}}function xC(g,c){return 256*(g=Se(Math.floor(g),0,255))+Se(Math.floor(c),0,255)}uo.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,vr(uo,"SegmentVector");const sde=ia([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),rde=ia([{name:"a_pattern_b",components:4,type:"Uint16"}]),nde=ia([{name:"a_dash",components:4,type:"Uint16"}]);class Tb{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(c,m,y,k){this.ids.push(VT(c)),this.positions.push(m,y,k)}eachPosition(c,m){const y=VT(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 HT(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 Tb;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 VT(g){const c=+g;return Number.isSafeInteger(c)?c:uv(String(g))}function HT(g,c,m,y){for(;m>1];let E=m-1,P=y+1;for(;;){do E++;while(g[E]k);if(E>=P)break;yC(g,E,P),yC(c,3*E,3*P),yC(c,3*E+1,3*P+1),yC(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 Eb(c):new wl(c)}}class Iv{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 _C(c):new wl(c)}}class Kf{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 Di(0,{brightness:P,worldview:B}),m,{},E,k,O):this.expression.kind==="constant"&&this.expression.value,ee=Ib(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=Ib(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=WT(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 Di(this.context.zoom,{brightness:P,worldview:B}),m,{},E,k,O),J=this.expression.evaluate(new Di(this.context.zoom+1,{brightness:P,worldview:B}),m,{},E,k,O),ee=Ib(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=Ib(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=WT(y.toPremultipliedRenderColor(E)),O=WT(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 Py&&_b(P.property.specification)))continue;const O=lde(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`),ce=E==="line-dasharray"&&c.layout.get("line-cap").value.kind!=="constant"||ne&&ne.value.kind!=="constant";if(B.kind!=="constant"||ce)if(B.kind==="source"||ce||ee){const ue=GT(E,W,"source");this.binders[E]=ee?new Yf(B,O,W,ue,c.id):new Kf(B,O,W,ue),k.push(`/a_${E}`)}else{const ue=GT(E,W,"composite");this.binders[E]=new Zf(B,O,W,J,m,ue),k.push(`/z_${E}`)}else this.binders[E]=ee?new Iv(B.value,O):new Lb(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 Kf||m instanceof Zf?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 Kf||J instanceof Zf||J instanceof Yf)&&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 Iv&&k.setConstantPatternPositions(c,m)}}getPatternTransitionVertexBuffer(c){const m=this.binders[c];return m instanceof Yf?m.paintTransitionVertexBuffer:null}updatePaintArrays(c,m,y,k,E,P,O,B,W,J){let ee=!1;const ne=Object.keys(c),ce=ne.length!==0&&!B,ue=ce?ne:m.uniqueIds;this.context.lut=E.lut;for(const je in this.binders){const Le=this.binders[je];if(Le.context=this.context,(Le instanceof Kf||Le instanceof Zf||Le instanceof Yf)&&Le.expression&&Le.expression.kind&&Le.expression.kind!=="constant"&&(Le.expression.isStateDependent===!0||Le.expression.isLightConstant===!1)){const Ie=E.paint.get(je);Le.expression=Ie.value;for(const Ge of ue){const Ye=c[Ge.toString()];m.eachPosition(Ge,(nt,bt,ft)=>{const St=k.feature(nt);Le.updatePaintArray(bt,ft,St,Ye,P,O,W,J)})}if(!ce)for(const Ge of y.uniqueIds){const Ye=c[Ge.toString()];y.eachPosition(Ge,(nt,bt,ft)=>{const St=k.feature(nt);Le.updatePaintArray(bt,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 Lb||y instanceof Iv)&&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 Lb||k instanceof Iv||k instanceof Zf)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 Kf||m instanceof Zf||m instanceof Yf)&&m.paintVertexBuffer&&this._buffers.push(m.paintVertexBuffer),m instanceof Yf&&m.paintTransitionVertexBuffer&&this._buffers.push(m.paintTransitionVertexBuffer)}}upload(c){for(const m in this.binders){const y=this.binders[m];(y instanceof Kf||y instanceof Zf||y instanceof Yf)&&y.upload(c)}this.updatePaintBuffers()}destroy(){for(const c in this.binders){const m=this.binders[c];(m instanceof Kf||m instanceof Zf||m instanceof Yf)&&m.destroy()}}}class Km{constructor(c,m,y=()=>!0){this.programConfigurations={};for(const k of c)this.programConfigurations[k.id]=new xx(k,m,y);this.needsUpload=!1,this._featureMap=new Tb,this._featureMapWithoutIds=new Tb,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 ode={"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 lde(g,c){return ode[g]||[g.replace(`${c}-`,"").replace(/-/g,"_")]}const cde={"line-pattern":{source:ku,composite:ku},"fill-pattern":{source:ku,composite:ku},"fill-extrusion-pattern":{source:ku,composite:ku},"line-dasharray":{source:Ry,composite:Ry}},dde={color:{source:Lp,composite:fx},number:{source:Wf,composite:Lp}};function GT(g,c,m){const y=cde[g];return y&&y[m]||dde[c][m]}vr(Lb,"ConstantBinder"),vr(Iv,"PatternConstantBinder"),vr(Kf,"SourceExpressionBinder"),vr(Yf,"PatternCompositeBinder"),vr(Zf,"CompositeExpressionBinder"),vr(xx,"ProgramConfiguration",{omit:["_buffers"]}),vr(Km,"ProgramConfigurationSet");const fd=Ys/Math.PI/2,lm=5,jC=6,ude=16383,Lv=64,KT=[Lv,32,16],cm=-fd,dm=fd;function zy(g,c,m,y=fd){return m=Pr(m),[g*Math.sin(m)*y,-c*y,g*Math.cos(m)*y]}function Dv(g,c,m){return zy(Math.cos(Pr(g)),Math.sin(Pr(g)),c,m)}const M=63710088e-1,h=2*Math.PI*M;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(st(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 M*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 Dv(this.lat,this.lng,fd+c*fd/M)}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,F=25.5;function z(g){return h*Math.cos(g*Math.PI/180)}function H(g){return(180+g)/360}function Q(g){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+g*Math.PI/360)))/360}function re(g,c){return g/z(c)}function oe(g){return 360*g-180}function ge(g){return 360/Math.PI*Math.atan(Math.exp((180-360*g)*Math.PI/180))-90}function me(g,c){return g*z(ge(c))}const xe=85.051129;function Pe(g){return Math.cos(Pr(Se(g,-xe,xe)))}function Me(g,c){const m=Se(c,D,F),y=Math.pow(2,m);return Pe(g)*h/(512*y)}function He(g){return 1/Math.cos(g*Math.PI/180)}function Be(g,c=0){const m=Math.exp(Math.PI*(1-(g.y+c/Ys)/(1<=B?(ut(g,c,m,W,J,E,ee,O,B),ut(g,W,J,y,k,ee,P,O,B)):g.push(P)}function tt(g,c,m){let y=g[0],k=y.x,E=y.y;c(y);const P=[y];for(let O=1;Og.x+1||yg.y+1)&&dr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),g}function Et(g,c,m){const y=g.loadGeometry(),k=g.extent,E=Ys/k;if(c&&m&&m.projection.isReprojectedInTileSpace){const P=1<{const ce=oe((c.x+ne.x/k)/P),ue=ge((c.y+ne.y/k)/P),je=J.project(ce,ue);ne.x=(je.x*O-B)*k,ne.y=(je.y*O-W)*k};for(let ne=0;ne=k||ue.y<0||ue.y>=k||(ee(ue),ce.push(ue));y[ne]=ce}}for(const P of y)for(const O of P)pt(O,E);return y}function Ht(g,c){return{type:g.type,id:g.id,properties:g.properties,geometry:c?Et(g):[]}}class Vt{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 es(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 ce=W(ne);J=ne.length===1?{type:"Point",coordinates:ce[0]}:{type:"MultiPoint",coordinates:ce}}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 je=ue.length;if(je<=1)return[ue];const Le=[];let Ie,Ge;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 Vt(this._pbf,m,this.extent,this._keys,this._values)}}function Bs(g,c,m){g===15?c.version=m.readVarint():g===1?c.name=m.readString():g===5?c.extent=m.readVarint():g===2?c._features.push(m.pos):g===3?c._keys.push(m.readString()):g===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 Yt{constructor(c,m){this.layers=c.readFields(Ft,{},m)}}function Ft(g,c,m){if(g===3){const y=new fs(m,m.readVarint()+m.pos);y.length&&(c[y.name]=y)}}const ds="3d_elevation_id",Jt="level";class Es{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 Qs{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 mr=new Qs((g,c,m)=>g.reset(c).require(ds,y=>{m.id=y}).optional("fixed_height_relative",y=>{m.constantHeight=y},$s.decodeRelativeHeight).geometry(y=>{m.bounds=y},Bf).success(),(g,c,m)=>g.reset(c).require(ds,y=>{m.id=y}).require("elevation_idx",y=>{m.idx=y}).require("extent",y=>{m.extent=y}).require("height_relative",y=>{m.height=y},$s.decodeRelativeHeight).geometry(y=>{m.position=y},$s.getPoint).success()),Ks=new Qs((g,c,m)=>g.reset(c).require(ds,y=>{m.id=y}).optional("fixed_height",y=>{m.constantHeight=y},$s.decodeMetricHeight).geometry(y=>{m.bounds=y},Bf).success(),(g,c,m)=>g.reset(c).require(ds,y=>{m.id=y}).require("elevation_idx",y=>{m.idx=y}).require("extent",y=>{m.extent=y}).require("height",y=>{m.height=y},$s.decodeMetricHeight).geometry(y=>{m.position=y},$s.getPoint).success());class $s{static getPoint(c){return vt(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"?Ks:void 0:mr}static parse(c){const m=[],y=[],k=c.length,E=new Es;for(let P=0;P=0);if(E===0)return 0;E!==c.length&&(m=!1)}return m?2:1}function jn(g,c){for(const m of g.projections){const y=fr(c,g.points[0],m.axis);if(m.projection[1]y[1])return 0}return 1}function ma(g,c){let m=0;const y=[0,0,0,0];for(let P=0;P=0&&m++;var k,E;return m}class Ga{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=Er.fromPoints(this.points),this.projections=[],this.frustumEdges=[Ne([],this.points[2],this.points[3]),Ne([],this.points[0],this.points[3]),Ne([],this.points[4],this.points[0]),Ne([],this.points[5],this.points[1]),Ne([],this.points[6],this.points[2]),Ne([],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:fr(this.points,this.points[0],k)}),this.projections.push({axis:E,projection:fr(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=ct([],W,c),ee=1/J[3]/m*E;return(ne=J)[0]=(ce=J)[0]*(ue=[ee,ee,k?1/J[3]:ee,ee])[0],ne[1]=ce[1]*ue[1],ne[2]=ce[2]*ue[2],ne[3]=ce[3]*ue[3],ne;var ne,ce,ue}),O=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(W=>{const J=Ae([],ht([],Ne([],P[W[0]],P[W[1]]),Ne([],P[W[2]],P[W[1]]))),ee=-We(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(We([m[0],m[1],m[2]],c)+y<0)return!1}return!0}}class Er{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),we(y,y,k);return new Er(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(Er,"Aabb");class za{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 es(Math.trunc(c.position[0]+y*E),Math.trunc(c.position[1]+k*E)),new es(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):ae(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;Cs(ee,c.x,c.y);const ne=new Sr(ee,null);for(let ce=0;ce0?Fa(B,O)/nt:0,ft=Se(bt,0,1),St=Math.abs((bt-ft)*this.edgeProps[ce].len);Ar(W,ee,Le),Cs(J,je[1],-je[0]);const It=St+Math.abs(Fa(W,J));It=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:ce,extent:ue}=this.vertices[B],je=this.vertexProps[O].dir,Le=this.vertexProps[B].dir;if(ae(m,W[0]/c,W[1]/c,J),ae(y,ne[0]/c,ne[1]/c,ce),ae(k,je[1],-je[0],0),ke(k,k,ee),ae(E,Le[1],-Le[0],0),ke(E,E,ue),this.distSqLines(ie(m[0]+.5*k[0],m[1]+.5*k[1],m[2]+.5*k[2]),ie(y[0]-.5*E[0],y[1]-.5*E[1],y[2]-.5*E[2]),ie(m[0]-.5*k[0],m[1]-.5*k[1],m[2]-.5*k[2]),ie(y[0]+.5*E[0],y[1]+.5*E[1],y[2]+.5*E[2]))<=.0025000000000000005)continue;const Ie=this.vertices.length,Ge=or(ir(),W,ne);this.vertices.push({position:Wn(Ge,Ge,.5),height:.5*(J+ce),extent:.5*(ee+ue)});const Ye=or(ir(),je,Le);this.vertexProps.push({dir:bo(Ye,Ye)}),this.edges.splice(P,1),this.edgeProps.splice(P,1),this.edges.push({a:O,b:Ie}),this.edges.push({a:Ie,b:B});const nt=Ar(ir(),this.vertices[Ie].position,W),bt=ai(nt),ft={vec:nt,dir:Wn(ir(),nt,1/bt),len:bt};this.edgeProps.push(ft),this.edgeProps.push(ft)}}distSqLines(c,m,y,k){const E=pe(te(),m,c),P=pe(te(),k,y),O=pe(te(),c,y),B=We(E,E),W=We(E,P),J=We(E,O),ee=We(P,P),ne=We(P,O),ce=B*ee-W*W;if(ce===0)return Ce(De(E,y,k,We(O,P)/We(P,P)),c);const ue=(B*ne-W*J)/ce;return Ce(De(E,c,m,(W*ne-J*ee)/ce),De(P,y,k,ue))}}class Xa{static parseFrom(c,m){const y=$s.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(ce=>ce.id===J.id&&ce.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 fi{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)*Ys,this.yOffset=(c.y*this.zScale-m.y)*Ys)}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 oi{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 px,this.indexArray=new bl,this.segments=new uo,this.programConfigurations=new Km(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 Wf),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 ce=this.layers[0]._featureFilter.needGeometry,ue=Ht(W,ce);if(!this.layers[0]._featureFilter.filter(new Di(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ue,y))continue;const je=O?O.evaluate(ue,{},y):void 0,Le={id:J,properties:W.properties,type:W.type,sourceLayerIndex:ne,index:ee,geometry:ce?ue.geometry:Et(W,y,k),patterns:{},sortKey:je};P.push(Le)}O&&P.sort((W,J)=>W.sortKey-J.sortKey);let B=null;k.projection.name==="globe"&&(this.globeExtVertexArray=new iC,B=k.projection);for(const W of P){const{geometry:J,index:ee,sourceLayerIndex:ne}=W,ce=c[ee].feature;this.addFeature(W,J,ee,m.availableImages,y,B,m.brightness,m.elevationFeatures),m.featureIndex.insert(ce,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,tO.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,sO.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=c.createVertexBuffer(this.elevatedLayoutVertexArray,tde.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=Xa.getElevationFeature(c,B));for(const J of m)for(const ee of J){const ne=ee.x,ce=ee.y;if(ne<0||ne>=Ys||ce<0||ce>=Ys)continue;if(P){const Le=P.projectTilePoint(ne,ce,E),Ie=P.upVector(E,ne,ce);this.addGlobeExtVertex(Le,Ie),this.addGlobeExtVertex(Le,Ie),this.addGlobeExtVertex(Le,Ie),this.addGlobeExtVertex(Le,Ie)}const ue=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,c.sortKey),je=ue.vertexLength;if(this.addCircleVertex(ne,ce,-1,-1),this.addCircleVertex(ne,ce,1,-1),this.addCircleVertex(ne,ce,1,1),this.addCircleVertex(ne,ce,-1,1),this.elevationMode!=="none"){const Le=W?W.pointElevation(new es(ne,ce)):0;this.hasElevation=this.hasElevation||Le!==0;for(let Ie=0;Ie<4;Ie++)this.elevatedLayoutVertexArray.emplaceBack(Le)}this.indexArray.emplaceBack(je,je+1,je+2),this.indexArray.emplaceBack(je,je+2,je+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 Oa(g,c){for(let m=0;m1){if(Wi(g,c))return!0;for(let y=0;y1?m:m.sub(c)._mult(k)._add(c))}function ho(g,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 ji(g,c){let m=!1;for(let y=0,k=g.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 ru(g,c,m,y,k){for(const P of g)if(c<=P.x&&m<=P.y&&y>=P.x&&k>=P.y)return!0;const E=[new es(c,m),new es(c,k),new es(y,k),new es(y,m)];if(g.length>2){for(const P of E)if(ji(g,P))return!0}for(let P=0;Pk.x&&c.x>k.x||g.yk.y&&c.y>k.y)return!1;const E=Cn(g,c,m[0]);return E!==Cn(g,c,m[1])||E!==Cn(g,c,m[2])||E!==Cn(g,c,m[3])}function jl(g,c,m,y,k,E){let P=c.y-g.y,O=g.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-g.x)*P+(m.y-g.y)*O-E<0||(y.x-g.x)*P+(y.y-g.y)*O-E<0||(k.x-g.x)*P+(k.y-g.y)*O-E<0)}function gd(g,c,m,y,k,E,P){return!(jl(g,c,y,k,E,P)||jl(c,m,y,k,E,P)||jl(m,g,y,k,E,P)||jl(y,k,g,c,m,P)||jl(k,E,g,c,m,P)||jl(E,y,g,c,m,P))}function xd(g,c,m){const y=c.paint.get(g).value;return y.kind==="constant"?y.value:m.programConfigurations.get(c.id).getMaxValue(g)}function Pc(g){return Math.sqrt(g[0]*g[0]+g[1]*g[1])}function vh(g,c,m,y,k){if(!c[0]&&!c[1])return g;const E=es.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=Oo(256*E,256*(P=Math.pow(2,O)-P-1),O),W=Oo(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 go(c,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new go(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 mo(this.wrap*+m,c,this.canonical.z,this.canonical.x,this.canonical.y);{const y=this.canonical.z-c;return mo(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 go(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 go(m,this.wrap,m,y,k),new go(m,this.wrap,m,y+1,k),new go(m,this.wrap,m,y,k+1),new go(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=g.canonical.x-1,m=g.wrap;return c<0&&(c=(1<{let c=g.canonical.x+1,m=g.wrap;return c===1<new go(g.overscaledZ,g.wrap,g.canonical.z,g.canonical.x,(g.canonical.y===0?1<new go(g.overscaledZ,g.wrap,g.canonical.z,g.canonical.x,g.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)}(g.a[c],g.b[c],g.angle,Se(m,0,1))+g.center[c]}function Ym(g){if(g.z<=1)return Xf[g.z+2*g.y+g.x];const c=hde(rO(g));return Er.fromPoints(c)}function Jf(g,c,m){return ke(g,g,1-m),Ze(g,g,c,m)}function q2e(g,c,m){for(const y of g)Dt(y,y,c),ke(y,y,m)}function U2e(g,c,m,y){const k=c/g.worldSize,E=g.globeMatrix;if(m.z<=1){const qt=Ym(m).getCorners();return q2e(qt,E,k),Er.fromPoints(qt)}const P=rO(m,y),O=hde(P,fd+Op(g._tileCoverLift));q2e(O,E,k);const B=Number.MAX_VALUE,W=[-B,-B,-B],J=[B,B,B];if(P.contains(g.center)){for(const Wt of O)ye(J,J,Wt),we(W,W,Wt);W[2]=0;const qt=g.point,is=[qt.x*k,qt.y*k,0];return ye(J,J,is),we(W,W,is),new Er(J,W)}if(g._tileCoverLift>0){for(const qt of O)ye(J,J,qt),we(W,W,qt);return new Er(J,W)}const ee=[E[12]*k,E[13]*k,E[14]*k],ne=P.getCenter(),ce=Se(g.center.lat,-xe,xe),ue=Se(ne.lat,-xe,xe),je=H(g.center.lng),Le=Q(ce);let Ie=je-H(ne.lng);const Ge=Le-Q(ue);Ie>.5?Ie-=1:Ie<-.5&&(Ie+=1);let Ye=0;Math.abs(Ie)>Math.abs(Ge)?Ye=Ie>=0?1:3:(Ye=Ge>=0?0:2,Ze(ee,ee,[E[4]*k,E[5]*k,E[6]*k],-Math.sin(Pr(Ge>=0?P.getSouth():P.getNorth()))*fd));const nt=O[Ye],bt=O[(Ye+1)%4],ft=new yx(nt,bt,ee),St=[Qf(ft,0)||nt[0],Qf(ft,1)||nt[1],Qf(ft,2)||nt[2]],It=Fv(g.zoom);if(It>0){const qt=function({x:Wt,y:ms,z:_s},bs,Os,Fs,Ps){const Ls=1/(1<<_s);let hs=Wt*Ls,cs=hs+Ls,Ds=ms*Ls,Xs=Ds+Ls,qs=0;const Lr=(hs+cs)/2-Fs;return Lr>.5?qs=-1:Lr<-.5&&(qs=1),hs=((hs+qs)*bs-(Fs*=bs))*Os+Fs,cs=((cs+qs)*bs-Fs)*Os+Fs,Ds=(Ds*bs-(Ps*=bs))*Os+Ps,Xs=(Xs*bs-Ps)*Os+Ps,[[hs,Xs,0],[cs,Xs,0],[cs,Ds,0],[hs,Ds,0]]}(m,c,g._pixelsPerMercatorPixel,je,Le);for(let Wt=0;WtMath.PI/2*1.01}const K2e=Pr(85),wet=Math.cos(K2e),jet=Math.sin(K2e),ket=b(),Z2e=g=>{const c=[];return g.paint.get("circle-pitch-alignment")==="map"&&c.push("PITCH_WITH_MAP"),g.paint.get("circle-pitch-scale")==="map"&&c.push("SCALE_WITH_MAP"),c};function Y2e(g,c,m,y,k,E,P,O,B){if(E&&g.queryGeometry.isAboveHorizon)return!1;E&&(B*=g.pixelToTileUnitsFactor);const W=g.tileID.canonical,J=m.projection.upVectorScale(W,m.center.lat,m.worldSize).metersToTile;for(const ee of c)for(const ne of ee){const ce=ne.add(O),ue=k&&m.elevation?m.elevation.exaggeration()*k.getElevationAt(ce.x,ce.y,!0):0,je=m.projection.projectTilePoint(ce.x,ce.y,W);if(ue>0){const Ye=m.projection.upVector(W,ce.x,ce.y);je.x+=Ye[0]*J*ue,je.y+=Ye[1]*J*ue,je.z+=Ye[2]*J*ue}const Le=E?ce:Net(je.x,je.y,je.z,y),Ie=E?g.tilespaceRays.map(Ye=>Met(Ye,ue)):g.queryGeometry.screenGeometry,Ge=ct([],[je.x,je.y,je.z,1],y);if(!P&&E?B*=Ge[3]/m.cameraToCenterDistance:P&&!E&&(B*=m.cameraToCenterDistance/Ge[3]),E){const Ye=ge((ne.y/Ys+W.y)/(1<g.width||k.height>g.height||m.x>g.width-k.width||m.y>g.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=g.data,W=c.data,J=E===4&&O;for(let ee=0;ee{c[g.evaluationKey]=B;const W=g.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(g.clips)for(let P=0,O=0;P80*m){O=g[0],B=g[1];let J=O,ee=B;for(let ne=m;neJ&&(J=ce),ue>ee&&(ee=ue)}W=Math.max(J-O,ee-B),W=W!==0?32767/W:0}return XT(E,P,m,O,B,W,0),P}function ije(g,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=dje(P/y|0,g[P],g[P+1],E);return E&&NC(E,E.next)&&(eA(E),E=E.next),E}function Rb(g,c){if(!g)return g;c||(c=g);let m,y=g;do if(m=!1,y.steiner||!NC(y,y.next)&&_c(y.prev,y,y.next)!==0)y=y.next;else{if(eA(y),y=c=y.prev,y===y.next)break;m=!0}while(m||y!==c);return c}function XT(g,c,m,y,k,E,P){if(!g)return;!P&&E&&function(B,W,J,ee){let ne=B;do ne.z===0&&(ne.z=xde(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(ce){let ue,je=1;do{let Le,Ie=ce;ce=null;let Ge=null;for(ue=0;Ie;){ue++;let Ye=Ie,nt=0;for(let ft=0;ft0||bt>0&&Ye;)nt!==0&&(bt===0||!Ye||Ie.z<=Ye.z)?(Le=Ie,Ie=Ie.nextZ,nt--):(Le=Ye,Ye=Ye.nextZ,bt--),Ge?Ge.nextZ=Le:ce=Le,Le.prevZ=Ge,Ge=Le;Ie=Ye}Ge.nextZ=null,je*=2}while(ue>1)}(ne)}(g,y,k,E);let O=g;for(;g.prev!==g.next;){const B=g.prev,W=g.next;if(E?Let(g,y,k,E):Iet(g))c.push(B.i,g.i,W.i),eA(g),g=W.next,O=W.next;else if((g=W)===O){P?P===1?XT(g=Det(Rb(g),c),c,m,y,k,E,2):P===2&&Oet(g,c,m,y,k,E):XT(Rb(g),c,m,y,k,E,1);break}}}function Iet(g){const c=g.prev,m=g,y=g.next;if(_c(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),ce=Math.max(O,B,W);let ue=y.next;for(;ue!==c;){if(ue.x>=J&&ue.x<=ne&&ue.y>=ee&&ue.y<=ce&&QT(k,O,E,B,P,W,ue.x,ue.y)&&_c(ue.prev,ue,ue.next)>=0)return!1;ue=ue.next}return!0}function Let(g,c,m,y){const k=g.prev,E=g,P=g.next;if(_c(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,ce=Math.min(O,B,W),ue=Math.min(J,ee,ne),je=Math.max(O,B,W),Le=Math.max(J,ee,ne),Ie=xde(ce,ue,c,m,y),Ge=xde(je,Le,c,m,y);let Ye=g.prevZ,nt=g.nextZ;for(;Ye&&Ye.z>=Ie&&nt&&nt.z<=Ge;){if(Ye.x>=ce&&Ye.x<=je&&Ye.y>=ue&&Ye.y<=Le&&Ye!==k&&Ye!==P&&QT(O,J,B,ee,W,ne,Ye.x,Ye.y)&&_c(Ye.prev,Ye,Ye.next)>=0||(Ye=Ye.prevZ,nt.x>=ce&&nt.x<=je&&nt.y>=ue&&nt.y<=Le&&nt!==k&&nt!==P&&QT(O,J,B,ee,W,ne,nt.x,nt.y)&&_c(nt.prev,nt,nt.next)>=0))return!1;nt=nt.nextZ}for(;Ye&&Ye.z>=Ie;){if(Ye.x>=ce&&Ye.x<=je&&Ye.y>=ue&&Ye.y<=Le&&Ye!==k&&Ye!==P&&QT(O,J,B,ee,W,ne,Ye.x,Ye.y)&&_c(Ye.prev,Ye,Ye.next)>=0)return!1;Ye=Ye.prevZ}for(;nt&&nt.z<=Ge;){if(nt.x>=ce&&nt.x<=je&&nt.y>=ue&&nt.y<=Le&&nt!==k&&nt!==P&&QT(O,J,B,ee,W,ne,nt.x,nt.y)&&_c(nt.prev,nt,nt.next)>=0)return!1;nt=nt.nextZ}return!0}function Det(g,c){let m=g;do{const y=m.prev,k=m.next.next;!NC(y,k)&&lje(y,m,m.next,k)&&JT(y,k)&&JT(k,y)&&(c.push(y.i,m.i,k.i),eA(m),eA(m.next),m=g=k),m=m.next}while(m!==g);return Rb(m)}function Oet(g,c,m,y,k,E){let P=g;do{let O=P.next.next;for(;O!==P.prev;){if(P.i!==O.i&&$et(P,O)){let B=cje(P,O);return P=Rb(P,P.next),B=Rb(B,B.next),XT(P,c,m,y,k,E,0),void XT(B,c,m,y,k,E,0)}O=O.next}P=P.next}while(P!==g)}function Ret(g,c){let m=g.x-c.x;return m===0&&(m=g.y-c.y,m===0)&&(m=(g.next.y-g.y)/(g.next.x-g.x)-(c.next.y-c.y)/(c.next.x-c.x)),m}function Fet(g,c){const m=function(k,E){let P=E;const O=k.x,B=k.y;let W,J=-1/0;if(NC(k,P))return P;do{if(NC(k,P.next))return P.next;if(B<=P.y&&B>=P.next.y&&P.next.y!==P.y){const je=P.x+(B-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(je<=O&&je>J&&(J=je,W=P.x=P.x&&P.x>=ne&&O!==P.x&&oje(BW.x||P.x===W.x&&zet(W,P)))&&(W=P,ue=je)}P=P.next}while(P!==ee);return W}(g,c);if(!m)return c;const y=cje(m,g);return Rb(y,y.next),Rb(m,m.next)}function zet(g,c){return _c(g.prev,g,c.prev)<0&&_c(c.next,g,g.next)<0}function xde(g,c,m,y,k){return(g=1431655765&((g=858993459&((g=252645135&((g=16711935&((g=(g-m)*k|0)|g<<8))|g<<4))|g<<2))|g<<1))|(c=1431655765&((c=858993459&((c=252645135&((c=16711935&((c=(c-y)*k|0)|c<<8))|c<<4))|c<<2))|c<<1))<<1}function Bet(g){let c=g,m=g;do(c.x=(g-P)*(E-O)&&(g-P)*(y-O)>=(m-P)*(c-O)&&(m-P)*(E-O)>=(k-P)*(y-O)}function QT(g,c,m,y,k,E,P,O){return!(g===P&&c===O)&&oje(g,c,m,y,k,E,P,O)}function $et(g,c){return g.next.i!==c.i&&g.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&&lje(k,k.next,m,y))return!0;k=k.next}while(k!==m);return!1}(g,c)&&(JT(g,c)&&JT(c,g)&&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}(g,c)&&(_c(g.prev,g,c.prev)||_c(g,c.prev,c))||NC(g,c)&&_c(g.prev,g,g.next)>0&&_c(c.prev,c,c.next)>0)}function _c(g,c,m){return(c.y-g.y)*(m.x-c.x)-(c.x-g.x)*(m.y-c.y)}function NC(g,c){return g.x===c.x&&g.y===c.y}function lje(g,c,m,y){const k=oO(_c(g,c,m)),E=oO(_c(g,c,y)),P=oO(_c(m,y,g)),O=oO(_c(m,y,c));return k!==E&&P!==O||!(k!==0||!iO(g,m,c))||!(E!==0||!iO(g,y,c))||!(P!==0||!iO(m,g,y))||!(O!==0||!iO(m,c,y))}function iO(g,c,m){return c.x<=Math.max(g.x,m.x)&&c.x>=Math.min(g.x,m.x)&&c.y<=Math.max(g.y,m.y)&&c.y>=Math.min(g.y,m.y)}function oO(g){return g>0?1:g<0?-1:0}function JT(g,c){return _c(g.prev,g,g.next)<0?_c(g,c,g.next)>=0&&_c(g,g.prev,c)>=0:_c(g,c,g.prev)<0||_c(g,g.next,c)<0}function cje(g,c){const m=yde(g.i,g.x,g.y),y=yde(c.i,c.x,c.y),k=g.next,E=c.prev;return g.next=c,c.prev=g,m.next=k,k.prev=m,y.next=m,m.prev=y,E.next=y,y.prev=E,y}function dje(g,c,m,y){const k=yde(g,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 eA(g){g.next.prev=g.prev,g.prev.next=g.next,g.prevZ&&(g.prevZ.nextZ=g.nextZ),g.nextZ&&(g.nextZ.prevZ=g.prevZ)}function yde(g,c,m){return{i:g,x:c,y:m,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function tA(g,c){const m=g.length;if(m<=1)return[g];const y=[];let k,E;for(let P=0;P1)for(let P=0;P=Ys&&m>=Ys}static evaluate(c){if(c.length===0)return new By;let m=[];for(const B of c)m.push(...B.portals);if(m.length===0)return new By;for(const B of m){const W=B.va,J=B.vb;(By.isOnBorder(W.x,J.x)||By.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 By;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 Km(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||ed(ee,ne,O))||this.isOnBorder(ee.x,ne.x)||this.isOnBorder(ee.y,ne.y))continue;const ce=_h.computeEdgeHash(this.unevalVertices[W],this.unevalVertices[J]);let ue,je=this.vertexHashLookup.get(_h.computePosHash(ee));je!=null?ue=je.next:(je=this.vertexHashLookup.get(_h.computePosHash(ne)),ue=je!=null?je.prev:ce),this.unevalEdges.push({polygonIdx:c,a:W,b:J,hash:ce,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=_h.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 Uet(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(c.portals,this.unevalEdges);const E=m(),P=m(),O=m(),B=(ne,ce)=>{ne.sort((je,Le)=>je.type===ce&&Le.type!==ce?-1:je.type!==ce&&Le.type===ce?1:0);const ue=ne.findIndex(je=>je.type!==ce);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),ce=B(ne,"tunnel")+W;this.unevalEdges.push(...ne),this.constructTunnelStructures(k,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:W},{min:W,max:ce})}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=uo.simpleSegment(0,ee.primitiveOffset,0,ee.primitiveLength),this.depthSegments=uo.simpleSegment(0,P.primitiveOffset,0,P.primitiveLength),this.renderableBridgeSegments=uo.simpleSegment(0,O.primitiveOffset,0,O.primitiveLength),this.renderableTunnelSegments=uo.simpleSegment(0,J.primitiveOffset,0,J.primitiveLength),this.shadowCasterSegments=uo.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,Eet.members),this.vertexBufferNormal=c.createVertexBuffer(this.vertexNormals,Pet.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;Wae(Os,m[Fs].x,m[Fs].y,y[Fs]*B),ee=te(),ne=te(),ce=te(),ue=te(),je=te(),Le=(Os,Fs)=>{const Ps=O.get(_h.computePosHash(m[Fs])),Ls=Ps.from,hs=Ps.to;if(!Ls||!hs)return;J(ee,Ls),J(ne,Fs),J(ce,hs),ot(ue),rt(ee,ne)||(Ne(je,ne,ee),Ae(ue,je)),rt(ce,ne)||(Ne(je,ce,ne),le(ue,ue,Ae(je,je)));const cs=qe(ue);return cs>0?ke(Os,ue,1/cs):void 0};let Ie=Number.POSITIVE_INFINITY;this.sortSubarray(k,E.min,E.max,(Os,Fs)=>Os.featureInfo.featureIndex-Fs.featureInfo.featureIndex);const Ge=te(),Ye=te(),nt=te(),bt=te(),ft=te(),St=te(),It=te(),qt=te(),is=te(),Wt=[te(),te(),te(),te()],ms=[te(),te(),te(),te()],_s=[{coord:new es(0,0),height:0},{coord:new es(0,0),height:0}],bs=(Os,Fs)=>Os>Fs;for(let Os=E.min;OsIe.featureInfo.featureIndex-Ge.featureInfo.featureIndex;this.sortSubarray(k,E.min,E.max,B),this.sortSubarray(k,P.min,P.max,B);const W=Ie=>Ae(Ie,Ie),J=[{coord:new es(0,0),height:0},{coord:new es(0,0),height:0}],ee=(Ie,Ge)=>IeO.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>=Ys&&m>=Ys}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(_h.computePosHash(c))<<32n|BigInt(_h.computePosHash(m))}static computePosHash(c){return((65535&c.x)<<16|65535&c.y)>>>0}}var mje,pje={exports:{}},fje=(mje||(mje=1,function(g){function c(gt,wt){return gt>wt?1:gt0){var Or=Rs+Math.floor(ar/2),zr={key:wt[Or],data:ps[Or],parent:gt};return zr.left=k(zr,wt,ps,Rs,Or),zr.right=k(zr,wt,ps,Or+1,nr),zr}return null}function E(gt,wt,ps,Rs,nr){if(!(ps>=Rs)){for(var ar=gt[ps+Rs>>1],Or=ps-1,zr=Rs+1;;){do Or++;while(nr(gt[Or],ar)<0);do zr--;while(nr(gt[zr],ar)>0);if(Or>=zr)break;var Sn=gt[Or];gt[Or]=gt[zr],gt[zr]=Sn,Sn=wt[Or],wt[Or]=wt[zr],wt[zr]=Sn}E(gt,wt,ps,zr,nr),E(gt,wt,zr+1,Rs,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,ps,Rs,nr,ar;gt.parent;)(ps=(wt=gt.parent).parent)&&ps.parent?((Rs=ps.parent).left===ps?Rs.left=gt:Rs.right=gt,gt.parent=Rs):(gt.parent=null,this._root=gt),nr=gt.left,ar=gt.right,gt===wt.left?(ps&&(ps.left===wt?(wt.right?(ps.left=wt.right,ps.left.parent=ps):ps.left=null,wt.right=ps,ps.parent=wt):(nr?(ps.right=nr,nr.parent=ps):ps.right=null,gt.left=ps,ps.parent=gt)),ar?(wt.left=ar,ar.parent=wt):wt.left=null,gt.right=wt,wt.parent=gt):(ps&&(ps.right===wt?(wt.left?(ps.right=wt.left,ps.right.parent=ps):ps.right=null,wt.left=ps,ps.parent=wt):(ar?(ps.left=ar,ar.parent=ps):ps.left=null,gt.right=ps,ps.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 ps=this._root,Rs=null,nr=this._compare;if(this._noDuplicates)for(;ps;){if(Rs=ps,nr(ps.key,gt)===0)return;ps=nr(ps.key,gt)<0?ps.right:ps.left}else for(;ps;)Rs=ps,ps=nr(ps.key,gt)<0?ps.right:ps.left;return ps={key:gt,data:wt,left:null,right:null,parent:Rs},Rs?nr(Rs.key,ps.key)<0?Rs.right=ps:Rs.left=ps:this._root=ps,this.splay(ps),this._size++,ps},m.prototype.find=function(gt){for(var wt=this._root,ps=this._compare;wt;){var Rs=ps(wt.key,gt);if(Rs<0)wt=wt.right;else{if(!(Rs>0))return wt;wt=wt.left}}return null},m.prototype.contains=function(gt){for(var wt=this._root,ps=this._compare;wt;){var Rs=ps(gt,wt.key);if(Rs===0)return!0;wt=Rs<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 ps=this.minNode(wt.right);ps.parent!==wt&&(this.replace(ps,ps.right),ps.right=wt.right,ps.right.parent=ps),this.replace(wt,ps),ps.left=wt.left,ps.left.parent=ps}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 ps=wt.left,Rs=wt.right,nr=null;ps&&(ps.parent=null,nr=this.maxNode(ps),this.splay(nr),this._root=nr),Rs&&(ps?nr.right=Rs:this._root=Rs,Rs.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,ps=[],Rs=!1,nr=0;!Rs;)wt?(ps.push(wt),wt=wt.left):ps.length>0?(gt(wt=ps.pop(),nr++),wt=wt.right):Rs=!0;return this},m.prototype.range=function(gt,wt,ps,Rs){for(var nr=[],ar=this._compare,Or=this._root;nr.length!==0||Or;)if(Or)nr.push(Or),Or=Or.left;else{if(ar((Or=nr.pop()).key,wt)>0)break;if(ar(Or.key,gt)>=0&&ps.call(Rs,Or))return this;Or=Or.right}return this},m.prototype.keys=function(){for(var gt=this._root,wt=[],ps=[],Rs=!1;!Rs;)gt?(wt.push(gt),gt=gt.left):wt.length>0?(gt=wt.pop(),ps.push(gt.key),gt=gt.right):Rs=!0;return ps},m.prototype.values=function(){for(var gt=this._root,wt=[],ps=[],Rs=!1;!Rs;)gt?(wt.push(gt),gt=gt.left):wt.length>0?(gt=wt.pop(),ps.push(gt.data),gt=gt.right):Rs=!0;return ps},m.prototype.at=function(gt){for(var wt=this._root,ps=[],Rs=!1,nr=0;!Rs;)if(wt)ps.push(wt),wt=wt.left;else if(ps.length>0){if(wt=ps.pop(),nr===gt)return wt;nr++,wt=wt.right}else Rs=!0;return null},m.prototype.load=function(gt,wt,ps){if(gt===void 0&&(gt=[]),wt===void 0&&(wt=[]),ps===void 0&&(ps=!1),this._size!==0)throw new Error("bulk-load: tree is not empty");var Rs=gt.length;return ps&&E(gt,wt,0,Rs-1,this._compare),this._root=k(null,gt,wt,0,Rs),this._size=Rs,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,ps,Rs,nr){return new m(ps,nr).load(gt,wt,Rs)},Object.defineProperties(m.prototype,y);var P=0,O=1,B=2,W=3,J=0,ee=1,ne=2,ce=3;function ue(gt,wt,ps){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=!je(wt,ps)||wt.isVertical()?wt.prevInResult:wt));var Rs=je(gt,ps);gt.resultTransition=Rs?function(nr,ar){var Or,zr=!nr.inOut,Sn=!nr.otherInOut;switch(ar){case J:Or=zr&&Sn;break;case ee:Or=zr||Sn;break;case ce:Or=zr^Sn;break;case ne:Or=nr.isSubject?zr&&!Sn:Sn&&!zr}return Or?1:-1}(gt,ps):0}function je(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 ce:return!0}break;case B:return wt===J||wt===ee;case W:return wt===ne;case O:return!1}return!1}var Le=function(gt,wt,ps,Rs,nr){this.left=wt,this.point=gt,this.otherEvent=ps,this.isSubject=Rs,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},Ie={inResult:{configurable:!0}};function Ge(gt,wt){return gt[0]===wt[0]&>[1]===wt[1]}Le.prototype.isBelow=function(gt){var wt=this.point,ps=this.otherEvent.point;return this.left?(wt[0]-gt[0])*(ps[1]-gt[1])-(ps[0]-gt[0])*(wt[1]-gt[1])>0:(ps[0]-gt[0])*(wt[1]-gt[1])-(wt[0]-gt[0])*(ps[1]-gt[1])>0},Le.prototype.isAbove=function(gt){return!this.isBelow(gt)},Le.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},Ie.inResult.get=function(){return this.resultTransition!==0},Le.prototype.clone=function(){var gt=new Le(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(Le.prototype,Ie);var Ye=11102230246251565e-32,nt=134217729,bt=(3+8*Ye)*Ye;function ft(gt,wt,ps,Rs,nr){var ar,Or,zr,Sn,zn=wt[0],Vn=Rs[0],oa=0,Jr=0;Vn>zn==Vn>-zn?(ar=zn,zn=wt[++oa]):(ar=Vn,Vn=Rs[++Jr]);var un=0;if(oazn==Vn>-zn?(zr=ar-((Or=zn+ar)-zn),zn=wt[++oa]):(zr=ar-((Or=Vn+ar)-Vn),Vn=Rs[++Jr]),ar=Or,zr!==0&&(nr[un++]=zr);oazn==Vn>-zn?(zr=ar-((Or=ar+zn)-(Sn=Or-ar))+(zn-Sn),zn=wt[++oa]):(zr=ar-((Or=ar+Vn)-(Sn=Or-ar))+(Vn-Sn),Vn=Rs[++Jr]),ar=Or,zr!==0&&(nr[un++]=zr);for(;oa0!=oa>0)return Jr;var un=Math.abs(Vn+oa);return Math.abs(Jr)>=It*un?Jr:-function(La,Ba,$a,li,Ni,_i,Ka){var Ja,Bn,ga,ro,Yr,la,wi,Pi,Oi,Ro,Ii,Xr,po,ci,Gi,kl,lc,il,ol=La-Ni,Gl=$a-Ni,Cu=Ba-_i,Li=li-_i;Wt[0]=(Gi=(Pi=ol-(wi=(la=nt*ol)-(la-ol)))*(Ro=Li-(Oi=(la=nt*Li)-(la-Li)))-((ci=ol*Li)-wi*Oi-Pi*Oi-wi*Ro))-((Ii=Gi-(lc=(Pi=Cu-(wi=(la=nt*Cu)-(la-Cu)))*(Ro=Gl-(Oi=(la=nt*Gl)-(la-Gl)))-((kl=Cu*Gl)-wi*Oi-Pi*Oi-wi*Ro)))+(Yr=Gi-Ii))+(Yr-lc),Wt[1]=(po=ci-((Xr=ci+Ii)-(Yr=Xr-ci))+(Ii-Yr))-((Ii=po-kl)+(Yr=po-Ii))+(Yr-kl),Wt[2]=Xr-((il=Xr+Ii)-(Yr=il-Xr))+(Ii-Yr),Wt[3]=il;var Eo=function(bx,td){for(var nu=td[0],wh=1;wh<4;wh++)nu+=td[wh];return nu}(0,Wt),Fo=qt*Ka;if(Eo>=Fo||-Eo>=Fo||(Ja=La-(ol+(Yr=La-ol))+(Yr-Ni),ga=$a-(Gl+(Yr=$a-Gl))+(Yr-Ni),Bn=Ba-(Cu+(Yr=Ba-Cu))+(Yr-_i),ro=li-(Li+(Yr=li-Li))+(Yr-_i),Ja===0&&Bn===0&&ga===0&&ro===0)||(Fo=is*Ka+bt*Math.abs(Eo),(Eo+=ol*ro+Li*Ja-(Cu*ga+Gl*Bn))>=Fo||-Eo>=Fo))return Eo;Os[0]=(Gi=(Pi=Ja-(wi=(la=nt*Ja)-(la-Ja)))*(Ro=Li-(Oi=(la=nt*Li)-(la-Li)))-((ci=Ja*Li)-wi*Oi-Pi*Oi-wi*Ro))-((Ii=Gi-(lc=(Pi=Bn-(wi=(la=nt*Bn)-(la-Bn)))*(Ro=Gl-(Oi=(la=nt*Gl)-(la-Gl)))-((kl=Bn*Gl)-wi*Oi-Pi*Oi-wi*Ro)))+(Yr=Gi-Ii))+(Yr-lc),Os[1]=(po=ci-((Xr=ci+Ii)-(Yr=Xr-ci))+(Ii-Yr))-((Ii=po-kl)+(Yr=po-Ii))+(Yr-kl),Os[2]=Xr-((il=Xr+Ii)-(Yr=il-Xr))+(Ii-Yr),Os[3]=il;var Hu=ft(4,Wt,4,Os,ms);Os[0]=(Gi=(Pi=ol-(wi=(la=nt*ol)-(la-ol)))*(Ro=ro-(Oi=(la=nt*ro)-(la-ro)))-((ci=ol*ro)-wi*Oi-Pi*Oi-wi*Ro))-((Ii=Gi-(lc=(Pi=Cu-(wi=(la=nt*Cu)-(la-Cu)))*(Ro=ga-(Oi=(la=nt*ga)-(la-ga)))-((kl=Cu*ga)-wi*Oi-Pi*Oi-wi*Ro)))+(Yr=Gi-Ii))+(Yr-lc),Os[1]=(po=ci-((Xr=ci+Ii)-(Yr=Xr-ci))+(Ii-Yr))-((Ii=po-kl)+(Yr=po-Ii))+(Yr-kl),Os[2]=Xr-((il=Xr+Ii)-(Yr=il-Xr))+(Ii-Yr),Os[3]=il;var Nl=ft(Hu,ms,4,Os,_s);Os[0]=(Gi=(Pi=Ja-(wi=(la=nt*Ja)-(la-Ja)))*(Ro=ro-(Oi=(la=nt*ro)-(la-ro)))-((ci=Ja*ro)-wi*Oi-Pi*Oi-wi*Ro))-((Ii=Gi-(lc=(Pi=Bn-(wi=(la=nt*Bn)-(la-Bn)))*(Ro=ga-(Oi=(la=nt*ga)-(la-ga)))-((kl=Bn*ga)-wi*Oi-Pi*Oi-wi*Ro)))+(Yr=Gi-Ii))+(Yr-lc),Os[1]=(po=ci-((Xr=ci+Ii)-(Yr=Xr-ci))+(Ii-Yr))-((Ii=po-kl)+(Yr=po-Ii))+(Yr-kl),Os[2]=Xr-((il=Xr+Ii)-(Yr=il-Xr))+(Ii-Yr),Os[3]=il;var Fp=ft(Nl,_s,4,Os,bs);return bs[Fp-1]}(nr,ar,Or,zr,Sn,zn,un)}(gt[0],gt[1],wt[0],wt[1],ps[0],ps[1]);return Rs>0?-1:Rs<0?1:0}function Ps(gt,wt){var ps=gt.point,Rs=wt.point;return ps[0]>Rs[0]?1:ps[0]Rs[1]?1:-1:function(nr,ar,Or,zr){return nr.left!==ar.left?nr.left?1:-1:Fs(Or,nr.otherEvent.point,ar.otherEvent.point)!==0?nr.isBelow(ar.otherEvent.point)?-1:1:!nr.isSubject&&ar.isSubject?1:-1}(gt,wt,ps)}function Ls(gt,wt,ps){var Rs=new Le(wt,!1,gt,gt.isSubject),nr=new Le(wt,!0,gt.otherEvent,gt.isSubject);return Ge(gt.point,gt.otherEvent.point)&&console.warn("what is that, a collapsed segment?",gt),Rs.contourId=nr.contourId=gt.contourId,Ps(nr,gt.otherEvent)>0&&(gt.otherEvent.left=!0,nr.left=!1),gt.otherEvent.otherEvent=nr,gt.otherEvent=Rs,ps.push(nr),ps.push(Rs),ps}function hs(gt,wt){return gt[0]*wt[1]-gt[1]*wt[0]}function cs(gt,wt){return gt[0]*wt[0]+gt[1]*wt[1]}function Ds(gt,wt,ps){var Rs=function(Sn,zn,Vn,oa,Jr){var un=[zn[0]-Sn[0],zn[1]-Sn[1]],La=[oa[0]-Vn[0],oa[1]-Vn[1]];function Ba(la,wi,Pi){return[la[0]+wi*Pi[0],la[1]+wi*Pi[1]]}var $a=[Vn[0]-Sn[0],Vn[1]-Sn[1]],li=hs(un,La),Ni=li*li,_i=cs(un,un);if(Ni>0){var Ka=hs($a,La)/li;if(Ka<0||Ka>1)return null;var Ja=hs($a,un)/li;return Ja<0||Ja>1?null:Ka===0||Ka===1?[Ba(Sn,Ka,un)]:Ja===0||Ja===1?[Ba(Vn,Ja,La)]:[Ba(Sn,Ka,un)]}if((Ni=(li=hs($a,un))*li)>0)return null;var Bn=cs(un,$a)/_i,ga=Bn+cs(un,La)/_i,ro=Math.min(Bn,ga),Yr=Math.max(Bn,ga);return ro<=1&&Yr>=0?ro===1?[Ba(Sn,ro>0?ro:0,un)]:Yr===0?[Ba(Sn,Yr<1?Yr:1,un)]:[Ba(Sn,ro>0?ro:0,un),Ba(Sn,Yr<1?Yr:1,un)]:null}(gt.point,gt.otherEvent.point,wt.point,wt.otherEvent.point),nr=Rs?Rs.length:0;if(nr===0||nr===1&&(Ge(gt.point,wt.point)||Ge(gt.otherEvent.point,wt.otherEvent.point))||nr===2&>.isSubject===wt.isSubject)return 0;if(nr===1)return Ge(gt.point,Rs[0])||Ge(gt.otherEvent.point,Rs[0])||Ls(gt,Rs[0],ps),Ge(wt.point,Rs[0])||Ge(wt.otherEvent.point,Rs[0])||Ls(wt,Rs[0],ps),1;var ar=[],Or=!1,zr=!1;return Ge(gt.point,wt.point)?Or=!0:Ps(gt,wt)===1?ar.push(wt,gt):ar.push(gt,wt),Ge(gt.otherEvent.point,wt.otherEvent.point)?zr=!0:Ps(gt.otherEvent,wt.otherEvent)===1?ar.push(wt.otherEvent,gt.otherEvent):ar.push(gt.otherEvent,wt.otherEvent),Or&&zr||Or?(wt.type=O,gt.type=wt.inOut===gt.inOut?B:W,Or&&!zr&&Ls(ar[1].otherEvent,ar[0].point,ps),2):zr?(Ls(ar[0],ar[1].point,ps),3):ar[0]!==ar[3].otherEvent?(Ls(ar[0],ar[1].point,ps),Ls(ar[1],ar[2].point,ps),3):(Ls(ar[0],ar[1].point,ps),Ls(ar[3].otherEvent,ar[2].point,ps),3)}function Xs(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 Ge(gt.point,wt.point)?gt.isBelow(wt.otherEvent.point)?-1:1:gt.point[0]===wt.point[0]?gt.point[1]wt.contourId?1:-1:Ps(gt,wt)===1?1:-1}var qs=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function Lr(gt,wt,ps,Rs){var nr,ar=gt+1,Or=wt[gt].point,zr=wt.length;for(arRs;)ar--;return ar}qs.prototype.isExterior=function(){return this.holeOf==null};var cr=kr,gr=kr;function kr(gt,wt){if(!(this instanceof kr))return new kr(gt,wt);if(this.data=gt||[],this.length=this.data.length,this.compare=wt||Hn,this.length>0)for(var ps=(this.length>>1)-1;ps>=0;ps--)this._down(ps)}function Hn(gt,wt){return gtwt?1:0}kr.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,ps=this.compare,Rs=wt[gt];gt>0;){var nr=gt-1>>1,ar=wt[nr];if(ps(Rs,ar)>=0)break;wt[gt]=ar,gt=nr}wt[gt]=Rs},_down:function(gt){for(var wt=this.data,ps=this.compare,Rs=this.length>>1,nr=wt[gt];gt=0)break;wt[gt]=zr,gt=ar}wt[gt]=nr}},cr.default=gr;var Us=Math.max,Nr=Math.min,mn=0;function pa(gt,wt,ps,Rs,nr,ar){var Or,zr,Sn,zn,Vn,oa;for(Or=0,zr=gt.length-1;Or0?oa.left=!0:Vn.left=!0;var Jr=Sn[0],un=Sn[1];nr[0]=Nr(nr[0],Jr),nr[1]=Nr(nr[1],un),nr[2]=Us(nr[2],Jr),nr[3]=Us(nr[3],un),Rs.push(Vn),Rs.push(oa)}}var xa=[];function Ln(gt,wt,ps){typeof gt[0][0][0]=="number"&&(gt=[gt]),typeof wt[0][0][0]=="number"&&(wt=[wt]);var Rs=function(un,La,Ba){var $a=null;return un.length*La.length==0&&(Ba===J?$a=xa:Ba===ne?$a=un:Ba!==ee&&Ba!==ce||($a=un.length===0?La:un)),$a}(gt,wt,ps);if(Rs)return Rs===xa?null:Rs;var nr=[1/0,1/0,-1/0,-1/0],ar=[1/0,1/0,-1/0,-1/0],Or=function(un,La,Ba,$a,li){var Ni,_i,Ka,Ja,Bn,ga,ro=new cr(null,Ps);for(Ka=0,Ja=un.length;Ka$a[2]||$a[0]>Ba[2]||Ba[1]>$a[3]||$a[1]>Ba[3])&&(li===J?Ni=xa:li===ne?Ni=un:li!==ee&&li!==ce||(Ni=un.concat(La))),Ni}(gt,wt,nr,ar,ps))return Rs===xa?null:Rs;for(var zr=function(un){var La,Ba,$a=function(Ka){var Ja,Bn,ga,ro,Yr=[];for(Bn=0,ga=Ka.length;Bn0){var Ii=la[Ro];if(Ii.holeOf!=null){var Xr=Ii.holeOf;la[Xr].holeIds.push(wi),Pi.holeOf=Xr,Pi.depth=la[Ro].depth}else la[Ro].holeIds.push(wi),Pi.holeOf=Ro,Pi.depth=la[Ro].depth+1}else Pi.holeOf=null,Pi.depth=la[Ro].depth}else Pi.holeOf=null,Pi.depth=0;return Pi}($a[La],Ni,Ka),Bn=function(Yr){li[Yr]=!0,Yr<$a.length&&$a[Yr]&&($a[Yr].outputContourId=Ka)},ga=La,ro=La;for(Ja.points.push($a[La].point);Bn(ga),Bn(ga=$a[ga].otherPos),Ja.points.push($a[ga].point),!((ga=Lr(ga,$a,li,ro))==ro||ga>=$a.length)&&$a[ga];);Ni.push(Ja)}};for(La=0,Ba=$a.length;Laro||Ni===ne&&Yr.point[0]>$a[2])break;if(Yr.left){Ka=_i=Bn.insert(Yr),_i=_i!==(Ja=Bn.minNode())?Bn.prev(_i):null,Ka=Bn.next(Ka);var la=_i?_i.key:null;if(ue(Yr,la,Ni),Ka&&Ds(Yr,Ka.key,un)===2&&(ue(Yr,la,Ni),ue(Ka.key,Yr,Ni)),_i&&Ds(_i.key,Yr,un)===2){var wi=_i;ue(la,(wi=wi!==Ja?Bn.prev(wi):null)?wi.key:null,Ni),ue(Yr,la,Ni)}}else Ka=_i=Bn.find(Yr=Yr.otherEvent),_i&&Ka&&(_i=_i!==Ja?Bn.prev(_i):null,Ka=Bn.next(Ka),Bn.remove(Yr),Ka&&_i&&Ds(_i.key,Ka.key,un))}return ga}(Or,0,0,nr,ar,ps)),Sn=[],zn=0;zn * @license MIT * @preserve */function lO(g,c,m,y){const k=[],E=y===0?(P,O,B,W,J,ee)=>{P.push(new es(ee,B+(ee-O)/(W-O)*(J-B)))}:(P,O,B,W,J,ee)=>{P.push(new es(O+(ee-B)/(J-B)*(W-O),ee))};for(const P of g){const O=[];for(const B of P){if(B.length<=2)continue;const W=[];for(let ne=0;nec&&E(W,ce,ue,je,Le,c):Ie>m?Ge=c&&E(W,ce,ue,je,Le,c),Ge>m&&Ie<=m&&E(W,ce,ue,je,Le,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 Vet(g,c){const m=bde(g),y=bde([c]),k=fje.intersection(m,y);return k==null?[]:gje(k)}function Het(g,c){let y=bde(g,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,ce=Math.hypot(ee,ne);if(ce===0)continue;const ue=Math.trunc(ne/ce*3),je=-Math.trunc(ee/ce*3);k.push([[[O,B],[W,J],[W+ue,J+je],[O+ue,B+je],[O,B]]])}return k.length>0&&(y=fje.diff(y,k)),gje(y,1/65536)}function bde(g,c=1){return[g.map(m=>m.map(y=>[y.x*c,y.y*c]))]}function gje(g,c=1){return g.map(m=>m.map((y,k)=>{const E=y.map(P=>new es(P[0]*c,P[1]*c).round());return k>0&&E.reverse(),E}))}class wde{constructor(c,m){this.layoutVertexArray=new px,this.indexArray=new bl,this.lineIndexArray=new yh,this.triangleSegments=new uo,this.lineSegments=new uo,this.programConfigurations=new Km(c.layers,{zoom:c.zoom,lut:c.lut}),this.uploaded=!1,m&&(this.elevatedLayoutVertexArray=new Wf)}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,Tet.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,Aet.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 jde{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 wde(c,!1),this.elevationBufferData=new wde(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=vde("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 Di(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ne,y))continue;const ce=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:ce};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=_de("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=tA(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=Xa.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 _h(W.elevationTileID,this.layers,this.zoom,this.lut));const ee=W.elevationFeature.isTunnel();let ne=0;c.properties.hasOwnProperty(Jt)&&(ne=+c.properties[Jt]);for(const ce of W.polygons)this.elevatedStructures.addPortalCandidates(W.elevationFeature.id,ce,ee,W.elevationFeature,ne)}W.elevationFeature.constantHeight==null&&(W.polygons=this.prepareElevatedPolygons(W.polygons,W.elevationFeature,W.elevationTileID));const J=new fi(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=[],ce=[],ue=[],je=[],Le=[],Ie=m.layoutVertexArray.length;for(const Ye of B){if(Ye.length===0)continue;Ye!==B[0]&&ce.push(ne.length/2);const nt=m.lineSegments.prepareSegment(Ye.length,m.layoutVertexArray,m.lineIndexArray),bt=nt.vertexLength;y&&Le.push(m.layoutVertexArray.length-Ie),O(Ye[0],ue,je),m.layoutVertexArray.emplaceBack(Ye[0].x,Ye[0].y),m.lineIndexArray.emplaceBack(bt+Ye.length-1,bt),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(),nt=y.elevation.safeArea,bt=this.elevatedStructures.addVertices(ue,je);this.elevatedStructures.addTriangles(Ge,bt,Ye);const ft=Le.length;if(ft>0){for(let St=0;St=y&&ce.max.x<=E&&ce.min.y>=k&&ce.max.y<=P?B:W).push(ne)}if(B.length===c.length)return c;const J=[new es(y,k),new es(E,k),new es(E,P),new es(y,P),new es(y,k)],ee=B;for(const ne of W)ee.push(...Vet(ne,J));return ee}}let xje,yje,vje,_je;vr(jde,"FillBucket",{omit:["layers","patternFeatures"]}),vr(wde,"FillBufferData"),vr(_h,"ElevatedStructures");class cO{constructor(c,m,y,k){if(this.triangleCount=m.length/3,this.min=new es(0,0),this.max=new es(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=vx(c.x-this.min.x,this.xScale,this.cellsX),k=vx(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=vx(c.x-this.min.x,this.xScale,this.cellsX),E=vx(m.x-this.min.x,this.xScale,this.cellsX),P=vx(c.y-this.min.y,this.yScale,this.cellsY),O=vx(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 Di(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 tA(m,2)){const W=[],J=[],ee=[],ne=new es(1/0,1/0),ce=new es(-1/0,-1/0);for(const Le of B)if(Le.length!==0){Le!==B[0]&&ee.push(J.length/2);for(let Ie=0;IeP===k)===void 0}(y,g.clipScope)}function dO(g,c){return g.x-c.x||g.y-c.y}function kje(g,c){return dO(g.min,c.min)===0&&dO(g.max,c.max)===0}function kde(g,c){return!(g.min.x>c.max.x||g.max.xc.max.y||g.max.ynew es((B.x+E.x*Ys)*O-P.x*Ys,(B.y+E.y*Ys)*O-P.y*Ys))}return Nde(m,k,g.indices,0,g.indices.length,0,0)}function Cje(g,c,m,y){const k=Math.pow(2,y.z-m.z);return new es((g+m.x*Ys)*k-y.x*Ys,(c+m.y*Ys)*k-y.y*Ys)}function Mje(g,c){const m=[];c.grid.queryPoint(g,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 Cde=Vt.types,ttt=["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"],stt=["fill-extrusion-flood-light-ground-radius"],rtt=Math.pow(2,13),ntt=Math.pow(2,15)-1,Aje=new es(0,1),$y=2147483648,Eje=7,Pje=450;function rA(g,c,m,y,k,E,P,O){g.emplaceBack((c<<1)+P,(m<<1)+E,(Math.floor(y*rtt)<<1)+k,Math.round(O))}function nA(g,c,m){g.emplaceBack(c.x*Ys,c.y*Ys,m?1:0)}function hO(g,c,m,y,k,E){g.emplaceBack(c.x,c.y,(m.x<<1)+y,(m.y<<1)+k,E)}function aA(g,c,m){g.emplaceBack(c.x,c.y,c.z,m[0]*16384,m[1]*16384,m[2]*16384)}class Ije{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class Lje{constructor(){this.centroidXY=new es(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 es(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new es(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new es(this.max.x-this.min.x,this.max.y-this.min.y)}}class Dje{constructor(){this.acc=new es(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===Ys)&&m.x===y.x)!=((m.y===0||m.y===Ys)&&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,Hr(m.y,c.y,(0-m.x)/(c.x-m.x))),m.x>Ys!=c.x>Ys&&this.addBorderIntersection(1,Hr(m.y,c.y,(Ys-m.x)/(c.x-m.x))),m.y<0!=c.y<0&&this.addBorderIntersection(2,Hr(m.x,c.x,(0-m.y)/(c.y-m.y))),m.y>Ys!=c.y>Ys&&this.addBorderIntersection(3,Hr(m.x,c.x,(Ys-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 es(0,0):new es(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 Oje(g,c){const m=g.add(c)._unit(),y=Se(g.x*m.x+g.y*m.y,-1,1);var k,E,P;return k=Math.acos(y),Math.min(4,Math.max(-4,Math.tan(k)))/4*ntt*((E=g).x*(P=c).y-E.y*P.x<0?-1:1)}const att=[g=>g.x<0,g=>g.x>Ys,g=>g.y<0,g=>g.y>Ys];function itt(g,c,m,y){const k=[4];if(y===0)return k;m._mult(y);const E=g.sub(m),P=c.sub(m),O=[g,c,E,P];for(let B=0;B<4;B++)for(const W of O)if(att[B](W)){k.push(B);break}return k}class Mde{constructor(c){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new ET,this.indexArray=new bl,this.programConfigurations=new Km(c.layers,{zoom:c.zoom,lut:c.lut},m=>stt.includes(m)),this._segments=new uo,this.hiddenByLandmarkVertexArray=new hC,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new uo}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=Oje(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 uo);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,Xet.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 mO{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 bl,this.footprintVertices=new px,this.footprintSegments=[],this.layoutVertexArray=new Av,this.centroidVertexArray=new eO,this.wallVertexArray=new Mb,this.indexArray=new bl,this.programConfigurations=new Km(c.layers,{zoom:c.zoom,lut:c.lut},m=>ttt.includes(m)),this.segments=new uo,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.groundEffect=new Mde(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=vde("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 Di(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,ce=Cde[ee.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:E.id,feature:_de("fill-extrusion",this.layers,ee,this.zoom,this.pixelRatio,m)});else if(this.wallMode)for(const ue of ee.geometry)for(const je of Tje(ue,ce))this.addFeature(E.id,ee,[je],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=Cde[B.type]==="Polygon",{geometry:J}=B;if(this.wallMode)for(const ee of J)for(const ne of Tje(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,Jet),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.wallVertexBuffer=c.createVertexBuffer(this.wallVertexArray,Yet.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=c.createVertexBuffer(this.layoutVertexExtArray,Qet.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,Zet.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 es(0,0),new es(Ys,Ys)],ne=B.projection,ce=ne.name==="globe",ue=this.wallMode||Cde[m.type]==="Polygon",je=new Dje;je.centroidDataIndex=this.centroidData.length;const Le=new Lje;Le.buildingId=c,m.properties&&m.properties.hasOwnProperty("building_id")&&(Le.buildingId=m.properties.building_id);const Ie=this.layers[0].paint.get("fill-extrusion-base").evaluate(m,{},E)<=0,Ge=this.layers[0].paint.get("fill-extrusion-height").evaluate(m,{},E);let Ye;if(Le.height=Ge,Le.vertexArrayOffset=this.layoutVertexArray.length,Le.groundVertexArrayOffset=this.groundEffect.vertexArray.length,ce&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new iC),this.wallMode){if(ce)return void dr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(y.length!==1)return;Ye=function(Wt){const ms=Wt[0].x===Wt[Wt.length-1].x&&Wt[0].y===Wt[Wt.length-1].y;(function(gr){let kr=0;const Hn=gr.length;for(let Us=0;Us=0})(Wt)||(Wt=Wt.reverse());const bs={geometry:[],joinNormals:[],indices:[]},Os=[],Fs=[],Ps=[];let Ls=Wt.length;for(;Ls>=2&&Wt[Ls-1].equals(Wt[Ls-2]);)Ls--;if(Ls<(ms?3:2))return bs;let hs,cs,Ds,Xs,qs,Lr=0;for(;Lr0;let mn="miter";const pa=2;mn==="miter"&&Us>pa&&(mn="bevel"),mn==="bevel"&&(Us>100&&(mn="flipbevel"),Us{const ps=new es(Ln.x,Ln.y),Rs=new es(Ln.x,Ln.y);ps.x+=vi.x*wt,ps.y+=vi.y*wt,Rs.x-=vi.x*Math.max(gt,1),Rs.y-=vi.y*Math.max(gt,1),Ps.push(vi),Os.push(ps),Fs.push(Rs)};if(mn==="miter")kr._mult(Us),xa(hs,kr,0,0);else if(mn==="flipbevel")kr=qs.mult(-1),xa(hs,kr,0,0),xa(hs,kr.mult(-1),0,0);else{const Ln=-Math.sqrt(Us*Us-1),vi=Nr?Ln:0,gt=Nr?0:Ln;cs&&xa(hs,Xs,vi,gt),Ds&&xa(hs,qs,vi,gt)}}bs.geometry=[...Os,...Fs.reverse(),Os[0]],bs.joinNormals=[...Ps,...Ps.reverse(),Ps[Ps.length-1]];const cr=bs.geometry.length-1;for(let gr=0;grWt<(ms.length-1)/2||Wt===ms.length-1,bt=this.wallMode?[y]:tA(y,500);for(let Wt=bt.length-1;Wt>=0;Wt--){const ms=bt[Wt];(ms.length===0||(ft=ms[0]).every(_s=>_s.x<=0)||ft.every(_s=>_s.x>=Ys)||ft.every(_s=>_s.y<=0)||ft.every(_s=>_s.y>=Ys))&&bt.splice(Wt,1)}var ft;let St;if(ce)St=Uje(bt,ee,E);else{St=[];for(const Wt of bt)St.push({polygon:Wt,bounds:ee})}const It=ue?this.edgeRadius:0,qt=It>0&&this.zoom<17,is=(Wt,ms)=>{if(Wt.length===0)return!1;const _s=Wt[Wt.length-1];return ms.x===_s.x&&ms.y===_s.y};for(const{polygon:Wt,bounds:ms}of St){let _s=0,bs=0;for(const Ls of Wt)ue&&!Ls[0].equals(Ls[Ls.length-1])&&Ls.push(Ls[0]),bs+=ue?Ls.length-1:Ls.length;const Os=this.segments.prepareSegment((ue?5:4)*bs,this.layoutVertexArray,this.indexArray);Le.footprintSegIdx<0&&(Le.footprintSegIdx=this.footprintSegments.length),Le.polygonSegIdx<0&&(Le.polygonSegIdx=this.polygonSegments.length);const Fs={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Ps=new Ije;if(Ps.vertexOffset=this.footprintVertices.length,Ps.indexOffset=3*this.footprintIndices.length,Ps.ringIndices=[],ue){const Ls=[],hs=[];_s=Os.vertexLength;for(let Ds=0;Ds4&&Bje(hs[hs.length-2],hs[0],hs[1]),Ds=It?ott(hs[hs.length-2],hs[0],hs[1],It):0;const Xs=[];let qs,Lr,cr;Lr=hs[1].sub(hs[0])._perp()._unit();let gr=!0;for(let kr=1,Hn=0;kr0?1:0,vi=Us.dist(Nr);if(Hn+vi>32768&&(Hn=0),It){cr=mn.sub(Nr)._perp()._unit();let Rs=Fje(Us,Nr,mn,Rje(Lr,cr),It);isNaN(Rs)&&(Rs=0);const nr=Nr.sub(Us)._unit();Us=Us.add(nr.mult(Ds))._round(),Nr=Nr.add(nr.mult(-Rs))._round(),Ds=Rs,Lr=cr,Ie&&this.zoom>=17&&(is(Xs,Us)||Xs.push(Us),is(Xs,Nr)||Xs.push(Nr))}const gt=Os.vertexLength,wt=hs.length>4&&Bje(Us,Nr,mn);let ps=$je(Hn,cs,gr);if(rA(this.layoutVertexArray,Us.x,Us.y,xa,Ln,0,0,ps),rA(this.layoutVertexArray,Us.x,Us.y,xa,Ln,0,1,ps),this.wallMode){const Rs=nt(kr-1,hs),nr=Ye.joinNormals[kr-1];nA(this.wallVertexArray,nr,Rs),nA(this.wallVertexArray,nr,Rs)}if(Hn+=vi,ps=$je(Hn,wt,!gr),cs=wt,rA(this.layoutVertexArray,Nr.x,Nr.y,xa,Ln,0,0,ps),rA(this.layoutVertexArray,Nr.x,Nr.y,xa,Ln,0,1,ps),this.wallMode){const Rs=nt(kr,hs),nr=Ye.joinNormals[kr];nA(this.wallVertexArray,nr,Rs),nA(this.wallVertexArray,nr,Rs)}if(Os.vertexLength+=4,this.indexArray.emplaceBack(gt+0,gt+1,gt+2),this.indexArray.emplaceBack(gt+1,gt+3,gt+2),Os.primitiveLength+=2,It){const Rs=_s+(kr===1?hs.length-2:kr-2),nr=kr===1?_s:Rs+1;if(this.indexArray.emplaceBack(gt+1,Rs,gt+3),this.indexArray.emplaceBack(Rs,nr,gt+3),Os.primitiveLength+=2,qs===void 0&&(qs=gt),!Tde(mn,hs[kr],ms)){const ar=kr===hs.length-1?qs:Os.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),Os.primitiveLength+=3}gr=!gr}if(ce){const Rs=this.layoutVertexExtArray,nr=ne.projectTilePoint(Us.x,Us.y,E),ar=ne.projectTilePoint(Nr.x,Nr.y,E),Or=ne.upVector(E,Us.x,Us.y),zr=ne.upVector(E,Nr.x,Nr.y);aA(Rs,nr,Or),aA(Rs,nr,Or),aA(Rs,ar,zr),aA(Rs,ar,zr)}}ue&&(_s+=hs.length-1),Ie&&It&&this.zoom>=17&&(Xs.length!==0&&is(Xs,Xs[0])&&Xs.pop(),this.groundEffect.addData(Xs,ms,J,It>0))}this.footprintSegments.push(Ps),Fs.triangleCount=this.indexArray.length-Fs.triangleArrayOffset,this.polygonSegments.push(Fs),++Le.footprintSegLen,++Le.polygonSegLen}if(Le.vertexCount=this.layoutVertexArray.length-Le.vertexArrayOffset,Le.groundVertexCount=this.groundEffect.vertexArray.length-Le.groundVertexArrayOffset,Le.vertexCount!==0){if(Le.centroidXY=je.borders?Aje:this.encodeCentroid(je,Le),this.centroidData.push(Le),je.borders){this.featuresOnBorder.push(je);const Wt=this.featuresOnBorder.length-1;for(let ms=0;msthis.featuresOnBorder[m].borders[c][0]-this.featuresOnBorder[y].borders[c][0])}splitToSubtiles(){const c=[];for(let O=0;OYs),J=2*W+(+(B.min.x+B.max.x>Ys)^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:ce,min:ee,max:ne}),B=W;for(let ue=B;ue[je[0]*(1-Ie[0])+Le[0]*Ie[0],je[1]*(1-Ie[1])+Le[1]*Ie[1]],ce=[],ue=[];for(const je of this.triangleSubSegments){ce[0]=je.min.x/Ys,ce[1]=je.min.y/Ys,ue[0]=je.max.x/Ys,ue[1]=je.max.y/Ys;const Le=ne(J,ee,ce),Ie=ne(J,ee,ue);if(new Er([Le[0],Le[1],E],[Ie[0],Ie[1],P]).intersectsPrecise(y)===0){W&&(k.segments.push(W),W=void 0);continue}const Ge=je.segment;W&&W.vertexOffset!==Ge.vertexOffset&&(k.segments.push(W),W=void 0),W?(W.vertexLength+=Ge.vertexLength,W.primitiveLength+=Ge.primitiveLength):W={vertexOffset:Ge.vertexOffset,primitiveLength:Ge.primitiveLength,vertexLength:Ge.vertexLength,primitiveOffset:Ge.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 es(Se(y.x,1,Ys-1)<<3|E,Se(y.y,1,Ys-1)<<3|P)}encodeBorderCentroid(c){if(!c.borders)return new es(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 es(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 es((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&$y?Aje: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|=$y);else for(const B of this.centroidData)if(!(B.flags&$y||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!=ce>m&&c<(this.footprintVertices.int16[2*(J+P.vertexOffset)+0]-ee)*(m-ne)/(ce-ne)+ee&&(k=!k)}O=B}}return k}getHeightAtTileCoord(c,m){let y=Number.NEGATIVE_INFINITY,k=!0;const E=4*(c+Ys)*Ys+(m+Ys);if(this.partLookup.hasOwnProperty(E)){const P=this.partLookup[E];return P?{height:P.height,hidden:!!(P.flags&$y)}: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&$y));if(y!==Number.NEGATIVE_INFINITY)return{height:y,hidden:k};this.partLookup[E]=void 0}}function Rje(g,c){const m=g.add(c)._unit();return g.x*m.x+g.y*m.y}function ott(g,c,m,y){const k=c.sub(g)._perp()._unit(),E=m.sub(c)._perp()._unit();return Fje(g,c,m,Rje(k,E),y)}function Fje(g,c,m,y,k){const E=Math.sqrt(1-y*y);return Math.min(g.dist(c)/3,c.dist(m)/3,k*E/y)}function Tde(g,c,m){return g.xm[1].x&&c.x>m[1].x||g.ym[1].y&&c.y>m[1].y}function zje(g,c){return g.xc[1].x||g.yc[1].y}function Bje(g,c,m){if(g.x<0||g.x>=Ys||c.x<0||c.x>=Ys||m.x<0||m.x>=Ys)return!1;const y=m.sub(c),k=y.perp(),E=g.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 $je(g,c,m){const y=c?2|g:-3&g;return m?1|y:-2&y}function qje(){const g=Math.PI/32,c=Math.tan(g),m=M;return m*Math.sqrt(1+2*c*c)-m}function Uje(g,c,m){const y=1<{for(const It of ft)ue.push({polygon:It,bounds:St})},Le=Math.ceil(Math.log2(J)),Ie=Math.ceil(Math.log2(ee)),Ge=Le-Ie,Ye=[];for(let ft=0;ft0?0:1);for(let ft=0;ftSt+1?bt.push({polygons:bs,bounds:Fs,depth:St+1}):je(bs,Fs)}if(Os.length){const Fs=[new es(It===0?_s:qt.x,It===1?_s:qt.y),is];Ye.length>St+1?bt.push({polygons:Os,bounds:Fs,depth:St+1}):je(Os,Fs)}}return ue}(g,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=ge((m.y+W/Ys)/y);return(Q(.5*(ge((m.y+J/Ys)/y)+ee))*y-m.y)*Ys}})}function ltt(g,c,m,y,k,E){const P=Math.pow(2,y.z-k.z);for(let O=0;O=B[P]&&(O=c,B=g),O[P]k&&Gje(O,B,P,k),O[P]E&&Gje(B,O,P,E)}}function pO(g,c,m,y,k,E){const P=[];for(let O=0;O=y&&ue.x>=y||(ce.x>=y?ce=new es(y,ce.y+(y-ce.x)/(ue.x-ce.x)*(ue.y-ce.y))._round():ue.x>=y&&(ue=new es(y,ce.y+(y-ce.x)/(ue.x-ce.x)*(ue.y-ce.y))._round()),ce.y>=k&&ue.y>=k||(ce.y>=k?ce=new es(ce.x+(k-ce.y)/(ue.y-ce.y)*(ue.x-ce.x),k)._round():ue.y>=k&&(ue=new es(ce.x+(k-ce.y)/(ue.y-ce.y)*(ue.x-ce.x),k)._round()),W&&ce.equals(W[W.length-1])||(W=[ce],P.push(W),E&&E.push({progress:{min:Le+Zje(Ie,Ge,ce)*je,max:1},parentIndex:O,prevPoint:Ie,nextPoint:Ge})),W.push(ue),E&&(E[E.length-1].progress.max=Le+Zje(Ie,Ge,ue)*je,E[E.length-1].nextPoint=Ge)))))}if(E&&ee>0)for(let ne=J;neW.t-J.t);let P=0,O=0,B=[];for(y.push(B);P!==g.length;){if(O===E.length){for(;P!==g.length;)B.length!==0&&B[B.length-1].equals(g[P])||B.push(g[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(g[P])||B.push(g[P]),P++)}}function Zje(g,c,m){return g.x!==c.x?(m.x-g.x)/(c.x-g.x):g.y!==c.y?(m.y-g.y)/(c.y-g.y):0}function iA(g,c){return g.x*c.x+g.y*c.y}function Yje(g,c){if(g.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{_s[0]=bs,_s[1]=Os,_s[2]=Fs,_s[3]=1},ms=qje();ce>0&&(ce+=ms),ue+=ms;for(const _s of ne){const bs=[],Os=[];for(const Fs of _s){const Ps=Fs.x+je.x,Ls=Fs.y+je.y,hs=ee.projection.projectTilePoint(Ps,Ls,bt),cs=ee.projection.upVector(bt,Fs.x,Fs.y);let Ds=ce,Xs=ue;if(Ie){const qs=Jje(Ps,Ls,ce,ue,Ie,Ge,Ye,nt);Ds+=qs.base,Xs+=qs.top}ce!==0?Wt(qt,hs.x+cs[0]*It*Ds,hs.y+cs[1]*It*Ds,hs.z+cs[2]*It*Ds):Wt(qt,hs.x,hs.y,hs.z),Wt(is,hs.x+cs[0]*It*Xs,hs.y+cs[1]*It*Xs,hs.z+cs[2]*It*Xs),Dt(qt,qt,Le),Dt(is,is,Le),bs.push(new Fb(qt[0],qt[1],qt[2])),Os.push(new Fb(is[0],is[1],is[2]))}ft.push(bs),St.push(Os)}return[ft,St]}(g,c,m,y,k,E,P,O,B,W,J):P?function(ee,ne,ce,ue,je,Le,Ie,Ge,Ye){const nt=[],bt=[],ft=[0,0,0,1];for(const St of ee){const It=[],qt=[];for(const is of St){const Wt=is.x+ue.x,ms=is.y+ue.y,_s=Jje(Wt,ms,ne,ce,Le,Ie,Ge,Ye);ft[0]=Wt,ft[1]=ms,ft[2]=_s.base,ft[3]=1,ct(ft,ft,je),ft[3]=Math.max(ft[3],1e-5);const bs=new Fb(ft[0]/ft[3],ft[1]/ft[3],ft[2]/ft[3]);ft[0]=Wt,ft[1]=ms,ft[2]=_s.top,ft[3]=1,ct(ft,ft,je),ft[3]=Math.max(ft[3],1e-5);const Os=new Fb(ft[0]/ft[3],ft[1]/ft[3],ft[2]/ft[3]);It.push(bs),qt.push(Os)}nt.push(It),bt.push(qt)}return[nt,bt]}(c,m,y,k,E,P,O,B,W):function(ee,ne,ce,ue,je){const Le=[],Ie=[],Ge=je[8]*ne,Ye=je[9]*ne,nt=je[10]*ne,bt=je[11]*ne,ft=je[8]*ce,St=je[9]*ce,It=je[10]*ce,qt=je[11]*ce;for(const is of ee){const Wt=[],ms=[];for(const _s of is){const bs=_s.x+ue.x,Os=_s.y+ue.y,Fs=je[0]*bs+je[4]*Os+je[12],Ps=je[1]*bs+je[5]*Os+je[13],Ls=je[2]*bs+je[6]*Os+je[14],hs=je[3]*bs+je[7]*Os+je[15],cs=Fs+Ge,Ds=Ps+Ye,Xs=Ls+nt,qs=Math.max(hs+bt,1e-5),Lr=Fs+ft,cr=Ps+St,gr=Ls+It,kr=Math.max(hs+qt,1e-5);Wt.push(new Fb(cs/qs,Ds/qs,Xs/qs)),ms.push(new Fb(Lr/kr,cr/kr,gr/kr))}Le.push(Wt),Ie.push(ms)}return[Le,Ie]}(c,m,y,k,E)}function Jje(g,c,m,y,k,E,P,O){const B=P*k.getElevationAt(g,c,!0,!0),W=E[0]!==0,J=W?E[1]===0?P*(E[0]/Eje-Pje):P*function(ee,ne,ce){const ue=Math.floor(ne[0]/8),je=Math.floor(ne[1]/8),Le=10*(ne[0]-8*ue),Ie=10*(ne[1]-8*je),Ge=ee.getElevationAt(ue,je,!0,!0),Ye=ee.getMeterToDEM(ce),nt=Math.floor(.5*(Le*Ye-1)),bt=Math.floor(.5*(Ie*Ye-1)),ft=ee.tileCoordToPixel(ue,je),St=2*nt+1,It=2*bt+1,qt=function(Os,Fs,Ps,Ls,hs){return[Os.getElevationAtPixel(Fs,Ps,!0),Os.getElevationAtPixel(Fs+hs,Ps,!0),Os.getElevationAtPixel(Fs,Ps+hs,!0),Os.getElevationAtPixel(Fs+Ls,Ps+hs,!0)]}(ee,ft.x-nt,ft.y-bt,St,It),is=Math.abs(qt[0]-qt[1]),Wt=Math.abs(qt[2]-qt[3]),ms=Math.abs(qt[0]-qt[2])+Math.abs(qt[1]-qt[3]),_s=Math.min(.25,.5*Ye*(is+Wt)/St),bs=Math.min(.25,.5*Ye*ms/It);return Ge+Math.max(_s*Le,bs*Ie)}(k,E,O):B;return{base:B+(m===0?-1:m),top:W?Math.max(J+y,B+m+2):B+y}}class dtt{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 utt{constructor(){this.tasks={},this.taskQueue=[],Ut(["process"],this),this.invoker=new dtt(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||ha(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(mx(m.error)):y(null,mx(m.data)))}else{const y=new Set,k=m.hasCallback?(P,O)=>{this.target.postMessage({id:c,type:"",sourceMapId:this.mapId,error:P?qf(P):null,data:qf(O,y)},y)}:()=>{},E=mx(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 oA={workerUrl:"",workerClass:null,workerParams:void 0};const Ade="mapboxgl_preloaded_worker_pool";class zb{constructor(c){this.active={},this.name=c}acquire(c,m=zb.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{m.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Ade]}numActive(){return Object.keys(this.active).length}}zb.workerCount=2;class SC{constructor(c,m,y="Worker",k=zb.workerCount){this.workerPool=c,this.actors=[],this.currentActor=0,this.id=Bt();const E=this.workerPool.acquire(this.id,k);for(let P=0;P{this.ready=!0})}broadcast(c,m,y){Tt(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 lA,Ede;function fO(){return lA||(lA=new zb),lA}SC.Actor=eke;const Pde=4096;class htt{constructor(c){this.module=c,this.memoryStack=this.module.malloc(Pde),this.memoryStackNextFree=this.memoryStack}createIntArray(c){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Pde?-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>Pde?-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 lke(g,c){const m=g.json.bufferViews[c];return new Uint8Array(g.buffers[m.buffer],m.byteOffset||0,m.byteLength)}function ytt(g,c,m,y){if(g.uri){const k=oke(g.uri,y);return fetch(k).then(E=>E.blob()).then(E=>createImageBitmap(E)).then(E=>{c.images[m]=E})}if(g.bufferView!==void 0){const k=lke(c,g.bufferView),E=new Blob([k],{type:g.mimeType});return createImageBitmap(E).then(P=>{c.images[m]=P})}}function cke(g,c=0,m){const y={json:null,images:[],buffers:[]};if(new Uint32Array(g,c,1)[0]===ake){const J=new Uint32Array(g,c);let ee=2;const ne=(J[ee++]>>2)-3,ce=J[ee++]>>2;if(ee++,y.json=JSON.parse(ike.decode(J.subarray(ee,ee+ce))),ee+=ce,ee{const J=[],ee=O&&O.includes(Dde),ne=O&&O.includes(yO);if(ee&&J.push(function(){if(!eg)return cA??(cA=function(ce){let ue,je=null;function Le(){ue=new Uint8Array(je.buffer)}function Ie(){throw new Error("Unexpected Draco error.")}const Ge={a:{a:Ie,d:function(Ye,nt,bt){return ue.copyWithin(Ye,nt,nt+bt)},c:function(Ye){const nt=ue.length,bt=Math.max(Ye>>>0,Math.ceil(1.2*nt)),ft=Math.ceil((bt-nt)/65536);try{return je.grow(ft),Le(),!0}catch{return!1}},b:Ie}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(ce,Ge):ce.then(Ye=>Ye.arrayBuffer()).then(Ye=>WebAssembly.instantiate(Ye,Ge))).then(Ye=>{const{Rb:nt,Qb:bt,P:ft,T:St,X:It,Ja:qt,La:is,Qa:Wt,Va:ms,Wa:_s,eb:bs,jb:Os,f:Fs,e:Ps,yb:Ls,zb:hs,Ab:cs,Bb:Ds,Db:Xs,Gb:qs}=Ye.instance.exports;je=Ps;const Lr=(()=>{let cr=0,gr=0,kr=0,Hn=0;return Us=>{kr&&(nt(Hn),nt(cr),gr+=kr,kr=cr=0),cr||(gr+=128,cr=bt(gr));const Nr=Us.length+7&-8;let mn=cr;Nr>=gr&&(kr=Nr,mn=Hn=bt(Nr));for(let pa=0;pa{eg=ce,cA=void 0}))}()),ne&&J.push(function(){if(Lde)return;const ce=function(ue){let je;const Le=WebAssembly.instantiateStreaming(ue,{}).then(Ye=>{je=Ye.instance,je.exports.__wasm_call_ctors()}),Ie={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Ge={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:Le,supported:!0,decodeGltfBuffer(Ye,nt,bt,ft,St,It){(function(qt,is,Wt,ms,_s,bs,Os){const Fs=qt.exports.sbrk,Ps=ms+3&-4,Ls=Fs(Ps*_s),hs=Fs(bs.length),cs=new Uint8Array(qt.exports.memory.buffer);cs.set(bs,hs);const Ds=is(Ls,ms,_s,hs,bs.length);if(Ds===0&&Os&&Os(Ls,Ps,_s),Wt.set(cs.subarray(Ls,Ls+ms*_s)),Fs(Ls-Fs(0)),Ds!==0)throw new Error(`Malformed buffer data: ${Ds}`)})(je,je.exports[Ge[St]],Ye,nt,bt,ft,je.exports[Ie[It]])}}}(fetch(rke()));return ce.ready.then(()=>{Lde=ce})}()),E)for(let ce=0;ce{if(ee&&P)for(const{primitives:ce}of P)for(const ue of ce)ftt(ue,y);if(ne&&P&&B)for(const ce of B)gtt(ce,y);return y})})}function dke(g){return fetch(g).then(c=>c.arrayBuffer()).then(c=>cke(c,0,g))}function Ode(g){switch(g){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 Rde(g){switch(g){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 Fde{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,Ode(this.format),Rde(this.format),c):"data"in c&&c.data&&P.texSubImage2D(P.TEXTURE_2D,0,O,B,y,k,Ode(this.format),Rde(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 uA{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 vtt=ia([{name:"a_pos_3f",components:3,type:"Float32"}]),_tt=ia([{name:"a_color_3f",components:3,type:"Float32"}]),btt=ia([{name:"a_color_4f",components:4,type:"Float32"}]),wtt=ia([{name:"a_uv_2f",components:2,type:"Float32"}]),jtt=ia([{name:"a_normal_3f",components:3,type:"Float32"}]),ktt=ia([{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=ia([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function uke(g,c){const m=vO(g.projection,g.zoom,g.width,g.height),y=function(E,P,O,B,W){const J=new x(O.lng-180*Bv,O.lat),ee=new x(O.lng+180*Bv,O.lat),ne=E.project(J.lng,J.lat),ce=E.project(ee.lng,ee.lat),ue=-Math.atan2(ce.y-ne.y,ce.x-ne.x),je=et.fromLngLat(O);je.y=Se(je.y,-1+Bv,1-Bv);const Le=je.toLngLat(),Ie=E.project(Le.lng,Le.lat),Ge=et.fromLngLat(Le);Ge.x+=Bv;const Ye=Ge.toLngLat(),nt=E.project(Ye.lng,Ye.lat),bt=mke(nt.x-Ie.x,nt.y-Ie.y,ue),ft=et.fromLngLat(Le);ft.y+=Bv;const St=ft.toLngLat(),It=E.project(St.lng,St.lat),qt=mke(It.x-Ie.x,It.y-Ie.y,ue),is=Math.abs(bt.x)/Math.abs(qt.y),Wt=w([]);$(Wt,Wt,-ue*(1-(W?0:B)));const ms=w([]);return I(ms,ms,[1,1-(1-is)*B,1]),ms[4]=-qt.x/qt.y*B,$(ms,ms,ue),C(ms,Wt,ms),ms}(g.projection,0,g.center,m,c),k=hke(g);return I(y,y,[k,k,1]),y}function hke(g){const c=g.projection,m=vO(g.projection,g.zoom,g.width,g.height),y=zde(c,g.center),k=zde(c,x.convert(c.center));return Math.pow(2,y*m+(1-m)*k)}function vO(g,c,m,y,k=1/0){const E=g.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 Bv=1/4e4;function zde(g,c){const m=Se(c.lat,-xe,xe),y=new x(c.lng-180*Bv,m),k=new x(c.lng+180*Bv,m),E=g.project(y.lng,m),P=g.project(k.lng,m),O=et.fromLngLat(y),B=et.fromLngLat(k),W=P.x-E.x,J=P.y-E.y,ee=B.x-O.x,ne=B.y-O.y,ce=Math.sqrt((ee*ee+ne*ne)/(W*W+J*J));return Math.log2(ce)}function mke(g,c,m){const y=Math.cos(m),k=Math.sin(m);return{x:g*y-c*k,y:g*k+c*y}}function pke(g,c,m){w(g),$(g,g,Pr(c[2])),L(g,g,Pr(c[0])),R(g,g,Pr(c[1])),I(g,g,m),C(g,g,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function _O(g,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(de(B)<1e-12||de(W)<1e-12)return Ve(g);const J=ht([],B,W);Ae(J,J),pe(W,y,c),B[2]=(E-k)*O,W[2]=(P-k)*O;const ee=B;return ht(ee,B,W),Ae(ee,ee),as(g,J,ee)}function bO(g,c,m=!1){const y=Fv(c.zoom),k=function(E,P,O){const B=P.worldSize,W=[E[12],E[13],E[14]],J=ge(W[1]/B),ee=oe(W[0]/B),ne=w([]),ce=re(1,J)*B,ue=re(1,0)*B*Me(J,P.zoom),je=1/pde(B);let Le=ue*je;if(O){const nt=vO(P.projection,P.zoom,P.width,P.height,1024);Le=je*P.projection.pixelSpaceConversion(P.center.lat,B,nt)}const Ie=Dv(J,ee);le(Ie,Ie,ke([],Ae([],Ie),ce*Le*W[2]));const Ge=function(nt){const bt=[nt[0],nt[1],nt[2]];let ft=[0,1,0];const St=ht([],ft,bt);return ht(ft,bt,St),Te(ft)===0&&(ft=[0,1,0],ht(St,bt,ft)),Ae(St,St),Ae(ft,ft),Ae(bt,bt),[St[0],St[1],St[2],0,ft[0],ft[1],ft[2],0,bt[0],bt[1],bt[2],0,nt[0],nt[1],nt[2],1]}(Ie);I(ne,ne,[Le,Le,Le*ce]),A(ne,ne,[-W[0],-W[1],-W[2]]);const Ye=C([],P.globeMatrix,Ge);return C(Ye,Ye,ne),C(Ye,Ye,E),Ye}(g,c,m);if(y>0){const E=function(P,O){const B=O.worldSize,W=re(1,0)*B*Me(O.center.lat,O.zoom)/pde(B),J=re(1,O.center.lat)*B,ee=w([]);R(ee,ee,Pr(O.center.lng)),L(ee,ee,Pr(O.center.lat)),A(ee,ee,[0,0,fd]),I(ee,ee,[W,W,W*J]);const ne=O.point;return A(ee,ee,[-ne.x,-ne.y,0]),C(ee,ee,P),C(ee,O.globeMatrix,ee)}(g,c);return function(P,O,B){const W=(ue,je,Le)=>{const Ie=de(ue),Ge=de(je),Ye=Jf(ue,je,Le);return ke(Ye,Ye,1/de(Ye)*Hr(Ie,Ge,Le))},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),ce=Jf([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,ce[0],ce[1],ce[2],1]}(k,E,y)}return k}function Bde(g,c,m,y){const k=Er.projectAabbCorners(y,m);let E=Number.MAX_VALUE;for(let O=0;O0||Le===0&&ue[0]*je[0]+ue[1]*je[1]>=0&&ue[0]*ue[0]+ue[1]*ue[1]>je[0]*je[0]+je[1]*je[1])&&(J=ce)}ee=J}while(ee!==W);return B.length>0&&B.push(B[0]),B}(k);if(Oa(g,P))return E}const Bb=64,AC={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function wO(g,c,m,y,k,E,P,O,B,W=!1){const J=m.zoom,ee=m.project(y),ne=Me(y.lat,J),ce=1/ne;w(g),A(g,g,[ee.x+P[0]*ce,ee.y+P[1]*ce,P[2]]);let ue=1,je=1;const Le=m.worldSize;if(W){if(m.projection.name==="mercator"){let nt=0;m.elevation&&(nt=m.elevation.getAtPointOrZero(new et(ee.x/Le,ee.y/Le),0));const bt=ct([],[ee.x,ee.y,nt,1],m.projMatrix)[3]/m.cameraToCenterDistance;ue=bt,je=bt*Me(m.center.lat,J)}else if(m.projection.name==="globe"){const nt=bO(g,m),bt=[0,0,0,1];ct(bt,bt,C([],m.projMatrix,nt));const ft=bt[3]/m.cameraToCenterDistance,St=Fv(J),It=m.projection.pixelsPerMeter(y.lat,Le)*Me(y.lat,J),qt=m.projection.pixelsPerMeter(m.center.lat,Le)*Me(m.center.lat,J);ue=ft/Hr(It,Pe(m.center.lat),St),je=ft*ne/It,ue*=qt,je*=qt}}else ue=ce;I(g,g,[ue,ue,je]);const Ie=[...g],Ge=c.orientation,Ye=[];if(pke(Ye,[Ge[0]+(k?k[0]:0),Ge[1]+(k?k[1]:0),Ge[2]+(k?k[2]:0)],E),C(g,Ie,Ye),O&&m.elevation){let nt=0;const bt=[];if(B&&m.elevation){nt=function(St,It,qt,is,Wt){const ms=It.elevation;if(!ms)return 0;const _s=Er.projectAabbCorners(qt,is),bs=re(1,Wt.lat)*It.worldSize,Os=function(gr,kr){const Hn=[0,0,1],Us=[{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 Nr of Us){const mn=gr[Nr.corners[0]],pa=gr[Nr.corners[1]],xa=gr[Nr.corners[2]],Ln=[pa[0]-mn[0],pa[1]-mn[1],kr*(pa[2]-mn[2])],vi=ht(Ln,Ln,[xa[0]-mn[0],xa[1]-mn[1],kr*(xa[2]-mn[2])]);Ae(vi,vi),Nr.dotProductWithUp=We(vi,Hn)}return Us.sort((Nr,mn)=>Nr.dotProductWithUp-mn.dotProductWithUp),Us[0].corners}(_s,bs),Fs=_s[Os[0]],Ps=_s[Os[1]],Ls=_s[Os[2]],hs=_s[Os[3]],cs=ms.getAtPointOrZero(new et(Fs[0]/It.worldSize,Fs[1]/It.worldSize),0),Ds=ms.getAtPointOrZero(new et(Ps[0]/It.worldSize,Ps[1]/It.worldSize),0),Xs=ms.getAtPointOrZero(new et(Ls[0]/It.worldSize,Ls[1]/It.worldSize),0),qs=ms.getAtPointOrZero(new et(hs[0]/It.worldSize,hs[1]/It.worldSize),0),Lr=(cs+qs)/2,cr=(Ds+Xs)/2;return Lr>cr?Ds=c.gl.NEAREST_MIPMAP_NEAREST}),g.uploaded=!0,g.image=null)}function Stt(g,c,m){g.indexBuffer=c.createIndexBuffer(g.indexArray,!1,!0),g.vertexBuffer=c.createVertexBuffer(g.vertexArray,vtt.members,!1,!0),g.normalArray&&(g.normalBuffer=c.createVertexBuffer(g.normalArray,jtt.members,!1,!0)),g.texcoordArray&&(g.texcoordBuffer=c.createVertexBuffer(g.texcoordArray,wtt.members,!1,!0)),g.colorArray&&(g.colorBuffer=c.createVertexBuffer(g.colorArray,(g.colorArray.bytesPerElement===12?_tt:btt).members,!1,!0)),g.featureArray&&(g.pbrBuffer=c.createVertexBuffer(g.featureArray,Ntt.members,!0)),g.segments=uo.simpleSegment(0,0,g.vertexArray.length,g.indexArray.length);const y=g.material;y.pbrMetallicRoughness.baseColorTexture&&hA(y.pbrMetallicRoughness.baseColorTexture,c),y.pbrMetallicRoughness.metallicRoughnessTexture&&hA(y.pbrMetallicRoughness.metallicRoughnessTexture,c),y.normalTexture&&hA(y.normalTexture,c),y.occlusionTexture&&hA(y.occlusionTexture,c,m),y.emissionTexture&&hA(y.emissionTexture,c)}function $de(g,c,m){if(g.meshes)for(const y of g.meshes)Stt(y,c,m);if(g.children)for(const y of g.children)$de(y,c,m)}function jO(g){if(g.meshes)for(const c of g.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(g.children)for(const c of g.children)jO(c)}function qde(g){if(g.meshes)for(const m of g.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(g.children)for(const m of g.children)qde(m)}function $b(g,c){const m=g.json.bufferViews[c.bufferView],y=xO[c.componentType];return new y(g.buffers[m.buffer],(c.byteOffset||0)+(m.byteOffset||0),c.count*(m.byteStride&&m.byteStride!==dA[c.type]*y.BYTES_PER_ELEMENT?m.byteStride/y.BYTES_PER_ELEMENT:dA[c.type]))}function Ude(g,c,m,y){const k=xO[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=g.json.bufferViews[c.bufferView],O=P.byteStride?P.byteStride/k.BYTES_PER_ELEMENT:dA[c.type],B=m.float32,W=B.length/m.capacity;for(let J=0,ee=0;J0){for(let Le=0;Le0){E.texcoordArray=new Lp;const ne=c.json.accessors[k.TEXCOORD_0];E.texcoordArray.resize(ne.count);const ce=$b(c,ne);Ude(c,ne,E.texcoordArray,ce)}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=$b(c,ne))}k._FEATURE_RGBA4444!==void 0&&(E.featureData=new Uint32Array($b(c,c.json.accessors[k._FEATURE_RGBA4444]).buffer));const ee=g.material;return E.material=function(ne,ce){const{emissiveFactor:ue=[0,0,0],alphaMode:je="OPAQUE",alphaCutoff:Le=.5,normalTexture:Ie,occlusionTexture:Ge,emissiveTexture:Ye,doubleSided:nt,name:bt}=ne,{baseColorFactor:ft=[1,1,1,1],metallicFactor:St=1,roughnessFactor:It=1,baseColorTexture:qt,metallicRoughnessTexture:is}=ne.pbrMetallicRoughness||{},Wt=Ge?ce[Ge.index]:void 0;if(Ge&&Ge.extensions&&Ge.extensions.KHR_texture_transform&&Wt){const ms=Ge.extensions.KHR_texture_transform;Wt.offsetScale=[ms.offset[0],ms.offset[1],ms.scale[0],ms.scale[1]]}return{name:bt,pbrMetallicRoughness:{baseColorFactor:new Fr(...ft),metallicFactor:St,roughnessFactor:It,baseColorTexture:qt?ce[qt.index]:void 0,metallicRoughnessTexture:is?ce[is.index]:void 0},doubleSided:nt,emissiveFactor:new Fr(...ue),alphaMode:je,alphaCutoff:Le,normalTexture:Ie?ce[Ie.index]:void 0,occlusionTexture:Wt,emissionTexture:Ye?ce[Ye.index]:void 0,defined:ne.defined===void 0}}(ee!==void 0?c.json.materials[ee]:{defined:!1},m),E}function gke(g,c,m){const{matrix:y,rotation:k,translation:E,scale:P,mesh:O,extras:B,children:W,name:J}=g,ee={};if(ee.name=J,ee.localMatrix=y||function(ne,ce,ue,je){var Le=ce[0],Ie=ce[1],Ge=ce[2],Ye=ce[3],nt=Le+Le,bt=Ie+Ie,ft=Ge+Ge,St=Le*nt,It=Le*bt,qt=Le*ft,is=Ie*bt,Wt=Ie*ft,ms=Ge*ft,_s=Ye*nt,bs=Ye*bt,Os=Ye*ft,Fs=je[0],Ps=je[1],Ls=je[2];return ne[0]=(1-(is+ms))*Fs,ne[1]=(It+Os)*Fs,ne[2]=(qt-bs)*Fs,ne[3]=0,ne[4]=(It-Os)*Ps,ne[5]=(1-(St+ms))*Ps,ne[6]=(Wt+_s)*Ps,ne[7]=0,ne[8]=(qt+bs)*Ls,ne[9]=(Wt-_s)*Ls,ne[10]=(1-(St+is))*Ls,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=j(ee.localMatrix),O!==void 0){ee.meshes=m[O];const ne=ee.anchor=[0,0];for(const ce of ee.meshes){const{min:ue,max:je}=ce.aabb;ne[0]+=ue[0]+je[0],ne[1]+=ue[1]+je[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 ce=function(Ge){const Ye=atob(Ge),nt=new Uint8Array(Ye.length);for(let bt=0;bt1&&y[y.length-1].equals(y[0])&&y.pop();let k=0;for(let P=0;P0&&y.reverse();const E=kC(y.flatMap(P=>[P.x,P.y]),[]);return E.length===0?null:{vertices:y,indices:E}}function Att(g,c){const m=[],y=[];let k=0;const E=[];for(const P of g){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 Vde(g){const c=function(B,W){const J=[],ee=WebGL2RenderingContext;if(B.json.textures)for(const ne of B.json.textures){const ce={magFilter:ee.LINEAR,minFilter:ee.NEAREST,wrapS:ee.REPEAT,wrapT:ee.REPEAT};ne.sampler!==void 0&&Object.assign(ce,B.json.samplers[ne.sampler]),J.push({image:W[ne.source],sampler:ce,uploaded:!1})}return J}(g,g.images),m=function(B,W){const J=[];for(const ee of B.json.meshes){const ne=[];for(const ce of ee.primitives)ne.push(Ctt(ce,B,W));J.push(ne)}return J}(g,c),{scenes:y,scene:k,nodes:E}=g.json,P=y?y[k||0].nodes:[...E.keys()],O=[];for(const B of P)O.push(gke(E[B],g,m));return function(B,W,J){const ee={},ne=new Set;for(let ce=0;ce0){const ce=Array.from(ne.values()).sort((ue,je)=>ue-je);for(let ue=ce.length-1;ue>=0;ue--)B.splice(ce[ue],1)}}(O,P,g.json.nodes),O}function Ett(g){g.heightmap=new Float32Array(4096),g.heightmap.fill(-1);const c=g.vertexArray.float32,m=g.aabb.min[0]-1,y=g.aabb.min[1]-1,k=Bb/(g.aabb.max[0]-m+2),E=Bb/(g.aabb.max[1]-y+2);for(let P=0;Pg.heightmap[W*Bb+B]&&(g.heightmap[W*Bb+B]=O)}}function xke(g,c,m,y,k){m.reserve(m.length+4*g.length),y.reserve(y.length+10*g.length),k.reserve(k.length+10*g.length);let E=y.length;for(const P of g){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=Ze([],P.pos,B,J/2),ne=Ze([],P.pos,B,-J/2),ce=[ee[0],ee[1],ee[2]+P.height],ue=[ne[0],ne[1],ne[2]+P.height],je=Ze([],P.normal,B,W);ke(je,je,O);const Le=Ze([],P.normal,B,-W);ke(Le,Le,O),le(je,ee,je),le(Le,ne,Le),ee[2]+=.1,ne[2]+=.1,y.emplaceBack(je[0],je[1],je[2]),y.emplaceBack(Le[0],Le[1],Le[2]),y.emplaceBack(ee[0],ee[1],ee[2]),y.emplaceBack(ne[0],ne[1],ne[2]),y.emplaceBack(ce[0],ce[1],ce[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(je[0],je[1],je[2]),y.emplaceBack(Le[0],Le[1],Le[2]);const Ie=J/O/2;k.emplaceBack(-Ie-W,-1,Ie,.8),k.emplaceBack(Ie+W,-1,Ie,.8),k.emplaceBack(-Ie,0,Ie,1.3),k.emplaceBack(Ie,0,Ie,1.3),k.emplaceBack(Ie+W,-.8,Ie,.7),k.emplaceBack(Ie+W,-.8,Ie,.7),k.emplaceBack(0,0,Ie,1.3),k.emplaceBack(0,0,Ie,1.3),k.emplaceBack(Ie+W,-1.2,Ie,.8),k.emplaceBack(Ie+W,-1.2,Ie,.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 Ptt(g,c){const m={};m.indexArray=new bl,m.vertexArray=new xh,m.colorArray=new fx,xke(g,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 Er([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),m}const yke=ia([{name:"a_pos_3f",components:3,type:"Float32"}]),Itt=ia([{name:"a_normal_3",components:3,type:"Int16"}]),Ltt=ia([{name:"a_centroid_3",components:3,type:"Int16"}]),vke=ia([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),Dtt=ia([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),Ott=ia([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Rtt=ia([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),Ftt=ia([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),ztt=ia([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),_ke=Vt.types,kO=32767;function Btt(g,c){const m=Ys+c;for(const y of g)for(const k of y)if(k.x<-c||k.x>m||k.y<-c||k.y>m)return!1;return!0}function $tt(g){switch(g){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: ${g}`)}}class Hde{constructor(){this.layoutVertexArray=new xh,this.layoutAttenuationArray=new fx,this.layoutColorArray=new yh,this.indexArray=new bl,this.indexArrayForConflation=new bl,this.segmentsBucket=new uo}}class Wde{constructor(c){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new uo,this.entranceBloom=new Hde;const m=66560;this.layoutVertexArray=new xh,this.layoutVertexArray.reserve(m),this.layoutNormalArray=new Tv,this.layoutNormalArray.reserve(m),this.layoutCentroidArray=new Tv,this.layoutCentroidArray.reserve(m),this.layoutColorArray=new yh,this.layoutColorArray.reserve(m),this.layoutFloodLightDataArray=new gx,this.layoutFloodLightDataArray.reserve(m),this.layoutAOArray=new hC,this.layoutAOArray.reserve(m),this.indexArray=new bl,this.indexArray.reserve(66560),this.indexArrayForConflation=new bl,this.segmentsBucket=new uo,this.entranceBloom=new Hde,c&&(this.layoutFacadePaintArray=new yh,this.layoutFacadeDataArray=new Ry,this.layoutFacadeVerticalRangeArray=new yh)}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 bke{constructor(c){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Lp,this.footprintsIndices=new gx,this.footprintsMin=new es(1/0,1/0),this.footprintsMax=new es(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Wde(!1),this.buildingWithFacade=new Wde(!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 Km(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 Mde(c),this.groundEffect.groundRadiusArray=new Wf,this.hasAppearances=null}updateFootprints(c,m){const y=new cO([],[],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(gO!=null||tke!=null)return null;if(TC!=null)return TC;const c=fetch(sa.BUILDING_GEN_URL);return TC=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 ce=y.length,ue=Math.max(ne>>>0,Math.ceil(1.2*ce)),je=Math.ceil((ue-ce)/65536);try{return O.grow(je),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 ce=ne.instance.exports;return(0,ce.g)(),O=ce.f,B(),new htt({setStyle:ce.h,setAOOptions:ce.i,setMetricOptions:ce.j,setStructuralOptions:ce.k,setFacadeOptions:ce.l,setFauxFacadeOptions:ce.m,setFacadeClassifierOptions:ce.n,addFeature:ce.o,addFacade:ce.p,generateMesh:ce.q,getLastError:ce.r,getOuterRingLength:ce.s,getMeshCount:ce.t,getPositionsPtr:ce.u,getPositionsLength:ce.v,getNormalsPtr:ce.w,getNormalsLength:ce.x,getAOPtr:ce.y,getAOLength:ce.z,getUVPtr:ce.A,getUVLength:ce.B,getFauxFacadePtr:ce.C,getFauxFacadeLength:ce.D,getIndicesPtr:ce.E,getIndicesLength:ce.F,getBuildingPart:ce.G,getRingCount:ce.H,getRingPtr:ce.I,getRingLength:ce.J,malloc:ce.K,free:ce.L,heapU8:y,heap16:k,heap32:E,heapF32:P})})}(c).then(m=>(TC=null,gO=m,gO)).catch(m=>{dr("Could not load building-gen"),TC=null,tke=m}),TC}()}populate(c,m,y,k){const E=mtt();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:Ie}of c){if(_ke[Ie.type]!=="LineString"){O.set(Ie.id,Ie.properties.source_id);continue}const Ge=this.layers[0]._featureFilter.needGeometry;if(Ge&&!this.layers[0]._featureFilter.filter(new Di(this.zoom),Ie,y))continue;const Ye=Ht(Ie,Ge);if(!Ge&&!this.layers[0]._featureFilter.filter(new Di(this.zoom),Ye,y))continue;const nt=Ge?Ye.geometry:Et(Ie,y,k),bt=[];for(const qt of nt)for(const is of qt)bt.push(is.x),bt.push(is.y);const ft={coordinates:bt,crossPerc:Ie.properties.cross_perc,distanceToRoad:Ie.properties.distance_to_road,entrances:Ie.properties.entrances,sourceId:0},St=Ie.properties.source_id;let It=B.get(St);It||(It=[],B.set(St,It)),It.push(ft),++W}this.maxHeight=0;const J=new Array,ee=new Set,ne=Ie=>{Ie!=null&&ee.add(Ie)},ce=(Ie,Ge)=>{Ie!=null&&J.push({buildingId:Ie,footprintIndex:Ge})},ue=64*(c.length-W),je=ue/2;this.buildingWithFacade.reserve(ue,je,!0),this.buildingWithoutFacade.reserve(2*ue,2*je,!1),this.footprintsIndices.reserve(16*(c.length-W)),this.footprintsVertices.reserve(8*(c.length-W));for(const{feature:Ie,id:Ge,index:Ye,sourceLayerIndex:nt}of c){if(_ke[Ie.type]==="LineString")continue;const bt=this.layers[0]._featureFilter.needGeometry;if(bt&&!this.layers[0]._featureFilter.filter(new Di(this.zoom),Ie,y))continue;let ft=null;if(Ie.properties&&Ie.properties.hasOwnProperty("building_id")&&(ft=Ie.properties.building_id,ee.has(ft)))continue;const St=Ht(Ie,bt);if(!bt&&!this.layers[0]._featureFilter.filter(new Di(this.zoom),St,y))continue;const It=bt?St.geometry:Et(Ie,y,k),qt=tA(It,500);let is=!1;for(const Xr of qt)if(Xr.length!==1){is=!0;break}if(is){ne(ft);continue}if(!Btt(It,163)){ne(ft);continue}const Wt=this.layers[0],ms=$tt(Wt.layout.get("building-roof-shape").evaluate(Ie,{},y)),_s=Wt.layout.get("building-base").evaluate(Ie,{},y),bs=Wt.layout.get("building-height").evaluate(Ie,{},y),Os=Wt.layout.get("building-flood-light-ground-radius").evaluate(Ie,{},y),Fs=Wt.paint.get("building-ambient-occlusion-intensity"),Ps=Os/this.tileToMeter;Ie.properties["building-part"]="roof";const Ls=Wt.paint.get("building-color").evaluate(Ie,{},this.canonical).toPremultipliedRenderColor(this.lut),hs=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);Ie.properties["building-part"]="wall";const cs=Wt.paint.get("building-color").evaluate(Ie,{},this.canonical).toPremultipliedRenderColor(this.lut),Ds=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);Ie.properties["building-part"]="window";const Xs=Wt.paint.get("building-color").evaluate(Ie,{},this.canonical).toPremultipliedRenderColor(this.lut),qs=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);Ie.properties["building-part"]="door";const Lr=Wt.paint.get("building-color").evaluate(Ie,{},this.canonical).toPremultipliedRenderColor(this.lut),cr=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);let gr=Wt.layout.get("building-flood-light-wall-radius").evaluate(Ie,{},y);gr=Se(gr,0,2048);const kr=gr/2048*kO,Hn=O.get(Ge),Us=B.get(Hn)||[],Nr=Us.length!==0&&Wt.layout.get("building-facade").evaluate(Ie,{},y);E.setFacadeOptions(4,!0),E.setFauxFacadeOptions(Nr,!1,1);let mn=0,pa=0,xa=0,Ln=0,vi=0,gt=0,wt=0,ps=0,Rs=0,nr=0,ar=0;if(Nr){let Xr=Math.round(Wt.layout.get("building-facade-floors").evaluate(Ie,{},y));if(_s===0){Xr=Math.max(1,Xr-(Us.length>0?1:0));let ci=4;if(bs>100){const Gi=[10,13,15];ci=Gi[Ie.id?Ie.id%Gi.length:0]}else bs<=10&&(ci=3);E.setFacadeOptions(ci,!0),vi=(bs<15?1.3:1.61803)*ci/P}else vi=_s/P;gt=bs/P,vi=Math.min(vi,gt),xa=Wt.layout.get("building-facade-unit-width").evaluate(Ie,{},y)/P,Ln=(gt-vi)/Xr,E.setFauxFacadeOptions(!0,!0,xa);const po=Wt.layout.get("building-facade-window").evaluate(Ie,{},y);mn=po[0],pa=po[1],wt=Math.floor(65535*Math.min(1,vi/Ys)),ps=Math.floor(65535*Math.min(1,gt/Ys)),Rs=Math.floor(255*mn)<<8|Math.floor(255*pa),nr=Math.floor(65535*Math.min(1,xa/Ys)),ar=Math.floor(65535*Math.min(1,Ln/Ys))}const Or=Array(qt.length),zr={x:1/0,y:1/0},Sn={x:-1/0,y:-1/0},zn={x:0,y:0};let Vn=0;for(let Xr=0;Xr0){const ci=[],Gi=Array(po.length+1);Gi[0]=0;for(let kl=0;klYs||zr.y<0||Sn.y>Ys)&&this.featuresOnBorder.push({featureId:Ie.id,footprintIndex:this.footprints.length});{const Xr=kC(wi,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+Xr.length),this.footprintsIndices.uint16.set(Xr,Yr),this.buildingIds.add(ft??Ie.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,Pi.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,Pi.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Oi.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Oi.y);const po={footprintVertexOffset:la,footprintVertexLength:this.footprintsVertices.length-la,footprintIndexOffset:Yr,footprintIndexLength:this.footprintsIndices.length-Yr,min:Pi,max:Oi,hiddenFlags:0,indicesOffset:Ja,indicesLength:ro,bloomIndicesOffset:li,bloomIndicesLength:Ni,groundEffectVertexOffset:Ro,groundEffectVertexLength:Ii,hasFauxFacade:Nr,height:Bn,promoteId:Ge,feature:St,parts:Ba,buildingBloom:$a},ci=this.footprints.length;Ie.id!==void 0&&this.featureFootprintLookup.set(Ie.id,ci),ce(ft,ci),this.footprints.push(po)}this.programConfigurations.populatePaintArrays(Jr.layoutVertexArray.length,Ie,Ye,{},m.availableImages,y,m.brightness),this.groundEffect.addPaintPropertiesData(Ie,Ye,{},m.availableImages,y,m.brightness),m.featureIndex.insert(Ie,It,Ye,nt,this.index,_i)}J.forEach(({buildingId:Ie,footprintIndex:Ge})=>{ee.has(Ie)&&(this.footprints[Ge].hiddenFlags|=4)});const Le=new Set;this.buildingIds.forEach((Ie,Ge,Ye)=>{ee.has(Ie)||Le.add(Ie)}),this.buildingIds=Le,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,yke.members),y.layoutNormalBuffer=c.createVertexBuffer(y.layoutNormalArray,Itt.members),y.layoutCentroidBuffer=c.createVertexBuffer(y.layoutCentroidArray,Ltt.members),y.layoutFloodLightDataBuffer=c.createVertexBuffer(y.layoutFloodLightDataArray,ztt.members),y.layoutFacadeDataArray&&y.layoutFacadeDataArray.length&&(y.layoutFacadeDataBuffer=c.createVertexBuffer(y.layoutFacadeDataArray,Ott.members)),y.layoutFacadeVerticalRangeArray&&y.layoutFacadeVerticalRangeArray.length&&(y.layoutFacadeVerticalRangeBuffer=c.createVertexBuffer(y.layoutFacadeVerticalRangeArray,Rtt.members)),y.entranceBloom.layoutVertexArray.length&&(y.entranceBloom.layoutVertexBuffer=c.createVertexBuffer(y.entranceBloom.layoutVertexArray,yke.members),y.entranceBloom.layoutAttenuationBuffer=c.createVertexBuffer(y.entranceBloom.layoutAttenuationArray,Ftt.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,vke.members,!0),y.layoutFacadePaintArray&&(y.layoutFacadePaintBuffer?y.layoutFacadePaintBuffer.updateData(y.layoutFacadePaintArray):y.layoutFacadePaintBuffer=c.createVertexBuffer(y.layoutFacadePaintArray,Dtt.members,!0)),y.entranceBloom.layoutColorBuffer?y.entranceBloom.layoutColorBuffer.updateData(y.entranceBloom.layoutColorArray):y.entranceBloom.layoutColorBuffer=c.createVertexBuffer(y.entranceBloom.layoutColorArray,vke.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 ce=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),je=k.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Ie of k.parts){let Ge,Ye=O;Ie.part===1?(Ye=O,Ge=B):Ie.part===0?(Ye=W,Ge=J):Ie.part===2?(Ye=ee,Ge=ne):Ie.part===3&&(Ye=ce,Ge=ue),Ge=Se(Ge,0,1);for(let nt=0;ntP.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||qtt(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 qtt(g,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 ce;const ue=E/y*(k+1);if(B.isDash){const je=k-Math.abs(ue);ce=Math.sqrt(ne*ne+je*je)}else ce=k-Math.sqrt(ne*ne+ue*ue);this.image.data[P+W]=Math.max(0,Math.min(255,ce+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 dr("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 aC,this.layoutVertexArray2=new xh,this.patternVertexArray=new xh,this.indexArray=new bl,this.programConfigurations=new Km(c.layers,{zoom:c.zoom,lut:c.lut}),this.segments=new uo,this.maxLineLength=0,this.zOffsetVertexArray=new xh,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.tessellationStep=c.tessellationStep?c.tessellationStep:Ys/64,this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,y,k){}populate(c,m,y,k){this.hasPattern=vde("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"),ce=ne.isConstant()&&!ne.constantOr(0);this.elevationType=P!=="sea"&&P!=="ground"&&ce?"none":"offset",this.elevationType==="offset"&&P==="none"&&dr(`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:ce,index:ue,sourceLayerIndex:je}of c){const Le=this.layers[0]._featureFilter.needGeometry,Ie=Ht(ne,Le);if(!this.layers[0]._featureFilter.filter(new Di(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),Ie,y))continue;const Ge=E?E.evaluate(Ie,{},y):void 0,Ye={id:ce,properties:ne.properties,type:ne.type,sourceLayerIndex:je,index:ue,geometry:Le?Ie.geometry:Et(ne,y,k),patterns:{},sortKey:Ge};B.push(Ye)}E&&B.sort((ne,ce)=>ne.sortKey-ce.sortKey);const{lineAtlas:W,featureIndex:J}=m,ee=this.addConstantDashes(W);for(const ne of B){const{geometry:ce,index:ue,sourceLayerIndex:je}=ne;if(ee&&this.addFeatureDashes(ne,W),this.hasPattern){const Le=_de("line",this.layers,ne,this.zoom,this.pixelRatio,m);this.patternFeatures.push(Le)}else this.addFeature(ne,ce,ue,y,W.positions,m.availableImages,m.brightness,m.elevationFeatures);J.insert(c[ue].feature,ce,ue,je,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,Ktt)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=c.createVertexBuffer(this.patternVertexArray,Ytt)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,Htt.members,!0)),this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,Wtt),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"),ce=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 je=this.layers[0].paint.get("line-width").value;if(je.kind!=="constant"&&je.isLineProgressConstant===!1&&(this.variableWidthValue=je),this.elevationType==="road"){const Le=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(c,m,k,B,J,ee,ne,ce)){const[Ie,Ge]=this.clipRuntimeLinesToTile(m,1);for(let Ye=0;Ye0?bt.parentIndex:null)}this.fillNonElevatedRoadSegment(Le)}}else for(let Le=0;Le0?Le: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 pO(c,-m,-m,Ys+m,Ys+m)}clipRuntimeLinesToTile(c,m){const y=[];return[pO(c,-m,-m,Ys+m,Ys+m,y),y]}addElevatedRoadFeature(c,m,y,k,E,P,O,B){const W=[],J=Xa.getElevationFeature(c,k);if(J){const ee=this.clipLinesToTile(m,1),ne=this.prepareElevatedLines(ee,J,y);for(const ce of ne)W.push({geometry:ce,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 ce=new fi(y,ee.elevationTileID);if(ee.elevation)for(let ue=ne;ue>1,this.layoutVertexArray.int16[6*ue+1]>>1),Le=ce.pointElevation(je,ee.elevation,.05);this.updateHeightRange(Le),this.zOffsetVertexArray.emplaceBack(Le,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)ctt(P,new za(m,E),0,k);return k}fillNonElevatedRoadSegment(c){for(let m=c;m0,ne=B&&B.progress.max<1;if(this.lineClips){let qt={min:this.lineClips.start,max:this.lineClips.end},is=1;if(B){const _s=this.lineClips.end-this.lineClips.start;qt=function(bs,Os,Fs){return{min:yi(bs.min,Os,Fs),max:yi(bs.max,Os,Fs)}}(B.progress,{min:0,max:1},qt),_s>0&&(is=(qt.max-qt.min)/_s)}const Wt=+m.properties.mapbox_clip_feature_len,ms=+m.properties.mapbox_clip_seg_len;if(Number.isNaN(Wt)||Number.isNaN(ms)){for(let bs=0;bs=2&&c[ue-1].equals(c[ue-2]);)ue--;let je=0;for(;je0,hs=this.overscaling<=16?15*Ys/(512*this.overscaling):0;if(is&&Wt==="round"){if(OsP&&(Wt="bevel"),Wt==="bevel"&&(Os>2&&(Wt="flipbevel"),Os2*hs){const Xs=Ie.sub(Ie.sub(Ge)._mult(hs/cs)._round());this.updateDistance(Ge,Xs),this.addCurrentVertex(Xs,nt,0,0,Le,It),Ge=Xs}this.updateDistance(Ge,Ie),_s._mult(Os),this.addCurrentVertex(Ie,_s,0,0,Le,It);const Ds=Ie.dist(Ye);if(Ds>2*hs){const Xs=Ie.add(Ye.sub(Ie)._mult(hs/Ds)._round());this.updateDistance(Ie,Xs),this.addCurrentVertex(Xs,bt,0,0,Le,It),Ie=Xs}}else _s._mult(Os),this.addCurrentVertex(Ie,_s,0,0,Le,It);else if(Wt==="flipbevel"){if(Os>100)_s=bt.mult(-1);else{const cs=Os*nt.add(bt).mag()/nt.sub(bt).mag();_s._perp()._mult(cs*(Ls?-1:1))}this.addCurrentVertex(Ie,_s,0,0,Le,It),this.addCurrentVertex(Ie,_s.mult(-1),0,0,Le,It)}else if(Wt==="bevel"||Wt==="fakeround"){It!=null&&Ge&&this.addCurrentVertex(Ie,St||nt,-1,-1,Le,It);const cs=Ie.dist(Ge)<=2*hs&&Wt!=="bevel",Ds=_s.mult(Ls?1:-1);Ds._mult(Os);const Xs=bt.mult(Ls?-1:1),qs=nt.mult(Ls?-1:1),Lr=this.evaluateLineProgressFeatures(this.distance);if(It==null&&(this.addHalfVertex(Ie,Ds.x,Ds.y,!1,!Ls,0,Le,Lr),cs||this.addHalfVertex(Ie,Ds.x+2*qs.x,Ds.y+2*qs.y,!1,Ls,0,Le,Lr)),Wt==="fakeround"){const cr=Math.round(180*Fs/Math.PI/20);this.addHalfVertex(Ie,qs.x,qs.y,!1,Ls,0,Le,Lr);for(let gr=0;gr1){this.lineSoFar=c.w;const je=(m.x-c.x)/ee,Le=(m.y-c.y)/ee,Ie=(m.z-c.z)/ee,Ge=(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 Kde(g,c,m){return g.xm||g.ym}let Nke,Ske;function Cke(g,c,m){return c*(Ys/(g.tileSize*Math.pow(2,m-g.tileID.overscaledZ)))}vr(Gde,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const Mke=(g,c,m)=>(1-m)*g+m*c;function Tke(g,c){return 1/Cke(g,1,c.tileZoom)}function Ake(g,c,m,y){return g.translatePosMatrix(y||c.tileID.projMatrix,c,m.paint.get("line-translate"),m.paint.get("line-translate-anchor"))}const Eke=g=>{const c=[];Pke(g)&&c.push("RENDER_LINE_DASH"),g.paint.get("line-gradient")&&c.push("RENDER_LINE_GRADIENT");const m=g.paint.get("line-trim-offset");m[0]===0&&m[1]===0||c.push("RENDER_LINE_TRIM_OFFSET"),g.paint.get("line-border-width").constantOr(1)!==0&&c.push("RENDER_LINE_BORDER");const y=g.layout.get("line-join").constantOr("miter")==="none",k=!!g.paint.get("line-pattern").constantOr(1);return y&&k&&c.push("LINE_JOIN_NONE"),c};function Pke(g){const c=g.paint.get("line-dasharray").value;return c.kind!=="constant"||c.value}let Zde;const Ike=()=>Zde||(Zde={layout:Nke||(Nke=new wo({"line-cap":new rr(Gt.layout_line["line-cap"]),"line-join":new rr(Gt.layout_line["line-join"]),"line-miter-limit":new Hs(Gt.layout_line["line-miter-limit"]),"line-round-limit":new Hs(Gt.layout_line["line-round-limit"]),"line-sort-key":new rr(Gt.layout_line["line-sort-key"]),"line-z-offset":new rr(Gt.layout_line["line-z-offset"]),"line-elevation-reference":new Hs(Gt.layout_line["line-elevation-reference"]),"line-cross-slope":new Hs(Gt.layout_line["line-cross-slope"]),visibility:new Hs(Gt.layout_line.visibility),"line-width-unit":new Hs(Gt.layout_line["line-width-unit"])})),paint:Ske||(Ske=new wo({"line-opacity":new rr(Gt.paint_line["line-opacity"]),"line-color":new rr(Gt.paint_line["line-color"]),"line-translate":new Hs(Gt.paint_line["line-translate"]),"line-translate-anchor":new Hs(Gt.paint_line["line-translate-anchor"]),"line-width":new rr(Gt.paint_line["line-width"]),"line-gap-width":new rr(Gt.paint_line["line-gap-width"]),"line-offset":new rr(Gt.paint_line["line-offset"]),"line-blur":new rr(Gt.paint_line["line-blur"]),"line-dasharray":new rr(Gt.paint_line["line-dasharray"]),"line-pattern":new rr(Gt.paint_line["line-pattern"]),"line-pattern-cross-fade":new Hs(Gt.paint_line["line-pattern-cross-fade"]),"line-gradient":new Ly(Gt.paint_line["line-gradient"]),"line-trim-offset":new Hs(Gt.paint_line["line-trim-offset"]),"line-trim-fade-range":new Hs(Gt.paint_line["line-trim-fade-range"]),"line-trim-color":new Hs(Gt.paint_line["line-trim-color"]),"line-emissive-strength":new rr(Gt.paint_line["line-emissive-strength"]),"line-border-width":new rr(Gt.paint_line["line-border-width"]),"line-border-color":new rr(Gt.paint_line["line-border-color"]),"line-occlusion-opacity":new Hs(Gt.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"})}))},Zde);class est extends rr{possiblyEvaluate(c,m){return m=new Di(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 mA;function Lke(g,c){return c>0?c+2*g:g}const tst=ia([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),sst=ia([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),rst=ia([{name:"a_projected_pos",components:4,type:"Float32"}],4);ia([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const nst=ia([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),ast=ia([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),ist=ia([{name:"a_texb",components:2,type:"Uint16"}]),ost=ia([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),lst=ia([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);ia([{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 Dke=ia([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),cst=ia([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ia([{name:"triangle",components:3,type:"Uint16"}]),ia([{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"}]),ia([{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"}]),ia([{type:"Float32",name:"offsetX"}]),ia([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var oc=24;function dst(g,c,m){return g.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()),Hf.applyArabicShaping&&(k=Hf.applyArabicShaping(k)),k}(y.text,c,m)}),g}const pA={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function ust(g){return g==="︶"||g==="﹈"||g==="︸"||g==="﹄"||g==="﹂"||g==="︾"||g==="︼"||g==="︺"||g==="︘"||g==="﹀"||g==="︐"||g==="︓"||g==="︔"||g==="`"||g===" ̄"||g==="︑"||g==="︒"}function hst(g){return g==="︵"||g==="﹇"||g==="︷"||g==="﹃"||g==="﹁"||g==="︽"||g==="︻"||g==="︹"||g==="︗"||g==="︿"}const Yde=4294967296,Oke=1/Yde,Rke=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let NO=class{constructor(g=new Uint8Array(16)){this.buf=ArrayBuffer.isView(g)?g:new Uint8Array(g),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(g,c,m=this.length){for(;this.pos>3,E=this.pos;this.type=7&y,g(k,c,this),this.pos===E&&this.skip(y)}return c}readMessage(g,c){return this.readFields(g,c,this.readVarint()+this.pos)}readFixed32(){const g=this.dataView.getUint32(this.pos,!0);return this.pos+=4,g}readSFixed32(){const g=this.dataView.getInt32(this.pos,!0);return this.pos+=4,g}readFixed64(){const g=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Yde;return this.pos+=8,g}readSFixed64(){const g=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Yde;return this.pos+=8,g}readFloat(){const g=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,g}readDouble(){const g=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,g}readVarint(g){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 EC(k,B,E);throw new Error("Expected varint not more than 10 bytes")}(m,g,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const g=this.readVarint();return g%2==1?(g+1)/-2:g/2}readBoolean(){return!!this.readVarint()}readString(){const g=this.readVarint()+this.pos,c=this.pos;return this.pos=g,g-c>=12&&Rke?Rke.decode(this.buf.subarray(c,g)):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,g)}readBytes(){const g=this.readVarint()+this.pos,c=this.buf.subarray(this.pos,g);return this.pos=g,c}readPackedVarint(g=[],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(g,c){this.writeVarint(g<<3|c)}realloc(g){let c=this.length||16;for(;c268435455||g<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)}(g,this):(this.realloc(4),this.buf[this.pos++]=127&g|(g>127?128:0),g<=127||(this.buf[this.pos++]=127&(g>>>=7)|(g>127?128:0),g<=127||(this.buf[this.pos++]=127&(g>>>=7)|(g>127?128:0),g<=127||(this.buf[this.pos++]=g>>>7&127))))}writeSVarint(g){this.writeVarint(g<0?2*-g-1:2*g)}writeBoolean(g){this.writeVarint(+g)}writeString(g){g=String(g),this.realloc(4*g.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,g,this.pos);const m=this.pos-c;m>=128&&Fke(c,m,this),this.pos=c-1,this.writeVarint(m),this.pos+=m}writeFloat(g){this.realloc(4),this.dataView.setFloat32(this.pos,g,!0),this.pos+=4}writeDouble(g){this.realloc(8),this.dataView.setFloat64(this.pos,g,!0),this.pos+=8}writeBytes(g){const c=g.length;this.writeVarint(c),this.realloc(c);for(let m=0;m=128&&Fke(m,y,this),this.pos=m-1,this.writeVarint(y),this.pos+=y}writeMessage(g,c,m){this.writeTag(g,2),this.writeRawMessage(c,m)}writePackedVarint(g,c){c.length&&this.writeMessage(g,mst,c)}writePackedSVarint(g,c){c.length&&this.writeMessage(g,pst,c)}writePackedBoolean(g,c){c.length&&this.writeMessage(g,xst,c)}writePackedFloat(g,c){c.length&&this.writeMessage(g,fst,c)}writePackedDouble(g,c){c.length&&this.writeMessage(g,gst,c)}writePackedFixed32(g,c){c.length&&this.writeMessage(g,yst,c)}writePackedSFixed32(g,c){c.length&&this.writeMessage(g,vst,c)}writePackedFixed64(g,c){c.length&&this.writeMessage(g,_st,c)}writePackedSFixed64(g,c){c.length&&this.writeMessage(g,bst,c)}writeBytesField(g,c){this.writeTag(g,2),this.writeBytes(c)}writeFixed32Field(g,c){this.writeTag(g,5),this.writeFixed32(c)}writeSFixed32Field(g,c){this.writeTag(g,5),this.writeSFixed32(c)}writeFixed64Field(g,c){this.writeTag(g,1),this.writeFixed64(c)}writeSFixed64Field(g,c){this.writeTag(g,1),this.writeSFixed64(c)}writeVarintField(g,c){this.writeTag(g,0),this.writeVarint(c)}writeSVarintField(g,c){this.writeTag(g,0),this.writeSVarint(c)}writeStringField(g,c){this.writeTag(g,2),this.writeString(c)}writeFloatField(g,c){this.writeTag(g,5),this.writeFloat(c)}writeDoubleField(g,c){this.writeTag(g,1),this.writeDouble(c)}writeBooleanField(g,c){this.writeVarintField(g,+c)}};function EC(g,c,m){return m?4294967296*c+(g>>>0):4294967296*(c>>>0)+(g>>>0)}function Fke(g,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>=g;k--)m.buf[k+y]=m.buf[k]}function mst(g,c){for(let m=0;m=0&&y>=c&&SO[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 PC;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(fA.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 Qde(g,c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je=1){const Le=PC.fromFeature(g,k,je);ee===bh.vertical&&Le.verticalizePunctuation(ne);let Ie=[];const Ge=function(St,It,qt,is,Wt,ms){if(!St)return[];const _s=[],bs=function(Ls,hs,cs,Ds,Xs,qs){let Lr=0;for(let cr=0;cr=0;let Fs=0;for(let Ls=0;Ls0&&$a>Ln&&(Ln=$a)}else{const La=qt[Rs.fontStack];if(!La)continue;La[ar]&&(Sn=La[ar]);const Ba=It[Rs.fontStack];if(!Ba)continue;const $a=Ba.glyphs[ar];if(!$a)continue;if(zr=$a.metrics,Vn=ar!==8203?oc:0,qs){const li=Ba.ascender!==void 0?Math.abs(Ba.ascender):0,Ni=Ba.descender!==void 0?Math.abs(Ba.descender):0,_i=(li+Ni)*Or;vi<_i&&(vi=_i,gt=(li-Ni)/2*Or),oa=-li*Or}else oa=(Nr-Or)*oc-17}un?(St.verticalizable=!0,xa.push({glyph:ar,image:zn,x:hs,y:cs+oa,vertical:un,scale:Or,localGlyph:zr.localGlyph,fontStack:Rs.fontStack,sectionIndex:nr,metrics:zr,rect:Sn}),hs+=Vn*Or+Fs):(xa.push({glyph:ar,image:zn,x:hs,y:cs+oa,vertical:un,scale:Or,localGlyph:zr.localGlyph,fontStack:Rs.fontStack,sectionIndex:nr,metrics:zr,rect:Sn}),hs+=zr.advance*Or+Fs)}xa.length!==0&&(Ds=Math.max(hs-Fs,Ds),qs?Vke(xa,Xs,Ln,gt,ms*Nr/2):Vke(xa,Xs,Ln,0,ms/2)),hs=0;const wt=ms*Nr+Ln;pa.lineOffset=Math.max(Ln,mn),cs+=wt,++Lr}var cr;const gr=cs,{horizontalAlign:kr,verticalAlign:Hn}=Jde(_s);(function(Us,Nr,mn,pa,xa,Ln){const vi=(Nr-mn)*xa,gt=-Ln*pa;for(const wt of Us)for(const ps of wt.positionedGlyphs)ps.x+=vi,ps.y+=gt})(St.positionedLines,Xs,kr,Hn,Ds,gr),St.top+=-Hn*gr,St.bottom=St.top+gr,St.left+=-kr*Ds,St.right=St.left+Ds,St.hasBaseline=qs}(ft,c,m,y,Ie,P,O,B,ee,W,ne,ue),!function(St){for(const It of St)if(It.positionedGlyphs.length!==0)return!1;return!0}(bt))return ft}const SO={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Nst={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function Bke(g,c,m,y,k,E){if(c.image){const P=y.get(c.image.toString());return P?P.displaySize[0]*c.scale*oc/E+k:0}{const P=m[c.fontStack],O=P&&P.glyphs[g];return O?O.metrics.advance*c.scale+k:0}}function $ke(g,c,m,y){const k=Math.pow(g-c,2);return y?g-m/2;){if(P--,P<0)return!1;O-=g[P].dist(E),E=g[P]}O+=g[P].dist(g[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 Zke(g){let c=0;for(let m=0;mW){const ue=(W-B)/ce,je=Hr(ee.x,ne.x,ue),Le=Hr(ee.y,ne.y,ue),Ie=new qy(je,Le,0,ne.angleTo(ee),J);return!P||Kke(g,Ie,O,P,c)?Ie:void 0}B+=ce}}function Mst(g,c,m,y,k,E,P,O,B){const W=Yke(y,E,P),J=Xke(y,k),ee=J*P,ne=g[0].x===0||g[0].x===B||g[0].y===0||g[0].y===B;return c-ee=0&&nt=0&&bt=0&&ne+W<=J){const ft=new qy(nt,bt,0,Ge,ue);y&&!Kke(g,ft,E,y,k)||ce.push(ft)}}ee+=Ie}return O||ce.length||P||(ce=Qke(g,ee/2,m,y,k,E,P,!0,B)),ce}function Jke(g){let c=0,m=0;for(const P of g)c+=P.w*P.h,m=Math.max(m,P.w);g.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 g)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,yd.copy(ee.data,W,{x:0,y:0},{x:je,y:Le},ee.data,y),yd.copy(ee.data,W,{x:0,y:Ge-ue},{x:je,y:Le-ue},{width:Ie,height:ue},y),yd.copy(ee.data,W,{x:0,y:0},{x:je,y:Le+Ge},{width:Ie,height:ue},y),yd.copy(ee.data,W,{x:Ie-ue,y:0},{x:je-ue,y:Le},{width:ue,height:Ge},y),yd.copy(ee.data,W,{x:0,y:0},{x:je+Ie,y:Le},{width:ue,height:Ge},y),yd.copy(ee.data,W,{x:Ie-ue,y:Ge-ue},{x:je-ue,y:Le-ue},{width:ue,height:ue},y),yd.copy(ee.data,W,{x:0,y:Ge-ue},{x:je+Ie,y:Le-ue},{width:ue,height:ue},y),yd.copy(ee.data,W,{x:0,y:0},{x:je+Ie,y:Le+Ge},{width:ue,height:ue},y),yd.copy(ee.data,W,{x:Ie-ue,y:0},{x:je-ue,y:Le+Ge},{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}=rue(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=Ff.parse(E);if(Ws.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=Ff.parse(E);if(Ws.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 yd(B);yd.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(gA,"ImagePosition"),vr(eNe,"ImageAtlas");const xA=1e20;function tNe(g,c,m,y,k,E,P,O,B){for(let W=c;W-1);B++,E[B]=O,P[B]=W,P[B+1]=xA}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 dr("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]=[],DC.loadGlyphRange(E,J,k,this.requestManager,(ne,ce)=>{if(ce){B.ascender=ce.ascender,B.descender=ce.descender;for(const ue in ce.glyphs)this._doesCharSupportLocalGlyph(+ue)||(B.glyphs[+ue]=ce.glyphs[+ue]);B.ranges[J]=!0}for(const ue of ee)ue(ne,ce);delete B.requests[J]})),ee.push((ne,ce)=>{ne?O(ne):ce&&O(null,{stack:E,id:P,glyph:ce.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!==nue.none&&(this.localGlyphMode===nue.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 je="400";/bold/i.test(m)?je="900":/medium/i.test(m)?je="500":/light/i.test(m)&&(je="200"),E=c.tinySDF=new DC.TinySDF({fontFamily:k,fontWeight:je,fontSize:24*sg,buffer:3*sg,radius:8*sg}),E.fontWeight=je}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:ce,glyphAdvance:ue}=E.draw(P);return this.localGlyphs[E.fontWeight][y]={id:y,bitmap:new zv({width:B,height:W},O),metrics:{width:J/sg,height:ee/sg,left:ne/sg,top:ce/sg-27,advance:ue/sg,localGlyph:!0}}}}DC.loadGlyphRange=function(g,c,m,y,k){const E=256*c,P=E+255,O=y.transformRequest(y.normalizeGlyphsURL(m).replace("{fontstack}",g).replace("{range}",`${E}-${P}`),Df.Glyphs);Uu(O,(B,W)=>{if(B)k(B);else if(W){const J={},ee=function(ne){return new NO(ne).readFields(wst,{})}(W);for(const ne of ee.glyphs)J[ne.id]=ne;k(null,{glyphs:J,ascender:ee.ascender,descender:ee.descender})}})},DC.TinySDF=class{constructor({fontSize:g=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=g+4*c,W=this._createCanvas(B),J=this.ctx=W.getContext("2d",{willReadFrequently:!0});J.font=`${P} ${E} ${g}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(g){const c=document.createElement("canvas");return c.width=c.height=g,c}draw(g){const{width:c,actualBoundingBoxAscent:m,actualBoundingBoxDescent:y,actualBoundingBoxLeft:k,actualBoundingBoxRight:E}=this.ctx.measureText(g),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),ce={data:ne,width:W,height:J,glyphWidth:O,glyphHeight:B,glyphTop:P,glyphLeft:0,glyphAdvance:c};if(O===0||B===0)return ce;const{ctx:ue,buffer:je,gridInner:Le,gridOuter:Ie}=this;this.lang&&(ue.lang=this.lang),ue.clearRect(je,je,O,B),ue.fillText(g,je,je+P);const Ge=ue.getImageData(je,je,O,B);Ie.fill(xA,0,ee),Le.fill(0,0,ee);for(let Ye=0;Ye0?St*St:0,Le[ft]=St<0?St*St:0}}tNe(Ie,0,0,W,J,W,this.f,this.v,this.z),tNe(Le,je,je,O,B,W,this.f,this.v,this.z);for(let Ye=0;Ye{const Os=TO(Wt.stretch-Ge,Ye,J,g.left*k),Fs=AO(Wt.fixed-ft,St,Wt.stretch,ue),Ps=TO(ms.stretch-nt,bt,ee,g.top*k),Ls=AO(ms.fixed-It,qt,ms.stretch,je),hs=TO(_s.stretch-Ge,Ye,J,g.left*k),cs=AO(_s.fixed-ft,St,_s.stretch,ue),Ds=TO(bs.stretch-nt,bt,ee,g.top*k),Xs=AO(bs.fixed-It,qt,bs.stretch,je),qs=new es(Os,Ps),Lr=new es(hs,Ps),cr=new es(hs,Ds),gr=new es(Os,Ds),kr=new es(Fs/O,Ls/O),Hn=new es(cs/O,Xs/O),Us=c*Math.PI/180;if(Us){const vi=Math.sin(Us),gt=Math.cos(Us),wt=[gt,-vi,vi,gt];qs._matMult(wt),Lr._matMult(wt),gr._matMult(wt),cr._matMult(wt)}const Nr=Wt.stretch+Wt.fixed,mn=_s.stretch+_s.fixed,pa=ms.stretch+ms.fixed,xa=bs.stretch+bs.fixed,Ln=g.imageSecondary;return{tl:qs,tr:Lr,bl:gr,br:cr,texPrimary:{x:P.paddedRect.x+_x+Nr,y:P.paddedRect.y+_x+pa,w:mn-Nr,h:xa-pa},texSecondary:Ln?{x:Ln.paddedRect.x+_x+Nr,y:Ln.paddedRect.y+_x+pa,w:mn-Nr,h:xa-pa}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:kr,pixelOffsetBR:Hn,minFontScaleX:St/O/J,minFontScaleY:qt/O/ee,isSDF:m}};if(y&&(P.stretchX||P.stretchY)){const Wt=nNe(ne,Le,ue),ms=nNe(ce,Ie,je);for(let _s=0;_sE)&&(E=ue.x),(!ce||ue.y>P)&&(P=ue.y)}const B=Math.min(E-y,P-k);let W=B/2;const J=new NS([],Pst);if(B===0)return new es(y,k);for(let ce=y;ceee.d||!ee.d)&&(ee=ce,m&&console.log("found best %d after %d probes",Math.round(1e4*ce.d)/1e4,ne)),ce.max-ee.d<=c||(W=ce.h/2,J.push(new OC(ce.p.x-W,ce.p.y-W,W,g)),J.push(new OC(ce.p.x+W,ce.p.y-W,W,g)),J.push(new OC(ce.p.x-W,ce.p.y+W,W,g)),J.push(new OC(ce.p.x+W,ce.p.y+W,W,g)),ne+=4)}return m&&(console.log(`num probes: ${ne}`),console.log(`best distance: ${ee.d}`)),ee.p}function Pst(g,c){return c.max-g.max}class OC{constructor(c,m,y,k){this.p=new es(c,m),this.h=y,this.d=function(E,P){let O=!1,B=1/0;for(let W=0;WE.y!=je.y>E.y&&E.x<(je.x-ue.x)*(E.y-ue.y)/(je.y-ue.y)+ue.x&&(O=!O),B=Math.min(B,Ao(E,ue,je))}}return(O?1:-1)*Math.sqrt(B)}(this.p,k),this.max=this.d+this.h*Math.SQRT2}}const Ist=Object.keys,iue=Number.POSITIVE_INFINITY,Lst=Math.sqrt(2);function $v(g,c,m,y,k){const E=eue(g)&&g.collisionPadding?g.collisionPadding:[0,0,0,0],P={top:g.top-E[1],bottom:g.bottom+E[3],left:g.left-E[0],right:g.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=Pr(B),J=new es(O.left,O.top),ee=new es(O.right,O.top),ne=new es(O.left,O.bottom),ce=new es(O.right,O.bottom),ue=new es(0,0);J._rotateAround(W,ue),ee._rotateAround(W,ue),ne._rotateAround(W,ue),ce._rotateAround(W,ue),O.left=Math.min(J.x,ee.x,ne.x,ce.x),O.right=Math.max(J.x,ee.x,ne.x,ce.x),O.top=Math.min(J.y,ee.y,ne.y,ce.y),O.bottom=Math.max(J.y,ee.y,ne.y,ce.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 iNe(g,[c,m]){let y=0,k=0;if(m===iue){c<0&&(c=0);const E=c/Lst;switch(g){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(g){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),g){case"top-right":case"top-left":case"top":k=m-7;break;case"bottom-right":case"bottom-left":case"bottom":k=7-m}switch(g){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 Dst(g,c,m,y,k,E,P,O,B,W,J,ee,ne,ce){const ue=g.layers[0],je=ue.appearances;if(je.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Le={iconBBox:null,iconVerticalBBox:null},Ie={textBBox:null,textVerticalBBox:null},{baseIconRotate:Ge,baseTextRotate:Ye,iconScaleFactor:nt}=function(ft,St,It){const qt=ft.get("icon-rotate").evaluate(St,{},It),is=ft.get("text-rotate").evaluate(St,{},It),[Wt,ms]=ft.get("icon-size-scale-range");return{baseIconRotate:qt,baseTextRotate:is,iconScaleFactor:Se(1,Wt,ms)}}(y,k,E);c&&(Le.iconBBox=$v(c,Le.iconBBox,Ge,P),m)&&(Le.iconVerticalBBox=$v(m,Le.iconVerticalBBox,Ge+90,P));const bt=PO(ee.horizontal);bt&&(Ie.textBBox=$v(bt,Ie.textBBox,Ye,1,ce)),ee.vertical&&(Ie.textVerticalBBox=$v(ee.vertical,Ie.textVerticalBBox,Ye+90,1,ce));for(const ft of je)ft.hasIconProperties()&&Ost(Le,g,ue,ft,k,E,O,Ge,P,B,c,W,nt,J),ft.hasTextProperties()&&Rst(Ie,ue,ft,k,E,ce,Ye,ne,bt,ee.vertical);return{iconBBox:Le.iconBBox,iconVerticalBBox:Le.iconVerticalBBox,textBBox:Ie.textBBox,textVerticalBBox:Ie.textVerticalBBox}}function Ost(g,c,m,y,k,E,P,O,B,W,J,ee,ne,ce){const{appearanceIconOffset:ue,appearanceIconRotate:je,appearanceIconSize:Le}=function(nt,bt,ft,St,It,qt,is,Wt){const ms=nt.hasProperty("icon-offset")?bt.getAppearanceValueAndResolveTokens(nt,"icon-offset",ft,St,[]):null,_s=ms&&Array.isArray(ms)?ms:It,bs=nt.hasProperty("icon-rotate")?bt.getAppearanceValueAndResolveTokens(nt,"icon-rotate",ft,St,[]):null,Os=typeof bs=="number"?bs:qt,Fs=nt.hasProperty("icon-size")?bt.getAppearanceValueAndResolveTokens(nt,"icon-size",ft,St,[]):null;return{appearanceIconOffset:_s,appearanceIconRotate:Os,appearanceIconSize:typeof Fs=="number"?Fs*Wt.iconScaleFactor:is}}(y,m,k,E,P,O,B,W);let Ie=null,Ge=null,Ye=null;y.hasProperty("icon-image")?Ye=function(nt,bt,ft,St,It,qt,is){let Wt=null;const ms=bt.getAppearanceValueAndResolveTokens(ft,"icon-image",St,It,[]);if(ms){const _s=nt.getResolvedImageFromTokens(ms),bs=ft.getUnevaluatedProperty("icon-size"),Os=yA(_s,IC(nt.zoom,bs,nt.worldview),bs,It,nt.zoom,St,nt.pixelRatio,is,nt.worldview);Wt=qt.get(Os.iconPrimary.toString())}return Wt}(c,m,y,k,E,ee,ne):J&&(Ye=J.imagePrimary),Ye&&(Ie=CO(Ye,null,ue,ce),c.allowVerticalPlacement&&(Ge=CO(Ye,null,ue,ce))),Ie&&(g.iconBBox=$v(Ie,g.iconBBox,je,Le)),Ge&&(g.iconVerticalBBox=$v(Ge,g.iconVerticalBBox,je+90,Le))}function Rst(g,c,m,y,k,E,P,O,B,W){const{appearanceTextOffset:J,appearanceTextRotate:ee,appearanceTextSize:ne}=function(ue,je,Le,Ie,Ge,Ye,nt){const bt=ue.hasProperty("text-offset")?je.getAppearanceValueAndResolveTokens(ue,"text-offset",Le,Ie,[]):null,ft=bt&&Array.isArray(bt)?[bt[0]*oc,bt[1]*oc]:Ge,St=ue.hasProperty("text-rotate")?je.getAppearanceValueAndResolveTokens(ue,"text-rotate",Le,Ie,[]):null,It=typeof St=="number"?St:Ye,qt=ue.hasProperty("text-size")?je.getAppearanceValueAndResolveTokens(ue,"text-size",Le,Ie,[]):null;return{appearanceTextOffset:ft,appearanceTextRotate:It,appearanceTextSize:typeof qt=="number"?qt:nt}}(m,c,y,k,E,P,O),ce=ne/O;B&&(g.textBBox=$v(B,g.textBBox,ee,ce,J)),W&&(g.textVerticalBBox=$v(W,g.textVerticalBBox,ee+90,ce,J))}function EO(g,c,m,y,k,E,P,O,B){if(!c||!c.usvg)return;const W=Gke(y),J=Gke(k),ee=E!=="both"&&E!=="width"||!Hke(y)?1:J.width/W.width,ne=E!=="both"&&E!=="height"||!Wke(y)?1:J.height/W.height;m.scaleSelf(ee,ne);const ce=m.toString();P.set(ce,m),O.set(ce,c);const{imagePosition:ue}=rue(ce,c,qb);B.set(ce,ue)}function oNe(g,c,m,y,k,E,P,O,B){if(!g)return;const W=function(J,ee,ne,ce,ue,je){if(J.kind==="camera")return J.maxSize;if(J.kind==="composite"){const Le=ee.possiblyEvaluate(new Di(J.maxZoom,{worldview:je}),ne).evaluate(ue,{},ne),Ie=ee.possiblyEvaluate(new Di(J.minZoom,{worldview:je}),ne).evaluate(ue,{},ne);return Math.max(Le,Ie)}return ee.possiblyEvaluate(new Di(ce,{worldview:je})).evaluate(ue,{},ne)}(c,m,y,k,E,B);return g.scaleSelf(W*O*P)}function yA(g,c,m,y,k,E,P,O,B){return{iconPrimary:oNe(g.getPrimary(),c,m,y,k,E,P,O,B),iconSecondary:oNe(g.getSecondary(),c,m,y,k,E,P,O,B)}}function Fst(g,c,m){if(!c)return;const y=m.get(g.toString()),k=m.get(c.toString());y&&k&&(y.paddedRect.w===k.paddedRect.w&&y.paddedRect.h===k.paddedRect.h||dr(`Mismatch in icon variant sizes: ${g.toString()} and ${c.toString()}`),y.usvg!==k.usvg&&dr(`Mismatch in icon variant image types: ${g.id} and ${c.id}`))}function lNe(g,c,m,y){if(!g)return;const k=c.get(m.toString());if(g.imagePrimary=k,y){const E=c.get(y.toString());g.imageSecondary=E}}function zst(g,c){for(const m in g.horizontal)cNe(g.horizontal[m],c);cNe(g.vertical,c)}function cNe(g,c){if(g){for(const m of g.positionedLines)for(const y of m.positionedGlyphs)if(y.image!==null){const k=y.image.toString();y.rect=c.get(k).paddedRect}}}function oue(g){switch(g){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Bst(g,c,m,y,k,E,P,O,B){const W=PO(E.horizontal)||E.vertical,J=m.get("icon-text-fit-padding").evaluate(y,{},k);let ee,ne=c;return c&&B!=="none"&&(g.allowVerticalPlacement&&E.vertical&&(ee=tue(c,E.vertical,B,J,O,P)),W&&(ne=tue(c,W,B,J,O,P))),{defaultShapedIcon:ne,verticallyShapedIcon:ee}}function $st(g,c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge,Ye,nt,bt,ft,St){let It=P.textMaxSize.evaluate(c,{},ne);It===void 0?It=O*P.textScaleFactor:It*=P.textScaleFactor;const qt=g.layers[0].layout,is=oc,Wt=O*P.textScaleFactor/is,ms=PO(m.horizontal)||m.vertical;if(Le!=="none"&&g.appearanceFeatureData&&c.index18&&Ds>2&&(Ds>>=1),Math.max(Ys/(512*Ds),1)*qt.get("symbol-spacing")),Fs=qt.get("text-padding")*g.tilePixelRatio,Ps=qt.get("icon-padding")*g.tilePixelRatio,Ls=Pr(qt.get("text-max-angle")),hs=qt.get("icon-rotation-alignment")==="map"&&Ye!=="point",cs=Os/2;var Ds;g.hasAnyIconTextFit===!1&&Le!=="none"&&(g.hasAnyIconTextFit=!0);const Xs=c.properties?+c.properties[ds]:null,qs=Xs&&g.elevationFeatureIdToIndex?g.elevationFeatureIdToIndex.get(Xs):65535,Lr=(cr,gr,kr)=>{if(gr.x<0||gr.x>=Ys||gr.y<0||gr.y>=Ys)return;let Hn=null;if(_s){const{x:Us,y:Nr,z:mn}=ce.projectTilePoint(gr.x,gr.y,kr);Hn={anchor:new qy(Us,Nr,mn,0,void 0),up:ce.upVector(kr,gr.x,gr.y)}}(function(Us,Nr,mn,pa,xa,Ln,vi,gt,wt,ps,Rs,nr,ar,Or,zr,Sn,zn,Vn,oa,Jr,un,La,Ba,$a,li,Ni,_i,Ka,Ja,Bn,ga,ro,Yr){const la=Us.addToLineVertexArray(Nr,pa);let wi,Pi,Oi,Ro,Ii,Xr,po,ci=0,Gi=0,kl=0,lc=0,il=-1,ol=-1;const Gl={};let Cu=uv("");const Li=mn?mn.anchor:Nr,Eo=Ka!=="none";let Fo=0,Hu=0;if(wt._unevaluatedLayout.getValue("text-radial-offset")===void 0){const td=wt.layout.get("text-offset").evaluate(un,{},li);Fo=td[0]*oc,Hu=td[1]*oc}else Fo=wt.layout.get("text-radial-offset").evaluate(un,{},li)*oc,Hu=iue;if(Us.allowVerticalPlacement&&xa.vertical){const td=xa.vertical;if(zr)Xr=lue(td),gt&&(po=lue(gt));else{const nu=wt.layout.get("text-rotate").evaluate(un,{},li)+90;Oi=IO(ps,Li,Nr,Rs,nr,ar,td,Or,nu,Sn,ro),gt&&(Ro=IO(ps,Li,Nr,Rs,nr,ar,gt,Vn,nu,null,ga))}}if(Ln){const td=Us.iconSizeData,nu=wt.layout.get("icon-rotate").evaluate(un,{},li),wh=aue(Ln,nu,Ba,Eo,La.iconScaleFactor),Vv=gt?aue(gt,nu,Ba,Eo,La.iconScaleFactor):void 0;Pi=IO(ps,Li,Nr,Rs,nr,ar,Ln,Vn,nu,null,Bn);const UC=function(ig,OA,MSe,Jrt,TSe,ASe,ent,tnt){const ESe=ig.layers[0],PSe=ESe.appearances;let VC=OA.length;if(MSe&&(VC=Math.max(VC,MSe.length)),PSe.length===0)return VC;const[snt,rnt]=Jrt.get("icon-size-scale-range"),nnt=Se(1,snt,rnt);for(const ISe of PSe){const LSe=ISe.getUnevaluatedProperties();if(LSe._values["icon-image"].value!==void 0){const DSe=ESe.getAppearanceValueAndResolveTokens(ISe,"icon-image",TSe,ASe,[]);if(DSe){const OSe=ig.getResolvedImageFromTokens(DSe);if(OSe){const RSe=LSe._values["icon-size"],ant=yA(OSe,IC(ig.zoom,RSe,ig.worldview),RSe,ASe,ig.zoom,TSe,ig.pixelRatio,nnt,ig.worldview),int=ent.get(ant.iconPrimary.toString());VC=Math.max(VC,Tst(int,tnt))}}}}return VC}(Us,wh,Vv,wt.layout,un,li,Us.iconAtlasPositions,Eo);ci=4*UC;let ag=null;td.kind==="source"?(ag=[tg*wt.layout.get("icon-size").evaluate(un,{},li)*La.iconScaleFactor],ag[0]>Uy&&dr(`${Us.layerIds[0]}: Value for "icon-size" is >= ${vA}. Reduce your "icon-size".`)):td.kind==="composite"&&(ag=[tg*La.compositeIconSizes[0].evaluate(un,{},li)*La.iconScaleFactor,tg*La.compositeIconSizes[1].evaluate(un,{},li)*La.iconScaleFactor],(ag[0]>Uy||ag[1]>Uy)&&dr(`${Us.layerIds[0]}: Value for "icon-size" is >= ${vA}. Reduce your "icon-size".`)),Us.addSymbols(Us.icon,wh,ag,Jr,oa,un,void 0,mn,Nr,la.lineStartIndex,la.lineLength,-1,$a,li,Ni,_i,Us.symbolInstances.length,UC),il=Us.icon.placedSymbolArray.length-1,Vv&&(Gi=4*UC,Us.addSymbols(Us.icon,Vv,ag,Jr,oa,un,bh.vertical,mn,Nr,la.lineStartIndex,la.lineLength,-1,$a,li,Ni,_i,Us.symbolInstances.length,UC),ol=Us.icon.placedSymbolArray.length-1)}for(const td in xa.horizontal){const nu=td,wh=xa.horizontal[nu];wi||(Cu=uv(wh.text),zr?Ii=lue(wh):wi=IO(ps,Li,Nr,Rs,nr,ar,wh,Or,wt.layout.get("text-rotate").evaluate(un,{},li),Sn,ro));const Vv=wh.positionedLines.length===1;if(kl+=dNe(Us,mn,Nr,wh,vi,wt,zr,un,Sn,la,xa.vertical?bh.horizontal:bh.horizontalOnly,Vv?Ist(xa.horizontal):[nu],Gl,il,La,$a,li,Us.symbolInstances.length,Ni),Vv)break}xa.vertical&&(lc+=dNe(Us,mn,Nr,xa.vertical,vi,wt,zr,un,Sn,la,bh.vertical,["vertical"],Gl,ol,La,$a,li,Us.symbolInstances.length,Ni));let Nl=-1;const Fp=(td,nu)=>td?Math.max(td,nu):nu;Nl=Fp(Ii,Nl),Nl=Fp(Xr,Nl),Nl=Fp(po,Nl);const bx=Nl>-1?1:0;Us.glyphOffsetArray.length>=65535&&dr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),un.sortKey!==void 0&&Us.addToSortKeyRanges(Us.symbolInstances.length,un.sortKey),Us.symbolInstances.emplaceBack(Nr.x,Nr.y,Li.x,Li.y,Li.z,Gl.right>=0?Gl.right:-1,Gl.center>=0?Gl.center:-1,Gl.left>=0?Gl.left:-1,Gl.vertical>=0?Gl.vertical:-1,il,ol,Cu,wi!==void 0?wi:Us.collisionBoxArray.length,wi!==void 0?wi+1:Us.collisionBoxArray.length,Oi!==void 0?Oi:Us.collisionBoxArray.length,Oi!==void 0?Oi+1:Us.collisionBoxArray.length,Pi!==void 0?Pi:Us.collisionBoxArray.length,Pi!==void 0?Pi+1:Us.collisionBoxArray.length,Ro||Us.collisionBoxArray.length,Ro?Ro+1:Us.collisionBoxArray.length,Rs,kl,lc,ci,Gi,bx,0,Fo,Hu,Nl,0,Eo?1:0,Ja)})(g,gr,Hn,cr,m,y,E,k,g.layers[0],g.collisionBoxArray,c.index,c.sourceLayerIndex,g.index,Fs,Ge,W,0,Ps,hs,Ie,c,P,J,ee,ne,ue,je,Le,qs,nt,bt,ft)};if(Ye==="line")for(const cr of pO(c.geometry,0,0,Ys,Ys)){const gr=Mst(cr,Os,Ls,m.vertical||ms,y,is,bs,g.overscaling,Ys);for(const kr of gr)ms&&qst(g,ms.text,cs,kr)||Lr(cr,kr,ne)}else if(Ye==="line-center"){for(const cr of c.geometry)if(cr.length>1){const gr=Cst(cr,Ls,m.vertical||ms,y,is,bs);gr&&Lr(cr,gr,ne)}}else if(c.type==="Polygon")for(const cr of tA(c.geometry,0)){const gr=Est(cr,16);Lr(cr[0],new qy(gr.x,gr.y,0,0,void 0),ne)}else if(c.type==="LineString")for(const cr of c.geometry)Lr(cr,new qy(cr[0].x,cr[0].y,0,0,void 0),ne);else if(c.type==="Point")for(const cr of c.geometry)for(const gr of cr)Lr([gr],new qy(gr.x,gr.y,0,0,void 0),ne)}const vA=255,Uy=vA*tg;function dNe(g,c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge){const Ye=function(ft,St,It,qt,is,Wt,ms,_s){const bs=[];if(St.positionedLines.length===0)return bs;const Os=qt.layout.get("text-rotate").evaluate(Wt,{})*Math.PI/180,Fs=function(Ds){const Xs=Ds[0],qs=Ds[1],Lr=Xs*qs;return Lr>0?[Xs,-qs]:Lr<0?[-Xs,qs]:Xs===0?[qs,Xs]:[qs,-Xs]}(It);let Ps=Math.abs(St.top-St.bottom);for(const Ds of St.positionedLines)Ps-=Ds.lineOffset;const Ls=St.positionedLines.length,hs=Ps/Ls;let cs=St.top-It[1];for(let Ds=0;DsUy&&dr(`${g.layerIds[0]}: Value for "text-size" is >= ${vA}. Reduce your "text-size".`)):nt.kind==="composite"&&(bt=[tg*ue.compositeTextSizes[0].evaluate(O,{},Le)*ue.textScaleFactor,tg*ue.compositeTextSizes[1].evaluate(O,{},Le)*ue.textScaleFactor],(bt[0]>Uy||bt[1]>Uy)&&dr(`${g.layerIds[0]}: Value for "text-size" is >= ${vA}. Reduce your "text-size".`)),g.addSymbols(g.text,Ye,bt,B,P,O,J,c,m,W.lineStartIndex,W.lineLength,ce,je,Le,Ge,!1,Ie,Ye.length);for(const ft of ee)ne[ft]=g.text.placedSymbolArray.length-1;return 4*Ye.length}function PO(g){for(const c in g)return g[c];return null}function IO(g,c,m,y,k,E,P,O,B,W,J){let ee,ne,ce,ue;if(ee=J?J.top:P.top,ne=J?J.bottom:P.bottom,ce=J?J.left:P.left,ue=J?J.right:P.right,eue(P)&&P.collisionPadding){const je=P.collisionPadding;ce-=je[0],ee-=je[1],ue+=je[2],ne+=je[3]}if(B){const je=new es(ce,ee),Le=new es(ue,ee),Ie=new es(ce,ne),Ge=new es(ue,ne),Ye=Pr(B);let nt=new es(0,0);W&&(nt=new es(W[0],W[1])),je._rotateAround(Ye,nt),Le._rotateAround(Ye,nt),Ie._rotateAround(Ye,nt),Ge._rotateAround(Ye,nt),ce=Math.min(je.x,Le.x,Ie.x,Ge.x),ue=Math.max(je.x,Le.x,Ie.x,Ge.x),ee=Math.min(je.y,Le.y,Ie.y,Ge.y),ne=Math.max(je.y,Le.y,Ie.y,Ge.y)}return g.emplaceBack(c.x,c.y,c.z,m.x,m.y,ce,ee,ue,ne,O,y,k,E),g.length-1}function lue(g){eue(g)&&g.collisionPadding&&(g.top-=g.collisionPadding[1],g.bottom+=g.collisionPadding[3]);const c=g.bottom-g.top;return c>0?Math.max(10,c):null}function qst(g,c,m,y){const k=g.compareText;if(c in k){const E=k[c];for(let P=E.length-1;P>=0;P--)if(y.dist(E[P])Ye&&(nt(ft,bs,It,qt,ms,_s),nt(bs,St,ms,_s,is,Wt))}nt(ee,ne,y,E,k,E),nt(ne,ce,k,E,k,P),nt(ce,ue,k,P,y,P),nt(ue,ee,y,P,y,E),je-=Ye,Le-=Ye,Ie+=Ye,Ge+=Ye;const bt=1/Math.max(Ie-je,Ge-Le);return{scale:bt,x:je*bt,y:Le*bt,x2:Ie*bt,y2:Ge*bt,projection:c}}function hNe(g,{x:c,y:m},y=0){return new es(((c-y)*g.scale-g.x)*Ys,(m*g.scale-g.y)*Ys)}const Ust=w(new Float32Array(16));class qv{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 uNe(c,c.pixelsPerMeter)}pointCoordinate(c,m,y,k){const E=c.horizonLineFromTop(!1),P=new es(m,Math.max(E,y));return c.rayIntersectionCoordinate(c.pointRayIntersection(P,k))}pointCoordinate3D(c,m,y){const k=new es(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<-RC+y&&(m=-RC+y):m>RC-y&&(m=RC-y);const P=E/Math.pow(DO(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(ii(B/y)+this.center[0],-180,180),J=Se(ii(2*Math.atan(Math.pow(k/O,1/y))-RC),-xe,xe);return new x(W,this.southernCenter?-J:J)}}class mNe extends qv{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:H(c),y:Q(m),z:0}}unproject(c,m){const y=oe(c),k=ge(m);return new x(y,k)}}const pNe=Pr(xe);class Kst extends qv{project(c,m){const y=(m=Pr(m))*m,k=y*y;return{x:.5*((c=Pr(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,-pNe,pNe)}while(Math.abs(E)>1e-6&&--k>0);P=y*y;const O=Se(ii(c/(.8707+P*(P*(P*P*P*(.003971-.001529*P)-.013791)-.131979))),-180,180),B=ii(y);return new x(O,B)}}const fNe=Pr(xe);class Zst extends qv{project(c,m){m=Pr(m),c=Pr(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,ce=W*W,ue=Math.cos(y/2),je=Math.sin(y/2),Le=2*ue*je,Ie=je*je,Ge=1-ce*ue*ue,Ye=Ge?1/Ge:0,nt=Ge?Math.acos(W*ue)*Math.sqrt(1/Ge):0,bt=.5*(2*nt*W*je+2*y/Math.PI)-c,ft=.5*(nt*J+k)-m,St=.5*Ye*(ce*Ie+nt*W*ue*ne)+1/Math.PI,It=Ye*(Le*ee/4-nt*J*je),qt=.125*Ye*(ee*je-nt*J*ce*Le),is=.5*Ye*(ne*ue+nt*Ie*W)+.5,Wt=It*qt-is*St;O=(ft*It-bt*is)/Wt,B=(bt*qt-ft*St)/Wt,y=Se(y-O,-Math.PI,Math.PI),k=Se(k-B,-fNe,fNe)}while((Math.abs(O)>P||Math.abs(B)>P)&&--E>0);return new x(ii(y),ii(k))}}class gNe extends qv{constructor(c){super(c),this.center=c.center||[0,0],this.parallels=c.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Pr(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:Pr(c)*k*y+.5,y:-Math.sin(Pr(m))/k*y+.5,z:0}}unproject(c,m){const{scale:y,cosPhi:k}=this,E=-(m-.5)/y,P=Se(ii((c-.5)/y)/k,-180,180),O=Math.asin(Se(E*k,-1,1)),B=Se(ii(O),-xe,xe);return new x(P,B)}}class Yst extends mNe{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=ZT(c,m,y);return Dt(k,k,aO(Ym(y))),{x:k[0],y:k[1],z:k[2]}}locationPoint(c,m,y){const k=Dv(m.lat,m.lng),E=Ae([],k),P=y?c._centerAltitude+y:c.elevation?c.elevation.getAtPointOrZero(c.locationCoordinate(m),c._centerAltitude):c._centerAltitude;Ze(k,k,E,re(1,0)*Ys*P);const O=w(new Float64Array(16));return C(O,c.pixelMatrix,c.globeMatrix),Dt(k,k,O),new es(k[0],k[1])}pixelsPerMeter(c,m){return re(1,0)*m}pixelSpaceConversion(c,m,y){const k=re(1,c)*m,E=Hr(re(1,45)*m,k,y);return this.pixelsPerMeter(c,m)/E}createTileMatrix(c,m,y){const k=mde(Ym(y.canonical));return C(new Float64Array(16),c.globeMatrix,k)}createInversionMatrix(c,m){const{center:y}=c,k=aO(Ym(m));return R(k,k,Pr(y.lng)),L(k,k,Pr(y.lat)),I(k,k,[c._pixelsPerMercatorPixel,c._pixelsPerMercatorPixel,1]),Float32Array.from(k)}pointCoordinate(c,m,y,k){return Rv(c,m,y,!0)||new et(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!Rv(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=le([],ke([],W,-P),[0,0,O]),ee=k.worldSize/(2*Math.PI),ne=[0,0,-ee],ce=k.width/k.height,ue=Math.tan(k.fovAboveCenter),je=ke([],B.up(),ue),Le=ke([],B.right(),ue*ce),Ie=Ae([],le([],le([],W,je),Le)),Ge=[];let Ye;if(new jr(J,Ie).closestPointOnSphere(ne,ee,Ge)){const nt=le([],Ge,ne),bt=Ne([],nt,J);Ye=Math.cos(k.fovAboveCenter)*de(bt)}else{const nt=Ne([],J,ne),bt=Ne([],ne,J);Ae(bt,bt);const ft=de(nt)-ee;Ye=Math.sqrt(ft*(ft+2*ee));const St=Math.acos(Ye/(ee+ft))-Math.acos(We(W,bt));Ye*=Math.cos(St)}return 1.01*Ye}(c,this.pixelsPerMeter(c.center.lat,c.worldSize)),y=Fv(c.zoom);if(y>0){const k=uNe(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 Hr(m,k+E*(1-Math.cos(P)),Math.pow(y,10))}return m}upVector(c,m,y){return ZT(m,y,c,1)}upVectorScale(c){return{metersToTile:Op(nO(Ym(c)))}}}function xNe(g){const c=g.parallels,m=!!c&&Math.abs(c[0]+c[1])<.01;switch(g.name){case"mercator":return new mNe(g);case"equirectangular":return new Wst(g);case"naturalEarth":return new Kst(g);case"equalEarth":return new Hst(g);case"winkelTripel":return new Zst(g);case"albers":return m?new gNe(g):new Vst(g);case"lambertConformalConic":return m?new gNe(g):new Gst(g);case"globe":return new Yst(g)}throw new Error(`Invalid projection name: ${g.name}`)}const Xst=Vt.types,Qst=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function NA(g,c,m,y,k,E,P,O,B,W,J,ee,ne){const ce=O?Math.min(Uy,Math.round(O[0])):0,ue=O?Math.min(Uy,Math.round(O[1])):0;g.emplaceBack(c,m,Math.round(32*y),Math.round(32*k),E,P,(ce<<1)+(B?1:0),0+(ue<<1),16*W,16*J,256*ee,256*ne)}function SA(g,c,m){g.emplaceBack(c,m)}function CA(g,c,m,y,k,E,P){g.emplaceBack(c,m,y,k,E,P)}const OO=(g,c,m,y)=>{for(let k=0;k0&&(this.iconTransitioningVertexBuffer=c.createVertexBuffer(this.iconTransitioningVertexArray,ist.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,sst.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||E)&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,nst.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=c.createVertexBuffer(this.orientationVertexArray,ast.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(cue,"SymbolBuffers");class due{constructor(c,m,y){this.layoutVertexArray=new c,this.layoutAttributes=m,this.indexArray=new y,this.segments=new uo,this.collisionVertexArray=new LT,this.collisionVertexArrayExt=new fx}upload(c){this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=c.createVertexBuffer(this.collisionVertexArray,ost.members,!0),this.collisionVertexBufferExt=c.createVertexBuffer(this.collisionVertexArrayExt,lst.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}vr(due,"CollisionBuffers");class RO{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=w([]),this.placementViewportMatrix=w([]);const m=this.layers[0]._unevaluatedLayout._values;this.worldview=c.worldview,this.localizable=c.localizable,this.textSizeData=IC(this.zoom,m["text-size"],this.worldview),this.iconSizeData=IC(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=>bh[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 cue(new Km(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("text")||c.startsWith("symbol"))),this.icon=new cue(new Km(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("icon")||c.startsWith("symbol"))),this.glyphOffsetArray=new fC,this.lineVertexArray=new JD,this.symbolInstances=new $T}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=pA[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=IC(this.zoom,B,this.worldview),J=LC(W,m);if(W.kind!=="constant"&&W.kind!=="camera"||(O=J.uSize),W.kind==="composite"){const{minZoom:ee,maxZoom:ne}=W,ce=B.possiblyEvaluate(new Di(ee,{worldview:this.worldview}),k),ue=B.possiblyEvaluate(new Di(ne,{worldview:this.worldview}),k),je=ce.evaluate(y,{},k,E);O=je+(ue.evaluate(y,{},k,E)-je)*J.uSizeT}return W.kind==="source"&&(O=B.possiblyEvaluate(new Di(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!uO(this.activeReplacements,y)&&(this.activeReplacements=y,!0)}getResolvedImageFromTokens(c){return typeof c=="string"?Jd.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"),ce=Se(m.scaleFactor||1,ee,ne),ue=(W.value.kind!=="constant"||W.value.value instanceof Qd&&!W.value.value.isEmpty()||W.value.value.toString().length>0)&&(B.value.kind!=="constant"||B.value.value.length>0),je=J.value.kind!=="constant"||!!J.value.value||Object.keys(J.parameters).length>0,Le=this.hasAnyAppearanceProperty("icon-image"),Ie=P.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!ue&&!je&&!Le)return;const Ge=m.iconDependencies,Ye=m.glyphDependencies,nt=m.availableImages,bt=new Di(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ft=St=>{const It=St.id.toString();Ge.has(It)?Ge.get(It).push(St):Ge.set(It,[St])};for(const St of c){const{feature:It,id:qt,index:is,sourceLayerIndex:Wt}=St,ms=E._featureFilter.needGeometry,_s=Ht(It,ms);if(!E._featureFilter.filter(bt,_s,y))continue;if(ms||(_s.geometry=Et(It,y,k)),O&&It.type!==1&&y.z<=5){const Ds=_s.geometry,Xs=.98078528056,qs=(Lr,cr)=>We(ZT(Lr.x,Lr.y,y,1),ZT(cr.x,cr.y,y,1)){if(!Ds.getProperty("icon-image"))return;const Xs=this.getCombinedIconPrimary(Ds,Fs,_s,y,nt,hs,ce);Xs&&ft(Xs)}),bs){const Ds=B.evaluate(_s,{},y).join(","),Xs=P.get("text-rotation-alignment")==="map"&&P.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(bh.vertical)>=0;for(const qs of bs.sections)if(qs.image){const Lr=qs.image.getPrimary().scaleSelf(this.pixelRatio),cr=Lr.id.toString(),gr=Ge.get(cr)||[];gr.push(Lr),Ge.set(cr,gr)}else{const Lr=jb(bs.toString()),cr=qs.fontStack||Ds,gr=Ye[cr]=Ye[cr]||{};this.calculateGlyphDependencies(qs.text,gr,Xs,this.allowVerticalPlacement,Lr)}}}if(P.get("symbol-placement")==="line"&&(this.features=function(St){const It={},qt={},is=[];let Wt=0;function ms(Fs){is.push(St[Fs]),Wt++}function _s(Fs,Ps,Ls){const hs=qt[Fs];return delete qt[Fs],qt[Ps]=hs,is[hs].geometry[0].pop(),is[hs].geometry[0]=is[hs].geometry[0].concat(Ls[0]),hs}function bs(Fs,Ps,Ls){const hs=It[Ps];return delete It[Ps],It[Fs]=hs,is[hs].geometry[0].shift(),is[hs].geometry[0]=Ls[0].concat(is[hs].geometry[0]),hs}function Os(Fs,Ps,Ls){const hs=Ls?Ps[0][Ps[0].length-1]:Ps[0][0];return`${Fs}:${hs.x}:${hs.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,It)=>St.sortKey-It.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=yA(B,IC(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 Le=je.id,Ie=m&&Le!==void 0?m[String(Le)]:void 0,Ge={type:"Point",id:je.id,properties:je.properties,geometry:[]},Ye=this.layers[0].appearances&&this.layers[0].appearances.find(nt=>nt.isActive({globals:k,feature:Ge,canonical:c,featureState:Ie}));if(je.activeAppearance===Ye){O+=ce.numIconVertices;continue}if(Ye){je.activeAppearance=Ye;const nt=this.getCombinedIconPrimary(Ye,E,Ge,c,y,{sortKey:void 0,text:void 0,icon:null,index:ce.featureIndex,sourceLayerIndex:ce.featureIndex,geometry:[],properties:je.properties,type:"Point",id:je.id},ee);if(!nt)continue;const bt=nt.toString(),ft=this.iconAtlasPositions&&this.iconAtlasPositions.get(bt);if(ft){const St=E.getAppearanceValueAndResolveTokens(Ye,"icon-offset",Ge,c,y),It=St&&Array.isArray(St)?St:[0,0];let qt=CO(ft,void 0,It,E.layout.get("icon-anchor").evaluate(Ge,{},c));const is=E.getAppearanceValueAndResolveTokens(Ye,"icon-rotate",Ge,c,y),Wt=typeof is=="number"?is:0,ms=ft.sdf,_s=E.layout.get("icon-text-fit").constantOr("none");_s!=="none"&&je.textShaping&&je.iconTextFitPadding&&je.fontScale&&(qt=tue(qt,je.textShaping,_s,je.iconTextFitPadding,It,je.fontScale));const bs=this.calculateEffectiveAppearanceIconSize(Ye,k.zoom,Ge,c,y,ee),Os=0,Fs=1+(Math.min(Uy,Math.round(bs*tg))<<1),Ps=aue(qt,Wt,ms,_s!=="none",ee);je.isUsingAppearanceVertexData||(je.isUsingAppearanceVertexData=!0,je.layoutBasedVertexData=this.icon.getIconVertexData(O,ce.numIconVertices));for(let hs=0;hs0&&(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+=ce.numIconVertices,je.activeAppearance=null;else if(je.isUsingAppearanceVertexData){const bt=je.layoutBasedVertexData.length/12;for(let ft=0;ft0||ne>0,Le=ce>0,Ie=this.elevationFeatures[B.elevationFeatureIndex];if(Ie){const Ge=new es(B.tileAnchorX,B.tileAnchorY),Ye=.075+Ie.pointElevation(Ge);B.zOffset!==Ye&&(m=!0,B.zOffset=Ye),Ye!==0&&(this.hasAnyZOffset=!0);const nt=Ie.computeSlopeNormal(Ge,k),bt=as(Ue(),ie(0,0,1),nt);Qe(W,W,bt),Qe(J,J,bt),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||je,P=P||Le)}if(je&&(OO(this.text.orientationVertexArray,ee,W,J),OO(this.text.orientationVertexArray,ne,W,J)),Le){const{placedIconSymbolIndex:Ge,verticalPlacedIconSymbolIndex:Ye}=B;Ge>=0&&OO(this.icon.orientationVertexArray,ce,W,J),Ye>=0&&OO(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:ce}=P;ne>=0&&m(this.icon.zOffsetVertexArray,W,J),ce>=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=xNe(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,ce,ue,je,Le,Ie,Ge){const Ye=c.indexArray,nt=c.layoutVertexArray,bt=c.globeExtVertexArray,ft=c.segments.prepareSegment(4*Ge,nt,Ye,this.canOverlap?P.sortKey:void 0),St=this.glyphOffsetArray.length,It=ft.vertexLength,qt=this.allowVerticalPlacement&&O===bh.vertical?Math.PI/2:0,is=P.text&&P.text.sections;for(let _s=0;_s=0?m.rightJustifiedTextSymbolIndex:m.centerJustifiedTextSymbolIndex>=0?m.centerJustifiedTextSymbolIndex:m.leftJustifiedTextSymbolIndex>=0?m.leftJustifiedTextSymbolIndex:m.verticalPlacedTextSymbolIndex>=0?m.verticalPlacedTextSymbolIndex:k),P=sue(this.textSizeData,c,E)/oc;return this.tilePixelRatio*P}getSymbolInstanceIconSize(c,m,y){const k=this.icon.placedSymbolArray.get(y),E=sue(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 g?String(g[y]):"")}let vNe,_Ne,uue;vr(RO,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),RO.addDynamicAttributes=FC;class bNe{constructor(c){this.type=c.property.overrides?c.property.overrides.runtimeType:Um,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(bNe,"FormatSectionOverride",{omit:["defaultValue"]});const hue=()=>uue||(uue={layout:vNe||(vNe=new wo({"symbol-placement":new Hs(Gt.layout_symbol["symbol-placement"]),"symbol-spacing":new Hs(Gt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Hs(Gt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new rr(Gt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Hs(Gt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Hs(Gt.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Hs(Gt.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Hs(Gt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Hs(Gt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Hs(Gt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Hs(Gt.layout_symbol["icon-rotation-alignment"]),"icon-size":new rr(Gt.layout_symbol["icon-size"]),"icon-size-scale-range":new Hs(Gt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new rr(Gt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new rr(Gt.layout_symbol["icon-text-fit-padding"]),"icon-image":new rr(Gt.layout_symbol["icon-image"]),"icon-image-use-theme":new Hs({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new rr(Gt.layout_symbol["icon-rotate"]),"icon-padding":new Hs(Gt.layout_symbol["icon-padding"]),"icon-keep-upright":new Hs(Gt.layout_symbol["icon-keep-upright"]),"icon-offset":new rr(Gt.layout_symbol["icon-offset"]),"icon-anchor":new rr(Gt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Hs(Gt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Hs(Gt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Hs(Gt.layout_symbol["text-rotation-alignment"]),"text-field":new rr(Gt.layout_symbol["text-field"]),"text-font":new rr(Gt.layout_symbol["text-font"]),"text-size":new rr(Gt.layout_symbol["text-size"]),"text-size-scale-range":new Hs(Gt.layout_symbol["text-size-scale-range"]),"text-max-width":new rr(Gt.layout_symbol["text-max-width"]),"text-line-height":new rr(Gt.layout_symbol["text-line-height"]),"text-letter-spacing":new rr(Gt.layout_symbol["text-letter-spacing"]),"text-justify":new rr(Gt.layout_symbol["text-justify"]),"text-radial-offset":new rr(Gt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Hs(Gt.layout_symbol["text-variable-anchor"]),"text-anchor":new rr(Gt.layout_symbol["text-anchor"]),"text-max-angle":new Hs(Gt.layout_symbol["text-max-angle"]),"text-writing-mode":new Hs(Gt.layout_symbol["text-writing-mode"]),"text-rotate":new rr(Gt.layout_symbol["text-rotate"]),"text-padding":new Hs(Gt.layout_symbol["text-padding"]),"text-keep-upright":new Hs(Gt.layout_symbol["text-keep-upright"]),"text-transform":new rr(Gt.layout_symbol["text-transform"]),"text-offset":new rr(Gt.layout_symbol["text-offset"]),"text-allow-overlap":new Hs(Gt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Hs(Gt.layout_symbol["text-ignore-placement"]),"text-optional":new Hs(Gt.layout_symbol["text-optional"]),visibility:new Hs(Gt.layout_symbol.visibility)})),paint:_Ne||(_Ne=new wo({"icon-opacity":new rr(Gt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new rr(Gt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new rr(Gt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new rr(Gt.paint_symbol["text-emissive-strength"]),"icon-color":new rr(Gt.paint_symbol["icon-color"]),"icon-halo-color":new rr(Gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new rr(Gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new rr(Gt.paint_symbol["icon-halo-blur"]),"icon-translate":new Hs(Gt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Hs(Gt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Hs(Gt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new rr(Gt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new rr(Gt.paint_symbol["text-occlusion-opacity"]),"text-color":new rr(Gt.paint_symbol["text-color"],{runtimeType:ju,getOverride:g=>g.textColor,hasOverride:g=>!!g.textColor}),"text-halo-color":new rr(Gt.paint_symbol["text-halo-color"]),"text-halo-width":new rr(Gt.paint_symbol["text-halo-width"]),"text-halo-blur":new rr(Gt.paint_symbol["text-halo-blur"]),"text-translate":new Hs(Gt.paint_symbol["text-translate"]),"text-translate-anchor":new Hs(Gt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Hs(Gt.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Hs(Gt.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Hs(Gt.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Hs(Gt.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new rr(Gt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"})}))},uue);class FO extends su{constructor(c,m,y,k){super(c,hue(),m,y,k,c.layout?c.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=w([]),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=Ji(E),P=ba(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],ce=.5-.5*P,ue=B-O;return C(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,ce,ce,ce,1]),C(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()||bb(P.value)||!E?E:yNe(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()||bb(B.value)||!O||typeof O!="string"?O:yNe(y.properties,O)}createBucket(c){return new RO(c)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const c of hue().paint.overridableProperties){if(!FO.hasPaintOverride(this.layout,c))continue;const m=this.paint.get(c),y=new bNe(m),k=new HS(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 Sv("source",k):new Ay("composite",k,m.value.zoomStops,m.value.interpolationType),this.paint._values[c]=new Py(m.property,E,m.parameters)}}_handleOverridablePaintPropertyUpdate(c,m,y){return!(!this.layout||m.isDataDriven()||y.isDataDriven())&&FO.hasPaintOverride(this.layout,c)}static hasPaintOverride(c,m){const y=c.get("text-field"),k=hue().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 Qd)P(y.value.value.sections);else if(y.value.kind==="source"){const O=W=>{E||(W instanceof zf&&ic(W.value)===ib?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 xx(this,{zoom:m,lut:y}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let wNe,jNe,kNe,NNe;var mue=ia([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function zO(g,c,m,y,k,E,P,O){const B=[g,c,1,m,y,1,k,E,1],W=[P,O,1],J=v([],B),[ee,ne,ce]=he(W,W,J);return _(B,B,[ee,0,0,0,ne,0,0,0,ce])}function SNe(g,c,m,y,k,E,P,O){const B=function(W,J,ee,ne,ce,ue,je,Le){const Ie=zO(0,0,1,0,1,1,0,1),Ge=zO(W,J,ee,ne,ce,ue,je,Le);return _(Ge,Ge,v([],Ie))}(g,c,m,y,k,E,P,O);return[B[2]/B[8]/Ys,B[5]/B[8]/Ys]}function BO(g){return[g[0],Math.min(Math.max(g[1],-xe),xe)]}class CNe extends Ts{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 rm("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return c&&(this.coordinates=c),this._loaded=!0,void this._finishLoading();this._imageRequest=tx(this.map._requestManager.transformRequest(this.url,Df.Image),(y,k)=>{this._imageRequest=null,this._loaded=!0,y?this.fire(new sx(y)):k&&(this.image=k instanceof HTMLImageElement?_l.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 uA(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 rm("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 uA||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]xe?this.onNorthPole=!0:k<-xe&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const E=c.map(et.fromLngLat);this.tileID=function(P){let O=1/0,B=1/0,W=-1/0,J=-1/0;for(const je of P)O=Math.min(O,je.x),B=Math.min(B,je.y),W=Math.max(W,je.x),J=Math.max(J,je.y);const ee=Math.max(W-O,J-B),ne=Math.max(0,Math.floor(-Math.log2(ee))),ce=Math.pow(2,ne);let ue=Math.floor((O+W)/2*ce);return ue>1&&(ue-=1),new ki(ne,ue,Math.floor((B+J)/2*ce))}(E),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new rm("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof uA||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(c){for(const Ie in this.tiles){const Ge=this.tiles[Ie];Ge.state!=="loaded"&&(Ge.state="loaded",Ge.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const m=_A(new ki(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(Ie){const Ge=Ie[1].x-Ie[0].x,Ye=Ie[1].y-Ie[0].y,nt=Ie[2].x-Ie[1].x,bt=Ie[2].y-Ie[1].y,ft=Ie[3].x-Ie[2].x,St=Ie[3].y-Ie[2].y,It=Ie[0].x-Ie[3].x,qt=Ie[0].y-Ie[3].y,is=Ge*bt-nt*Ye,Wt=nt*St-ft*bt,ms=ft*qt-It*St,_s=It*Ye-Ge*qt;return is>0&&Wt>0&&ms>0&&_s>0||is<0&&Wt<0&&ms<0&&_s<0}(y))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const k=_A(this.tileID,this.map.transform.projection),[E,P,O,B]=this.coordinates.map(Ie=>{const Ge=k.projection.project(Ie[0],Ie[1]);return hNe(k,Ge)._round()});this.perspectiveTransform=SNe(E.x,E.y,P.x,P.y,O.x,O.y,B.x,B.y);const W=this._boundsArray=new Av;W.emplaceBack(E.x,E.y,0,0),W.emplaceBack(P.x,P.y,Ys,0),W.emplaceBack(B.x,B.y,0,Ys),W.emplaceBack(O.x,O.y,Ys,Ys),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=c.createVertexBuffer(W,mue.members),this.boundsSegments=uo.simpleSegment(0,0,4,2);const J=[],ee=[BO((ne=this.coordinates)[0]),BO(ne[1]),BO(ne[2]),BO(ne[3])];var ne;const[ce,ue,je,Le]=function(Ie){let Ge=Ie[0][0],Ye=Ge,nt=Ie[0][1],bt=nt;for(let ft=1;ftYe&&(Ye=Ie[ft][0]),Ie[ft][1]bt&&(bt=Ie[ft][1]);return[Ge,nt,Ye-Ge,bt-nt]}(ee);{const Ie=new Av,[Ge,Ye,nt,bt]=function(Ps){let Ls=Ps[0].x,hs=Ls,cs=Ps[0].y,Ds=cs;for(let Xs=1;Xshs&&(hs=Ps[Xs].x),Ps[Xs].yDs&&(Ds=Ps[Xs].y);return[Ls,cs,hs-Ls,Ds-cs]}(y),ft=Ps=>[(Ps.x-Ge)/nt,(Ps.y-Ye)/bt],[St,It,qt,is]=y.map(ft),Wt=function(Ps,Ls,hs,cs,Ds,Xs,qs,Lr){const cr=zO(0,0,1,0,1,1,0,1);return _(cr,cr,v([],zO(Ps,Ls,hs,cs,Ds,Xs,qs,Lr)))}(St[0],St[1],It[0],It[1],qt[0],qt[1],is[0],is[1]);this.elevatedGlobePerspectiveTransform=SNe(St[0],St[1],It[0],It[1],qt[0],qt[1],is[0],is[1]);const ms=(Ps,Ls)=>{J.push(Ps.lng);const hs=Math.round((Ps.lng-ce)/je*Ys),cs=Math.round((Ps.lat-ue)/Le*Ys),Ds=ft(Ls),Xs=he([],[Ds[0],Ds[1],1],Wt),qs=Math.round(Xs[0]/Xs[2]*Ys),Lr=Math.round(Xs[1]/Xs[2]*Ys);Ie.emplaceBack(hs,cs,qs,Lr)},_s=y[3].x-y[0].x,bs=y[3].y-y[0].y,Os=y[2].x-y[1].x,Fs=y[2].y-y[1].y;for(let Ps=0;Ps<65;Ps++){const Ls=Ps/64,hs=[y[0].x+Ls*_s,y[0].y+Ls*bs],cs=[y[1].x+Ls*Os,y[1].y+Ls*Fs],Ds=cs[0]-hs[0],Xs=cs[1]-hs[1];for(let qs=0;qs<65;qs++){const Lr=qs/64,cr={x:hs[0]+Ds*Lr,y:hs[1]+Xs*Lr};ms(m.projection.unproject(cr.x,cr.y),cr)}}this.elevatedGlobeVertexBuffer=c.createVertexBuffer(Ie,mue.members)}{this.maxLongitudeTriangleSize=0;let Ie=[],Ge=new bl;const Ye=(nt,bt,ft)=>{Ge.emplaceBack(nt,bt,ft);const St=J[nt],It=J[bt],qt=J[ft],is=Math.min(Math.min(St,It),qt),Wt=Math.max(Math.max(St,It),qt)-is;Wt>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Wt),Ie.push(is+Wt/2)};for(let nt=0;nt<64;nt++)for(let bt=0;bt<64;bt++){const ft=65*nt+bt,St=ft+1,It=ft+65,qt=It+1;Ye(ft,It,St),Ye(St,It,qt)}[Ie,Ge]=function(nt,bt){const ft=Array.from({length:nt.length},(qt,is)=>is);ft.sort((qt,is)=>nt[qt]-nt[is]);const St=[],It=new bl;for(let qt=0;qt{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=Qi(y,0,y.length,k+B);return ee===y.length||O(ee,Wo(y,ee+1,y.length,k+360-B)-ee),P}kYs?k-Ys:k,new es(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 gue{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 Di(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:{}},ce=this.addFeature(ne,ne.geometry,ee);ce&&m.featureIndex.insert(P,ne.geometry,B,W,this.index,this.instancesPerModel[ce].instancedDataArray.length,Ys/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*_e(E.aabb.max,E.aabb.min)*P.maxScale+P.maxXYTranslationDistance,B=Math.min(Ys,Math.max(O/this.tileToMeter,Ys/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(uO(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 ce=0;ceYs;je=Le?je-Ys:je;const Ie=Math.floor(je),Ge=Math.floor(W.float32[ue+1]);let Ye=!1;for(const nt of this.activeReplacements)if(!jje(nt,y,DNe.Model,k)&&!(nt.min.x>Ie||Ie>nt.max.x||nt.min.y>Ge||Ge>nt.max.y)&&(Ye=Mje(Cje(Ie,Ge,c.canonical,nt.footprintTileId.canonical),nt.footprint),Ye))break;W.float32[ue]=Ye?je+Ys:je,P=P||Ye!==Le}}}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,ktt.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 dr(`modelId is not evaluated for layer ${k.id} and it is not going to get rendered.`),E;(fue(E,!1)||this.styleDefinedModelURLs[E]!==void 0)&&(this.modelUris.includes(E)||this.modelUris.push(E)),this.instancesPerModel[E]||(this.instancesPerModel[E]=new RNe);const P=this.instancesPerModel[E],O=P.instancedDataArray,B=new ONe(y,O.length);for(const W of m)for(const J of W){if(J.x<0||J.x>=Ys||J.y<0||J.y>=Ys)continue;if(this.lookupDim!==0){const ne=(this.lookupDim-1)/Ys,ce=this.lookupDim*(J.y*ne|0)+J.x*ne|0;if(this.lookup){if(this.lookup[ce]!==0)continue;this.lookup[ce]=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(ce):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])),pke(ne,B,W);const je=Math.round(100*ee.a)+ee.b/1.05;for(let Le=0;Le10?this.tileToMeter:Be(O,bt)),Ye[Ge+4]=J[0],Ye[Ge+5]=J[1],Ye[Ge+6]=J[2]+nt,Ye[Ge+7]=ne[0],Ye[Ge+8]=ne[1],Ye[Ge+9]=ne[2],Ye[Ge+10]=ne[4],Ye[Ge+11]=ne[5],Ye[Ge+12]=ne[6],Ye[Ge+13]=ne[8],Ye[Ge+14]=ne[9],Ye[Ge+15]=ne[10],y.instancesEvaluatedElevation[Ie]=J[2]}}}let FNe,zNe;vr(gue,"ModelBucket",{omit:["layers"]}),vr(RNe,"PerModelAttributes"),vr(ONe,"ModelFeature");class zC{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|=AC.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,k&&(this.modelTraits|=AC.HasMapboxMeshFeatures),E&&(this.modelTraits|=AC.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 UNe(W)),$Ne(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(!nn(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):$de(k,c,!0)}for(const y of m)jO(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||MA(y.paint.get("model-color").value,P)||MA(y.paint.get("model-color-mix-intensity").value,P)||MA(y.paint.get("model-roughness").value,P)||MA(y.paint.get("model-emissive-strength").value,P)||MA(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(nn(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 Ps=xue[Fs],Ls=Math.abs(Ps);Ls>Wt&&(is=Ps,Wt=Ls,ms=Os,_s=bs)}if(Wt>.1){const bs=1-(ft+.5*Math.abs(ms*_s))/ue;let Os=m._dem.get(It,St)+is*bs;const Fs=m._dem.get(It+ms,St+_s),Ps=m._dem.get(It-ms,St-_s,!0);(Os-Fs)*(Os-Ps)>0&&(Os=(Fs+Ps)/2),xue[qt]=m._dem.set(It,St,Os),Ub[qt]=ft}}}}}O&&(m._demTile.needsDEMTextureUpload=!0,m._dem._timestamp=_l.now())}setFilter(c){this.filter=c?eC(c):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(c=>this.filter.filter(new Di(this.id.overscaledZ,{worldview:this.worldview}),c.feature,this.id.canonical)):this.nodesInfo}destroy(){const c=this.getNodesInfo();for(const m of c)jO(m.node),qde(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=w([]);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,Dt(k,k,E);const W=(k[0]-O.aabb.min[0])/(O.aabb.max[0]-O.aabb.min[0])*Bb|0,J=Math.min(63,(k[1]-O.aabb.min[1])/(O.aabb.max[1]-O.aabb.min[1])*Bb|0)*Bb+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 es(c,m),new es(c,m),y),y.length>0)return{height:void 0,maxHeight:P.feature.properties.height,hidden:P.hiddenByReplacement,verticalScale:P.evaluatedScale[2]}}}}function MA(g,c){return g instanceof Sv&&!g.isLightConstant&&c}function srt(g,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=Hr(B,255*m[0],m[3]),W=Hr(W,255*m[1],m[3]),J=Hr(J,255*m[2],m[3]));const ee=B<<8|W,ne=J<<8|Math.floor(255*y[3]),ce=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),je=Se(k[1],0,1),Le=Se(k[2],0,1),Ie=Se(k[3],0,1);let Ge,Ye,nt,bt;if(ue!==je&&P!==E&&je!==ue){const ft=P-E;Ye=1/(ft*(je-ue)),nt=-(E+ft*ue)/(ft*(je-ue));const St=Se(k[4],-1,1);bt=Math.pow(10,St),Ge=255*Le<<8|255*Ie}else Ge=65535,Ye=0,nt=1,bt=1;if(g.emplaceBack(ee,ne,ce,Ge,Ye,nt,bt),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=g.evaluatedRMEA[ee],ce=g.evaluatedColor[ee],ue=g.emissionHeightBasedParams[ee];let je;if(O&&ee===2&&y.lights&&(je=new uC,je.resize(10*y.lights.length)),srt(P.featureArray,W,ce,ne,ue,P.aabb.min[2],P.aabb.max[2],je),je&&O){O=!1;const Le=y.meshes[y.lightMeshIndex];Le.featureArray=je,Le.featureArray._trim()}}P.featureArray._trim(),k++}}vr(qO,"Tiled3dModelBucket",{omit:["layers"]}),vr(UNe,"Tiled3dModelFeature");const nrt=["id","tile","layer","source","sourceLayer","state"];class Vb{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 Vb(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 nrt)this[m]!==void 0&&(c[m]=this[m]);return c}}class Hb extends Ts{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,Hb.applyModelSpecification(E,y),E.computeBoundsAndApplyParent(),this.models.push(E)}else{const E=dke(this.map._requestManager.transformRequest(y.uri,Df.Model).url).then(P=>{if(!P)return;const O=Vde(P),B=new fke(m,y.uri,y.position,y.orientation,O);Hb.applyModelSpecification(B,y),B.computeBoundsAndApplyParent(),this.models.push(B),this._modelsInfo.set(m,{modelSpec:y,model:B})}).catch(P=>{this.fire(new sx(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 rm("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(m=>{this._loaded=!0,this.fire(new sx(new Error(`Could not load models: ${m.message}`)))})}static applyModelSpecification(c,m){m.nodeOverrides&&Hb.convertNodeOverrides(c,m.nodeOverrides),m.materialOverrides&&Hb.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=Gm(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 yue(g,c,m,y){const k=1<nt.polygon).flat());const Le=ce?O:null,[Ie,Ge]=Qje(E,y,ee,J,W,P,Le,ne,ue,E.center.lat,g.tileID.canonical),Ye=g.queryGeometry;return Xje(Ie,Ge,Ye.isPointQuery()?Ye.screenBounds:Ye.screenGeometry)}},building:class extends su{constructor(g,c,m,y){super(g,{layout:wke||(wke=new wo({visibility:new Hs(Gt.layout_building.visibility),"building-facade":new rr(Gt.layout_building["building-facade"]),"building-facade-floors":new rr(Gt.layout_building["building-facade-floors"]),"building-facade-unit-width":new rr(Gt.layout_building["building-facade-unit-width"]),"building-facade-window":new rr(Gt.layout_building["building-facade-window"]),"building-roof-shape":new rr(Gt.layout_building["building-roof-shape"]),"building-height":new rr(Gt.layout_building["building-height"]),"building-base":new rr(Gt.layout_building["building-base"]),"building-flood-light-wall-radius":new rr(Gt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new rr(Gt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new rr(Gt.layout_building["building-flip-roof-orientation"])})),paint:jke||(jke=new wo({"building-opacity":new Hs(Gt.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Hs(Gt.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Hs(Gt.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Hs(Gt.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Hs(Gt.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Hs(Gt.paint_building["building-vertical-scale"]),"building-cast-shadows":new Hs(Gt.paint_building["building-cast-shadows"]),"building-color":new rr(Gt.paint_building["building-color"]),"building-emissive-strength":new rr(Gt.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Hs(Gt.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Hs(Gt.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new Hs(Gt.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Hs(Gt.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Hs(Gt.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"})}))},c,m,y),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(g){return new bke(g)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(g){return!0}queryRadius(g){return 0}queryIntersectsFeature(g,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=g.tile.getBucket(this).getFootprint(c);if(ee){if(ee.hiddenFlags!==0)return!1;W=ee.height}const[ne,ce]=Qje(E,y,J,W,new es(0,0),P,null,[0,0],1,E.center.lat,g.tileID.canonical),ue=g.queryGeometry;return Xje(ne,ce,ue.isPointQuery()?ue.screenBounds:ue.screenGeometry)}},line:class extends su{constructor(g,c,m,y){const k=Ike();super(g,k,c,m,y),k.layout&&(this.layout=new Iy(k.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(g){if(g==="line-gradient"){const c=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=c._styleExpression&&c._styleExpression.expression instanceof fb,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(g,c){super.recalculate(g,c),this.paint._values["line-floorwidth"]=(()=>{if(mA)return mA;const m=Ike();return mA=new est(m.paint.properties["line-width"].specification),mA.useIntegerZoom=!0,mA})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,g)}createBucket(g){return new Gde(g)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(g,c,m){const y=Eke(this);return{config:new xx(this,{zoom:c,lut:m}),defines:y,overrideFog:!1}}queryRadius(g){const c=g,m=Lke(xd("line-width",this,c),xd("line-gap-width",this,c)),y=xd("line-offset",this,c);return m/2+Math.abs(y)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(g,c,m,y,k,E){if(g.queryGeometry.isAboveHorizon)return!1;const P=vh(g.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),E.angle,g.pixelToTileUnitsFactor),O=g.pixelToTileUnitsFactor/2*Lke(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 es(0,0);for(let ce=0;ce=3){for(let ue=0;ue>16&255)/255,(g>>8&255)/255,(255&g)/255,1)}function vrt(g,c,m){g===1?(c.rgb_color=WO(m.readVarint()),c.paint="rgb_color"):g===2?(c.linear_gradient_idx=m.readVarint(),c.paint="linear_gradient_idx"):g===3?(c.radial_gradient_idx=m.readVarint(),c.paint="radial_gradient_idx"):g===5?m.readPackedFloat(c.dasharray):g===6?c.dashoffset=m.readFloat():g===7?c.miterlimit=m.readFloat():g===8?c.opacity=m.readVarint():g===9?c.width=m.readFloat():g===10?c.linecap=m.readVarint():g===11&&(c.linejoin=m.readVarint())}function _rt(g,c,m){g===1?c.transform=HO(m,m.readVarint()+m.pos):g===2?c.spread_method=m.readVarint():g===3?c.stops.push(GNe(m,m.readVarint()+m.pos)):g===4?c.x1=m.readFloat():g===5?c.y1=m.readFloat():g===6?c.x2=m.readFloat():g===7&&(c.y2=m.readFloat())}function GNe(g,c){return g.readFields(brt,{offset:0,opacity:255,rgb_color:vue},c)}function brt(g,c,m){g===1?c.offset=m.readFloat():g===2?c.opacity=m.readVarint():g===3&&(c.rgb_color=WO(m.readVarint()))}function wrt(g,c,m){g===1?c.transform=HO(m,m.readVarint()+m.pos):g===2?c.spread_method=m.readVarint():g===3?c.stops.push(GNe(m,m.readVarint()+m.pos)):g===4?c.cx=m.readFloat():g===5?c.cy=m.readFloat():g===6?c.r=m.readFloat():g===7?c.fx=m.readFloat():g===8?c.fy=m.readFloat():g===9&&(c.fr=m.readFloat())}function jrt(g,c,m){g===1?c.transform=HO(m,m.readVarint()+m.pos):g===2?c.clip_path_idx=m.readVarint():g===3&&c.children.push(VO(m,m.readVarint()+m.pos))}function krt(g,c,m){g===1?c.left=c.top=m.readFloat():g===2?c.width=c.height=m.readFloat():g===3?c.top=m.readFloat():g===4?c.height=m.readFloat():g===5?c.mask_type=m.readVarint():g===6?c.mask_idx=m.readVarint():g===7&&c.children.push(VO(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 BC(g,c=255,m){const y=c/255,k=g.toString(),E=m.has(k)?m.get(k).clone():g.clone();return E.a*=y,E.toString()}function AA(g,c){if(!em()){const m=document.createElement("canvas");return m.width=g,m.height=c,m}return new OffscreenCanvas(g,c)}let wue,EA=null;function jue(g,c,m,y,k){for(const E of y.children)KNe(g,c,m,E,k)}function KNe(g,c,m,y,k){y.group?(g.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=$C(B.transform).preMultiplySelf(P)),!function(ue,je,Le){return ue.opacity!==255||je||Le}(B,ee!=null,J!=null))return void jue(E,P,O,B,W);const ne=AA(E.canvas.width,E.canvas.height),ce=ne.getContext("2d");jue(ce,P,O,B,W),ee&&tSe(ce,P,O,ee),J&&sSe(ce,P,O,J,W),E.globalAlpha=B.opacity/255,E.drawImage(ne,0,0)}(g,c,m,y.group,k),g.restore()):y.path&&(g.save(),function(E,P,O,B,W){E.setTransform(P),B.paint_order===ort.PAINT_ORDER_FILL_AND_STROKE?(ZNe(E,O,B,W),XNe(E,O,B,W)):(XNe(E,O,B,W),ZNe(E,O,B,W))}(g,c,m,y.path,k),g.restore())}function ZNe(g,c,m,y){const k=m.fill;if(!k)return;const E=k.opacity/255;switch(g.save(),g.beginPath(),rSe(m,g),k.paint){case"rgb_color":g.fillStyle=BC(k.rgb_color,k.opacity,y);break;case"linear_gradient_idx":{const P=c.linear_gradients[k.linear_gradient_idx];P.transform&&g.setTransform($C(P.transform).preMultiplySelf(g.getTransform())),g.fillStyle=QNe(g,P,E,y);break}case"radial_gradient_idx":{const P=c.radial_gradients[k.radial_gradient_idx];P.transform&&g.setTransform($C(P.transform).preMultiplySelf(g.getTransform())),g.fillStyle=JNe(g,P,E,y)}}g.fill(YNe(m)),g.restore()}function YNe(g){return g.rule===_ue.PATH_RULE_NON_ZERO?"nonzero":g.rule===_ue.PATH_RULE_EVEN_ODD?"evenodd":void 0}function XNe(g,c,m,y){const k=m.stroke;if(!k)return;const E=nSe(m);g.lineWidth=k.width,g.miterLimit=k.miterlimit,g.setLineDash(k.dasharray),g.lineDashOffset=k.dashoffset;const P=k.opacity/255;switch(k.paint){case"rgb_color":g.strokeStyle=BC(k.rgb_color,k.opacity,y);break;case"linear_gradient_idx":g.strokeStyle=QNe(g,c.linear_gradients[k.linear_gradient_idx],P,y,!0);break;case"radial_gradient_idx":g.strokeStyle=JNe(g,c.radial_gradients[k.radial_gradient_idx],P,y,!0)}switch(k.linejoin){case UO.LINE_JOIN_MITER_CLIP:case UO.LINE_JOIN_MITER:g.lineJoin="miter";break;case UO.LINE_JOIN_ROUND:g.lineJoin="round";break;case UO.LINE_JOIN_BEVEL:g.lineJoin="bevel"}switch(k.linecap){case bue.LINE_CAP_BUTT:g.lineCap="butt";break;case bue.LINE_CAP_ROUND:g.lineCap="round";break;case bue.LINE_CAP_SQUARE:g.lineCap="square"}g.stroke(E)}function QNe(g,c,m,y,k=!1){if(c.stops.length===1){const ne=c.stops[0];return BC(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=$C(c.transform);W=ne.transformPoint(W),J=ne.transformPoint(J)}const ee=g.createLinearGradient(W.x,W.y,J.x,J.y);for(const ne of c.stops)ee.addColorStop(ne.offset,BC(ne.rgb_color,ne.opacity*m,y));return ee}function JNe(g,c,m,y,k=!1){if(c.stops.length===1){const Ie=c.stops[0];return BC(Ie.rgb_color,Ie.opacity*m,y)}const E=$C(c.transform),{fx:P,fy:O,fr:B,cx:W,cy:J,r:ee}=c;let ne=new DOMPoint(P,O),ce=new DOMPoint(W,J),ue=B,je=ee;if(k){ne=E.transformPoint(ne),ce=E.transformPoint(ce);const Ie=(E.a+E.d)/2;ue=B*Ie,je=c.r*Ie}const Le=g.createRadialGradient(ne.x,ne.y,ue,ce.x,ce.y,je);for(const Ie of c.stops)Le.addColorStop(Ie.offset,BC(Ie.rgb_color,Ie.opacity*m,y));return Le}function eSe(g,c,m,y){const k=y.transform?$C(y.transform).preMultiplySelf(c):c,E=AA(g.canvas.width,g.canvas.height),P=E.getContext("2d");for(const B of y.children)if(B.group)eSe(P,k,m,B.group);else if(B.path){const W=B.path,J=new Path2D;J.addPath(nSe(W),k),P.fill(J,YNe(W))}const O=y.clip_path_idx!=null?m.clip_paths[y.clip_path_idx]:null;O&&tSe(P,k,m,O),g.globalCompositeOperation="source-over",g.drawImage(E,0,0)}function tSe(g,c,m,y){const k=AA(g.canvas.width,g.canvas.height);eSe(k.getContext("2d"),c,m,y),g.globalCompositeOperation="destination-in",g.drawImage(k,0,0)}function sSe(g,c,m,y,k){if(y.children.length===0)return;const E=y.mask_idx!=null?m.masks[y.mask_idx]:null;E&&sSe(g,c,m,E,k);const P=g.canvas.width,O=g.canvas.height,B=AA(P,O),W=B.getContext("2d"),J=y.width,ee=y.height,ne=y.left,ce=y.top,ue=new Path2D,je=new Path2D;je.rect(ne,ce,J,ee),ue.addPath(je,c),W.clip(ue);for(const Ge of y.children)KNe(W,c,m,Ge,k);const Le=W.getImageData(0,0,P,O),Ie=Le.data;if(y.mask_type===VNe.MASK_TYPE_LUMINANCE)for(let Ge=0;Gec[P])return null}else{const O=1/y[P];let B=(g[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 oSe(g,c,m,y,k,E,P,O,B,W,J){const ee=y-g,ne=k-c,ce=E-m,ue=P-g,je=O-c,Le=B-m,Ie=J[1]*Le-J[2]*je,Ge=J[2]*ue-J[0]*Le,Ye=J[0]*je-J[1]*ue,nt=ee*Ie+ne*Ge+ce*Ye;if(Math.abs(nt)<1e-15)return null;const bt=1/nt,ft=W[0]-g,St=W[1]-c,It=W[2]-m,qt=(ft*Ie+St*Ge+It*Ye)*bt;if(qt<0||qt>1)return null;const is=St*ce-It*ne,Wt=It*ee-ft*ce,ms=ft*ne-St*ee,_s=(J[0]*is+J[1]*Wt+J[2]*ms)*bt;return _s<0||qt+_s>1?null:(ue*is+je*Wt+Le*ms)*bt}function lSe(g,c,m){return(g-c)/(m-c)}function cSe(g,c,m,y,k,E,P,O,B){const W=1<{const Ge=Le?1:0,Ye=(ce+1)*je-Ge,nt=ue*je,bt=(ue+1)*je-Ge;Ie[0]=ce*je,Ie[1]=nt,Ie[2]=Ye,Ie[3]=bt};let ee=new aSe(B);const ne=[];for(let ce=0;ce=1;B/=2){const ce=O[O.length-1];ee=new aSe(B);for(let ue=0;ue0;){const{idx:ue,t:je,nodex:Le,nodey:Ie,depth:Ge}=ce.pop();if(this.leaves[ue]){cSe(Le,Ie,Ge,c,m,y,k,ee,ne);const nt=1<=Fs[2])return je}continue}let Ye=0;for(let nt=0;nt=W[J[It]]&&(J.splice(It,0,nt),St=!0);St||(J[Ye]=nt),Ye++}}for(let nt=0;nt=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=KO.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 aje({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&g[c]);return g}function zrt(g,c){switch(c){case"uint32":return g;case"uint16":for(let m=0;m>4|(61440&y)>>8|(240&k)<<4|61440&k,g[m+1]=15&y|(3840&y)>>4|(15&k)<<8|(3840&k)<<4}return g;case"uint8":for(let m=0;m>6|(192&k)>>4|(192&E)>>2|192&P,g[m+1]=(48&y)>>4|(48&k)>>2|48&E|(48&P)<<2,g[m+2]=(12&y)>>2|12&k|(12&E)<<2|(12&P)<<4,g[m+3]=3&y|(3&k)<<2|(3&E)<<4|(3&P)<<6}return g;default:throw new Error(`Invalid pixel format, "${c}"`)}}vr(KO,"DEMData"),vr(dSe,"DemMinMaxQuadTree",{omit:["dem"]});var Xm=Uint8Array,PA=Uint16Array,Brt=Int32Array,hSe=new Xm([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]),mSe=new Xm([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 Xm([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pSe=function(g,c){for(var m=new PA(31),y=0;y<31;++y)m[y]=c+=1<>1|(21845&Wl)<<1;xSe[Wl]=((65280&(qC=(61680&(qC=(52428&qC)>>2|(13107&qC)<<2))>>4|(3855&qC)<<4))>>8|(255&qC)<<8)>>1}var IA=function(g,c,m){for(var y=g.length,k=0,E=new PA(c);k>B]=W;return P},LA=new Xm(288);for(Wl=0;Wl<144;++Wl)LA[Wl]=8;for(Wl=144;Wl<256;++Wl)LA[Wl]=9;for(Wl=256;Wl<280;++Wl)LA[Wl]=7;for(Wl=280;Wl<288;++Wl)LA[Wl]=8;var ySe=new Xm(32);for(Wl=0;Wl<32;++Wl)ySe[Wl]=5;var Vrt=IA(LA,9),Hrt=IA(ySe,5),Nue=function(g){for(var c=g[0],m=1;mc&&(c=g[m]);return c},rg=function(g,c,m){var y=c/8|0;return(g[y]|g[y+1]<<8)>>(7&c)&m},Sue=function(g,c){var m=c/8|0;return(g[m]|g[m+1]<<8|g[m+2]<<16)>>(7&c)},Wrt=["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"],ng=function(g,c,m){var y=new Error(c||Wrt[g]);if(y.code=g,Error.captureStackTrace&&Error.captureStackTrace(y,ng),!m)throw y;return y},Grt=new Xm(0),Krt=typeof TextDecoder<"u"&&new TextDecoder;try{Krt.decode(Grt,{stream:!0})}catch{}const Zrt={gzip_data:"gzip"};class Rp extends Error{constructor(c){super(c),this.name="MRTError"}}const Yrt={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},vSe={uint32:1,uint16:2,uint8:4},Xrt={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let Cue;class ZO{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 Cue(m.subarray(0,y)).readFields(Trt,{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 _Se(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 bSe(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 _Se{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=Yrt[E],this.dataIndex=O,this.bandShape=[k+2*P,k+2*P,vSe[this.pixelFormat]],this._decodedBlocks=new GO(B?B.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return vSe[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}}}ZO.setPbf=function(g){Cue=g};class bSe{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)}}ZO.performDecoding=function(g,c){const m=new Uint8Array(g);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),ce=new Uint32Array(B[0]*B[1]*B[2]);let ue;if(ee!=="gzip_data")throw new Rp(`Unhandled codec: ${ee}`);return ue=function(je,Le){if(!globalThis.DecompressionStream&&Le==="gzip_data")return Promise.resolve(((nt=function(St){St[0]==31&&St[1]==139&&St[2]==8||ng(6,"invalid gzip data");var It=St[3],qt=10;4&It&&(qt+=2+(St[10]|St[11]<<8));for(var is=(It>>3&1)+(It>>4&1);is>0;is-=!St[qt++]);return qt+(2&It)}(Ye=je))+8>Ye.length&&ng(6,"invalid gzip data"),function(St,It,qt,is){var Wt=St.length;if(!Wt||It.f&&!It.l)return qt||new Xm(0);var ms=!qt,_s=ms||It.i!=2,bs=It.i;ms&&(qt=new Xm(3*Wt));var Os,Fs,Ps=function(_i){var Ka=qt.length;if(_i>Ka){var Ja=new Xm(Math.max(2*Ka,_i));Ja.set(qt),qt=Ja}},Ls=It.f||0,hs=It.p||0,cs=It.b||0,Ds=It.l,Xs=It.d,qs=It.m,Lr=It.n,cr=8*Wt;do{if(!Ds){Ls=rg(St,hs,1);var gr=rg(St,hs+1,3);if(hs+=3,!gr){var kr=St[(ps=4+((hs+7)/8|0))-4]|St[ps-3]<<8,Hn=ps+kr;if(Hn>Wt){bs&&ng(0);break}_s&&Ps(cs+kr),qt.set(St.subarray(ps,Hn),cs),It.b=cs+=kr,It.p=hs=8*Hn,It.f=Ls;continue}if(gr==1)Ds=Vrt,Xs=Hrt,qs=9,Lr=5;else if(gr==2){var Us=rg(St,hs,31)+257,Nr=rg(St,hs+10,15)+4,mn=Us+rg(St,hs+5,31)+1;hs+=14;for(var pa=new Xm(mn),xa=new Xm(19),Ln=0;Ln>4)<16)pa[Ln++]=ps;else{var nr=0,ar=0;for(ps==16?(ar=3+rg(St,hs,3),hs+=2,nr=pa[Ln-1]):ps==17?(ar=3+rg(St,hs,7),hs+=3):ps==18&&(ar=11+rg(St,hs,127),hs+=7);ar--;)pa[Ln++]=nr}}var Or=pa.subarray(0,Us),zr=pa.subarray(Us);qs=Nue(Or),Lr=Nue(zr),Ds=IA(Or,qs),Xs=IA(zr,Lr)}else ng(1);if(hs>cr){bs&&ng(0);break}}_s&&Ps(cs+131072);for(var Sn=(1<>4;if((hs+=15&nr)>cr){bs&&ng(0);break}if(nr||ng(2),oa<256)qt[cs++]=oa;else{if(oa==256){Vn=hs,Ds=null;break}var Jr=oa-254;oa>264&&(Jr=rg(St,hs,(1<<(Ba=hSe[Ln=oa-257]))-1)+gSe[Ln],hs+=Ba);var un=Xs[Sue(St,hs)&zn],La=un>>4;if(un||ng(3),hs+=15&un,zr=Urt[La],La>3){var Ba=mSe[La];zr+=Sue(St,hs)&(1<cr){bs&&ng(0);break}_s&&Ps(cs+131072);var $a=cs+Jr;if(csOs.length)&&(Fs=Os.length),new Xm(Os.subarray(0,Fs))):qt.subarray(0,cs)}(Ye.subarray(nt,-8),{i:2},new Xm(((Ie=Ye)[(Ge=Ie.length)-4]|Ie[Ge-3]<<8|Ie[Ge-2]<<16|Ie[Ge-1]<<24)>>>0))));var Ie,Ge,Ye,nt;const bt=Zrt[Le];if(!bt)throw new Error(`Unhandled codec: ${Le}`);const ft=new globalThis.DecompressionStream(bt);return new Response(new Blob([je]).stream().pipeThrough(ft)).arrayBuffer().then(St=>new Uint8Array(St))}(ne,ee).then(je=>(function(Le,Ie){Le.readFields(Drt,Ie)}(new Cue(je),ce),new Xrt[O](ce.buffer))),ue.then(je=>{for(let Le=J.length-1;Le>=0;Le--)switch(J[Le]){case"delta_filter":Rrt(je,B);break;case"zigzag_filter":Frt(je);break;case"bitshuffle_filter":zrt(je,O);break;default:throw new Rp(`Unhandled filter "${J[Le]}"`)}return{layerName:k,blockIndex:W,data:je}}).catch(je=>{throw je})}))},vr(bSe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),vr(ZO,"MapboxRasterTile"),vr(_Se,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class wSe{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 Yt(new NO(this.rawTileData)).layers,this.sourceLayerCoder=new wSe(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,(je,Le,Ie,Ge)=>ru(y.bufferedTilespaceGeometry,je-W,Le-W,Ie+W,Ge+W));ee.sort(Qrt);let ne=null;k.elevation&&ee.length>0&&(ne=zC.create(k.elevation,this.tileID));const ce={};let ue;for(let je=0;je(Ge||(Ge=Et(Ye,this.tileID.canonical,E)),nt.queryIntersectsFeature(y,Ye,bt,Ge,this.z,k,P,ne,ft)))}return ce}loadMatchingFeature(c,m,y,k,E,P){const{featureIndex:O,bucketIndex:B,sourceLayerIndex:W,layoutVertexArrayOffset:J}=m,ee=this.bucketLayerIDs[B],ne=y.layers,ce=Object.keys(ne);if(ce.length&&!pr(ce,ee))return;const ue=y.sourceCache,je=this.sourceLayerCoder.decode(W),Le=this.vtLayers[je].feature(O),Ie=this.getId(Le,je);for(let Ge=0;Ge`${O.key}: ${O.message}`).join(", ");return void dr(`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 kSe(g,c,m,y,k){return Xt(g,(E,P)=>{const O=c instanceof Iy?c.get(P):null;return O&&O.evaluate?O.evaluate(m,y,void 0,k):O})}function Qrt(g,c){return c-g}vr(jSe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const NSe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Mue{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=NSe[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 Mue(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=NSe.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 Tue(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 Le=ne;Le<=ee;Le++){const Ie=P[2*Le],Ge=P[2*Le+1];Ie>=c&&Ie<=y&&Ge>=m&&Ge<=k&&W.push(E[Le])}continue}const ce=ne+ee>>1,ue=P[2*ce],je=P[2*ce+1];ue>=c&&ue<=y&&je>=m&&je<=k&&W.push(E[ce]),(J===0?c<=ue:m<=je)&&(B.push(ne),B.push(ce-1),B.push(1-J)),(J===0?y>=ue:k>=je)&&(B.push(ce+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 Le=ne;Le<=ee;Le++)CSe(E[2*Le],E[2*Le+1],c,m)<=W&&B.push(k[Le]);continue}const ce=ne+ee>>1,ue=E[2*ce],je=E[2*ce+1];CSe(ue,je,c,m)<=W&&B.push(k[ce]),(J===0?c-y<=ue:m-y<=je)&&(O.push(ne),O.push(ce-1),O.push(1-J)),(J===0?c+y>=ue:m+y>=je)&&(O.push(ce+1),O.push(ee),O.push(1-J))}return B}}function Tue(g,c,m,y,k,E){if(k-y<=m)return;const P=y+k>>1;SSe(g,c,P,y,k,E),Tue(g,c,m,y,P-1,1-E),Tue(g,c,m,P+1,k,1-E)}function SSe(g,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),ce=.5*Math.sqrt(ee*ne*(W-ne)/W)*(J-W/2<0?-1:1);SSe(g,c,m,Math.max(y,Math.floor(m-J*ne/W+ce)),Math.min(k,Math.floor(m+(W-J)*ne/W+ce)),E)}const P=c[2*m+E];let O=y,B=k;for(DA(g,c,y,m),c[2*k+E]>P&&DA(g,c,y,k);OP;)B--}c[2*y+E]===P?DA(g,c,y,B):(B++,DA(g,c,B,k)),B<=m&&(y=B+1),m<=B&&(k=B-1)}}function DA(g,c,m,y){Aue(g,m,y),Aue(c,2*m,2*y),Aue(c,2*m+1,2*y+1)}function Aue(g,c,m){const y=g[c];g[c]=g[m],g[m]=y}function CSe(g,c,m,y){const k=g-m,E=c-y;return k*k+E*E}i.$=vS,i.A=Ff,i.B=Gm,i.C=2,i.D=SC,i.E=Ts,i.F=gA,i.G=Jke,i.H=yS,i.I=Ws,i.J=$D,i.K=Ir,i.L=pv,i.M=US,i.N=_b,i.O=MD,i.P=es,i.Q=bb,i.R=Df,i.S=JS,i.T=Fde,i.U=hx,i.V=$O,i.W=jT,i.X=vv,i.Y=yv,i.Z=pb,i._=eu,i.a=function(g){return sa.API_CDN_URL_REGEX.test(g)},i.a$=ge,i.a0=dn,i.a1=ea,i.a2=Pp,i.a3=class extends $O{},i.a4=VS,i.a5=CD,i.a6=Gt,i.a7=function(g){const c=g.value;return c?dn(c)?fue(c,!0)?[]:[new $O(g.key,c,`invalid url "${c}"`)]:[new $O(g.key,c,`string expected, "${Ir(c)}" found`)]:[]},i.a8=RD,i.a9=wo,i.aA=Se,i.aB=C,i.aC=ct,i.aD=fd,i.aE=ji,i.aF=H,i.aG=tt,i.aH=function(g,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[g],3e3)})),()=>{k.result||(k.callbacks=k.callbacks.filter(E=>E!==y),k.callbacks.length||(k.cancel(),delete this.entries[g]))}}},i.aL=function(g,c,m){const y=JSON.stringify(g.request);return g.data&&(this.deduped.entries[y]={result:[null,g.data]}),this.deduped.request(y,{type:"parseTile",isSymbolTile:g.isSymbolTile,zoom:g.tileZoom},k=>{const E=Uu(g.request,(P,O,B)=>{P?k(P):O&&k(null,{rawData:O,vectorTile:m?void 0:new Yt(new NO(O)),responseHeaders:new Map(B.entries())})});return()=>{E.cancel(),k()}},c)},i.aM=function(g){return g?{cacheControl:g.get("Cache-Control"),expires:g.get("Expires")}:{cacheControl:void 0,expires:void 0}},i.aN=hl,i.aO=function(g){Qc++,Qc>cv&&(g.getActor().send("enforceCacheSizeLimit",lv),Qc=0)},i.aP=function(g){return g<=1?1:Math.pow(2,Math.floor(Math.log2(g)))},i.aQ=go,i.aR=MNe,i.aS=LNe,i.aT=x,i.aU=CNe,i.aV=function(g,c){const m=document.createElement("video");m.muted=!0,m.onloadstart=function(){c(null,m)};for(let y=0;y{}}},i.aW=uA,i.aX=Hb,i.aY=Ut,i.aZ=_A,i.a_=oe,i.aa=Hs,i.ab=class{constructor(g){this.specification=g}possiblyEvaluate(g,c){return wn(g.expression.evaluate(c))}interpolate(g,c,m){return{x:Hr(g.x,c.x,m),y:Hr(g.y,c.y,m),z:Hr(g.z,c.z,m),azimuthal:Hr(g.azimuthal,c.azimuthal,m),polar:Hr(g.polar,c.polar,m)}}},i.ac=Di,i.ad=Ay,i.ae=et,i.af=Dt,i.ag=de,i.ah=ze,i.ai=Iy,i.aj=Fv,i.ak=Hr,i.al=Ys,i.am=jy,i.an=Pr,i.ao=Fr,i.ap=class{constructor(g){this.specification=g}possiblyEvaluate(g,c){return function([m,y]){const k=wn([1,m,y]);return{x:k.x,y:k.y,z:k.z}}(g.expression.evaluate(c))}interpolate(g,c,m){return{x:Hr(g.x,c.x,m),y:Hr(g.y,c.y,m),z:Hr(g.z,c.z,m)}}},i.aq=function(g,c,m=0,y=!0){const k=new es(m,m),E=g.sub(k),P=c.add(k),O=[E,new es(P.x,E.y),P,new es(E.x,P.y)];return y&&O.push(E.clone()),O},i.ar=function(g,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(g,k,E,P),B=y.upVector(g.canonical,k.x,k.y);return ke(B,B,O*y.upVectorScale(g.canonical,c,m).metersToTile),B}}getForTilePoints(g,c,m,y){if(this.isUsingMockSource())return!1;const k=zC.create(this,g,y);return!!k&&(c.forEach(E=>{E[2]=this.exaggeration()*k.getElevationAt(E[0],E[1],m)}),!0)}getMinMaxForTile(g){if(this.isUsingMockSource())return null;const c=this.findDEMTileFor(g);if(!c||!c.dem)return null;const m=c.dem.tree,y=c.tileID,k=1<0&&(y+=(g[k]-0)*(g[k]-0)),c[k]<0&&(y+=(0-c[k])*(0-c[k]));return y},i.c0=Mje,i.c1=Jde,i.c2=iNe,i.c3=oue,i.c4=Mue,i.c5=ke,i.c6=qe,i.c7=Ve,i.c8=function(g,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 g[0]=y*B+k*O,g[1]=k*B-y*O,g[2]=E*B+P*O,g[3]=P*B-E*O,g},i.c9=Je,i.cA=te,i.cB=Ga,i.cC=hke,i.cD=ki,i.cE=U2e,i.cF=function(g,c,m,y,k,E,P,O,B){if(B.name==="globe")return U2e(g,c,new ki(m,y,k),!1);const W=_A({z:m,x:y,y:k},B);return new Er([(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(g,c,m){return g[0]=Math.min(c[0],m[0]),g[1]=Math.min(c[1],m[1]),g[2]=Math.min(c[2],m[2]),g[3]=Math.min(c[3],m[3]),g},i.cH=function(g,c,m){return g[0]=Math.max(c[0],m[0]),g[1]=Math.max(c[1],m[1]),g[2]=Math.max(c[2],m[2]),g[3]=Math.max(c[3],m[3]),g},i.cI=function(g){const c=Math.round((g+45+360)%360/90)%4;return nl[c]},i.cJ=xe,i.cK=$e,i.cL=jC,i.cM=function(g){const c=w(new Float64Array(16));C(c,g.pixelMatrix,g.globeMatrix);const m=[0,cm,0],y=[0,dm,0];return Dt(m,m,c),Dt(y,y,c),[m[0]>0&&m[0]<=g.width&&m[1]>0&&m[1]<=g.height&&!fde(g,new x(g.center.lat,90)),y[0]>0&&y[0]<=g.width&&y[1]>0&&y[1]<=g.height&&!fde(g,new x(g.center.lat,-90))]},i.cN=function(g,c){const{scale:m}=g.tileTransform,y=m*Ys/(g.tileSize*Math.pow(2,c.zoom-g.tileID.overscaledZ+g.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=vO,i.cP=se,i.cQ=uke,i.cR=function(g){const c=uke(g,!0);return p([],[c[0],c[1],c[4],c[5]])},i.cS=I,i.cT=lr,i.cU=L,i.cV=function(g){const{x:c,y:m}=g.point,{lng:y,lat:k}=g._center;return W2e(c,m,g.worldSize,y,k)},i.cW=be,i.cX=ii,i.cY=mo,i.cZ=ed,i.c_=lm,i.ca=Wa,i.cb=function(g,c){return g[0]=-c[0],g[1]=-c[1],g[2]=-c[2],g[3]=c[3],g},i.cc=X,i.cd=function(g,c,m,y,k){var E=1/Math.tan(c/2);if(g[0]=E/m,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=E,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[11]=-1,g[12]=0,g[13]=0,g[15]=0,k!=null&&k!==1/0){var P=1/(y-k);g[10]=(k+y)*P,g[14]=2*k*y*P}else g[10]=-1,g[14]=-2*y;return g},i.ce=function(g,c,m,y,k,E,P){var O=1/(c-m),B=1/(y-k),W=1/(E-P);return g[0]=-2*O,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=-2*B,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=2*W,g[11]=0,g[12]=(c+m)*O,g[13]=(k+y)*B,g[14]=(P+E)*W,g[15]=1,g},i.cf=re,i.cg=function(g,c,m){g[4*c+0]=m[0],g[4*c+1]=m[1],g[4*c+2]=m[2],g[4*c+3]=m[3]},i.ch=vC,i.ci=Ab,i.cj=wl,i.ck=Dp,i.cl=Pb,i.cm=xNe,i.cn=function(){var g=new u(4);return u!=Float32Array&&(g[1]=0,g[2]=0),g[0]=1,g[3]=1,g},i.co=function(g,c,m){var y=c[0],k=c[1],E=c[2],P=c[3],O=Math.sin(m),B=Math.cos(m);return g[0]=y*B+E*O,g[1]=k*B+P*O,g[2]=y*-O+E*B,g[3]=k*-O+P*B,g},i.cp=function(g,c){return g[0]===c[0]&&g[1]===c[1]&&g[2]===c[2]&&g[3]===c[3]},i.cq=rt,i.cr=function(g){var c=g[0],m=g[1],y=g[2],k=g[3];return Math.sqrt(c*c+m*m+y*y+k*k)},i.cs=rs,i.ct=Qe,i.cu=Go,i.cv=3,i.cw=2,i.cx=7,i.cy=6,i.cz=De,i.d=function(g){return sa.API_TILEJSON_REGEX.test(g)},i.d$=class{constructor(g,c,m,y){this.context=g,this.format=y,this.size=m,this.texture=g.gl.createTexture();const[k,E,P]=this.size,{gl:O}=g;O.bindTexture(O.TEXTURE_3D,this.texture),g.pixelStoreUnpackFlipY.set(!1),g.pixelStoreUnpack.set(1),g.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in c&&c.data&&O.texImage3D(O.TEXTURE_3D,0,this.format,k,E,P,0,Ode(this.format),Rde(this.format),c.data)}bind(g,c){const{context:m}=this,{gl:y}=m;y.bindTexture(y.TEXTURE_3D,this.texture),g!==this.minFilter&&(y.texParameteri(y.TEXTURE_3D,y.TEXTURE_MAG_FILTER,g),y.texParameteri(y.TEXTURE_3D,y.TEXTURE_MIN_FILTER,g),this.minFilter=g),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:g}=this.context;g.deleteTexture(this.texture),this.texture=null}},i.d0=function(g){return g*g*g*g*g},i.d1=z,i.d2=45,i.d3=_C,i.d4=function(g,c,m){const y=Math.sqrt(g*g+c*c+m*m),k=y>0?Math.acos(m/y)*aa:0;let E=g!==0||c!==0?Math.atan2(-c,-g)*aa+90:0;return E<0&&(E+=360),[y,E,k]},i.d5=ie,i.d6=wn,i.d7=Be,i.d8=le,i.d9=Er,i.dA=function(g){return g({pluginStatus:tu,pluginURL:Vf}),XS.on("pluginStateChange",g),g},i.dB=Eb,i.dC=class extends Gf{constructor(g){super(g),this.current=bC}set(g,c,m){if(this.fetchUniformLocation(g,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=mi,i.dE=function(g,c,m){const y=Fv(m.zoom),k=g.style.map._antialias,E=g.terrain&&g.terrain.exaggeration()>0;return y===0&&!k&&!E},i.dF=function(g){const c=g.pixelsPerMeter,m=c/re(1,g.center.lat),y=w(new Float64Array(16));return A(y,y,[g.point.x,g.point.y,0]),I(y,y,[m,m,c]),Float32Array.from(y)},i.dG=rO,i.dH=function(g){const c=xe-5;g=Se(g,-c,c)/c*90;const m=Math.pow(Math.abs(Math.sin(Pr(g))),3);return Math.round(m*(KT.length-1))},i.dI=function(g,c,m,y){const k=c.getNorth(),E=c.getSouth(),P=c.getWest(),O=c.getEast(),B=1<0){const ue=180/y;_(ce,ce,[ue/W+1,0,0,0,ue/J+1,0,-.5*ue/ee,.5*ue/ne,1])}return ce[2]=B,ce[5]=g.x,ce[8]=g.y,ce},i.dJ=Ym,i.dK=function(g,c,m){const y=w(new Float64Array(16)),k=(c/(1<({u_matrix:new Pb(g),u_texsize:new Dp(g),u_pixels_to_tile_units:new wC(g),u_device_pixel_ratio:new wl(g),u_width_scale:new wl(g),u_floor_width_scale:new wl(g),u_image:new vC(g),u_units_to_pixels:new Dp(g),u_tile_units_to_pixels:new wl(g),u_alpha_discard_threshold:new wl(g),u_trim_offset:new Dp(g),u_trim_fade_range:new Dp(g),u_trim_color:new _C(g),u_zbias_factor:new wl(g),u_tile_to_meter:new wl(g),u_ground_shadow_factor:new Ab(g),u_pattern_transition:new wl(g)}),i.dX=g=>({u_matrix:new Pb(g),u_pixels_to_tile_units:new wC(g),u_device_pixel_ratio:new wl(g),u_width_scale:new wl(g),u_floor_width_scale:new wl(g),u_units_to_pixels:new Dp(g),u_dash_image:new vC(g),u_gradient_image:new vC(g),u_image_height:new wl(g),u_texsize:new Dp(g),u_tile_units_to_pixels:new wl(g),u_alpha_discard_threshold:new wl(g),u_trim_offset:new Dp(g),u_trim_fade_range:new Dp(g),u_trim_color:new _C(g),u_zbias_factor:new wl(g),u_tile_to_meter:new wl(g),u_ground_shadow_factor:new Ab(g)}),i.dY=g=>({u_camera_to_center_distance:new wl(g),u_extrude_scale:new wC(g),u_device_pixel_ratio:new wl(g),u_matrix:new Pb(g),u_inv_rot_matrix:new Pb(g),u_merc_center:new Dp(g),u_tile_id:new Ab(g),u_zoom_transition:new wl(g),u_up_dir:new Ab(g),u_emissive_strength:new wl(g)}),i.dZ=dC,i.d_=cst,i.da=pe,i.db=function(g){return[Math.pow(g[0],1/2.2),Math.pow(g[1],1/2.2),Math.pow(g[2],1/2.2)]},i.dc=dke,i.dd=Vde,i.de=fke,i.df=fue,i.dg=function(g,c){return g.readFields(lrt,{icons:[]},c)},i.dh=fO,i.di=DC,i.dj=nue,i.dk=dv,i.dl=kb,i.dm=ex,i.dn=uv,i.dp=xs,i.dq=function(g){const c=g.indexOf(Oy);return c>=0?g.slice(0,c):g},i.dr=function(g){return g.indexOf(Oy)>=0},i.ds=function(g){const c=g.lastIndexOf(Oy);return c>=0?g.slice(c+1):""},i.dt=function(g){const c=[],m=g.id;return m===void 0&&c.push({message:`layers.${m}: missing required property "id"`}),g.render===void 0&&c.push({message:`layers.${m}: missing required method "render"`}),g.renderingMode&&g.renderingMode!=="2d"&&g.renderingMode!=="3d"&&c.push({message:`layers.${m}: property "renderingMode" must be either "2d" or "3d"`}),c},i.du=function(g,c,m,y){return g.type==="custom"?new trt(g,c):new irt[g.type](g,c,m,y)},i.dv=Is,i.dw=function(g){const c=g.indexOf(Oy);return c>=0?g.slice(c+1):""},i.dx=class extends Vb{constructor(g,c){super(g._vectorTileFeature,g._z,g._x,g._y,g.id),g.state&&(this.state=Object.assign({},g.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=g.source,this.sourceLayer=g.sourceLayer,this.layer=g.layer)}toJSON(){const g=super.toJSON();return g.target=this.target,g.namespace=this.namespace,g}},i.dy=XS,i.dz=Of,i.e=sa,i.e$=ae,i.e0=Z2e,i.e1=(g,c,m,y,k,E)=>{const P=g.transform,O=P.projection.name==="globe";let B;if(E.paint.get("circle-pitch-alignment")==="map")if(O){const J=H2e(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:g.transform.getCameraToCenterDistance(P.projection),u_matrix:g.translatePosMatrix(c.projMatrix,m,E.paint.get("circle-translate"),E.paint.get("circle-translate-anchor")),u_device_pixel_ratio:_l.devicePixelRatio,u_extrude_scale:B,u_inv_rot_matrix:ket,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=g.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:Ake(g,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:Tke(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=(g,c,m,y,k,E,P,O,B,W)=>{const J=g.transform,ee=J.calculatePixelsToTileUnitsMatrix(c),ne=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none",ce=J.pitch<15?Mke(.07,.7,Se((14-J.zoom)/5,0,1)):.07;return{u_matrix:Ake(g,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:Pke(m)&&c.lineAtlasTexture?c.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Tke(c,g.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:ce,u_tile_to_meter:Be(c.tileID.canonical,0),u_ground_shadow_factor:W}},i.e6=Zt,i.e7=YT,i.e8=me,i.e9=hm,i.eA=function(g,c){var m=2*Math.acos(c[3]),y=Math.sin(m/2);return y>d?(g[0]=c[0]/y,g[1]=c[1]/y,g[2]=c[2]/y):(g[0]=1,g[1]=0,g[2]=0),m},i.eB=yue,i.eC=wO,i.eD=bO,i.eE=[1,1,1],i.eF=zC,i.eG=Xe,i.eH=function(g,c,m,y){var k=c[0],E=c[1],P=c[2],O=c[3];return g[0]=k+y*(m[0]-k),g[1]=E+y*(m[1]-E),g[2]=P+y*(m[2]-P),g[3]=O+y*(m[3]-O),g},i.eI=AC,i.eJ=yh,i.eK=Lp,i.eL=function(g,c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je){var Le=new u(16);return Le[0]=g,Le[1]=c,Le[2]=m,Le[3]=y,Le[4]=k,Le[5]=E,Le[6]=P,Le[7]=O,Le[8]=B,Le[9]=W,Le[10]=J,Le[11]=ee,Le[12]=ne,Le[13]=ce,Le[14]=ue,Le[15]=je,Le},i.eM=M,i.eN=Pv,i.eO=FT,i.eP=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new es(1/0,1/0),max:new es(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(g,c=!1){const m=Nje(new es(0,0),new es(Ys,Ys),g),y=[];if(c&&!kde(m,this._globalClipBounds))return y;for(const k of this._activeRegions){if(k.hiddenByOverlap||!kde(m,k))continue;const E=ett(k.min,k.max,g);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(g){this._setSources(g.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(g){const c=g.getFootprints();if(c.length===0)return;const m=g.getOrder(),y=g.getClipMask(),k=g.getClipScope();for(const E of c){if(!E.footprint)continue;const P=Nje(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(g.getSourceId())}_computeReplacement(){this._activeRegions.sort((c,m)=>c.priority-m.priority||dO(c.min,m.min)||dO(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 g=this._activeRegions.length!==this._prevRegions.length;if(!g){let c=0;for(;!g&&c!==this._activeRegions.length;){const m=this._activeRegions[c],y=this._prevRegions[c];g=m.priority!==y.priority||!kje(m,y)||m.order!==y.order||m.clipMask!==y.clipMask||!nn(m.clipScope,y.clipScope),this._activeRegions[c].hiddenByOverlap=y.hiddenByOverlap,++c}}if(g){++this._updateTime;for(const m of this._activeRegions)m.order!==sA&&(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(g[c]);this._computeReplacement()}},i.eQ=sA,i.eR=class{constructor(g){this._createGrid(g),this._createPoles(g)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const g of this._poleSegments)g.destroy();for(const g of this._gridSegments)g.withSkirts.destroy(),g.withoutSkirts.destroy()}_fillGridMeshWithLods(g,c){const m=new px,y=new bl,k=[],E=g+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?(Le=2*Math.sqrt(je+1),g[3]=.25*Le,g[0]=(ee-ce)/Le,g[1]=(ne-B)/Le,g[2]=(O-W)/Le):P>J&&P>ue?(Le=2*Math.sqrt(1+P-J-ue),g[3]=(ee-ce)/Le,g[0]=.25*Le,g[1]=(O+W)/Le,g[2]=(ne+B)/Le):J>ue?(Le=2*Math.sqrt(1+J-P-ue),g[3]=(ne-B)/Le,g[0]=(O+W)/Le,g[1]=.25*Le,g[2]=(ee+ce)/Le):(Le=2*Math.sqrt(1+ue-P-J),g[3]=(O-W)/Le,g[0]=(ne+B)/Le,g[1]=(ee+ce)/Le,g[2]=.25*Le),g},i.f=function(g){return btoa(encodeURIComponent(g).replace(/%([0-9A-F]{2})/g,(c,m)=>String.fromCharCode(+("0x"+m))))},i.f0=function([g,c,m]){const y=Math.hypot(g,c,m),k=Math.atan2(g,m),E=.5*Math.PI-Math.acos(-c/y);return new x(ii(k),ii(E))},i.f1=Ke,i.f2=zde,i.f3=function(g){const c=g.navigator?g.navigator.userAgent:null;return!!function(m){if($o==null){const y=m.navigator?m.navigator.userAgent:null;$o=!!m.safari||!(!y||!(/\b(iPad|iPhone|iPod)\b/.test(y)||y.match("Safari")&&!y.match("Chrome")))}return $o}(g)&&!(!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(g,c){lv=g,cv=c},i.f5=fde,i.f6=G2e,i.f7=function(g){const c=[0,0,0],m=w(new Float64Array(16));return C(m,g.pixelMatrix,g.globeMatrix),Dt(c,c,m),new es(c[0],c[1])},i.f8=function(){const g=lA;g&&(g.isPreloaded()&&g.numActive()===1?(g.release(Ade),lA=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(){fO().acquire(Ade)},i.fA=KO,i.fB=Vt,i.fC=function(g){let c=0;if(new Uint32Array(g,0,1)[0]!==ake){const m=new Uint32Array(g,0,7),[,,y,k,E,P]=m;c=m.byteLength+k+E+P+E,(y!==g.byteLength||c>=g.byteLength)&&dr("Invalid b3dm header information.")}return cke(g,c)},i.fD=function(g,c){const m=Vde(g);for(const y of m){for(const k of y.meshes)Ett(k);y.lights&&(y.lightMeshIndex=y.meshes.length,y.meshes.push(Ptt(y.lights,c)))}return m},i.fE=qO,i.fF=ha,i.fG=eke,i.fH=Hf,i.fI=Vu,i.fJ=function(g){md(),hh!=null&&hh.then(c=>{c.keys().then(m=>{for(let y=0;ydr(k.message))}).catch(m=>dr(m.message))}).catch(c=>dr(c.message))},i.fa=Nb,i.fb=function(g,c,m=!1){if(tu===Vu.deferred||tu===Vu.loading||tu===Vu.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Vf=_l.resolveURL(g),tu=Vu.deferred,CT=c,YS(),m||OD()},i.fc=function(g){CC=_l.resolveURL(g),MC||(MC=new SC(fO(),new Ts)),MC.broadcast("setMeshoptUrl",CC)},i.fd=rke,i.fe=function(g){Ide=_l.resolveURL(g),MC||(MC=new SC(fO(),new Ts)),MC.broadcast("setDracoUrl",Ide)},i.ff=ske,i.fg=oA,i.fh=function(g){const c=mh();if(!c)return;const m=c.delete(ov);g&&m.then(()=>g()).catch(g)},i.fi=zb,i.fj=vr,i.fk=zv,i.fl=sg,i.fm=wSe,i.fn=jSe,i.fo=kke,i.fp=ds,i.fq="hd_road_elevation",i.fr=Xa,i.fs=Xt,i.ft=By,i.fu=rue,i.fv=qb,i.fw=function(g,c,m,y,k,E,P,O=1,B,W,J){g.createArrays(),g.tilePixelRatio=Ys/(512*g.overscaling),g.compareText={},g.iconsNeedLinear=!1;const ee=g.layers[0].layout,ne=g.layers[0]._unevaluatedLayout._values,ce={};ce.scaleFactor=O,ce.textSizeScaleRange=ee.get("text-size-scale-range"),ce.iconSizeScaleRange=ee.get("icon-size-scale-range");const[ue,je]=ce.textSizeScaleRange,[Le,Ie]=ce.iconSizeScaleRange;ce.textScaleFactor=Se(ce.scaleFactor,ue,je),ce.iconScaleFactor=Se(ce.scaleFactor,Le,Ie);const Ge=ne["text-size"],Ye=ne["icon-size"];if(g.textSizeData.kind==="composite"){const{minZoom:qt,maxZoom:is}=g.textSizeData;ce.compositeTextSizes=[Ge.possiblyEvaluate(new Di(qt,{worldview:J}),E),Ge.possiblyEvaluate(new Di(is,{worldview:J}),E)]}if(g.iconSizeData.kind==="composite"){const{minZoom:qt,maxZoom:is}=g.iconSizeData;ce.compositeIconSizes=[Ye.possiblyEvaluate(new Di(qt,{worldview:J}),E),Ye.possiblyEvaluate(new Di(is,{worldview:J}),E)]}ce.layoutTextSize=Ge.possiblyEvaluate(new Di(P+1,{worldview:J}),E),ce.layoutIconSize=Ye.possiblyEvaluate(new Di(P+1,{worldview:J}),E),ce.textMaxSize=Ge.possiblyEvaluate(new Di(18,{worldview:J}),E);const nt=ee.get("symbol-placement"),bt=ee.get("text-rotation-alignment")==="map"&&nt!=="point",ft=ee.get("text-size");let St=!1;const It=[];for(const qt of g.features){const is=ee.get("text-font").evaluate(qt,{},E).join(","),Wt=ft.evaluate(qt,{},E)*ce.textScaleFactor,ms=ce.layoutTextSize.evaluate(qt,{},E)*ce.textScaleFactor,_s=ce.layoutIconSize.evaluate(qt,{},E)*ce.iconScaleFactor,bs={horizontal:{},vertical:void 0},Os=qt.text;let Fs,Ps=[0,0];if(Os){const Ln=Os.toString(),vi=ee.get("text-letter-spacing").evaluate(qt,{},E)*oc,gt=ee.get("text-line-height").evaluate(qt,{},E)*oc,wt=NT(Ln)?vi:0,ps=ee.get("text-anchor").evaluate(qt,{},E),Rs=ee.get("text-variable-anchor");if(!Rs){const Sn=ee.get("text-radial-offset").evaluate(qt,{},E);if(Sn)Ps=iNe(ps,[Sn*oc,iue]);else{const zn=ee.get("text-offset").evaluate(qt,{},E);Ps=[zn[0]*oc,zn[1]*oc]}}let nr=bt?"center":ee.get("text-justify").evaluate(qt,{},E);const ar=nt==="point",Or=ar?ee.get("text-max-width").evaluate(qt,{},E)*oc:1/0,zr=Sn=>{g.allowVerticalPlacement&&jb(Ln)&&(bs.vertical=Qde(Os,c,m,k,is,Or,gt,ps,Sn,wt,Ps,bh.vertical,!0,ms,Wt,B))};if(!bt&&Rs){const Sn=nr==="auto"?Rs.map(Vn=>oue(Vn)):[nr];let zn=!1;for(let Vn=0;Vn=0||!jb(Ln)){const Sn=Qde(Os,c,m,k,is,Or,gt,ps,nr,wt,Ps,bh.horizontal,!1,ms,Wt,B);Sn&&(bs.horizontal[nr]=Sn)}zr(ar?"left":nr)}}let Ls,hs,cs,Ds,Xs,qs,Lr=!1;const cr=ee.get("icon-text-fit").evaluate(qt,{},E);if(qt.icon&&qt.icon.hasPrimary()){const Ln=yA(qt.icon,g.iconSizeData,ne["icon-size"],E,g.zoom,qt,B,ce.iconScaleFactor,J);Ls=Ln.iconPrimary,cs=Ln.iconSecondary;const vi=Ls.toString();if(hs=y.get(vi),hs&&(Xs=ee.get("icon-offset").evaluate(qt,{},E),qs=ee.get("icon-anchor").evaluate(qt,{},E),Fs=CO(k.get(vi),cs?k.get(cs.toString()):void 0,Xs,qs),Lr=hs.sdf,g.sdfIcons===void 0?g.sdfIcons=hs.sdf:g.sdfIcons!==hs.sdf&&dr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(hs.pixelRatio!==g.pixelRatio||ee.get("icon-rotate").constantOr(1)!==0)&&(g.iconsNeedLinear=!0)),cs){const gt=cs.toString();Ds=y.get(gt)}}St=St||!(!qt.icon||!qt.icon.hasSecondary());const gr=PO(bs.horizontal)||bs.vertical;g.iconsInText||(g.iconsInText=!!gr&&gr.iconsInText);const kr=ms*ce.textScaleFactor/oc,{defaultShapedIcon:Hn,verticallyShapedIcon:Us}=Bst(g,Fs,ee,qt,E,bs,kr,Xs,cr);cr!=="none"&&Fs&&(Hke(Fs)||Wke(Fs))&&(EO(0,hs,Ls,Fs,Hn,cr,W,y,k),EO(0,Ds,cs,Fs,Hn,cr,W,y,k),Us&&(EO(0,hs,Ls,Fs,Us,cr,W,y,k),EO(0,Ds,cs,Fs,Us,cr,W,y,k))),Fs=Hn;const{iconBBox:Nr,iconVerticalBBox:mn,textBBox:pa,textVerticalBBox:xa}=Dst(g,Fs,Us,ee,qt,E,_s,Xs,ce,k,qs,bs,ms,Ps);It.push({feature:qt,shapedTextOrientations:bs,shapedText:gr,shapedIcon:Fs,iconPrimary:Ls,iconSecondary:cs,iconOffset:Xs,iconAnchor:qs,verticallyShapedIcon:Us,layoutTextSize:ms,layoutIconSize:_s,textOffset:Ps,isSDFIcon:Lr,iconTextFit:cr,iconCollisionBounds:Nr,iconVerticalCollisionBounds:mn,textCollisionBounds:pa,textVerticalCollisionBounds:xa})}return{featureData:It,sizes:ce,hasAnySecondaryIcon:St,textAlongLine:bt,symbolPlacement:nt}},i.fx=eNe,i.fy=function(g,c,m,y,k,E,P,O,B,W){g.iconAtlasPositions=W.iconPositions;const{featureData:J,hasAnySecondaryIcon:ee,sizes:ne,textAlongLine:ce,symbolPlacement:ue}=c;for(const je of J){const{shapedIcon:Le,verticallyShapedIcon:Ie,feature:Ge,shapedTextOrientations:Ye,shapedText:nt,layoutTextSize:bt,textOffset:ft,isSDFIcon:St,iconPrimary:It,iconSecondary:qt,iconTextFit:is,iconOffset:Wt,iconCollisionBounds:ms,iconVerticalCollisionBounds:_s,textCollisionBounds:bs}=je;lNe(Le,W.iconPositions,It,qt),lNe(Ie,W.iconPositions,It,qt),zst(Ye,W.iconPositions),Fst(It,qt,W.iconPositions),(nt||Le)&&$st(g,Ge,Ye,Le,Ie,B,ne,bt,0,ft,St,y,k,P,O,ee,is,Wt,ce,ue,ms,_s,bs)}m&&g.generateCollisionDebugBuffers(E,g.collisionBoxArray,ne.textScaleFactor)},i.fz=Yt,i.g=function(g,c){return Of(Object.assign(g,{method:"GET"}),c)},i.h=function(g){return g.indexOf("mapbox:")===0},i.i=function(g){return sa.API_STYLE_REGEX.test(g)&&!ac(g)},i.j=eo,i.k=Pd,i.l=function(g){return decodeURIComponent(atob(g).split("").map(c=>"%"+("00"+c.charCodeAt(0).toString(16)).slice(-2)).join(""))},i.m=function(g,c){return Of(Object.assign(g,{type:"json"}),c)},i.n=tx,i.o=_l,i.p=function(g,c){return Of(Object.assign(g,{method:"POST"}),c)},i.q=yd,i.r=em,i.s=function(g){try{const c=self[g];return c.setItem("_mapbox_test_",1),c.removeItem("_mapbox_test_"),!0}catch{return!1}},i.t=function(){return Ede||(Ede=new zb("ImageRasterizer")),Ede},i.u=function(){return function g(c){return c?(c^Math.random()*(16>>c/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,g)}()},i.v=function(g){return!!g&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(g)},i.w=dr,i.x=kue,i.y=sx,i.z=rm}),o(["./shared"],function(i){function d(dt){const Se=dt?dt.url.toString():void 0;return Se?performance.getEntriesByName(Se):[]}function u(dt){if(typeof dt=="number"||typeof dt=="boolean"||typeof dt=="string"||dt==null)return JSON.stringify(dt);if(Array.isArray(dt)){let ze="[";for(const st of dt)ze+=`${u(st)},`;return`${ze}]`}let Se="{";for(const ze of Object.keys(dt).sort())Se+=`${ze}:${u(dt[ze])},`;return`${Se}}`}function p(dt){let Se="";for(const ze of i.bx)Se+=`/${u(dt[ze])}`;return Se}class f{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,st){this._options=st;for(const Nt of Se)this._layerConfigs[Nt.id]=Nt,(this._layers[Nt.id]=i.du(Nt,this.scope,null,this._options)).compileFilter(st),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 Tt=function(Nt,Bt){const Zt={};for(let Xt=0;Xtthis._layers[pr.id]),Zt=Bt[0];if(Zt.visibility==="none")continue;const Ut=Zt.source||"";let Xt=this.familiesBySource[Ut];Xt||(Xt=this.familiesBySource[Ut]={});const Is=Zt.sourceLayer||"_geojsonTileLayer";let xs=Xt[Is];xs||(xs=Xt[Is]=[]),xs.push(Bt)}}}const v=1*i.fl;class _{constructor(Se){const ze={},st=[];for(const Zt in Se){const Ut=Se[Zt],Xt=ze[Zt]={};for(const Is in Ut.glyphs){const xs=Ut.glyphs[+Is];if(!xs||xs.bitmap.width===0||xs.bitmap.height===0)continue;const pr=xs.metrics.localGlyph?v:1,qr={x:0,y:0,w:xs.bitmap.width+2*pr,h:xs.bitmap.height+2*pr};st.push(qr),Xt[Is]=qr}}const{w:Tt,h:Nt}=i.G(st),Bt=new i.fk({width:Tt||1,height:Nt||1});for(const Zt in Se){const Ut=Se[Zt];for(const Xt in Ut.glyphs){const Is=Ut.glyphs[+Xt];if(!Is||Is.bitmap.width===0||Is.bitmap.height===0)continue;const xs=ze[Zt][Xt],pr=Is.metrics.localGlyph?v:1;i.fk.copy(Is.bitmap,Bt,{x:0,y:0},{x:xs.x+pr,y:xs.y+pr},Is.bitmap)}}this.image=Bt,this.positions=ze}}function b(dt,Se,ze){dt[Se]?ze&&(dt[Se].center=ze):dt[Se]={floorIds:new Set,center:ze||[0,0],floors:{}}}function j(dt,Se,ze,st){for(const Tt of Se)b(dt,Tt),dt[Tt].floors[ze]=st,dt[Tt].floorIds.add(ze)}function w(dt){return{id:dt.properties.id.toString(),center:dt.properties.center.toString().split(";").map(Number)}}function N(dt){return{id:dt.properties.id.toString(),isDefault:!!dt.properties.is_default&&dt.properties.is_default,connections:dt.properties.connected_floor_ids?new Set(dt.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:dt.properties.conflicted_floor_ids?new Set(dt.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:dt.properties.building_ids?new Set(dt.properties.building_ids.toString().split(";")):new Set,name:dt.properties.name.toString(),zIndex:dt.properties.z_index}}function C(dt,Se){return Se.every(ze=>dt.properties&&dt.properties[ze]!=null)}function A(dt){return C(dt,["type","id","name"])&&dt.properties.type==="building"}function I(dt){return C(dt,["type","id","name","z_index"])&&dt.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,st,Tt,Nt,Bt){this.status="parsing",this.data=Se,this.collisionBoxArray=new i.b3;const Zt=new i.fm(Object.keys(Se.layers).sort()),Ut=new i.fn(this.tileID,this.promoteId);Ut.bucketLayerIDs=[];const Xt={},Is=new i.fo(256,256),xs={featureIndex:Ut,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Is,availableImages:st,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const Cn=this.indoor.indoorState.activeFloorsVisible,Mn=function(wn,ha,co){const $o=function(Qi,ba){if(!Qi)return i.w("No source layers defined in indoor specification"),ba;if(Qi.size===0)return ba;const Ji=Qi.difference(ba);for(const yi of Ji)i.w(`Missing source layer required in indoor specification: ${yi}`);return ba.intersection(ba)}(ha.sourceLayers,new Set(Object.keys(wn.layers))),Wa=ha.indoorState,Wo=function(Qi,ba,Ji,yi){const sa=new Set,eo=new Set,ac=new Set,yc=new Map,Ad={},kp=vl=>{const wu=yc.get(vl)||new Set;for(const Xc of sa)if((yc.get(Xc)||new Set).has(vl)||wu.has(Xc))return!0;return!1};for(const vl of ba){const wu=Qi.layers[vl];if(wu)for(let Xc=0;Xc=Ji.maxzoom||Ji.visibility==="none")continue;R(ba,this.zoom,xs.brightness,st,this.worldview);const yi=Xt[Ji.id]=Ji.createBucket({index:Ut.bucketLayerIDs.length,layers:ba,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:$o,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:Tt,worldview:this.worldview,localizable:Wo});Ut.bucketLayerIDs.push(ba.map(eo=>i.B(eo.id,eo.scope)));let sa=yi.prepare?yi.prepare():null;sa!=null?(sa=sa.then(()=>yi.populate(Wa,xs,this.tileID.canonical,this.tileTransform)),pr.push(sa)):yi.populate(Wa,xs,this.tileID.canonical,this.tileTransform)}}const dr=()=>{let Cn,Mn,wn,ha,co,$o;Is.trim();const Wa={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},Wo=()=>{if(Cn)return this.status="done",Bt(Cn);if(this.extraShadowCaster)this.status="done",Bt(null,{buckets:Object.values(Xt).filter(ba=>!ba.isEmpty()),featureIndex:Ut,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:xs.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Mn&&wn&&ha){const ba=new _(Mn),Ji=new Map;for(const[eo,ac]of wn.entries()){const{imagePosition:yc}=i.fu(eo,ac,i.fv);Ji.set(eo,yc)}const yi={};for(const eo in Xt){const ac=Xt[eo];ac instanceof i.b4&&(R(ac.layers,this.zoom,xs.brightness,st,this.worldview),yi[eo]=i.fw(ac,Mn,ba.positions,wn,Ji,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,co,this.worldview))}const sa={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(Nt,wn,co,()=>{sa.iconsPending=!1,Qi(yi,ba,sa)}),this.rasterizeIfNeeded(Nt,ha,$o,()=>{sa.patternsPending=!1,Qi(yi,ba,sa)})}},Qi=(ba,Ji,yi,sa)=>{if(yi.iconsPending||yi.patternsPending)return;const eo=new i.fx(wn,ha,this.lut);for(const ac in Xt){const yc=Xt[ac];if(ac in ba)i.fy(yc,ba[ac],this.showCollisionBoxes,st,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,wn,eo);else if(yc.hasPattern&&(yc instanceof i.ba||yc instanceof i.bb||yc instanceof i.ea)){R(yc.layers,this.zoom,xs.brightness,st,this.worldview);const Ad=Object.fromEntries(eo.patternPositions);yc.addFeatures(xs,this.tileID.canonical,Ad,st,this.tileTransform,this.brightness)}}this.status="done",Bt(null,{buckets:Object.values(Xt).filter(ac=>!ac.isEmpty()),featureIndex:Ut,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Ji.image,lineAtlas:Is,imageAtlas:eo,brightness:xs.brightness})};if(!this.extraShadowCaster){const ba=i.fs(xs.glyphDependencies,sa=>Object.keys(sa).map(Number));Object.keys(ba).length?Nt.send("getGlyphs",{uid:this.uid,stacks:ba},(sa,eo)=>{Cn||(Cn=sa,Mn=eo,Wo())},void 0,!1,Wa):Mn={};const Ji=Array.from(xs.iconDependencies.keys()).map(sa=>i.I.parse(sa));Ji.length?Nt.send("getImages",{images:Ji,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(sa,eo)=>{Cn||(Cn=sa,wn=new Map,co=this.updateImageMapAndGetImageTaskQueue(wn,eo,xs.iconDependencies),Wo())},void 0,!1,Wa):(wn=new Map,co=new Map);const yi=Array.from(xs.patternDependencies.keys()).map(sa=>i.I.parse(sa));yi.length?Nt.send("getImages",{images:yi,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(sa,eo)=>{Cn||(Cn=sa,ha=new Map,$o=this.updateImageMapAndGetImageTaskQueue(ha,eo,xs.patternDependencies),Wo())},void 0,!1,Wa):(ha=new Map,$o=new Map)}if(xs.elevationFeatures&&xs.elevationFeatures.length>0){const ba=[];for(const yi of Object.values(Xt))if(yi instanceof i.bb){const sa=yi.getUnevaluatedPortalGraph();sa&&ba.push(sa)}const Ji=i.ft.evaluate(ba);for(const yi of Object.values(Xt))if(yi instanceof i.bb){const sa=Se.layers[Zt.decode(yi.sourceLayerIndex)];yi.setEvaluatedPortalGraph(Ji,sa,this.tileID.canonical,xs.availableImages,xs.brightness)}}Wo()};pr.length>0?Promise.allSettled(pr).then(dr).catch(Bt):dr()}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,st,Tt){Array.from(ze.values()).some(Nt=>Nt.usvg)?this.rasterize(Se,ze,st,Tt):Tt()}updateImageMapAndGetImageTaskQueue(Se,ze,st){const Tt=new Map;for(const Nt of ze.keys()){const Bt=st.get(Nt)||[];for(const Zt of Bt){const Ut=Zt.toString(),Xt=ze.get(Zt.id.toString());Xt.usvg?Tt.has(Ut)||(Tt.set(Ut,Zt),Se.set(Ut,Object.assign({},Xt))):Se.set(Ut,Xt)}}return Tt}rasterize(Se,ze,st,Tt){this.rasterizeTask=Se.send("rasterizeImages",{scope:this.scope,tasks:st},(Nt,Bt)=>{if(!Nt)for(const[Zt,Ut]of Bt.entries()){const Xt=Object.assign(ze.get(Zt),{data:Ut});ze.set(Zt,Xt)}Tt()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function R(dt,Se,ze,st,Tt){const Nt=new i.ac(Se,{brightness:ze,worldview:Tt});for(const Bt of dt)Bt.recalculate(Nt,st)}class $ extends i.E{constructor(Se,ze,st,Tt,Nt,Bt,Zt){super(),this.actor=Se,this.layerIndex=ze,this.availableImages=st,this.availableModels=Tt,this.loadVectorData=Bt||i.aL,this.loading={},this.loaded={},this.deduped=new i.aK(Se.scheduler),this.isSpriteLoaded=Nt,this.scheduler=Se.scheduler,this.brightness=Zt}loadTile(Se,ze){const st=Se.uid,Tt=Se&&Se.request,Nt=Tt&&Tt.collectResourceTiming,Bt=this.loading[st]=new L(Se);Bt.abort=this.loadVectorData(Se,(Zt,Ut)=>{const Xt=!this.loading[st];if(delete this.loading[st],Bt.cancelRasterize(),Xt||Zt||!Ut)return Bt.status="done",Xt||(this.loaded[st]=Bt),ze(Zt);const Is=Ut.rawData,xs={},pr=i.aM(Ut.responseHeaders);pr&&pr.expires&&(xs.expires=pr.expires),pr&&pr.cacheControl&&(xs.cacheControl=pr.cacheControl),Bt.vectorTile=Ut.vectorTile||new i.fz(new i.bt(Is));const qr=()=>{Bt.parse(Bt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(dr,Cn)=>{if(dr||!Cn)return ze(dr);const Mn={};if(Nt){const wn=d(Tt);wn.length>0&&(Mn.resourceTiming=JSON.parse(JSON.stringify(wn)))}ze(null,Object.assign({rawTileData:Is.slice(0),responseHeaders:Ut.responseHeaders},Cn,xs,Mn))})};this.isSpriteLoaded?qr():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(qr,{type:"parseTile",isSymbolTile:Se.isSymbolTile,zoom:Se.tileZoom}):qr()}),this.loaded=this.loaded||{},this.loaded[st]=Bt})}reloadTile(Se,ze){const st=this.loaded,Tt=Se.uid;if(st&&st[Tt]){const Nt=st[Tt];Nt.updateParameters(Se);const Bt=(Zt,Ut)=>{const Xt=Nt.reloadCallback;Xt&&(delete Nt.reloadCallback,Nt.parse(Nt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Xt)),ze(Zt,Ut)};Nt.status==="parsing"?Nt.reloadCallback=Bt:Nt.status==="done"&&(Nt.vectorTile?Nt.parse(Nt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Bt):Bt())}else ze(null,void 0)}abortTile(Se,ze){const st=Se.uid,Tt=this.loading[st];Tt&&(Tt.abort&&Tt.abort(),delete this.loading[st]),ze()}removeTile(Se,ze){const st=this.loaded,Tt=Se.uid;st&&st[Tt]&&delete st[Tt],ze()}}class q{loadTile(Se,ze){const{uid:st,encoding:Tt,rawImageData:Nt,padding:Bt}=Se,Zt=ImageBitmap&&Nt instanceof ImageBitmap?this.getImageData(Nt,Bt):Nt;ze(null,new i.fA(st,Zt,Tt,Bt<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 st=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),st}}i.bs.setPbf(i.bt);class U{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 st=this._mrt;this.status="parsing",this._entireBuffer=Se;try{st.parseHeader(Se),this._isHeaderLoaded=!0;const Tt=[];for(const Nt in st.layers){const Bt=st.getLayer(Nt),Zt=Bt.getDataRange(Bt.getBandList()),Ut=st.createDecodingTask(Zt),Xt=Se.slice(Zt.firstByte,Zt.lastByte+1),Is=i.bs.performDecoding(Xt,Ut).then(xs=>Ut.complete(null,xs)).catch(xs=>Ut.complete(xs,null));Tt.push(Is)}Promise.allSettled(Tt).then(()=>ze(null,st)).catch(Nt=>ze(Nt))}catch(Tt){ze(Tt)}}}class V{constructor(Se){this.actor=Se,this.loading={},this.loaded={}}loadTile(Se,ze){const st=Se.uid,Tt=Se.request,Nt=this.loading[st]=new U(Se),{cancel:Bt}=i.bu(Tt,(Zt,Ut,Xt)=>{const Is=!this.loading[st];if(delete this.loading[st],Is||Zt||!Ut)return Nt.status="done",Is||(this.loaded[st]=Nt),ze(Zt);Nt.parse(Ut,(xs,pr)=>{if(xs||!pr)return ze(xs);ze(null,pr,Xt)}),this.loaded[st]=Nt});Nt.abort=Bt}reloadTile(Se,ze){ze(null,void 0)}abortTile(Se,ze){const st=Se.uid,Tt=this.loading[st];Tt&&(Tt.abort&&Tt.abort(),delete this.loading[st]),ze()}removeTile(Se,ze){const st=Se.uid;this.loaded[st]&&delete this.loaded[st],ze()}decodeRasterArray(Se,ze){i.bs.performDecoding(Se.buffer,Se.task).then(st=>ze(null,st)).catch(st=>ze(st))}}const X=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 st=[];for(const Tt of ze)st.push(new i.P(Tt[0],Tt[1]));Se.push(st)}return Se}}toGeoJSON(Se,ze,st){return X.call(this,Se,ze,st)}}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 de=64/4096,ie=128;class ae{constructor(){this.features=new Map}clear(){this.features.clear()}load(Se=[],ze){for(const st of Se){const Tt=st.id;if(Tt==null)continue;let Nt=this.features.get(Tt);Nt&&this.updateCache(Nt,ze),st.geometry?(Nt=pe(st),this.updateCache(Nt,ze),this.features.set(Tt,Nt)):this.features.delete(Tt),this.updateCache(Nt,ze)}}updateCache(Se,ze){for(const{canonical:st,uid:Tt}of Object.values(ze)){const{z:Nt,x:Bt,y:Zt}=st;le(Se,Math.pow(2,Nt),Bt,Zt)&&delete ze[Tt]}}getTile(Se,ze,st){const Tt=Math.pow(2,Se),Nt=[];for(const Bt of this.features.values())le(Bt,Tt,ze,st)&&Nt.push(ke(Bt,Tt,ze,st));return{features:Nt}}getFeatures(){return[...this.features.values()]}}function le({minX:dt,minY:Se,maxX:ze,maxY:st},Tt,Nt,Bt){return dt<(Nt+1+de)/Tt&&Se<(Bt+1+de)/Tt&&ze>(Nt-de)/Tt&&st>(Bt-de)/Tt}function pe(dt){const{id:Se,geometry:ze,properties:st}=dt;if(!ze)return;if(ze.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:Tt,coordinates:Nt}=ze,Bt={id:Se,type:1,geometry:[],tags:st,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Zt=Bt.geometry;if(Tt==="Point")be(Nt,Zt,Bt);else if(Tt==="MultiPoint")for(const Ut of Nt)be(Ut,Zt,Bt);else if(Tt==="LineString")Bt.type=2,ye(Nt,Zt,Bt);else if(Tt==="MultiLineString")Bt.type=2,we(Nt,Zt,Bt);else if(Tt==="Polygon")Bt.type=3,we(Nt,Zt,Bt,!0);else{if(Tt!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Bt.type=3;for(const Ut of Nt)we(Ut,Zt,Bt,!0)}return Bt}function be([dt,Se],ze,st){const Tt=i.aF(dt);let Nt=i.aJ(Se);Nt=Nt<0?0:Nt>1?1:Nt,ze.push(Tt,Nt),st.minX=Math.min(st.minX,Tt),st.minY=Math.min(st.minY,Nt),st.maxX=Math.max(st.maxX,Tt),st.maxY=Math.max(st.maxY,Nt)}function ye(dt,Se,ze,st=!1,Tt=!1){const Nt=[];for(const Bt of dt)be(Bt,Nt,ze);Se.push(Nt),st&&function(Bt,Zt){let Ut=0;for(let Xt=0,Is=Bt.length,xs=Is-2;Xt0===Zt)for(let Xt=0,Is=Bt.length;Xt=Bt&&xs>=Bt||(Xt>=Bt?(Is+=Math.round(dr*((Bt-Xt)/qr)),Xt=Bt):xs>=Bt&&(pr=Is+Math.round(dr*((Bt-Xt)/qr)),xs=Bt),Is>=Bt&&pr>=Bt||(Is>=Bt?(Xt+=Math.round(qr*((Bt-Is)/dr)),Is=Bt):pr>=Bt&&(xs=Xt+Math.round(qr*((Bt-Is)/dr)),pr=Bt),Zt&&Xt===Zt[Zt.length-1][0]&&Is===Zt[Zt.length-1][1]||(Zt=[[Xt,Is]],Tt.push(Zt)),Zt.push([xs,pr])))))}}function _e(dt,Se,ze,st,Tt){const Nt=(ze-de)/Se,Bt=(st-de)/Se,Zt=(ze+1+de)/Se,Ut=(st+1+de)/Se;function Xt(pr,qr){let dr=0;return prZt&&(dr|=2),qrUt&&(dr|=8),dr}let Is=[];for(let pr=1;pr<=8;pr*=2){let qr=dt[dt.length-2],dr=dt[dt.length-1],Cn=!(Xt(qr,dr)&pr);for(let Mn=0;Mn>31}function ht(dt,Se){const{geometry:ze,type:st}=dt;let Tt=0,Nt=0;if(st===1){Se.writeVarint(Ae(1,ze.length));for(const Bt of ze){const Zt=Bt[0]-Tt,Ut=Bt[1]-Nt;Se.writeVarint(We(Zt)),Se.writeVarint(We(Ut)),Tt+=Zt,Nt+=Ut}}else for(const Bt of ze){Se.writeVarint(Ae(1,1));const Zt=Bt.length-(st===3?1:0);for(let Ut=0;Utdt},he=Math.fround||(Qe=new Float32Array(1),dt=>(Qe[0]=+dt,Qe[0]));var Qe;const ot=3,rt=5,Ne=6;class it{constructor(Se){this.options=Object.assign(Object.create(Dt),Se),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(Se){const{log:ze,minZoom:st,maxZoom:Tt}=this.options;ze&&console.time("total time");const Nt=`prepare ${Se.length} points`;ze&&console.time(Nt),this.points=Se;const Bt=[];for(let Ut=0;Ut=st;Ut--){const Xt=+Date.now();Zt=this.trees[Ut]=this._createTree(this._cluster(Zt,Ut)),ze&&console.log("z%d: %d clusters in %dms",Ut,Zt.numItems,+Date.now()-Xt)}return ze&&console.timeEnd("total time"),this}getClusters(Se,ze){let st=((Se[0]+180)%360+360)%360-180;const Tt=Math.max(-90,Math.min(90,Se[1]));let Nt=Se[2]===180?180:((Se[2]+180)%360+360)%360-180;const Bt=Math.max(-90,Math.min(90,Se[3]));if(Se[2]-Se[0]>=360)st=-180,Nt=180;else if(st>Nt){const xs=this.getClusters([st,Tt,180,Bt],ze),pr=this.getClusters([-180,Tt,Nt,Bt],ze);return xs.concat(pr)}const Zt=this.trees[this._limitZoom(ze)],Ut=Zt.range($e(st),Ke(Bt),$e(Nt),Ke(Tt)),Xt=Zt.data,Is=[];for(const xs of Ut){const pr=this.stride*xs;Is.push(Xt[pr+rt]>1?qe(Xt,pr,this.clusterProps):this.points[Xt[pr+ot]])}return Is}getChildren(Se){const ze=this._getOriginId(Se),st=this._getOriginZoom(Se),Tt="No cluster with the specified id.",Nt=this.trees[st];if(!Nt)throw new Error(Tt);const Bt=Nt.data;if(ze*this.stride>=Bt.length)throw new Error(Tt);const Zt=this.options.radius/(this.options.extent*Math.pow(2,st-1)),Ut=Nt.within(Bt[ze*this.stride],Bt[ze*this.stride+1],Zt),Xt=[];for(const Is of Ut){const xs=Is*this.stride;Bt[xs+4]===Se&&Xt.push(Bt[xs+rt]>1?qe(Bt,xs,this.clusterProps):this.points[Bt[xs+ot]])}if(Xt.length===0)throw new Error(Tt);return Xt}getLeaves(Se,ze,st){const Tt=[];return this._appendLeaves(Tt,Se,ze=ze||10,st=st||0,0),Tt}getTile(Se,ze,st){const Tt=this.trees[this._limitZoom(Se)],Nt=Math.pow(2,Se),{extent:Bt,radius:Zt}=this.options,Ut=Zt/Bt,Xt=(st-Ut)/Nt,Is=(st+1+Ut)/Nt,xs={features:[]};return this._addTileFeatures(Tt.range((ze-Ut)/Nt,Xt,(ze+1+Ut)/Nt,Is),Tt.data,ze,st,Nt,xs),ze===0&&this._addTileFeatures(Tt.range(1-Ut/Nt,Xt,1,Is),Tt.data,Nt,st,Nt,xs),ze===Nt-1&&this._addTileFeatures(Tt.range(0,Xt,Ut/Nt,Is),Tt.data,-1,st,Nt,xs),xs.features.length?xs:null}getClusterExpansionZoom(Se){let ze=this._getOriginZoom(Se)-1;for(;ze<=this.options.maxZoom;){const st=this.getChildren(Se);if(ze++,st.length!==1)break;Se=st[0].properties.cluster_id}return ze}_appendLeaves(Se,ze,st,Tt,Nt){const Bt=this.getChildren(ze);for(const Zt of Bt){const Ut=Zt.properties;if(Ut&&Ut.cluster?Nt+Ut.point_count<=Tt?Nt+=Ut.point_count:Nt=this._appendLeaves(Se,Ut.cluster_id,st,Tt,Nt):Nt1;let Is,xs,pr;if(Xt)Is=Xe(ze,Ut,this.clusterProps),xs=ze[Ut],pr=ze[Ut+1];else{const Cn=this.points[ze[Ut+ot]];Is=Cn.properties;const[Mn,wn]=Cn.geometry.coordinates;xs=$e(Mn),pr=Ke(wn)}const qr={type:1,geometry:[[Math.round(this.options.extent*(xs*Nt-st)),Math.round(this.options.extent*(pr*Nt-Tt))]],tags:Is};let dr;dr=Xt||this.options.generateId?ze[Ut+ot]:this.points[ze[Ut+ot]].id,dr!==void 0&&(qr.id=dr),Bt.features.push(qr)}}_limitZoom(Se){return Math.max(this.options.minZoom,Math.min(Math.floor(+Se),this.options.maxZoom+1))}_cluster(Se,ze){const{radius:st,extent:Tt,reduce:Nt,minPoints:Bt}=this.options,Zt=st/(Tt*Math.pow(2,ze)),Ut=Se.data,Xt=[],Is=this.stride;for(let xs=0;xsze&&(Mn+=Ut[ha+rt])}if(Mn>Cn&&Mn>=Bt){let wn,ha=pr*Cn,co=qr*Cn,$o=-1;const Wa=(xs/Is<<5)+(ze+1)+this.points.length;for(const Wo of dr){const Qi=Wo*Is;if(Ut[Qi+2]<=ze)continue;Ut[Qi+2]=ze;const ba=Ut[Qi+rt];ha+=Ut[Qi]*ba,co+=Ut[Qi+1]*ba,Ut[Qi+4]=Wa,Nt&&(wn||(wn=this._map(Ut,xs,!0),$o=this.clusterProps.length,this.clusterProps.push(wn)),Nt(wn,this._map(Ut,Qi)))}Ut[xs+4]=Wa,Xt.push(ha/Mn,co/Mn,1/0,Wa,-1,Mn),Nt&&Xt.push($o)}else{for(let wn=0;wn1)for(const wn of dr){const ha=wn*Is;if(!(Ut[ha+2]<=ze)){Ut[ha+2]=ze;for(let co=0;co>5}_getOriginZoom(Se){return(Se-this.points.length)%32}_map(Se,ze,st){if(Se[ze+rt]>1){const Bt=this.clusterProps[Se[ze+Ne]];return st?Object.assign({},Bt):Bt}const Tt=this.points[Se[ze+ot]].properties,Nt=this.options.map(Tt);return st&&Nt===Tt?Object.assign({},Nt):Nt}}function qe(dt,Se,ze){return{type:"Feature",id:dt[Se+ot],properties:Xe(dt,Se,ze),geometry:{type:"Point",coordinates:[(st=dt[Se],360*(st-.5)),ct(dt[Se+1])]}};var st}function Xe(dt,Se,ze){const st=dt[Se+rt],Tt=st>=1e4?`${Math.round(st/1e3)}k`:st>=1e3?Math.round(st/100)/10+"k":st,Nt=dt[Se+Ne],Bt=Nt===-1?{}:Object.assign({},ze[Nt]);return Object.assign(Bt,{cluster:!0,cluster_id:dt[Se+ot],point_count:st,point_count_abbreviated:Tt})}function $e(dt){return dt/360+.5}function Ke(dt){const Se=Math.sin(dt*Math.PI/180),ze=.5-.25*Math.log((1+Se)/(1-Se))/Math.PI;return ze<0?0:ze>1?1:ze}function ct(dt){const Se=(180-360*dt)*Math.PI/180;return 360*Math.atan(Math.exp(Se))/Math.PI-90}function Ue(dt,Se,ze,st){let Tt=st;const Nt=Se+(ze-Se>>1);let Bt,Zt=ze-Se;const Ut=dt[Se],Xt=dt[Se+1],Is=dt[ze],xs=dt[ze+1];for(let pr=Se+3;prTt)Bt=pr,Tt=qr;else if(qr===Tt){const dr=Math.abs(pr-Nt);drst&&(Bt-Se>3&&Ue(dt,Se,Bt,st),dt[Bt+2]=Tt,ze-Bt>3&&Ue(dt,Bt,ze,st))}function Ve(dt,Se,ze,st,Tt,Nt){let Bt=Tt-ze,Zt=Nt-st;if(Bt!==0||Zt!==0){const Ut=((dt-ze)*Bt+(Se-st)*Zt)/(Bt*Bt+Zt*Zt);Ut>1?(ze=Tt,st=Nt):Ut>0&&(ze+=Bt*Ut,st+=Zt*Ut)}return Bt=dt-ze,Zt=Se-st,Bt*Bt+Zt*Zt}function Je(dt,Se,ze,st){const Tt={id:dt??null,type:Se,geometry:ze,tags:st,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(Se==="Point"||Se==="MultiPoint"||Se==="LineString")Rt(Tt,ze);else if(Se==="Polygon")Rt(Tt,ze[0]);else if(Se==="MultiLineString")for(const Nt of ze)Rt(Tt,Nt);else if(Se==="MultiPolygon")for(const Nt of ze)Rt(Tt,Nt[0]);return Tt}function Rt(dt,Se){for(let ze=0;ze0&&(Bt+=st?(Tt*Is-Xt*Nt)/2:Math.sqrt(Math.pow(Xt-Tt,2)+Math.pow(Is-Nt,2))),Tt=Xt,Nt=Is}const Zt=Se.length-3;Se[2]=1,Ue(Se,0,Zt,ze),Se[Zt+2]=1,Se.size=Math.abs(Bt),Se.start=0,Se.end=Se.size}function rs(dt,Se,ze,st){for(let Tt=0;Tt1?1:ze}function vt(dt,Se,ze,st,Tt,Nt,Bt,Zt){if(st/=Se,Nt>=(ze/=Se)&&Bt=st)return null;const Ut=[];for(const Xt of dt){const Is=Xt.geometry;let xs=Xt.type;const pr=Tt===0?Xt.minX:Xt.minY,qr=Tt===0?Xt.maxX:Xt.maxY;if(pr>=ze&&qr=st)continue;let dr=[];if(xs==="Point"||xs==="MultiPoint")Cs(Is,dr,ze,st,Tt);else if(xs==="LineString")or(Is,dr,ze,st,Tt,!1,Zt.lineMetrics);else if(xs==="MultiLineString")Wn(Is,dr,ze,st,Tt,!1);else if(xs==="Polygon")Wn(Is,dr,ze,st,Tt,!0);else if(xs==="MultiPolygon")for(const Cn of Is){const Mn=[];Wn(Cn,Mn,ze,st,Tt,!0),Mn.length&&dr.push(Mn)}if(dr.length){if(Zt.lineMetrics&&xs==="LineString"){for(const Cn of dr)Ut.push(Je(Xt.id,xs,Cn,Xt.tags));continue}xs!=="LineString"&&xs!=="MultiLineString"||(dr.length===1?(xs="LineString",dr=dr[0]):xs="MultiLineString"),xs!=="Point"&&xs!=="MultiPoint"||(xs=dr.length===3?"Point":"MultiPoint"),Ut.push(Je(Xt.id,xs,dr,Xt.tags))}}return Ut.length?Ut:null}function Cs(dt,Se,ze,st,Tt){for(let Nt=0;Nt=ze&&Bt<=st&&ai(Se,dt[Nt],dt[Nt+1],dt[Nt+2])}}function or(dt,Se,ze,st,Tt,Nt,Bt){let Zt=Ar(dt);const Ut=Tt===0?bo:Fa;let Xt,Is,xs=dt.start;for(let Mn=0;Mnze&&(Is=Ut(Zt,wn,ha,$o,Wa,ze),Bt&&(Zt.start=xs+Xt*Is)):Wo>st?Qi=ze&&(Is=Ut(Zt,wn,ha,$o,Wa,ze),ba=!0),Qi>st&&Wo<=st&&(Is=Ut(Zt,wn,ha,$o,Wa,st),ba=!0),!Nt&&ba&&(Bt&&(Zt.end=xs+Xt*Is),Se.push(Zt),Zt=Ar(dt)),Bt&&(xs+=Xt)}let pr=dt.length-3;const qr=dt[pr],dr=dt[pr+1],Cn=Tt===0?qr:dr;Cn>=ze&&Cn<=st&&ai(Zt,qr,dr,dt[pr+2]),pr=Zt.length-3,Nt&&pr>=3&&(Zt[pr]!==Zt[0]||Zt[pr+1]!==Zt[1])&&ai(Zt,Zt[0],Zt[1],Zt[2]),Zt.length&&Se.push(Zt)}function Ar(dt){const Se=[];return Se.size=dt.size,Se.start=dt.start,Se.end=dt.end,Se}function Wn(dt,Se,ze,st,Tt,Nt){for(const Bt of dt)or(Bt,Se,ze,st,Tt,Nt,!1)}function ai(dt,Se,ze,st){dt.push(Se,ze,st)}function bo(dt,Se,ze,st,Tt,Nt){const Bt=(Nt-Se)/(st-Se);return ai(dt,Nt,ze+(Tt-ze)*Bt,1),Bt}function Fa(dt,Se,ze,st,Tt,Nt){const Bt=(Nt-ze)/(Tt-ze);return ai(dt,Se+(st-Se)*Bt,Nt,1),Bt}function yn(dt,Se){const ze=[];for(let st=0;st0&&Se.size<(Tt?Bt:st))return void(ze.numPoints+=Se.length/3);const Zt=[];for(let Ut=0;UtBt)&&(ze.numSimplified++,Zt.push(Se[Ut],Se[Ut+1])),ze.numPoints++;Tt&&function(Ut,Xt){let Is=0;for(let xs=0,pr=Ut.length,qr=pr-2;xs0===Xt)for(let xs=0,pr=Ut.length;xs24)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 Tt=function(Nt,Bt){const Zt=[];if(Nt.type==="FeatureCollection")for(let Ut=0;Ut1&&console.time("creation"),qr=this.tiles[pr]=Kt(Se,ze,st,Tt,Xt),this.tileCoords.push({z:ze,x:st,y:Tt}),Is)){Is>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",ze,st,Tt,qr.numFeatures,qr.numPoints,qr.numSimplified),console.timeEnd("creation"));const ba=`z${ze}`;this.stats[ba]=(this.stats[ba]||0)+1,this.total++}if(qr.source=Se,Nt==null){if(ze===Xt.indexMaxZoom||qr.numPoints<=Xt.indexMaxPoints)continue}else{if(ze===Xt.maxZoom||ze===Nt)continue;if(Nt!=null){const ba=Nt-ze;if(st!==Bt>>ba||Tt!==Zt>>ba)continue}}if(qr.source=null,Se.length===0)continue;Is>1&&console.time("clipping");const dr=.5*Xt.buffer/Xt.extent,Cn=.5-dr,Mn=.5+dr,wn=1+dr;let ha=null,co=null,$o=null,Wa=null,Wo=vt(Se,xs,st-dr,st+Mn,0,qr.minX,qr.maxX,Xt),Qi=vt(Se,xs,st+Cn,st+wn,0,qr.minX,qr.maxX,Xt);Se=null,Wo&&(ha=vt(Wo,xs,Tt-dr,Tt+Mn,1,qr.minY,qr.maxY,Xt),co=vt(Wo,xs,Tt+Cn,Tt+wn,1,qr.minY,qr.maxY,Xt),Wo=null),Qi&&($o=vt(Qi,xs,Tt-dr,Tt+Mn,1,qr.minY,qr.maxY,Xt),Wa=vt(Qi,xs,Tt+Cn,Tt+wn,1,qr.minY,qr.maxY,Xt),Qi=null),Is>1&&console.timeEnd("clipping"),Ut.push(ha||[],ze+1,2*st,2*Tt),Ut.push(co||[],ze+1,2*st,2*Tt+1),Ut.push($o||[],ze+1,2*st+1,2*Tt),Ut.push(Wa||[],ze+1,2*st+1,2*Tt+1)}}getTile(Se,ze,st){Se=+Se,ze=+ze,st=+st;const Tt=this.options,{extent:Nt,debug:Bt}=Tt;if(Se<0||Se>24)return null;const Zt=1<1&&console.log("drilling down to z%d-%d-%d",Se,ze,st);let Xt,Is=Se,xs=ze,pr=st;for(;!Xt&&Is>0;)Is--,xs>>=1,pr>>=1,Xt=this.tiles[aa(Is,xs,pr)];return Xt&&Xt.source?(Bt>1&&(console.log("found parent tile z%d-%d-%d",Is,xs,pr),console.time("drilling down")),this.splitTile(Xt.source,Is,xs,pr,Se,ze,st),Bt>1&&console.timeEnd("drilling down"),this.tiles[Ut]?Nn(this.tiles[Ut],Nt):null):null}}function aa(dt,Se,ze){return 32*((1<Xt.tags&&"3d_elevation_id"in Xt.tags&&"source"in Xt.tags&&Xt.tags.source==="elevation",Nt=st.features.filter(Xt=>Tt(Xt));let Bt={_geojsonTileLayer:st.features};Nt.length>0&&(Bt={_geojsonTileLayer:st.features.filter(Xt=>!Tt(Xt)),hd_road_elevation:Nt});const Zt=new Y(Bt),Ut=function(Xt){const Is=new i.bt;for(const xs of Object.keys(Xt))Is.writeMessage(3,Ce,{name:xs,features:Xt[xs]});return Is.finish()}(Bt).buffer;Se(null,{vectorTile:Zt,rawData:Ut})}class ii extends ${constructor(Se,ze,st,Tt,Nt,Bt,Zt){super(Se,ze,st,Tt,Nt,Pr,Zt),Bt&&(this.loadGeoJSON=Bt),this._dynamicIndex=new ae}loadData(Se,ze){const st=Se&&Se.request,Tt=st&&st.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(Se,(Nt,Bt)=>{if(Nt||!Bt)return ze(Nt);if(typeof Bt!="object")return ze(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`));{try{if(Se.filter){const Ut=i.U(Se.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Ut.result==="error")throw new Error(Ut.value.map(Xt=>`${Xt.key}: ${Xt.message}`).join(", "));Bt.features=Bt.features.filter(Xt=>Ut.value.evaluate({zoom:0},Xt))}Se.dynamic?(Bt.type==="Feature"&&(Bt={type:"FeatureCollection",features:[Bt]}),Se.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Bt.features,this.loaded),Se.cluster&&(Bt.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=Se.cluster?new it(function({superclusterOptions:Ut,clusterProperties:Xt}){if(!Xt||!Ut)return Ut;const Is={},xs={},pr={accumulated:null,zoom:0},qr={properties:null},dr=Object.keys(Xt);for(const Cn of dr){const[Mn,wn]=Xt[Cn],ha=i.U(wn),co=i.U(typeof Mn=="string"?[Mn,["accumulated"],["get",Cn]]:Mn);Is[Cn]=ha.value,xs[Cn]=co.value}return Ut.map=Cn=>{qr.properties=Cn;const Mn={};for(const wn of dr)Mn[wn]=Is[wn].evaluate(pr,qr);return Mn},Ut.reduce=(Cn,Mn)=>{qr.properties=Mn;for(const wn of dr)pr.accumulated=Cn[wn],Cn[wn]=xs[wn].evaluate(pr,qr)},Ut}(Se)).load(Bt.features):Se.dynamic?this._dynamicIndex:function(Ut,Xt){return new _a(Ut,Xt)}(Bt,Se.geojsonVtOptions)}catch(Ut){return ze(Ut)}const Zt={};if(Tt){const Ut=d(st);Ut&&(Zt.resourceTiming={},Zt.resourceTiming[Se.source]=JSON.parse(JSON.stringify(Ut)))}ze(null,Zt)}})}reloadTile(Se,ze){const st=this.loaded;return st&&st[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(st){ze(st)}}getClusterChildren(Se,ze){try{ze(null,this._geoJSONIndex.getChildren(Se.clusterId))}catch(st){ze(st)}}getClusterLeaves(Se,ze){try{ze(null,this._geoJSONIndex.getLeaves(Se.clusterId,Se.limit,Se.offset))}catch(st){ze(st)}}}class nl{constructor(Se,ze,st){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=st}parse(Se,ze,st,Tt){this.status="parsing";const Nt=new i.aQ(st.tileID.overscaledZ,st.tileID.wrap,st.tileID.canonical.z,st.tileID.canonical.x,st.tileID.canonical.y),Bt=[],Zt=ze.familiesBySource[st.source],Ut=new i.fn(Nt,st.promoteId);Ut.bucketLayerIDs=[],Ut.is3DTile=!0,i.fC(Se).then(Xt=>{if(!Xt)return Tt(new Error("Could not parse tile"));const Is=Xt.json.extensionsUsed&&Xt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Xt.json.asset.extras&&Xt.json.asset.extras.MAPBOX_mesh_features,xs=Xt.json.extensionsUsed&&Xt.json.extensionsUsed.includes("EXT_meshopt_compression"),pr=new i.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const qr in Zt)for(const dr of Zt[qr]){const Cn=dr[0];Ut.bucketLayerIDs.push(dr.map(ha=>i.B(ha.id,ha.scope))),Cn.recalculate(pr,[]);const Mn=i.fD(Xt,1/i.d7(st.tileID.canonical)),wn=new i.fE(dr,Mn,Nt,Is,xs,this.brightness,Ut,this.worldview);Is||(wn.needsUpload=!0),Bt.push(wn),wn.evaluate(Cn)}this.status="done",Tt(null,{buckets:Bt,featureIndex:Ut,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Xt=>Tt(new Error(Xt.message)))}}class mi{constructor(Se,ze,st,Tt,Nt,Bt,Zt,Ut){this.actor=Se,this.layerIndex=ze,this.availableImages=st,this.availableModels=Tt,this.brightness=Zt,this.loading={},this.loaded={},this.worldview=Ut}loadTile(Se,ze){const st=Se.uid,Tt=this.loading[st]=new nl(Se,this.brightness,this.worldview);i.bu(Se.request,(Nt,Bt)=>{const Zt=!this.loading[st];return delete this.loading[st],Zt||Nt?(Tt.status="done",Zt||(this.loaded[st]=Tt),ze(Nt)):Bt&&Bt.byteLength!==0?void Tt.parse(Bt,this.layerIndex,Se,(Ut,Xt)=>{Tt.status="done",this.loaded=this.loaded||{},this.loaded[st]=Tt,Ut||!Xt?ze(Ut):ze(null,Xt)}):(Tt.status="done",this.loaded[st]=Tt,ze())})}reloadTile(Se,ze){const st=this.loaded,Tt=Se.uid;if(st&&st[Tt]){const Nt=st[Tt];Nt.projection=Se.projection,Nt.brightness=Se.brightness;const Bt=(Zt,Ut)=>{Nt.reloadCallback&&(delete Nt.reloadCallback,this.loadTile(Se,ze)),ze(Zt,Ut)};Nt.status==="parsing"?Nt.reloadCallback=Bt:Nt.status==="done"&&this.loadTile(Se,ze)}}abortTile(Se,ze){const st=Se.uid;this.loading[st]&&delete this.loading[st],ze()}removeTile(Se,ze){const st=this.loaded,Tt=Se.uid;st&&st[Tt]&&delete st[Tt],ze()}}class Vl{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:ii,"raster-dem":q,"raster-array":V,"batched-model":mi},this.workerSources={},this.self.registerWorkerSource=(ze,st)=>{if(this.workerSourceTypes[ze])throw new Error(`Worker source with name "${ze}" already registered.`);this.workerSourceTypes[ze]=st},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 st of this.rtlPluginParsingListeners)st(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(Se,ze,st){delete this.layerIndexes[Se],delete this.availableImages[Se],delete this.availableModels[Se],delete this.workerSources[Se],st()}checkIfReady(Se,ze,st){st()}setReferrer(Se,ze){this.referrer=ze}spriteLoaded(Se,ze){this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={});const{scope:st,isLoaded:Tt}=ze;if(this.isSpriteLoaded[Se][st]=Tt,this.workerSources[Se]&&this.workerSources[Se][st])for(const Nt in this.workerSources[Se][st]){const Bt=this.workerSources[Se][st][Nt];for(const Zt in Bt){const Ut=Bt[Zt];Ut instanceof $&&(Ut.isSpriteLoaded=Tt,Ut.fire(new i.z("isSpriteLoaded")))}}}setImages(Se,ze,st){this.availableImages[Se]||(this.availableImages[Se]={});const{scope:Tt,images:Nt}=ze;if(this.availableImages[Se][Tt]=Nt,this.workerSources[Se]&&this.workerSources[Se][Tt]){for(const Bt in this.workerSources[Se][Tt]){const Zt=this.workerSources[Se][Tt][Bt];for(const Ut in Zt)Zt[Ut].availableImages=Nt}st()}else st()}setModels(Se,{scope:ze,models:st},Tt){if(this.availableModels[Se]||(this.availableModels[Se]={}),this.availableModels[Se][ze]=st,this.workerSources[Se]&&this.workerSources[Se][ze]){for(const Nt in this.workerSources[Se][ze]){const Bt=this.workerSources[Se][ze][Nt];for(const Zt in Bt)Bt[Zt].availableModels=st}Tt()}else Tt()}setProjection(Se,ze){this.projections[Se]=i.cm(ze)}setBrightness(Se,ze,st){this.brightness=ze,st()}setWorldview(Se,ze,st){this.worldview=ze,st()}setLayers(Se,ze,st){this.getLayerIndex(Se,ze.scope).replace(ze.layers,ze.options),st()}updateLayers(Se,ze,st){this.getLayerIndex(Se,ze.scope).update(ze.layers,ze.removedIds,ze.options),st()}loadTile(Se,ze,st){ze.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,ze.type,ze.source,ze.scope).loadTile(ze,st)}decodeRasterArray(Se,ze,st){this.getWorkerSource(Se,ze.type,ze.source,ze.scope).decodeRasterArray(ze,st)}reloadTile(Se,ze,st){ze.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,ze.type,ze.source,ze.scope).reloadTile(ze,st)}abortTile(Se,ze,st){this.getWorkerSource(Se,ze.type,ze.source,ze.scope).abortTile(ze,st)}removeTile(Se,ze,st){this.getWorkerSource(Se,ze.type,ze.source,ze.scope).removeTile(ze,st)}removeSource(Se,ze,st){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 Tt=this.workerSources[Se][ze.scope][ze.type][ze.source];delete this.workerSources[Se][ze.scope][ze.type][ze.source],Tt.removeSource!==void 0?Tt.removeSource(ze,st):st()}loadWorkerSource(Se,ze,st){try{this.self.importScripts(ze.url),st()}catch(Tt){st(Tt)}}syncRTLPluginState(Se,ze,st){if(i.fH.isParsed())st(null,!0);else if(i.fH.isParsing())this.rtlPluginParsingListeners.push(st);else try{i.fH.setState(ze);const Tt=i.fH.getPluginURL();!i.fH.isLoaded()||i.fH.isParsed()||i.fH.isParsing()||Tt==null||(i.fH.setState({pluginStatus:i.fI.parsing,pluginURL:i.fH.getPluginURL()}),this.self.importScripts(Tt),i.fH.isParsed()?st(null,!0):this.rtlPluginParsingListeners.push(st))}catch(Tt){st(Tt)}}setDracoUrl(Se,ze){this.dracoUrl=ze}getAvailableImages(Se,ze){this.availableImages[Se]||(this.availableImages[Se]={});let st=this.availableImages[Se][ze];return st||(st=[]),st}getAvailableModels(Se,ze){this.availableModels[Se]||(this.availableModels[Se]={});let st=this.availableModels[Se][ze];return st||(st={}),st}getLayerIndex(Se,ze){this.layerIndexes[Se]||(this.layerIndexes[Se]={});let st=this.layerIndexes[Se][ze];return st||(st=this.layerIndexes[Se][ze]=new f,st.scope=ze),st}getWorkerSource(Se,ze,st,Tt){const Nt=this.workerSources;return Nt[Se]||(Nt[Se]={}),Nt[Se][Tt]||(Nt[Se][Tt]={}),Nt[Se][Tt][ze]||(Nt[Se][Tt][ze]={}),this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={}),Nt[Se][Tt][ze][st]||(Nt[Se][Tt][ze][st]=new this.workerSourceTypes[ze]({send:(Bt,Zt,Ut,Xt,Is,xs)=>this.actor.send(Bt,Zt,Ut,Se,Is,xs),scheduler:this.actor.scheduler},this.getLayerIndex(Se,Tt),this.getAvailableImages(Se,Tt),this.getAvailableModels(Se,Tt),this.isSpriteLoaded[Se][Tt],void 0,this.brightness,this.worldview)),Nt[Se][Tt][ze][st]}rasterizeImagesWorker(Se,ze,st){const Tt=new Map;for(const[Nt,{image:Bt,imageVariant:Zt}]of ze.tasks.entries()){const Ut=this.imageRasterizer.rasterize(Zt,Bt,ze.scope,Se);Tt.set(Nt,Ut)}st(void 0,Tt)}removeRasterizedImages(Se,ze,st){this.imageRasterizer.removeImagesFromCacheByIds(ze.imageIds,ze.scope,Se),st()}enforceCacheSizeLimit(Se,ze){i.fJ(ze)}getWorkerPerformanceMetrics(Se,ze,st){st(void 0,void 0)}}return i.fF(self)&&(self.worker=new Vl(self)),Vl}),o(["./shared"],function(i){var d="3.17.0";const u={create:"create",load:"load",fullLoad:"fullLoad"},p={mark(M){performance.mark(M)},measure(M,h,x){performance.measure(M,h,x)}};function f(M){const h=M.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 M(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 F,z,H=new Blob([""],{type:"text/javascript"}),Q=URL.createObjectURL(H);try{z=new Worker(Q),F=!0}catch{F=!1}return z&&z.terminate(),URL.revokeObjectURL(Q),F}()?function(){var F=document.createElement("canvas");F.width=F.height=1;var z=F.getContext("2d");if(!z)return!1;var H=z.getImageData(0,0,1,1);return H&&H.width===F.width}()?(x[D=T&&T.failIfMajorPerformanceCaveat]===void 0&&(x[D]=function(F){var z,H=function(Q){var re=document.createElement("canvas"),oe=Object.create(M.webGLContextAttributes);return oe.failIfMajorPerformanceCaveat=Q,re.getContext("webgl2",oe)}(F);if(!H)return!1;try{z=H.createShader(H.VERTEX_SHADER)}catch{return!1}return!(!z||H.isContextLost())&&(H.shaderSource(z,"void main() {}"),H.compileShader(z),H.getShaderParameter(z,H.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=M,_.notSupportedReason=h;var x={};return M.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},_}();function j(M,h,x){const T=document.createElement(M);return h!=null&&(T.className=h),x&&x.appendChild(T),T}function w(M,h,x){const T=document.createElementNS("http://www.w3.org/2000/svg",M);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,C=N&&N.userSelect!==void 0?"userSelect":"WebkitUserSelect";let A;function I(){N&&C&&(A=N[C],N[C]="none")}function L(){N&&C&&(N[C]=A)}function R(M){M.preventDefault(),M.stopPropagation(),window.removeEventListener("click",R,!0)}function $(){window.addEventListener("click",R,!0),window.setTimeout(()=>{window.removeEventListener("click",R,!0)},0)}function q(M,h){const x=M.getBoundingClientRect();return X(M,x,h)}function U(M,h){const x=M.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=ie(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=ie(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=ie(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 F=ie(h);return F.path=`/v4/${F.authority}.json`,F.params.push("secure"),T&&F.params.push(`language=${T}`),D&&F.params.push(`worldview=${D}`),this._makeAPIURL(F,this._customAccessToken||x)}normalizeIconsetURL(h,x){const T=ie(h);return i.h(h)?(T.path=`/styles/v1${T.path}/iconset.pbf`,this._makeAPIURL(T,this._customAccessToken||x)):ae(T)}normalizeSpriteURL(h,x,T,D){const F=ie(h);return i.h(h)?(F.path=`/styles/v1${F.path}/sprite${x}${T}`,this._makeAPIURL(F,this._customAccessToken||D)):(F.path+=`${x}${T}`,ae(F))}normalizeTileURL(h,x,T){if(this._isSkuTokenExpired()&&this._createSkuToken(),h&&!i.h(h))return h;const D=ie(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 F=this._customAccessToken||function(z){for(const H of z){const Q=H.match(/^access_token=(.*)$/);if(Q)return Q[1]}return null}(D.params)||i.e.ACCESS_TOKEN;return i.e.REQUIRE_ACCESS_TOKEN&&F&&this._skuToken&&D.params.push(`sku=${this._skuToken}`),this._makeAPIURL(D,F)}canonicalizeTileURL(h,x){const T=ie(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 F=T.params;return x&&(F=F.filter(z=>!z.match(/^access_token=/))),F.length&&(D+=`?${F.join("&")}`),D}canonicalizeTileset(h,x){const T=!!x&&i.h(x),D=[];for(const F of h.tiles||[])i.j(F)?D.push(this.canonicalizeTileURL(F,T)):D.push(F);return D}_makeAPIURL(h,x){const T="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",D=ie(i.e.API_URL);if(h.protocol=D.protocol,h.authority=D.authority,h.protocol==="http"){const F=h.params.indexOf("secure");F>=0&&h.params.splice(F,1)}if(D.path!=="/"&&(h.path=`${D.path}${h.path}`),!i.e.REQUIRE_ACCESS_TOKEN)return ae(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(F=>F.indexOf("access_token")===-1),h.params.push(`access_token=${x||""}`),ae(h)}}const de=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ie(M){const h=M.match(de);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 ae(M){const h=M.params.length?`?${M.params.join("&")}`:"";return`${M.protocol}://${M.authority}${M.path}${h}`}const le="mapbox.eventData";function pe(M){if(!M)return null;const h=M.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=pe(i.e.ACCESS_TOKEN);let T="";return T=x&&x.u?i.f(x.u):i.e.ACCESS_TOKEN||"",h?`${le}.${h}:${T}`:`${le}:${T}`}fetchEventData(){const h=i.s("localStorage"),x=this.getStorageKey(),T=this.getStorageKey("uuid"),D=this.getStorageKey("uuidTimestamp");if(h)try{const F=localStorage.getItem(x);F&&(this.eventData=JSON.parse(F));const z=localStorage.getItem(T);z&&(this.anonId=z);const H=localStorage.getItem(D);H&&(this.anonIdTimestamp=Number(H));const Q=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 F=ie(i.e.EVENTS_URL);F.params.push(`access_token=${D||i.e.ACCESS_TOKEN||""}`);const z={event:this.type,created:new Date(h).toISOString()},H=x?Object.assign(z,x):z,Q={url:ae(F),headers:{"Content-Type":"text/plain"},body:JSON.stringify([H])};this.pendingRequest=i.p(Q,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 we=new class extends be{constructor(M){super("appUserTurnstile"),this._customAccessToken=M}postTurnstileEvent(M,h){i.e.EVENTS_URL&&i.e.ACCESS_TOKEN&&Array.isArray(M)&&M.some(x=>i.h(x)||i.j(x))&&this.queueRequest(Date.now(),h)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const h=pe(i.e.ACCESS_TOKEN),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 F=new Date(this.eventData.lastSuccess),z=new Date(D),H=(D-this.eventData.lastSuccess)/864e5;T=T||H>=1||H<-1||F.getDate()!==z.getDate()}else T=!0;T?this.postEvent(D,{sdkIdentifier:"mapbox-gl-js",sdkVersion:d,skuId:se,"enabled.telemetry":!1,userId:this.anonId},F=>{F||(this.eventData.lastSuccess=D,this.eventData.tokenU=x)},M):this.processRequests()}},ke=we.postTurnstileEvent.bind(we),Ze=new class extends be{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(M,h,x,T){this.skuToken=h,this.errorCb=T,i.e.EVENTS_URL&&(x||i.e.ACCESS_TOKEN?this.queueRequest({id:M,timestamp:Date.now()},x):this.errorCb(new Error(te)))}processRequests(M){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)},M))}remove(){this.errorCb=null}},_e=Ze.postMapLoadEvent.bind(Ze),Ce=new class extends be{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(M){let h=this.mapInstanceIdMap.get(M);return h||(h=i.u(),this.mapInstanceIdMap.set(M,h)),h}getEventId(M){const h=this.eventIdPerMapInstanceMap.get(M)||0;return this.eventIdPerMapInstanceMap.set(M,h+1),h}postStyleLoadEvent(M,h){const{map:x,style:T,importedStyles:D}=h;if(!i.e.EVENTS_URL||!M&&!i.e.ACCESS_TOKEN)return;const F=this.getMapInstanceId(x),z={mapInstanceId:F,eventId:this.getEventId(F),style:T};D.length&&(z.importedStyles=D),this.queueRequest({timestamp:Date.now(),payload:z},M)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,payload:x}=this.queue.shift();this.postEvent(h,x,()=>{},M)}},Te=Ce.postStyleLoadEvent.bind(Ce),Fe=new ye({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Ae=Fe.postMetricsEvent.bind(Fe),We=new ye({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),ht=We.postMetricsEvent.bind(We),De=new class extends be{constructor(){super("gljs.performance")}postPerformanceEvent(M,h){i.e.EVENTS_URL&&(M||i.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:h},M)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,performanceData:x}=this.queue.shift(),T=function(D){const F=performance.getEntriesByType("resource"),z=performance.getEntriesByType("mark"),H=function(xe){const Pe={};if(xe){for(const Me in xe)if(Me!=="other")for(const He of xe[Me]){const Be=`${Me}ResolveRangeMin`,et=`${Me}ResolveRangeMax`,ut=`${Me}RequestCount`,tt=`${Me}RequestCachedCount`;Pe[Be]=Math.min(Pe[Be]||1/0,He.startTime),Pe[et]=Math.max(Pe[et]||-1/0,He.responseEnd);const Mt=_t=>{Pe[_t]===void 0&&(Pe[_t]=0),++Pe[_t]};He.transferSize!==void 0&&He.transferSize===0&&Mt(tt),Mt(ut)}}return Pe}(function(xe,Pe){const Me={};if(xe)for(const He of xe){const Be=Pe(He);Me[Be]===void 0&&(Me[Be]=[]),Me[Be].push(He)}return Me}(F,f)),Q=window.devicePixelRatio,re=navigator.connection||navigator.mozConnection||navigator.webkitConnection,oe=re?re.effectiveType:void 0,ge={counters:[],metadata:[],attributes:[]},me=(xe,Pe,Me)=>{Me!=null&&xe.push({name:Pe,value:Me.toString()})};for(const xe in H)me(ge.counters,xe,H[xe]);if(D.interactionRange[0]!==1/0&&D.interactionRange[1]!==-1/0&&(me(ge.counters,"interactionRangeMin",D.interactionRange[0]),me(ge.counters,"interactionRangeMax",D.interactionRange[1])),z)for(const xe of Object.values(u)){const Pe=z.find(Me=>Me.name===xe);Pe&&me(ge.counters,xe,Pe.startTime)}return me(ge.counters,"visibilityHidden",D.visibilityHidden),me(ge.attributes,"style",function(xe){if(xe)for(const Pe of xe){const Me=Pe.name.split("?")[0];if(i.i(Me)){const He=Me.split("/").slice(-2);if(He.length===2)return`mapbox://styles/${He[0]}/${He[1]}`}}}(F)),me(ge.attributes,"terrainEnabled",D.terrainEnabled?"true":"false"),me(ge.attributes,"fogEnabled",D.fogEnabled?"true":"false"),me(ge.attributes,"projection",D.projection),me(ge.attributes,"zoom",D.zoom),me(ge.metadata,"devicePixelRatio",Q),me(ge.metadata,"connectionEffectiveType",oe),me(ge.metadata,"navigatorUserAgent",navigator.userAgent),me(ge.metadata,"screenWidth",window.screen.width),me(ge.metadata,"screenHeight",window.screen.height),me(ge.metadata,"windowWidth",window.innerWidth),me(ge.metadata,"windowHeight",window.innerHeight),me(ge.metadata,"mapWidth",D.width/Q),me(ge.metadata,"mapHeight",D.height/Q),me(ge.metadata,"webglRenderer",D.renderer),me(ge.metadata,"webglVendor",D.vendor),me(ge.metadata,"sdkVersion",d),me(ge.metadata,"sdkIdentifier","mapbox-gl-js"),ge}(x);for(const D of T.metadata);for(const D of T.counters);for(const D of T.attributes);this.postEvent(h,T,()=>{},M)}},Dt=De.postPerformanceEvent.bind(De),he=new class extends be{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(M,h,x,T){if(!i.e.API_URL||!i.e.SESSION_PATH)return;const D=ie(i.e.API_URL+i.e.SESSION_PATH);D.params.push(`sku=${h||""}`),D.params.push(`access_token=${T||i.e.ACCESS_TOKEN||""}`);const F={url:ae(D),headers:{"Content-Type":"text/plain"}};this.pendingRequest=i.g(F,z=>{this.pendingRequest=null,x(z),this.saveEventData(),this.processRequests(T)})}getSessionAPI(M,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:M,timestamp:Date.now()},x):this.errorCb(new Error(te)))}processRequests(M){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)},M)}remove(){this.errorCb=null}},Qe=he.getSessionAPI.bind(he),ot=new Set;function rt(M,h){h?ot.add(M):ot.delete(M)}class Ne{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 it(M){const{userImage:h}=M;return!!(h&&h.render&&h.render())&&(M.data.replace(new Uint8Array(h.data.buffer)),!0)}class qe 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=[],F=[],z=this.imageProviders.get(x);for(const oe of h){if(!oe.iconsetId){D.push(oe);continue}const ge=z.get(oe.iconsetId);ge&&(this.getImage(oe,x)?F.push(oe):ge.addPendingRequest(oe))}if(D.length===0)return void this._notify(F,x,T);let H=!0;const Q=!!this.loaded.get(x),re=this.images.get(x);if(!Q)for(const oe of D)re.has(oe.toString())||(H=!1);Q||H?this._notify(D,x,T):this.requestors.push({ids:D,scope:x,callback:T})}rasterizeImages(h,x){const T=new Map,{tasks:D,scope:F}=h;for(const[z,H]of D.entries()){const Q=this.getImage(H.id,F);Q&&T.set(z,{image:Q,imageVariant:H})}this._rasterizeImages(F,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[F,{image:z,imageVariant:H}]of x.entries())D.set(F,this.imageRasterizer.rasterize(H,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),F=new Map;for(const z of h){if(!D.get(z.toString())){if(z.iconsetId)continue;this.fire(new i.z("styleimagemissing",{id:z.name}))}const H=D.get(z.toString());if(!H){i.w(`Image "${z.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}const Q={data:H.usvg?null:H.data.clone(),pixelRatio:H.pixelRatio,sdf:H.sdf,usvg:H.usvg,version:H.version,stretchX:H.stretchX,stretchY:H.stretchY,content:H.content,hasRenderCallback:!!(H.userImage&&H.userImage.render)};H.usvg&&Object.assign(Q,{width:H.icon.usvg_tree.width,height:H.icon.usvg_tree.height}),F.set(i.I.toString(z),Q)}T(null,F)}getPixelSize(h){const{width:x,height:T}=this.atlasImage.get(h);return{width:x,height:T}}getPattern(h,x,T){const D=h.toString(),F=this.patterns.get(x),z=F.get(D),H=this.getImage(h,x);if(!H)return null;if(z){if(z.position.version===H.version)return z.position;z.position.version=H.version}else{if(H.usvg&&!H.data){const Q=this.getPatternInFlightId(D,x);if(this.patternsInFlight.has(Q))return null;this.patternsInFlight.add(Q);const re=new i.A(h).scaleSelf(i.o.devicePixelRatio),oe=new Map([[re.toString(),{image:H,imageVariant:re}]]);return this._rasterizeImages(x,oe,(ge,me)=>this.storePatternImage(re,x,H,T,me)),null}this.storePattern(h,x,H)}return this._updatePatternAtlas(x,T),F.get(D).position}getPatternInFlightId(h,x){return i.B(h,x)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(h,x,T,D,F){const z=h.toString(),H=F?F.get(z):void 0;H&&(T.data=H,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},F=new i.F(D,T,i.C);this.patterns.get(x).set(h.toString(),{bin:D,position:F})}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:F,h:z}=i.G(D),H=this.atlasImage.get(h);H.resize({width:F||1,height:z||1});const Q=this.images.get(h);for(const[re,{bin:oe,position:ge}]of T.entries()){let me=ge.padding;const xe=oe.x+me,Pe=oe.y+me,Me=Q.get(re).data,He=Me.width,Be=Me.height;me=me>1?me-1:me,i.q.copy(Me,H,{x:0,y:0},{x:xe,y:Pe},{width:He,height:Be},x),i.q.copy(Me,H,{x:0,y:Be-me},{x:xe,y:Pe-me},{width:He,height:me},x),i.q.copy(Me,H,{x:0,y:0},{x:xe,y:Pe+Be},{width:He,height:me},x),i.q.copy(Me,H,{x:He-me,y:0},{x:xe-me,y:Pe},{width:me,height:Be},x),i.q.copy(Me,H,{x:0,y:0},{x:xe+He,y:Pe},{width:me,height:Be},x),i.q.copy(Me,H,{x:He-me,y:Be-me},{x:xe-me,y:Pe-me},{width:me,height:me},x),i.q.copy(Me,H,{x:0,y:Be-me},{x:xe+He,y:Pe-me},{width:me,height:me},x),i.q.copy(Me,H,{x:0,y:0},{x:xe+He,y:Pe+Be},{width:me,height:me},x),i.q.copy(Me,H,{x:He-me,y:0},{x:xe-me,y:Pe+Be},{width:me,height:me},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 F=T.get(D.toString());it(F)&&this.updateImage(D,x,F)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function Xe(M){const h=M.value,x=M.valueSpec,T=M.style,D=M.styleSpec,F=M.key,z=M.arrayElementValidator||yn;if(!Array.isArray(h))return[new i.V(F,h,`array expected, ${i.K(h)} found`)];if(x.length&&h.length!==x.length)return[new i.V(F,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 Ke(M){const h=M.key,x=M.value;if(!i.H(x))return[new i.V(h,x,`object expected, ${i.K(x)} found`)];const T=M.valueSpec,D=i.J(x.type);let F,z,H,Q={};const re=D!=="categorical"&&x.property===void 0,oe=!re,ge=function(Me){const He=Me.stops;return Array.isArray(He)&&Array.isArray(He[0])&&i.H(He[0][0])}(x),me=na({key:M.key,value:M.value,valueSpec:M.styleSpec.function,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{stops:function(Me){if(D==="identity")return[new i.V(Me.key,Me.value,'identity function may not have a "stops" property')];let He=[];const Be=Me.value;return He=He.concat(Xe({key:Me.key,value:Be,valueSpec:Me.valueSpec,style:Me.style,styleSpec:Me.styleSpec,arrayElementValidator:xe})),Array.isArray(Be)&&Be.length===0&&He.push(new i.V(Me.key,Be,"array must have at least one stop")),He},default:function(Me){return yn({key:Me.key,value:Me.value,valueSpec:T,style:Me.style,styleSpec:Me.styleSpec})}}});return D==="identity"&&re&&me.push(new i.V(M.key,M.value,'missing required property "property"')),D==="identity"||x.stops||me.push(new i.V(M.key,M.value,'missing required property "stops"')),D==="exponential"&&T.expression&&!i.M(T)&&me.push(new i.V(M.key,M.value,"exponential functions not supported")),M.styleSpec.$version>=8&&(oe&&!i.N(T)?me.push(new i.V(M.key,M.value,"property functions not supported")):re&&!i.O(T)&&me.push(new i.V(M.key,M.value,"zoom functions not supported"))),D!=="categorical"&&!ge||x.property!==void 0||me.push(new i.V(M.key,M.value,'"property" property is required')),me;function xe(Me){let He=[];const Be=Me.value,et=Me.key;if(!Array.isArray(Be))return[new i.V(et,Be,`array expected, ${i.K(Be)} found`)];if(Be.length!==2)return[new i.V(et,Be,`array length 2 expected, length ${Be.length} found`)];if(ge){if(!i.H(Be[0]))return[new i.V(et,Be,`object expected, ${i.K(Be[0])} found`)];const ut=Be[0];if(ut.zoom===void 0)return[new i.V(et,Be,"object stop key must have zoom")];if(ut.value===void 0)return[new i.V(et,Be,"object stop key must have value")];const tt=i.J(ut.zoom);if(typeof tt!="number")return[new i.V(et,ut.zoom,"stop zoom values must be numbers")];if(H&&H>tt)return[new i.V(et,ut.zoom,"stop zoom values must appear in ascending order")];tt!==H&&(H=tt,z=void 0,Q={}),He=He.concat(na({key:`${et}[0]`,value:Be[0],valueSpec:{zoom:{}},style:Me.style,styleSpec:Me.styleSpec,objectElementValidators:{zoom:$e,value:Pe}}))}else He=He.concat(Pe({key:`${et}[0]`,value:Be[0],style:Me.style,styleSpec:Me.styleSpec},Be));return i.Q(i.S(Be[1]))?He.concat([new i.V(`${et}[1]`,Be[1],"expressions are not allowed in function stops.")]):He.concat(yn({key:`${et}[1]`,value:Be[1],valueSpec:T,style:Me.style,styleSpec:Me.styleSpec}))}function Pe(Me,He){const Be=i.K(Me.value),et=i.J(Me.value),ut=Me.value!==null?Me.value:He;if(F){if(Be!==F)return[new i.V(Me.key,ut,`${Be} stop domain type must match previous stop domain type ${F}`)]}else F=Be;if(Be!=="number"&&Be!=="string"&&Be!=="boolean"&&typeof et!="number"&&typeof et!="string"&&typeof et!="boolean")return[new i.V(Me.key,ut,"stop domain value must be a number, string, or boolean")];if(Be!=="number"&&D!=="categorical"){let tt=`number expected, ${Be} found`;return i.N(T)&&D===void 0&&(tt+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new i.V(Me.key,ut,tt)]}return D!=="categorical"||Be!=="number"||typeof et=="number"&&isFinite(et)&&Math.floor(et)===et?D!=="categorical"&&Be==="number"&&typeof et=="number"&&typeof z=="number"&&z!==void 0&&etnew i.V(`${M.key}${T.key}`,M.value,T.message));const x=h.value.expression||h.value._styleExpression.expression;if(M.expressionContext==="property"&&M.propertyKey==="text-font"&&!x.outputDefined())return[new i.V(M.key,M.value,`Invalid data expression for "${M.propertyKey}". Output values must be contained as literals within the expression.`)];if(M.expressionContext==="property"&&M.propertyType==="layout"&&!i.Z(x))return[new i.V(M.key,M.value,'"feature-state" data expressions are not supported with layout properties.')];if(M.expressionContext==="filter")return Ue(x,M);if(M.expressionContext==="appearance")return Ve(x,M);if(M.expressionContext&&M.expressionContext.indexOf("cluster")===0){if(!i.X(x,["zoom","feature-state"]))return[new i.V(M.key,M.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(M.expressionContext==="cluster-initial"&&!i.Y(x))return[new i.V(M.key,M.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ue(M,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 M instanceof i._&&x.has(M.name)?[new i.V(h.key,h.value,`["${M.name}"] expression is not supported in a filter for a ${h.object.type} layer with id: ${h.object.id}`)]:(M.eachChild(D=>{T.push(...Ue(D,h))}),T)}function Ve(M,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 M instanceof i._&&!x.has(M.name)?[new i.V(h.key,h.value,`["${M.name}"] is not an allowed parameter`)]:(M.eachChild(D=>{T.push(...Ve(D,h))}),T)}function Je(M){const h=M.key,x=M.value,T=M.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 Rt(M){return i.a2(i.S(M.value))?ct(Object.assign({},M,{expressionContext:"filter",valueSpec:M.styleSpec[`filter_${M.layerType||"fill"}`]})):$t(M)}function $t(M){const h=M.value,x=M.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=M.styleSpec;let D=Je({key:`${x}[0]`,value:h[0],valueSpec:T.filter_operator});const F=()=>{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`)),F();break;case"==":case"!=":h.length!==3&&D.push(new i.V(x,h,`filter array for operator "${h[0]}" must have 3 elements`)),F();break;case"in":case"!in":F();break;case"any":case"all":case"none":for(let z=1;z{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)===H&&(Q=re)}),Q?Q.ref?h.push(new i.V(T,x.ref,"ref cannot reference another ref layer")):z=i.J(Q.type):typeof H=="string"&&h.push(new i.V(T,x.ref,`ref layer "${H}" not found`))}else if(z!=="background"&&z!=="sky"&&z!=="slot")if(x.source)if(i.a0(x.source)){const Q=D.sources&&D.sources[x.source],re=Q&&i.J(Q.type);Q?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"&&!Q.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(na({key:T,value:x,valueSpec:F.layer,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{"*":()=>[],type:()=>yn({key:`${T}.type`,value:x.type,valueSpec:F.layer.type,style:M.style,styleSpec:M.styleSpec,object:x,objectKey:"type"}),filter:Q=>Rt(Object.assign({layerType:z},Q)),layout:Q=>na({layer:x,key:Q.key,value:Q.value,valueSpec:{},style:Q.style,styleSpec:Q.styleSpec,objectElementValidators:{"*":re=>rs(Object.assign({layerType:z},re))}}),paint:Q=>na({layer:x,key:Q.key,value:Q.value,valueSpec:{},style:Q.style,styleSpec:Q.styleSpec,objectElementValidators:{"*":re=>Qt(Object.assign({layerType:z,layer:x},re))}}),appearances(Q){const re=Xe({key:Q.key,value:Q.value,valueSpec:Q.valueSpec,style:Q.style,styleSpec:Q.styleSpec,arrayElementValidator:me=>function(xe){const{key:Pe,layer:Me,layerType:He}=xe,Be=i.J(xe.value),et=i.J(Be.name),ut=i.J(Be.condition),tt=na({key:Pe,value:Be,valueSpec:xe.styleSpec.appearance,style:xe.style,styleSpec:xe.styleSpec,objectElementValidators:{condition:Mt=>function(_t){const kt=[];return kt.push(...ct({key:_t.key,value:_t.object.condition,valueSpec:i.a6.appearance.condition,expressionContext:"appearance"})),kt}(Object.assign({layer:Me,layerType:He},Mt)),properties:Mt=>function(_t){const kt=[],{styleSpec:xt,layer:pt,layerType:Et}=_t,Ht=xt[`paint_${Et}`],Vt=xt[`layout_${Et}`],ts=_t.object[_t.objectKey];for(const ss in ts){const fs=ss in Ht?"paint":ss in Vt?"layout":void 0;if(!fs){kt.push(new i.V(_t.key,ss,`unknown property "${ss}" for layer type "${Et}"`));continue}const Bs=Object.assign({},_t,{key:`${_t.key}.${ss}`,object:ts,objectKey:ss,layer:pt,layerType:Et,value:ts[ss],valueSpec:fs==="paint"?Ht[ss]:Vt[ss]});kt.push(...ls(Bs,fs))}return kt}(Object.assign({layer:Me,layerType:He},Mt))}});return et!=="hidden"&&ut===void 0&&tt.push(new i.V(xe.key,"name",'Appearance with name different than "hidden" must have a condition')),tt}(Object.assign({layerType:z,layer:x},me))}),oe=Array.isArray(Q.value)?Q.value:[],ge=new Set;return oe.forEach((me,xe)=>{const Pe=i.J(me.name);if(Pe)if(ge.has(Pe)){const Me=i.J(x.id);re.push(new i.V(Q.key,Pe,`Duplicated appearance name "${Pe}" for layer "${Me}"`))}else ge.add(Pe)}),re}}})),h}function ir({key:M,value:h}){return i.a0(h)?[]:[new i.V(M,h,`string expected, ${i.K(h)} found`)]}const vt={promoteId:function M({key:h,value:x}){if(i.a0(x))return ir({key:h,value:x});if(Array.isArray(x)){const D=[],F=i.S(x),z=i.U(F);return z.result==="error"&&z.value.forEach(H=>{D.push(new i.V(`${h}${H.key}`,null,`${H.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(...M({key:`${h}.${D}`,value:x[D]}));return T}};function Cs(M){const h=M.value,x=M.key,T=M.styleSpec,D=M.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 F=i.J(h.type);let z=[];switch(["vector","raster","raster-dem","raster-array"].includes(F)&&("url"in h||"tiles"in h||z.push(new i.a3(x,h,'Either "url" or "tiles" is required.'))),F){case"vector":case"raster":case"raster-dem":case"raster-array":return z=z.concat(na({key:x,value:h,valueSpec:T[`source_${F.replace("-","_")}`],style:M.style,styleSpec:T,objectElementValidators:vt})),z;case"geojson":if(z=na({key:x,value:h,valueSpec:T.source_geojson,style:D,styleSpec:T,objectElementValidators:vt}),"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 H in h.clusterProperties){const Q=h.clusterProperties[H];if(!Array.isArray(Q))return[new i.V(`${x}.clusterProperties.${H}`,Q,"array expected")];const[re,oe]=Q,ge=typeof re=="string"?[re,["accumulated"],["get",H]]:re;z.push(...ct({key:`${x}.${H}.map`,value:oe,expressionContext:"cluster-map"})),z.push(...ct({key:`${x}.${H}.reduce`,value:ge,expressionContext:"cluster-reduce"}))}}return z;case"video":return na({key:x,value:h,valueSpec:T.source_video,style:D,styleSpec:T});case"image":return na({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:or(T)}})}}function or(M){return M.source.reduce((h,x)=>{const T=M[x];return T.type.type==="enum"&&(h=h.concat(Object.keys(T.type.values||{}))),h},[])}function Ar(M){const h=M.value,x=M.styleSpec,T=x.light,D=M.style;if(h===void 0)return[];if(!i.H(h))return[new i.V("light",h,`object expected, ${i.K(h)} found`)];let F=[];for(const z in h){const H=z.match(/^(.*)-transition$/),Q=z.match(/^(.*)-use-theme$/);F=F.concat(Q&&T[Q[1]]?yn({key:z,value:h[z],valueSpec:{type:"string"},style:D,styleSpec:x}):H&&T[H[1]]&&T[H[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 F}function Wn(M){const h=M.value;if(!h)return[];const x=M.key;if(!i.H(h))return[new i.V(x,h,`object expected, ${i.K(h)} found`)];let T=[];const D=M.styleSpec,F=D["light-3d"],z=M.style,H=M.style.lights;for(const oe of["type","id"])if(!(oe in h))return T=T.concat([new i.V(x,h,`missing property "${oe}"`)]),T;if(!i.a0(h.type))return T=T.concat([new i.V(`${x}.type`,h.type,"string expected")]),T;if(H)for(let oe=0;oe[],array:Xe,boolean:function(M){const h=M.value,x=M.key;return i.$(h)?[]:[new i.V(x,h,`boolean expected, ${i.K(h)} found`)]},number:$e,color:function({key:M,value:h}){return i.a0(h)?i.a1.parseCSSColor(h)===null?[new i.V(M,h,`color expected, "${h}" found`)]:[]:[new i.V(M,h,`color expected, ${i.K(h)} found`)]},enum:Je,filter:Rt,function:Ke,layer:as,object:na,source:Cs,model:i.a7,light:Ar,"light-3d":Wn,terrain:ai,fog:bo,string:ir,formatted:function(M){return ir(M).length===0?[]:ct(M)},resolvedImage:function(M){return ir(M).length===0?[]:ct(M)},projection:function(M){const h=M.value,x=M.styleSpec,T=x.projection,D=M.style;if(i.H(h)){let F=[];for(const z in h)F=F.concat(yn({key:z,value:h[z],valueSpec:T[z],style:D,styleSpec:x}));return F}return i.a0(h)?[]:[new i.V("projection",h,`object or string expected, ${i.K(h)} found`)]},import:function(M){const h=M.key,{value:x,styleSpec:T}=M;if(!i.H(x))return[new i.V(h,x,"import must be an object")];const{data:D,...F}=x;Object.defineProperty(F,"__line__",{value:x.__line__,enumerable:!1});let z=na(Object.assign({},M,{value:F,valueSpec:T.import}));return i.J(F.id)===""&&z.push(new i.V(`${M.key}.id`,F,"import id can't be an empty string")),D&&(z=z.concat(ta(D,T,{key:`${M.key}.data`}))),z},iconset:function(M){const h=M.value,x=M.key,T=M.styleSpec,D=M.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 F=i.J(h.type);let z=[];if(z=z.concat(na({key:x,value:h,valueSpec:T[`iconset_${F}`],style:D,styleSpec:T})),function(H,Q){return!(H!=="source"||!Q.source)}(F,h)){const H=D.sources&&D.sources[h.source],Q=H&&i.J(H.type);H?Q!=="raster-array"&&z.push(new i.V(x,h.source,`iconset cannot be used with a source of type ${String(Q)}, it only be used with a "raster-array" source type`)):z.push(new i.V(x,h.source,`source "${h.source}" not found`))}return z}};function yn(M,h=!1){const x=M.value,T=M.valueSpec,D=M.styleSpec;if(T.expression){if(i.a4(i.J(x)))return Ke(M);if(i.Q(i.S(x)))return ct(M)}if(T.type&&Fa[T.type]){const F=Fa[T.type](M);return h===!0&&F.length>0&&Array.isArray(M.value)?ct(M):F}return na(Object.assign({},M,{valueSpec:T.type?D[T.type]:T}))}function na(M){const h=M.key,x=M.value,T=M.valueSpec||{},D=M.objectElementValidators||{},F=M.style,z=M.styleSpec;if(!i.H(x))return[new i.V(h,x,`object expected, ${i.K(x)} found`)];let H=[];for(const Q in x){const re=Q.split(".")[0];let oe;D[re]?oe=D[re]:T[re]?oe=yn:D["*"]?oe=D["*"]:T["*"]&&(oe=yn),oe?H=H.concat(oe({key:(h&&`${h}.`)+Q,value:x[Q],valueSpec:T[re]||T["*"],style:F,styleSpec:z,object:x,objectKey:Q},x)):H.push(new i.a3(h,x[Q],`unknown property "${Q}"`))}for(const Q in T){if(D[Q])continue;const re=T[Q];re.required&&re.default===void 0&&x[Q]===void 0&&H.push(new i.V(h,x,`missing required property "${Q}"`))}return H}function Nn({key:M,value:h}){const x=ir({key:M,value:h});if(x.length)return x;const T=h;return T.indexOf("{fontstack}")===-1&&x.push(new i.V(M,h,'"glyphs" url must include a "{fontstack}" token')),T.indexOf("{range}")===-1&&x.push(new i.V(M,h,'"glyphs" url must include a "{range}" token')),x}function ta(M,h=i.a6,x={}){return na({key:x.key||"",value:M,valueSpec:Object.assign(h.$root,{"*":{type:"*"}}),styleSpec:h,style:M,objectElementValidators:{glyphs:Nn}})}function Kt(M,h=i.a6){return ze(ta(M,h))}const $r=M=>ze(Cs(M)),es=M=>ze(Ar(M)),nn=M=>ze(Wn(M)),_a=M=>ze(ai(M)),aa=M=>ze(bo(M)),Pr=M=>ze(function(h){const x=h.value,T=h.style,D=h.styleSpec,F=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 H in x){const Q=H.match(/^(.*)-transition$/);z=z.concat(Q&&F[Q[1]]&&F[Q[1]].transition?yn({key:H,value:x[H],valueSpec:D.transition,style:T,styleSpec:D}):F[H]?yn({key:H,value:x[H],valueSpec:F[H],style:T,styleSpec:D}):[new i.a3(H,x[H],`unknown property "${H}"`)])}return z}(M)),ii=M=>ze(function(h){const x=h.value,T=h.style,D=h.styleSpec,F=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 H in x){const Q=H.match(/^(.*)-transition$/);z=z.concat(Q&&F[Q[1]]&&F[Q[1]].transition?yn({key:H,value:x[H],valueSpec:D.transition,style:T,styleSpec:D}):F[H]?yn({key:H,value:x[H],valueSpec:F[H],style:T,styleSpec:D}):[new i.a3(H,x[H],`unknown property "${H}"`)])}return z}(M)),nl=M=>ze(as(M)),mi=M=>ze(Rt(M)),Vl=M=>ze(Qt(M)),dt=M=>ze(rs(M)),Se=M=>ze(i.a7(M));function ze(M){return M.slice().sort((h,x)=>h.line&&x.line?h.line-x.line:0)}function st(M,h){let x=!1;if(h&&h.length)for(const T of h)T instanceof i.a3?i.w(T.message):(M.fire(new i.y(new Error(T.message))),x=!0);return x}const Tt=i.a6.light;let Nt;class Bt extends i.E{constructor(h,x="flat"){super(),this._transitionable=new i.a8(Nt||(Nt=new i.a9({anchor:new i.aa(Tt.anchor),position:new i.ab(Tt.position),color:new i.aa(Tt.color),intensity:new i.aa(Tt.intensity)}))),this.setLight(h,x),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(h,x,T={}){this._validate(es,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)&&st(this,h.call(Kt,Object.assign({value:x,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}const Zt=i.a6.terrain;let Ut=class extends i.E{constructor(M,h,x,T,D){super(),this.scope=x,this._transitionable=new i.a8(new i.a9({source:new i.aa(Zt.source),exaggeration:new i.aa(Zt.exaggeration)}),x,T),this._transitionable.setTransitionOrValue(M,T),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=h,this.worldview=D}get(){return this._transitionable.serialize()}set(M,h){this._transitionable.setTransitionOrValue(M,h)}updateTransitions(M){this._transitioning=this._transitionable.transitioned(M,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(M){this.properties=this._transitioning.possiblyEvaluate(M)}getExaggeration(M){return this._transitioning.possiblyEvaluate(new i.ac(M,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const M=this._transitionable._values.exaggeration;if(!M)return null;const h=M.value.expression;if(!h)return null;let x=-1,T=-1,D=1;for(const F of h.zoomStops)D=h.evaluate(new i.ac(F,{worldview:this.worldview})),D>.01?(x=F,T=-1):T=F;return D<.01&&x>0&&T>x?[x,T]:null}isZoomDependent(){const M=this._transitionable._values.exaggeration;return M!=null&&M.value!=null&&M.value.expression!=null&&M.value.expression instanceof i.ad}};const Xt=45,Is=65,xs=.05;function pr(M,h,x,T){const D=i.ah(Xt,Is,x),[F,z]=qr(M,T);let H=1-Math.min(1,Math.exp((h-F)/(z-F)*-6));return H*=H*H,H=Math.min(1,1.00747*H),H*D*M.alpha}function qr(M,h){const x=.5/Math.tan(.5*h);return[M.range[0]+x,M.range[1]+x]}function dr(M,h,x,T,D){const F=i.af([],[h,x,T],D.mercatorFogMatrix);return pr(M,i.ag(F),D.pitch,D._fov)}function Cn(M,h,x,T,D,F,z){const H=[[x,T,0],[D,T,0],[D,F,0],[x,F,0]];let Q=Number.MAX_VALUE,re=-Number.MAX_VALUE;for(const oe of H){const ge=i.af([],oe,h),me=i.ag(ge);Q=Math.min(Q,me),re=Math.max(re,me)}return[pr(M,Q,z.pitch,z._fov),pr(M,re,z.pitch,z._fov)]}const Mn=i.a6.fog;class wn extends i.E{constructor(h,x,T,D){super();const F=new i.a9({range:new i.aa(Mn.range),color:new i.aa(Mn.color),"color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new i.aa(Mn["high-color"]),"high-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new i.aa(Mn["space-color"]),"space-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new i.aa(Mn["horizon-blend"]),"star-intensity":new i.aa(Mn["star-intensity"]),"vertical-range":new i.aa(Mn["vertical-range"])});this._transitionable=new i.a8(F,T,new Map(D)),this.set(h,D),this._transitioning=this._transitionable.untransitioned(),this._transform=x,this.properties=new i.ai(F),this.scope=T}get state(){const h=this._transform,x=h.projection.name==="globe",T=i.aj(h.zoom),D=this.properties.get("range"),F=[.5,3];return{range:x?[i.ak(F[0],D[0],T),i.ak(F[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(aa,h,T))return;const D=Object.assign({},h);for(const F of Object.keys(Mn))D[F]===void 0&&(D[F]=Mn[F].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(Xt,Is,h))*x.a}getOpacityAtLatLng(h,x){return this._transform.projection.supportsFog?function(T,D,F){const z=i.ae.fromLngLat(D),H=F.elevation?F.elevation.getAtPointOrZero(z):0;return dr(T,z.x,z.y,H,F)}(this.state,h,x):0}getOpacityForTile(h){if(!this._transform.projection.supportsFog)return[1,1];const x=this._transform.calculateFogTileMatrix(h.toUnwrapped());return Cn(this.state,x,0,0,i.al,i.al,this._transform)}getOpacityForBounds(h,x,T,D,F){return this._transform.projection.supportsFog?Cn(this.state,h,x,T,D,F,this._transform):[1,1]}getFovAdjustedRange(h){return this._transform.projection.supportsFog?qr(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 F;if(D[2]>=0)F=D;else{const z=h.points[T-4];F=i.am(z,D,z[2]/(z[2]-D[2]))}if(dr(this.state,F[0],F[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)&&st(this,h.call(Kt,Object.assign({value:x,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}let ha,co,$o,Wa,Wo=class extends i.E{constructor(M,h,x,T){super();const D=ha||(ha=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(M,T),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=x}get state(){const M=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),F=[Math.cos(T)*Math.cos(D),Math.sin(T)*Math.cos(D),Math.sin(D)],z=this.properties.get("vignette"),H=this.properties.get("vignette-color");return H.a=z,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.ao(h.r,h.g,h.b,h.a*M),direction:F,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:H}}get(){return this._transitionable.serialize()}set(M,h,x={}){if(this._validate(Pr,M,x))return;const T=Object.assign({},M),D=i.a6.snow;for(const F of Object.keys(D))T[F]===void 0&&(T[F]=D[F].default);this._options=T,this._transitionable.setTransitionOrValue(this._options,h)}updateConfig(M){this._transitionable.setTransitionOrValue(this._options,new Map(M))}updateTransitions(M){this._transitioning=this._transitionable.transitioned(M,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(M){this.properties=this._transitioning.possiblyEvaluate(M)}_validate(M,h,x){return(!x||x.validate!==!1)&&st(this,M.call(Kt,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}},Qi=class extends i.E{constructor(M,h,x,T){super();const D=co||(co=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(M,T),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=x}get state(){const M=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),F=[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*M),direction:F,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:z}}get(){return this._transitionable.serialize()}set(M,h,x={}){if(this._validate(ii,M,x))return;const T=Object.assign({},M),D=i.a6.rain;for(const F of Object.keys(D))T[F]===void 0&&(T[F]=D[F].default);this._options=T,this._transitionable.setTransitionOrValue(this._options,h)}updateConfig(M){this._transitionable.setTransitionOrValue(this._options,new Map(M))}updateTransitions(M){this._transitioning=this._transitionable.transitioned(M,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(M){this.properties=this._transitioning.possiblyEvaluate(M)}_validate(M,h,x){return(!x||x.validate!==!1)&&st(this,M.call(Kt,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}};class ba 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 Ji{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 F=i.P.convert(h);T=[F],D=x.isPointAboveHorizon(F)}else{const F=i.P.convert(h[0]),z=i.P.convert(h[1]),H=F.add(z)._div(2);T=[F,z],D=i.aq(F,z).every(Q=>x.isPointAboveHorizon(Q))&&x.isPointAboveHorizon(H)}return new Ji(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),F=this.cameraPoint.clone();switch(3*((F.y>x.y)+(F.y>T.y))+((F.x>x.x)+(F.x>T.x))){case 0:D[0]=F,D[4]=F.clone();break;case 1:D.splice(1,0,F);break;case 2:D[1]=F;break;case 3:D.splice(4,0,F);break;case 5:D.splice(2,0,F);break;case 6:D[3]=F;break;case 7:D.splice(3,0,F);break;case 8:D[2]=F}return D}containsTile(h,x,T,D=0){const F=Math.max(h.queryPadding,h.evaluateQueryRenderedFeaturePadding())/x._pixelsPerMercatorPixel+1,z=T?this._bufferedCameraMercator(F,x):this._bufferedScreenMercator(F,x);let H=h.tileID.wrap+(z.unwrapped?D:0);const Q=z.polygon.map(He=>i.as(h.tileTransform,He,H));if(!i.at(Q,0,0,i.al,i.al))return;H=h.tileID.wrap+(this.screenGeometryMercator.unwrapped?D:0);const re=this.screenGeometryMercator.polygon.map(He=>i.au(h.tileTransform,He,H)),oe=re.map(He=>new i.P(He[0],He[1])),ge=x.getFreeCameraOptions().position||new i.ae(0,0,0),me=i.au(h.tileTransform,ge,H),xe=re.map(He=>{const Be=i.av(He,He,me);return i.aw(Be,Be),new i.ax(me,Be)}),Pe=i.ay(h,1,x.zoom)*x._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:oe,tilespaceRays:xe,bufferedTilespaceGeometry:Q,bufferedTilespaceBounds:(Me=i.az(Q),Me.min.x=i.aA(Me.min.x,0,i.al),Me.min.y=i.aA(Me.min.y,0,i.al),Me.max.x=i.aA(Me.max.x,0,i.al),Me.max.y=i.aA(Me.max.y,0,i.al),Me),tile:h,tileID:h.tileID,pixelToTileUnitsFactor:Pe};var Me}_bufferedScreenMercator(h,x){const T=eo(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(F=>x.pointCoordinate3D(F)),unwrapped:!0},this._screenRaycastCache[T]=D,D}}_bufferedCameraMercator(h,x){const T=eo(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(F=>x.pointCoordinate3D(F)),unwrapped:!0},this._cameraRaycastCache[T]=D,D}}_projectAndResample(h,x){const T=function(F,z){const H=i.aB([],z.pixelMatrix,z.globeMatrix),Q=[0,-i.aD,0,1],re=[0,i.aD,0,1],oe=[0,0,0,1];i.aC(Q,Q,H),i.aC(re,re,H),i.aC(oe,oe,H);const ge=new i.P(Q[0]/Q[3],Q[1]/Q[3]),me=new i.P(re[0]/re[3],re[1]/re[3]),xe=i.aE(F,ge)&&Q[3]1?yi(F.slice(0,He),z):[],ut=Henew i.P(sa(kt.x),kt.y)),ut=ut.map(kt=>new i.P(sa(kt.x),kt.y));const tt=[...et];tt.length===0&&tt.push(ut[ut.length-1]);const Mt=i.ak(tt[tt.length-1].y,(ut.length===0?et[0]:ut[0]).y,Be);let _t;return _t=xe?[new i.P(0,Mt),new i.P(0,0),new i.P(1,0),new i.P(1,Mt)]:[new i.P(1,Mt),new i.P(1,1),new i.P(0,1),new i.P(0,Mt)],tt.push(..._t),ut.length===0?tt.push(et[0]):tt.push(...ut),{polygon:tt.map(kt=>new i.ae(kt.x,kt.y)),unwrapped:!1}}(h,x);if(T)return T;const D=function(F,z){let H=!1,Q=-1/0,re=0;for(let ge=0;geQ&&(Q=F[ge].x,re=ge);for(let ge=0;ge.5&&(xe.x{ge.x-=1}),{polygon:F,unwrapped:H}}(yi(h,x).map(F=>new i.P(sa(F.x),F.y)),x);return{polygon:D.polygon.map(F=>new i.ae(F.x,F.y)),unwrapped:D.unwrapped}}}function yi(M,h){return i.aG(M,x=>{const T=h.pointCoordinate3D(x);x.x=T.x,x.y=T.y},1/256)}function sa(M){return M<0?1+M%1:M%1}function eo(M){return 100*M|0}function ac(M,h,x,T,D){const F=function(H,Q){if(H)return D(H);if(Q){if(M.url&&Q.tiles&&M.tiles&&delete M.tiles,Q.variants){if(!Array.isArray(Q.variants))return D(new Error("variants must be an array"));for(const oe of Q.variants){if(oe==null||typeof oe!="object"||oe.constructor!==Object)return D(new Error("variant must be an object"));if(!Array.isArray(oe.capabilities))return D(new Error("capabilities must be an array"));if(oe.capabilities.length===1&&oe.capabilities[0]==="meshopt"){Q=Object.assign(Q,oe);break}}}const re=i.aH(Object.assign({},Q,M),["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,M.url),D(null,re)}},z=function(H,Q,re){if(!H)return null;if(!Q&&!re)return H;re=re||H.worldview_default;const oe=Object.values(H.language||{});if(oe.length===0)return null;const ge=Object.values(H.worldview||{});if(ge.length===0)return null;const me=oe.every(Pe=>Pe===Q),xe=ge.every(Pe=>Pe===re);return me&&xe?H:Q in(H.language_options||{})||re in(H.worldview_options||{})?null:H.language_options&&H.worldview_options?H:null}(M.data,x,T);return z?i.o.frame(()=>F(null,z)):M.url?i.m(h.transformRequest(h.normalizeSourceURL(M.url,null,x,T),i.R.Source),F):i.o.frame(()=>{const{data:H,...Q}=M;F(null,Q)})}function yc(M,h){const x=Math.pow(2,h.z),T=Math.floor(i.aF(M.getWest())*x),D=Math.floor(i.aJ(M.getNorth())*x),F=Math.ceil(i.aF(M.getEast())*x),z=Math.ceil(i.aJ(M.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(F){if(Object.assign(this,F),this.hasWorldviews=!!F.worldview_options,F.worldview_default&&(this.worldviewDefault=F.worldview_default),F.vector_layers){this.vectorLayers=F.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const z of F.vector_layers)this.vectorLayerIds.push(z.id),F.worldview&&F.worldview[z.source]&&this.localizableLayerIds.add(z.id)}this.tileBounds=Ad.fromTileJSON(F),ke(F.tiles,this.map._requestManager._customAccessToken),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}h&&h(D)})}loaded(){return this._loaded}hasTile(h){return!this.tileBounds||this.tileBounds.contains(h.canonical)}onAdd(h){this.map=h,this.load()}reload(){this.cancelTileJSONRequest();const h=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(h))}setTiles(h){return this._options.tiles=h,this.reload(),this}setUrl(h){return this.url=h,this._options.url=h,this.reload(),this}onRemove(h){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(h,x){const T=h.tileID.canonical.url(this.tiles,this.scheme),D=this.map._requestManager.normalizeTileURL(T),F=this.map._requestManager.transformRequest(D,i.R.Tile),z=this.map.style?this.map.style.getLut(this.scope):null,H=z?{image:z.image.clone()}:null,Q={request:F,data:void 0,uid:h.uid,tileID:h.tileID,tileZoom:h.tileZoom,zoom:h.tileID.overscaledZ,maxZoom:this.maxzoom,lut:H,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)&&(Q.localizableLayerIds=this.localizableLayerIds),Q.request.collectResourceTiming=this._collectResourceTiming,h.actor&&h.state!=="expired")h.state==="loading"?h.reloadCallback=x:h.request=h.actor.send("reloadTile",Q,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",Q,re.bind(this),void 0,!0);else{const oe=i.aL.call({deduped:this._deduped},Q,(ge,me)=>{if(ge||!me)re.call(this,ge);else{const xe=i.aM(me.responseHeaders);Q.data={rawData:me.rawData.slice(0),expires:xe.expires,cacheControl:xe.cacheControl},h.actor&&h.actor.send("loadTile",Q,re.bind(this),void 0,!0)}},!0);h.request={cancel:oe}}function re(oe,ge){return delete h.request,h.aborted?x(null):oe&&oe instanceof i.aN&&oe.status!==404?x(oe):(ge&&ge.resourceTiming&&(h.resourceTiming=ge.resourceTiming),this.map._refreshExpiredTiles&&ge&&h.setExpiryData(ge),h.loadVectorData(ge,this.map.painter),i.aO(this.dispatcher),x(null,ge),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 vl 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=ac(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(F=>F.id)),this.tileBounds=Ad.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),(F,z,H)=>{if(delete h.request,h.aborted)return h.state="unloaded",x(null);if(F)return h.state="errored",x(F);if(!z)return x(null);const Q=i.aM(H);this.map._refreshExpiredTiles&&h.setExpiryData(Q),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 wu([M,h],x,T,{scaled:D=!0}={}){const{tileSize:F,buffer:z}=T,{x:H,y:Q,z:re}=x;if(!isFinite(H)||!isFinite(Q)||!isFinite(re))throw new Error("Invalid MRT header");const oe=2**re,ge=oe*i.aF(M),me=oe*i.aJ(h);return function([xe,Pe],Me,{scaled:He=!0}={}){if(!Me)throw new Error("bandView is undefined");const{data:Be,tileSize:et,buffer:ut,offset:tt,scale:Mt,dimension:_t}=Me;if(xe<-ut||xe>et+ut||Pe<-ut||Pe>et+ut)throw new Error(`Point (${xe}, ${Pe}) out of bounds for tileSize=${et}, buffer=${ut}`);const kt=(Pe+ut)*(et+2*ut)+(xe+ut);if(new Uint32Array(Be.buffer)[kt]===4294967295)return null;let xt=[];xt=He?[]:new Me.data.constructor(_t);for(let pt=0;pt<_t;pt++)xt[pt]=Math.round(1e12*(Be[_t*kt+pt]*Mt+tt))/1e12;return xt}([Math.min(Math.max(-z,Math.floor((ge-H)*F)),F-1+z),Math.min(Math.max(-z,Math.floor((me-Q)*F)),F-1+z)],T,{scaled:D})}class Xc extends vl{constructor(h,x,T,D){super(h,x,T,D),this.type="raster-array",this.maxzoom=22,this.partial=!0,this._loadTilePending={},this._loadTileLoaded={},this._options=Object.assign({type:"raster-array"},x)}triggerRepaint(h){const x=this.map.painter._terrain,T=this.map.style.getSourceCache(this.id);x&&x.enabled&&T&&x._clearRenderCacheForTile(T.id,h.tileID),this.map.triggerRepaint()}loadTile(h,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),F={request:D,uid:h.uid,tileID:h.tileID,type:this.type,source:this.id,scope:this.scope,partial:this.partial};h.source=this.id,h.scope=this.scope,h.requestParams=D,h.actor||(h.actor=this.dispatcher.getActor());const z=(H,Q,re)=>{if(delete h.request,h.aborted)return h.state="unloaded",x(null);if(H)return H.name==="AbortError"?void 0:(h.state="errored",x(H));if(this.map._refreshExpiredTiles&&Q){const oe=i.aM(re);h.setExpiryData(oe)}if(this.partial&&h.state!=="expired")h.state="empty";else if(!this.partial){if(!Q)return x(null);h.state="loaded",h._isHeaderLoaded=!0,h._mrt=Q}x(null)};h.request=this.partial?h.fetchHeader(void 0,z.bind(this)):h.actor.send("loadTile",F,z.bind(this),void 0,!0)}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.actor&&h.actor.send("abortTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(h,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,(F,z)=>{if(F)return h.state="errored",this.fire(new i.y(F)),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:F})=>F===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 F=null;x instanceof i.aR?F=x.paint.get("raster-array-band"):x instanceof i.aS&&(F=x.paint.get("raster-particle-array-band"));const z=F||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 H=h.textureDescriptorPerLayer.get(x.id);return Object.assign({},H,{texture:h.texturePerLayer.get(x.id)})}getImages(h,x){const T=new Map;for(const D of h)for(const F of x){const[z,H]=F.split("/"),Q=D.getLayer(z);if(!Q||!Q.hasBand(H)||!Q.hasDataForBand(H))continue;const{bytes:re,tileSize:oe,buffer:ge}=Q.getBandView(H),me=oe+2*ge,xe={data:new i.q({width:me,height:me},re),pixelRatio:2,sdf:!1,usvg:!1,version:0};T.set(F,xe)}return T}queryRasterArrayValueByBandId(h,x,T){const D=x._mrt;return new Promise(F=>{const z={},H=new Set;for(const[Q,re]of Object.entries(D.layers)){if(T.layerName&&Q!==T.layerName)continue;const oe={};z[Q]=oe;for(const{bands:ge}of re.dataIndex)for(const me of ge)T.bands&&!T.bands.includes(me)||(H.add(i.B(Q,me)),x.fetchBand(Q,null,me,xe=>{i.o.frame(()=>{oe[me]=xe?null:wu([h.lng,h.lat],D,re.getBandView(me)),H.delete(i.B(Q,me)),H.size===0&&F(z)})},!1))}H.size===0&&F(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},(F,z,H)=>{if(F)return this._loadTilePending[h.uid].forEach(Q=>Q(F,null)),void delete this._loadTilePending[h.uid];if(!z)return this._loadTilePending[h.uid].forEach(Q=>Q(null,null)),void delete this._loadTilePending[h.uid];if(this.map._refreshExpiredTiles&&z){const Q=i.aM(H);h.setExpiryData(Q)}h._mrt=z,h._isHeaderLoaded=!0,h.state="loaded",this._loadTilePending[h.uid].forEach(Q=>Q(null,z)),this._loadTileLoaded[h.uid]=!0,delete this._loadTilePending[h.uid]},void 0,!0)}queryRasterArrayValueByAllBands(h,x,T){return new Promise((D,F)=>{this._loadTileForQuery(x,(z,H)=>{z?F(z):D(H?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&&(H[new i.aQ(M.overscaledZ,D,h.z,T,h.y-1).key]={backfilled:!1},H[new i.aQ(M.overscaledZ,M.wrap,h.z,h.x,h.y-1).key]={backfilled:!1},H[new i.aQ(M.overscaledZ,z,h.z,F,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 F={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&D&&D.resourceTiming&&D.resourceTiming[this.id]&&(F.resourceTiming=D.resourceTiming[this.id]),M&&(this._partialReload=!0),this.fire(new i.z("data",F)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(M),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const M=i.B(this.id,this.scope);this.map.style.clearSource(M),this._updateWorkerData()}loadTile(M,h){const x=M.actor?"reloadTile":"loadTile";M.actor=this.actor;const T=this.map.style?this.map.style.getLut(this.scope):null,D=T?{image:T.image.clone()}:null,F=this._partialReload,z={type:this.type,uid:M.uid,tileID:M.tileID,tileZoom:M.tileZoom,zoom:M.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:M.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:F,worldview:this.map.getWorldview(),indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};M.request=this.actor.send(x,z,(H,Q)=>F&&!Q?(M.state="loaded",h(null)):(delete M.request,M.destroy(!1),M.aborted?h(null):H?h(H):(M.loadVectorData(Q,this.map.painter,x==="reloadTile"),h(null))),void 0,x==="loadTile")}abortTile(M){M.request&&(M.request.cancel(),delete M.request),M.aborted=!0}unloadTile(M,h){this.actor.send("removeTile",{uid:M.uid,type:this.type,source:this.id,scope:this.scope}),M.destroy()}onRemove(M){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(M,h,x,T){super(M,h,x,T),this.roundZoom=!0,this.type="video",this.options=h}load(){this._loaded=!1;const M=this.options;this.urls=[];for(const h of M.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(M){if(this.video){const h=this.video.seekable;Mh.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=M}}getVideo(){return this.video}onAdd(M){this.map||(this.map=M,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 M=this.map.painter.context,h=M.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(M,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(M)}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(M,h,x,T){super(),this.type="batched-model",this.id=M,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(M){this.map=M,this.load()}reload(){this.cancelTileJSONRequest();const M=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(M))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(M){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=ac(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 Ad(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"}))),M&&M(T)})}hasTransition(){return!1}hasTile(M){return!this.tileBounds||this.tileBounds.contains(M.canonical)}loaded(){return this._loaded}loadTile(M,h){const x=this.map._requestManager.normalizeTileURL(M.tileID.canonical.url(this.tiles,this.scheme)),T={request:this.map._requestManager.transformRequest(x,i.R.Tile),data:void 0,uid:M.uid,tileID:M.tileID,tileZoom:M.tileZoom,zoom:M.tileID.overscaledZ,tileSize:this.tileSize*M.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:M.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:i.o.devicePixelRatio,promoteId:this.promoteId};if(M.actor&&M.state!=="expired")if(M.state==="loading")M.reloadCallback=h;else{if(M.buckets){const F=Object.values(M.buckets);for(const z of F)z.dirty=!0;return void(M.state="loaded")}M.request=M.actor.send("reloadTile",T,D.bind(this))}else M.actor=this.dispatcher.getActor(),M.request=M.actor.send("loadTile",T,D.bind(this),void 0,!0);function D(F,z){return M.aborted?h(null):F&&F.status!==404?h(F):(this.map._refreshExpiredTiles&&z&&M.setExpiryData(z),M.loadModelData(z,this.map.painter),M.state="loaded",void h(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends i.aU{constructor(M,h,x,T){super(M,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(F=>typeof F!="number"))||this.fire(new i.y(new i.V(`sources.${M}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.y(new i.V(`sources.${M}`,null,'missing required property "coordinates"'))),h.animate&&typeof h.animate!="boolean"&&this.fire(new i.y(new i.V(`sources.${M}`,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.${M}`,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.${M}`,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(M){this.map=M,this.load(),this.canvas&&this.animate&&this.play()}onRemove(M){this.pause()}prepare(){let M=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,M=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,M=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const h=this.map.painter.context;this.texture?!M&&!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 M of[this.canvas.width,this.canvas.height])if(isNaN(M)||M<=0)return!0;return!1}},custom:class extends i.E{constructor(M,h,x,T){super(),this.id=M,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 Ad(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(M){this.map=M,this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(M),this.load()}onRemove(M){this._implementation.onRemove&&this._implementation.onRemove(M)}hasTile(M){if(this._implementation.hasTile){const{x:h,y:x,z:T}=M.canonical;return this._implementation.hasTile({x:h,y:x,z:T})}return!this.tileBounds||this.tileBounds.contains(M.canonical)}loadTile(M,h){const{x,y:T,z:D}=M.tileID.canonical,F=new AbortController;M.request=Promise.resolve(this._implementation.loadTile({x,y:T,z:D},{signal:F.signal})).then((function(z){return delete M.request,M.aborted?(M.state="unloaded",h(null)):z===void 0?(M.state="errored",h(null)):z===null?(this.loadTileData(M,{width:this.tileSize,height:this.tileSize,data:null}),M.state="loaded",h(null)):function(H){return H instanceof ImageData||H instanceof HTMLCanvasElement||H instanceof ImageBitmap||H instanceof HTMLImageElement}(z)?(this.loadTileData(M,z),M.state="loaded",void h(null)):(M.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"&&(M.state="errored",h(z))}),M.request.cancel=()=>F.abort()}loadTileData(M,h){M.setTexture(h,this.map.painter)}unloadTile(M,h){if(M.texture&&M.texture instanceof i.T?(M.destroy(!1),M.texture&&M.texture instanceof i.T&&this.map.painter.saveTileTexture(M.texture)):M.destroy(),this._implementation.unloadTile){const{x,y:T,z:D}=M.tileID.canonical;this._implementation.unloadTile({x,y:T,z:D})}h&&h()}abortTile(M,h){M.request&&M.request.cancel&&(M.request.cancel(),delete M.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(M=>({x:M.canonical.x,y:M.canonical.y,z:M.canonical.z}))}_clearTiles(){const M=i.B(this.id,this.scope);this.map.style.clearSource(M)}_update(){this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}}},_l=function(M,h,x,T){const D=new em[h.type](M,h,x,T);if(D.id!==M)throw new Error(`Expected Source id to be ${M} instead of ${D.id}`);return i.aY(["load","abort","unload","serialize","prepare"],D),D};function Lf(M,h,x=""){return`${x}:${h.id||""}:${h.layer.id}:${function(T){if("layerId"in T)return`layer:${T.layerId}`;{const{featuresetId:D,importId:F}=T;return`featureset:${D}${F?`:import:${F}`:""}`}}(M.target)}`}function ex(M,h,x,T=""){if(M.uniqueFeatureID){const D=Lf(M,h,T);if(x.has(D))return!0;x.add(D)}return!1}function ov(M,h,x,T,D=!1){const F=h.sourceCache.transform,z=h.sourceCache.tilesIn(M,h.has3DLayers,D);z.sort($m);const H=[];for(const Q of z){const re=Q.tile.queryRenderedFeatures(h,Q,x,T,F,D);Object.keys(re).length&&H.push({wrappedTileID:Q.tile.tileID.wrapped().key,queryResults:re})}for(const Q in h.layers){const re=h.layers[Q];if(re.styleLayer){const oe=re.styleLayer.queryRenderedFeatures(M,h.sourceCache,T);Object.keys(oe).length&&H.push({wrappedTileID:0,queryResults:oe})}}return H.length===0?{}:function(Q){const re={},oe={};for(const ge of Q){const me=ge.queryResults,xe=ge.wrappedTileID,Pe=oe[xe]=oe[xe]||{};for(const Me in me){const He=me[Me],Be=Pe[Me]=Pe[Me]||{},et=re[Me]=re[Me]||[];for(const ut of He)Be[ut.featureIndex]||(Be[ut.featureIndex]=!0,et.push(ut))}}return re}(H)}function lv(M,h,x,T,D,F){const z={},H=T.queryRenderedSymbols(M),Q=[];for(const re of Object.keys(H).map(Number))Q.push(D[re]);Q.sort($m);for(const re of Q){const oe=re.featureIndex.lookupSymbolFeatures(H[re.bucketInstanceId],re.bucketIndex,re.sourceLayerIndex,h,x,F);for(const ge in oe){const me=z[ge]=z[ge]||[],xe=oe[ge];xe.sort((Pe,Me)=>{const He=re.featureSortOrder;if(He){const Be=He.indexOf(Pe.featureIndex);return He.indexOf(Me.featureIndex)-Be}return Me.featureIndex-Pe.featureIndex});for(const Pe of xe)me.push(Pe)}}return z}function cv(M,h){const x=M.getRenderableIds().map(F=>M.getTileByID(F)),T=[],D={};for(let F=0;Fh.getLayer(F)).filter(Boolean);if(D.length!==0){T.layers=D,T.stateDependentLayerIds&&(T.stateDependentLayers=T.stateDependentLayerIds.map(F=>D.filter(z=>z.id===F)[0]));for(const F of D)x[F.fqid]=T}}return x}const Ed=32,mh=33,md=new Uint16Array(8184);for(let M=0;M<2046;M++){let h=M+2,x=0,T=0,D=0,F=0,z=0,H=0;for(1&h?D=F=z=Ed:x=T=H=Ed;(h>>=1)>1;){const re=x+D>>1,oe=T+F>>1;1&h?(D=x,F=T,x=z,T=H):(x=D,T=F,D=z,F=H),z=re,H=oe}const Q=4*M;md[Q+0]=x,md[Q+1]=T,md[Q+2]=D,md[Q+3]=F}const Qc=new Uint16Array(2178),Pd=new Uint8Array(1089),Np=new Uint16Array(1089);function Sp(M){return M===0?-.03125:M===32?.03125:0}const tm={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 sm{constructor(h,x,T,D,F,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=F,D&&D.style&&(this._lastUpdatedBrightness=D.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",D&&D.transform&&(this.projection=D.transform.projection),this.worldview=z,this._hasAppearances=null}registerFadeDuration(h){const 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 F in this.buckets){if(!h.style.hasLayer(F))continue;const z=this.buckets[F],H=z.layers[0],Q=H.sourceLayer||"_geojsonTileLayer",re=h.style.getLayerSourceCache(H);let oe={};re&&(oe=re._state.getState(Q,void 0));const ge=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},me=Object.keys(oe).length>0&&!x;z.hasAppearances=z.layers.some(Me=>Me.appearances&&Me.appearances.length>0);const xe=me?z.stateDependentLayers:z.layers;if(me&&z.stateDependentLayers.length!==0||x){const Me=this.latestFeatureIndex.loadVTLayers();z.update(oe,Me[Q],T,ge,xe,x,D)}if(me&&z.stateDependentLayers.length!==0||x||z.hasAppearances){const Me={zoom:h.transform.zoom,pitch:h.transform.pitch,brightness:h.style.getBrightness()||0,worldview:h.worldview};z.updateAppearances(this.tileID.canonical,oe,T,Me)}(z instanceof i.ba||z instanceof i.bb)&&h._terrain&&h._terrain.enabled&&re&&z.uploadPending()&&h._terrain._clearRenderCacheForTile(re.id,this.tileID);const Pe=h&&h.style&&h.style.getOwnLayer(F);Pe&&(this.queryPadding=Math.max(this.queryPadding,Pe.queryRadius(z)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;He--){const Be=4*He,et=md[Be+0],ut=md[Be+1],tt=md[Be+2],Mt=md[Be+3],_t=et+tt>>1,kt=ut+Mt>>1,xt=_t+kt-ut,pt=kt+et-_t,Et=ut*mh+et,Ht=Mt*mh+tt,Vt=kt*mh+_t,ts=Math.hypot((Qc[2*Et+0]+Qc[2*Ht+0])/2-Qc[2*Vt+0],(Qc[2*Et+1]+Qc[2*Ht+1])/2-Qc[2*Vt+1])>=16;Pd[Vt]=Pd[Vt]||(ts?1:0),He<1022&&(Pd[Vt]=Pd[Vt]||Pd[(ut+pt>>1)*mh+(et+xt>>1)]||Pd[(Mt+pt>>1)*mh+(tt+xt>>1)])}const ge=new i.b1,me=new i.b0;let xe=0;function Pe(He,Be){const et=Be*mh+He;return Np[et]===0&&(ge.emplaceBack(Qc[2*et+0],Qc[2*et+1],He*i.al/Ed,Be*i.al/Ed),Np[et]=++xe),Np[et]-1}function Me(He,Be,et,ut,tt,Mt){const _t=He+et>>1,kt=Be+ut>>1;if(Math.abs(He-tt)+Math.abs(Be-Mt)>1&&Pd[kt*mh+_t])Me(tt,Mt,He,Be,_t,kt),Me(et,ut,tt,Mt,_t,kt);else{const xt=Pe(He,Be),pt=Pe(et,ut),Et=Pe(tt,Mt);me.emplaceBack(xt,pt,Et)}}return Me(0,0,Ed,Ed,Ed,0),Me(Ed,Ed,0,0,0,Ed),{vertices:ge,indices:me}}(this.tileID.canonical,x);D=z.vertices,F=z.indices}else{D=new i.b1,F=new i.b0;for(const{x:H,y:Q}of T)D.emplaceBack(H,Q,0,0);const z=i.bh(D.int16.subarray(0,4*D.length),void 0,4);for(let H=0;H0&&(Q=i.bl(new Float64Array(16),x.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(h,D,x,z,Q,H),this._makeGlobeTileDebugTextBuffer(h,D,x,z,Q,H)}_globePoint(h,x,T,D,F,z,H){let Q=i.bm(h,x,T);if(z){const re=1<.5?xe=-1:me<-.5&&(xe=1);let Pe=(h/i.al+T.x)/re+xe,Me=(x/i.al+T.y)/re;Pe=(Pe-oe)*D._pixelsPerMercatorPixel+oe,Me=(Me-ge)*D._pixelsPerMercatorPixel+ge;const He=[Pe*D.worldSize,Me*D.worldSize,0];i.af(He,He,z),Q=i.bn(Q,He,H)}return i.af(Q,Q,F)}_makeGlobeTileDebugBorderBuffer(h,x,T,D,F,z){const H=new i.bd,Q=new i.be,re=new i.bo,oe=(me,xe,Pe,Me,He)=>{const Be=(Pe-me)/(He-1),et=(Me-xe)/(He-1),ut=H.length;for(let tt=0;ttge*xe+Pe;for(let xe=0;xe{if(F)x(F);else try{const Q=T.getHeaderLength(z);if(Q>h)return void(this.request=this.fetchHeader(Q,x));T.parseHeader(z),this._isHeaderLoaded=!0;let re=0;for(const oe of Object.values(T.layers))re=Math.max(re,oe.dataIndex[oe.dataIndex.length-1].lastByte);z.byteLength>=re&&(this.entireBuffer=z),x(null,this.entireBuffer||z,H)}catch(Q){x(Q)}}),this.request}fetchBandForRender(h,x,T,D){this.fetchBand(h,x,T,F=>{if(F)return void D(F);this.updateTextureDescriptor(h,x,T);const z=this.textureDescriptorPerLayer.get(x);D(null,z?z.img:null)})}fetchBand(h,x,T,D,F=!0){const z=this._mrt;if(!this._isHeaderLoaded||!z)return void D(new Error("Tile header is not ready"));const H=this.actor;if(!H)return void D(new Error("Can't fetch tile band without an actor"));let Q;const re=i.B(String(T),i.B(this.tileID.key,h));let oe=this._taskQueue.get(re);oe?oe.add(D):(oe=new Set,oe.add(D),this._taskQueue.set(re,oe));const ge=(Me,He)=>{Q.complete(Me,He),Me?D(Me):(oe.forEach(Be=>Be(null,He)),this._taskQueue.delete(re))},me=(Me,He)=>{if(Me)return D(Me);const Be=H.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:He,task:Q},ge,void 0,!0);if(x!==null){const et=this._workQueuePerLayer.get(x)||[];et.push(()=>{Be&&Be.cancel(),Q.cancel()}),this._workQueuePerLayer.has(x)||this._workQueuePerLayer.set(x,et)}};let xe;try{xe=z.getLayer(h)}catch(Me){if(this.state==="reloading")return;throw Me}if(!xe)return void D(new Error(`Unknown sourceLayer "${h}"`));if(xe.hasDataForBand(T))return oe.forEach(Me=>Me(null,null)),void this._taskQueue.delete(re);const Pe=xe.getDataRange([T]);if(Q=z.createDecodingTask(Pe),!Q||Q.tasks.length)if(x!==null&&this.flushQueues(x),this.entireBuffer)me(null,this.entireBuffer.slice(Pe.firstByte,Pe.lastByte+1));else{const Me=Object.assign({},this.requestParams,{headers:{Range:`bytes=${Pe.firstByte}-${Pe.lastByte}`}}),He=i.bu(Me,me);if(x!==null){const Be=this._fetchQueuePerLayer.get(x)||[];Be.push(()=>{He.cancel(),Q.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:F,tileSize:z,buffer:H,offset:Q,scale:re}=D.getBandView(T),oe=z+2*H,ge=new i.q({width:oe,height:oe},F),me=this.texturePerLayer.get(x);me&&me instanceof i.T&&me.update(ge,{premultiply:!1}),this.textureDescriptorPerLayer.set(x,{layer:h,band:T,img:ge,buffer:H,offset:Q,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 vy{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 F={value:x,timeout:void 0};if(T!==void 0&&(F.timeout=setTimeout(()=>{this.remove(h,F)},T)),this.data[D].push(F),this.order.push(D),this.order.length>this.max){const z=this._getAndRemoveByKey(this.order[0]);z&&this.onRemove(z)}return this}has(h){return h.wrapped().key in this.data}getAndRemove(h){return this.has(h)?this._getAndRemoveByKey(h.wrapped().key):null}_getAndRemoveByKey(h){const 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),F=this.data[T][D];return this.data[T].splice(D,1),F.timeout&&clearTimeout(F.timeout),this.data[T].length===0&&delete this.data[T],this.onRemove(F.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 Df{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 F in this.state[h])F!==D&&(this.deletedStates[h][F]=null)}else if(this.deletedStates[h]&&this.deletedStates[h][D]===null){this.deletedStates[h][D]={};for(const F in this.state[h][D])T[F]||(this.deletedStates[h][D][F]=null)}else for(const F in T)this.deletedStates[h]&&this.deletedStates[h][D]&&this.deletedStates[h][D][F]===null&&delete this.deletedStates[h][D][F]}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]||{},F=this.deletedStates[h];if(F===null)return{};if(x!==void 0){const H=String(x),Q=Object.assign({},T[H],D[H]);if(F){const re=F[x];if(re===null)return{};for(const oe in re)delete Q[oe]}return Q}const z=Object.assign({},T,D);if(F)for(const H in F)delete z[H];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 F={};for(const z in this.stateChanges[D])this.state[D][z]||(this.state[D][z]={}),Object.assign(this.state[D][z],this.stateChanges[D][z]),F[z]=this.state[D][z];T[D]=F}for(const D in this.deletedStates){this.state[D]=this.state[D]||{};const F={};if(this.deletedStates[D]===null)for(const z in this.state[D])F[z]={},this.state[D][z]={};else for(const z in this.deletedStates[D]){if(this.deletedStates[D][z]===null)this.state[D][z]={};else if(this.state[D][z])for(const H of Object.keys(this.deletedStates[D][z]))delete this.state[D][z][H];F[z]=this.state[D][z]}T[D]=T[D]||{},Object.assign(T[D],F)}if(this.stateChanges={},this.deletedStates={},Object.keys(T).length!==0)for(const D in h)h[D].refreshFeatureState(x)}}class hl 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 vy(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 Df,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(dv).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,F)=>{const z=D.tileID,H=F.tileID,Q=new i.P(z.canonical.x,z.canonical.y)._rotate(this.transform.angle),re=new i.P(H.canonical.x,H.canonical.y)._rotate(this.transform.angle);return z.overscaledZ-H.overscaledZ||re.y-Q.y||re.x-Q.x}).map(D=>D.tileID.key):T.map(D=>D.tileID).sort(dv).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,F){if(D){if(h.state="errored",D.status!==404)this._source.fire(new i.y(D,{tile:h}));else{if(this._source.fire(new i.z("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:h})),!(h.tileID.key in this._loadedParentTiles))return;if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const H=this.map.painter.terrain;this.update(this.transform,H.getScaledDemTileSize(),!0),H.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;F&&F.responseHeaders&&(z=F.responseHeaders),this._source.fire(new i.z("data",{dataType:"source",tile:h,coord:h.tileID,sourceCacheId:this.id,responseHeaders:z}))}_backfillDEM(h){const x=this.getRenderableIds();for(let D=0;D1||(Math.abs(z)>1&&(Math.abs(z+Q)===1?z+=Q:Math.abs(z-Q)===1&&(z-=Q)),F.dem&&D.dem&&(D.dem.backfillBorder(F.dem,z,H),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 F in this._tiles){let z=this._tiles[F];if(D[F]||!z.hasData()||z.tileID.overscaledZ<=x||z.tileID.overscaledZ>T)continue;let H=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()&&(H=re)}let Q=H;for(;Q.overscaledZ>x;)if(Q=Q.scaledTo(Q.overscaledZ-1),h[Q.key]){D[H.key]=H;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),F=this._getLoadedTile(D);if(F)return F}}_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,F=Math.floor(T*D*5),z=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,F):F,H=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,z):z;this._cache.setMaxSize(H)}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 F=this._tiles[D];F.tileID=F.tileID.unwrapTo(F.tileID.wrap+x),T[F.tileID.key]=F}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,F){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 H,Q=this._source.maxzoom;const re=this.map&&this.map.painter?this.map.painter._terrain:null;if(re&&re.sourceCache===this&&re.attenuationRange()){const me=re.attenuationRange()[0],xe=Math.floor(me)-Math.log2(re.getDemUpscale());Q>xe&&(Q=xe)}if(this.used||this.usedForTerrain){if(this._source.tileID)H=h.getVisibleUnwrappedCoordinates(this._source.tileID).map(me=>new i.aQ(me.canonical.z,me.wrap,me.canonical.z,me.canonical.x,me.canonical.y));else if(this.tileCoverLift!==0){const me=h.clone();me.tileCoverLift=this.tileCoverLift,H=me.coveringTiles({tileSize:x||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:Q,roundZoom:this._source.roundZoom&&!T,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.minzoom<=1&&h.projection.name==="globe"&&(H.push(new i.aQ(1,0,1,0,0)),H.push(new i.aQ(1,0,1,1,0)),H.push(new i.aQ(1,0,1,0,1)),H.push(new i.aQ(1,0,1,1,1)))}else if(H=h.coveringTiles({tileSize:x||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:Q,roundZoom:this._source.roundZoom&&!T,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.hasTile){const me=this._source.hasTile.bind(this._source);H=H.filter(xe=>me(xe))}}else H=[];if(H.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!Of(this._source.type)){const me=h.coveringZoomLevel({tileSize:x||this._source.tileSize,roundZoom:this._source.roundZoom&&!T}),xe=Math.min(me,this._source.maxzoom);if(z){const Pe=h.extendTileCover(H,xe);for(const Me of Pe)H.push(Me)}else if(F){const Pe=h.extendTileCoverToNearPlane(H,this.transform.getFrustum(xe),xe);for(const Me of Pe)H.push(Me)}else if(this.castsShadows&&D){const Pe=h.extendTileCover(H,xe,D,16);for(const Me of Pe)this._shadowCasterTiles[Me.key]=!0,H.push(Me)}}const oe=this._updateRetainedTiles(H);if(Of(this._source.type)&&H.length!==0){const me={},xe={},Pe=Object.keys(oe);for(const He of Pe){const Be=oe[He],et=this._tiles[He];if(!et||et.fadeEndTime&&et.fadeEndTime<=i.o.now())continue;const ut=this.findLoadedParent(Be,Math.max(Be.overscaledZ-hl.maxOverzooming,this._source.minzoom));ut&&(this._addTile(ut.tileID),me[ut.tileID.key]=ut.tileID),xe[He]=Be}const Me=H[H.length-1].overscaledZ;for(const He in this._tiles){const Be=this._tiles[He];if(oe[He]||!Be.hasData())continue;let et=Be.tileID;for(;et.overscaledZ>Me;){et=et.scaledTo(et.overscaledZ-1);const ut=this._tiles[et.key];if(ut&&ut.hasData()&&xe[et.key]){oe[He]=Be.tileID;break}}}for(const He in me)oe[He]||(this._coveredTiles[He]=!0,oe[He]=me[He])}for(const me in oe)this._tiles[me].clearFadeHold();const ge=i.bv(this._tiles,oe);for(const me of ge){const xe=this._tiles[me];xe.hasSymbolBuckets&&!xe.holdingForFade()?xe.setHoldDuration(this.map._fadeDuration):xe.hasSymbolBuckets&&!xe.symbolFadeFinished()||this._removeTile(+me)}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,oe)=>Math.min(re,oe.overscaledZ),1/0),F=h[0].overscaledZ,z=Math.max(F-hl.maxOverzooming,this._source.minzoom),H=Math.max(F+hl.maxUnderzooming,this._source.minzoom),Q={};for(const re of h){const oe=this._addTile(re);x[re.key]=re,oe.hasData()||D=this._source.maxzoom){const me=re.children(this._source.maxzoom)[0],xe=this.getTile(me);if(xe&&xe.hasData()){x[me.key]=me;continue}}else{const me=re.children(this._source.maxzoom);if(x[me[0].key]&&x[me[1].key]&&x[me[2].key]&&x[me[3].key])continue}let ge=oe.wasRequested();for(let me=re.overscaledZ-1;me>=z;--me){const xe=re.scaledTo(me);if(T[xe.key]||(T[xe.key]=!0,oe=this.getTile(xe),!oe&&ge&&(oe=this._addTile(xe)),oe&&(x[xe.key]=xe,ge=oe.wasRequested(),oe.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 F=D.scaledTo(D.overscaledZ-1);if(T=this._getLoadedTile(F),T)break;D=F}for(const F of x)this._loadedParentTiles[F]=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,F=this._source.tileSize*h.overscaleFactor();x=this._source.type==="raster-array"?new Jc(h,F,this.transform.tileZoom,D,this._isRaster):new sm(h,F,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=[],F=this.transform;if(!F)return D;const z=F.projection.name==="globe",H=i.aF(F.center.lng);for(const Q in this._tiles){const re=this._tiles[Q];if(T&&re.clearQueryDebugViz(),re.holdingForFade())continue;let oe;if(z){const ge=re.tileID.canonical;if(ge.z===0){const me=[Math.abs(i.aA(H,...Uu(ge,-1))-H),Math.abs(i.aA(H,...Uu(ge,1))-H)];oe=[0,2*me.indexOf(Math.min(...me))-1]}else{const me=[Math.abs(i.aA(H,...Uu(ge,-1))-H),Math.abs(i.aA(H,...Uu(ge,0))-H),Math.abs(i.aA(H,...Uu(ge,1))-H)];oe=[me.indexOf(Math.min(...me))-1]}}else oe=[0];for(const ge of oe){const me=h.containsTile(re,F,x,ge);me&&D.push(me)}}return D}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(h){return this._getRenderableCoordinates(h)}_getRenderableCoordinates(h,x){const T=this.getRenderableIds(h,x).map(F=>this._tiles[F].tileID),D=this.transform.projection.name==="globe";for(const F of T)F.projMatrix=this.transform.calculateProjMatrix(F.toUnwrapped()),F.expandedProjMatrix=D?this.transform.calculateProjMatrix(F.toUnwrapped(),!1,!0):F.projMatrix;return T}sortCoordinatesByDistance(h){const x=h.slice(),T=this.transform._camera.position,D=this.transform._camera.forward(),F={};for(const z of x){const H=1/(1<F[z.key]-F[H.key]),x}hasTransition(){if(this._source.hasTransition())return!0;if(Of(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 Q=()=>{this._sourceLoaded&&(this._source.off("data",Q),this._preloadTiles(h,x))};return void this._source.on("data",Q)}const T=new Map,D=Array.isArray(h)?h:[h],F=this.map.painter.terrain,z=this.usedForTerrain&&F?F.getScaledDemTileSize():this._source.tileSize;for(const Q of D){const re=Q.coveringTiles({tileSize:z,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const oe of re)T.set(oe.key,oe);this.usedForTerrain&&Q.updateElevation(!1)}const H=Array.from(T.values());i.bw(H,(Q,re)=>{const oe=new sm(Q,this._source.tileSize*Q.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(oe,ge=>{this._source.type==="raster-dem"&&oe.dem&&this._backfillDEM(oe),re(ge,oe)})},x)}}function dv(M,h){const x=Math.abs(2*M.wrap)-+(M.wrap<0),T=Math.abs(2*h.wrap)-+(h.wrap<0);return M.overscaledZ-h.overscaledZ||T-x||h.canonical.y-M.canonical.y||h.canonical.x-M.canonical.x}function Of(M){return M==="raster"||M==="image"||M==="video"||M==="custom"}function Uu(M,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 F=D.layer,z=this.style.getLayerSourceCache(F);let H=1;F.type==="fill-extrusion"?H=D.visible?F.paint.get("fill-extrusion-vertical-scale"):0:F.type==="building"&&(H=D.visible?F.paint.get("building-vertical-scale"):0);let Q=z?z.getTile(x):null;if(!Q&&z)for(const re in z._tiles){const oe=z._tiles[re];if(x.canonical.isChildOf(oe.tileID.canonical)){Q=oe;break}}this.currentBuildingBuckets.push({bucket:Q?Q.getBucket(F):null,tileID:Q?Q.tileID:x,verticalScale:H})}h.hasAnyZOffset=!1;let T=!1;for(let D=0;D{T in h&&(x[T]=h[T])}),x}function _y(M){M=M.slice();const h=Object.create(null);for(let x=0;x0?(D-z)/H:0;return this.points[F].mult(1-Q).add(this.points[x].mult(Q))}}class ab{constructor(h,x,T){const D=this.boxCells=[],F=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!F&&[];const H=[];if(h<=0&&x<=0&&this.width<=T&&this.height<=D){if(F)return!0;for(let Q=0;Q0:H}_queryCircle(h,x,T,D,F){const z=h-T,H=h+T,Q=x-T,re=x+T;if(H<0||z>this.width||re<0||Q>this.height)return!D&&[];const oe=[];return this._forEachCell(z,Q,H,re,this._queryCellCircle,oe,{hitTest:D,circle:{x:h,y:x,radius:T},seenUids:{box:{},circle:{}}},F),D?oe.length>0:oe}query(h,x,T,D,F){return this._query(h,x,T,D,!1,F)}hitTest(h,x,T,D,F){return this._query(h,x,T,D,!0,F)}hitTestCircle(h,x,T,D){return this._queryCircle(h,x,T,!0,D)}_queryCell(h,x,T,D,F,z,H,Q){const re=H.seenUids,oe=this.boxCells[F];if(oe!==null){const me=this.bboxes;for(const xe of oe)if(!re.box[xe]){re.box[xe]=!0;const Pe=4*xe;if(h<=me[Pe+2]&&x<=me[Pe+3]&&T>=me[Pe+0]&&D>=me[Pe+1]&&(!Q||Q(this.boxKeys[xe]))){if(H.hitTest)return z.push(!0),!0;z.push({key:this.boxKeys[xe],x1:me[Pe],y1:me[Pe+1],x2:me[Pe+2],y2:me[Pe+3]})}}}const ge=this.circleCells[F];if(ge!==null){const me=this.circles;for(const xe of ge)if(!re.circle[xe]){re.circle[xe]=!0;const Pe=3*xe;if(this._circleAndRectCollide(me[Pe],me[Pe+1],me[Pe+2],h,x,T,D)&&(!Q||Q(this.circleKeys[xe]))){if(H.hitTest)return z.push(!0),!0;{const Me=me[Pe],He=me[Pe+1],Be=me[Pe+2];z.push({key:this.circleKeys[xe],x1:Me-Be,y1:He-Be,x2:Me+Be,y2:He+Be})}}}}}_queryCellCircle(h,x,T,D,F,z,H,Q){const re=H.circle,oe=H.seenUids,ge=this.boxCells[F];if(ge!==null){const xe=this.bboxes;for(const Pe of ge)if(!oe.box[Pe]){oe.box[Pe]=!0;const Me=4*Pe;if(this._circleAndRectCollide(re.x,re.y,re.radius,xe[Me+0],xe[Me+1],xe[Me+2],xe[Me+3])&&(!Q||Q(this.boxKeys[Pe])))return z.push(!0),!0}}const me=this.circleCells[F];if(me!==null){const xe=this.circles;for(const Pe of me)if(!oe.circle[Pe]){oe.circle[Pe]=!0;const Me=3*Pe;if(this._circlesCollide(xe[Me],xe[Me+1],xe[Me+2],re.x,re.y,re.radius)&&(!Q||Q(this.circleKeys[Pe])))return z.push(!0),!0}}}_forEachCell(h,x,T,D,F,z,H,Q){const re=this._convertToXCellCoord(h),oe=this._convertToYCellCoord(x),ge=this._convertToXCellCoord(T),me=this._convertToYCellCoord(D);for(let xe=re;xe<=ge;xe++)for(let Pe=oe;Pe<=me;Pe++)if(F.call(this,h,x,T,D,this.xCellCount*Pe+xe,z,H,Q))return}_convertToXCellCoord(h){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(h*this.xScale)))}_convertToYCellCoord(h){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(h*this.yScale)))}_circlesCollide(h,x,T,D,F,z){const H=D-h,Q=F-x,re=T+z;return re*re>H*H+Q*Q}_circleAndRectCollide(h,x,T,D,F,z,H){const Q=(z-D)/2,re=Math.abs(h-(D+Q));if(re>Q+T)return!1;const oe=(H-F)/2,ge=Math.abs(x-(F+oe));if(ge>oe+T)return!1;if(re<=Q||ge<=oe)return!0;const me=re-Q,xe=ge-oe;return me*me+xe*xe<=T*T}}const yt={unknown:0,flipRequired:1,flipNotRequired:2},Ts=Math.tan(85*Math.PI/180);function Ws(M,h,x,T,D,F,z){const H=i.bC();if(x)if(F.name==="globe"){const Q=i.bD(D,h);i.aB(H,H,Q)}else{const Q=i.bE([],z);H[0]=Q[0],H[1]=Q[1],H[4]=Q[2],H[5]=Q[3],T||i.bB(H,H,D.angle)}else i.aB(H,D.labelPlaneMatrix,M);return H}function ln(M,h,x,T,D,F,z){const H=Ws(M,h,x,T,D,F,z);return F.name==="globe"&&x||(H[2]=H[6]=H[10]=H[14]=0),H}function cn(M,h,x,T,D,F,z){if(x){if(F.name==="globe"){const H=Ws(M,h,x,T,D,F,z);return i.bl(H,H),i.aB(H,M,H),H}{const H=i.bz(M),Q=i.bA([]);return Q[0]=z[0],Q[1]=z[1],Q[4]=z[2],Q[5]=z[3],i.aB(H,H,Q),T||i.bB(H,H,-D.angle),H}}return D.glCoordMatrix}function ea(M,h,x,T){const D=[M,h,x,1];x?i.aC(D,D,T):Rr(D,D,T);const F=D[3];return D[0]/=F,D[1]/=F,D[2]/=F,D}function Fr(M,h){return Math.min(.5+M/h*.5,1.5)}function to(M,h){const x=M[0]/M[3],T=M[1]/M[3];return x>=-h[0]&&x<=h[0]&&T>=-h[1]&&T<=h[1]}function Rf(M,h,x,T,D,F,z,H,Q,re,oe=1){const ge=x.transform,me=T?M.textSizeData:M.iconSizeData,xe=i.bK(me,x.transform.zoom,oe),Pe=ge.projection.name==="globe",Me=[256/x.width*2+1,256/x.height*2+1],He=T?M.text.dynamicLayoutVertexArray:M.icon.dynamicLayoutVertexArray;He.clear();let Be=null;Pe&&(Be=T?M.text.globeExtVertexArray:M.icon.globeExtVertexArray);const et=M.lineVertexArray,ut=T?M.text.placedSymbolArray:M.icon.placedSymbolArray,tt=x.transform.width/x.transform.height;let Mt,_t=!1;for(let kt=0;ktMath.abs(x)?{useVertical:!0}:M===i.bL.vertical?T>0?{needsFlipping:!0}:null:h!==yt.unknown&&function(D,F){return D===0||Math.abs(F/D)>Ts}(x,T)?h===yt.flipRequired?{needsFlipping:!0}:null:x<0?{needsFlipping:!0}:null}function jy(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Me,He,Be,et,ut){const tt=h/24,Mt=M.lineOffsetX*tt,_t=M.lineOffsetY*tt,{lineStartIndex:kt,glyphStartIndex:xt,numGlyphs:pt,segment:Et,writingMode:Ht,flipState:Vt}=M,ts=kt+M.lineLength,ss=fs=>{if(oe){const[ds,Jt,Es]=fs.up,Qs=re.length;i.bN(oe,Qs+0,ds,Jt,Es),i.bN(oe,Qs+1,ds,Jt,Es),i.bN(oe,Qs+2,ds,Jt,Es),i.bN(oe,Qs+3,ds,Jt,Es)}const[Bs,Yt,Ft]=fs.point;i.bO(re,Bs,Yt,Ft,fs.angle)};if(pt>1){const fs=qm(tt,H,Mt,_t,x,ge,me,M,Q,F,xe,Me,!1,He,Be,et,ut);if(!fs)return{notEnoughRoom:!0};if(T&&!x){let[Bs,Yt,Ft]=fs.first.point,[ds,Jt,Es]=fs.last.point;[Bs,Yt]=ea(Bs,Yt,Ft,z),[ds,Jt]=ea(ds,Jt,Es,z);const Qs=Hr(Ht,Vt,(ds-Bs)*Pe,Jt-Yt);if(M.flipState=Qs&&Qs.needsFlipping?yt.flipRequired:yt.flipNotRequired,Qs)return Qs}ss(fs.first);for(let Bs=xt+1;Bs0?ds:nm(me,Ft,Bs,1,D,void 0,He,Be.canonical),Es=Hr(Ht,Vt,(Jt[0]-Bs[0])*Pe,Jt[1]-Bs[1]);if(M.flipState=Es&&Es.needsFlipping?yt.flipRequired:yt.flipNotRequired,Es)return Es}const fs=hv(tt*H.getoffsetX(xt),Mt,_t,x,ge,me,Et,kt,ts,Q,F,xe,Me,!1,!1,He,Be,et,ut);if(!fs)return{notEnoughRoom:!0};ss(fs)}return{}}function ky(M,h,x,T,D){const{x:F,y:z,z:H}=T.projectTilePoint(M.x,M.y,h);if(!D)return ea(F,z,H,x);const[Q,re,oe]=D.getElevation(M,D.elevation,D.elevationFeature);return ea(F+Q,z+re,H+oe,x)}function nm(M,h,x,T,D,F,z,H){const Q=ky(M.sub(h)._unit()._add(M),H,D,z,F);return i.av(Q,x,Q),i.aw(Q,Q),i.bH(Q,x,Q,T)}function hv(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Me,He,Be,et){const ut=T?M-h:M+h;let tt=ut>0?1:-1,Mt=0;T&&(tt*=-1,Mt=Math.PI),tt<0&&(Mt+=Math.PI);let _t=H+z+(tt>0?0:1)|0,kt=D,xt=D,pt=0,Et=0;const Ht=Math.abs(ut),Vt=[],ts=[];let ss=F,fs=ss,Bs=i.bF([]);const Yt=()=>nm(fs,ss,xt,Ht-pt+1,oe,me,Me,He.canonical);for(;pt+Et<=Ht;){if(_t+=tt,_t=Q)return null;if(xt=kt,fs=ss,Vt.push(xt),xe&&ts.push(fs),ss=new i.P(re.getx(_t),re.gety(_t)),kt=ge[_t],!kt){const jr=ky(ss,He.canonical,oe,Me,me);kt=jr[3]>0?ge[_t]=jr:Yt()}pt+=Et;const $s=i.av([],kt,xt),Sr=i.bG(xt,kt);if(x&&Sr>0&&Et>0&&i.bJ(Bs,$s)/(Et*Sr)0,ut),kt=re*_t.perspectiveRatio,xt=(T.x1*x+H.x-T.padding)*kt+_t.point.x,pt=(T.y1*x+H.y-T.padding)*kt+_t.point.y,Et=(T.x2*x+H.x+T.padding)*kt+_t.point.x,Ht=(T.y2*x+H.y+T.padding)*kt+_t.point.y,Vt=_t.perspectiveRatio<=.55||_t.occluded;return!this.isInsideGrid(xt,pt,Et,Ht)||!Q&&this.grid.hitTest(xt,pt,Et,Ht,ge)||Vt?{box:[],offscreen:!1,occluded:_t.occluded}:{box:[xt,pt,Et,Ht],offscreen:this.isOffscreen(xt,pt,Et,Ht),occluded:!1}}placeCollisionCircles(h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Me,He){const Be=[],et=this.transform.elevation,ut=h.getProjection(),tt=h.elevationType==="road",Mt=!!et||tt,_t=i.bV.getAtTileOffsetFunc(He,this.transform.center.lat,this.transform.worldSize,ut),kt=new i.P(T.tileAnchorX,T.tileAnchorY),xt=new i.P(T.tileAnchorX,T.tileAnchorY);let{x:pt,y:Et,z:Ht}=ut.projectTilePoint(xt.x,xt.y,He.canonical),Vt=null;if(Mt){const Sr=tt?h.getElevationFeatureForText(D):null;Vt={getElevation:_t,elevation:et,elevationFeature:Sr};const[jr,lr,fr]=_t(kt,et,Sr);pt+=jr,Et+=lr,Ht+=fr}const ts=ut.name==="globe",ss=this.projectAndGetPerspectiveRatio(Q,pt,Et,Ht,He,ts||!!et||this.transform.pitch>0,ut),{perspectiveRatio:fs}=ss,Bs=(me?H/fs:H*fs)/i.bY,Yt=ea(pt,Et,Ht,re),Ft=T.lineOffsetX*Bs,ds=T.lineOffsetY*Bs,Jt=i.an(h.layers[0].layout.get("text-max-angle")),Es=Math.cos(Jt),Qs=ss.signedDistanceFromCamera>0?qm(Bs,z,Ft,ds,tt&&T.flipState===1,Yt,xt,T,F,re,{},Mt&&!me?Vt:null,me&&Mt,ut,He,me,Es):null;let mr=!1,Ks=!1,$s=!0;if(Qs&&!ss.occluded){const Sr=.5*Pe*fs+Me,jr=new i.P(-100,-100),lr=new i.P(this.screenRightBoundary,this.screenBottomBoundary),fr=new sx,{first:Vr,last:jn}=Qs,ma=Vr.path.length;let Ga=[];for(let vn=ma-1;vn>=1;vn--)Ga.push(Vr.path[vn]);for(let vn=1;vn(Mt&&!ts&&(fi=_t(oivn[3]<=0)&&(Ga=[]));let za=[];if(Ga.length>0){let vn=1/0,Xa=-1/0,fi=1/0,oi=-1/0;for(const Oa of Ga)vn=Math.min(vn,Oa[0]),fi=Math.min(fi,Oa[1]),Xa=Math.max(Xa,Oa[0]),oi=Math.max(oi,Oa[1]);Xa>=jr.x&&vn<=lr.x&&oi>=jr.y&&fi<=lr.y&&(za=[Ga.map(Oa=>new i.P(Oa[0],Oa[1]))],(vnlr.x||filr.y)&&(za=i.bW(za,jr.x,jr.y,lr.x,lr.y)))}for(const vn of za){fr.reset(vn,.25*Sr);let Xa=0;Xa=fr.length<=.5*Sr?1:Math.ceil(fr.paddedLength/Er)+1;for(let fi=0;fi0?(i.aC(Q,Q,h),this.fogState&&F&&H.name!=="globe"&&(re=function(me,xe,Pe,Me,He,Be){const et=Be.calculateFogTileMatrix(He),ut=[xe,Pe,Me];return i.af(ut,ut,et),pr(me,i.ag(ut),Be.pitch,Be._fov)}(this.fogState,x,T,D,F.toUnwrapped(),this.transform)>.9)):Rr(Q,Q,h);const oe=Q[3];return{point:new i.P((Q[0]/oe+1)/2*this.transform.width+ja,(-Q[1]/oe+1)/2*this.transform.height+ja),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(H)/oe*.5,1.5),signedDistanceFromCamera:oe,occluded:z&&Q[2]>oe||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 pd(M,h,x,T,D){const{horizontalAlign:F,verticalAlign:z}=i.c1(M),H=-(F-.5)*h,Q=-(z-.5)*x,re=i.c2(M,T);return new i.P(H+re[0]*D,Q+re[1]*D)}function al(M,h,x,T,D){const F=new i.P(M,h);return x&&F._rotate(T?D:-D),F}class Ice{constructor(h,x,T,D,F,z){this.transform=h.clone(),this.projection=h.projection.name,this.collisionIndex=new pi(this.transform,F),this.buildingIndex=z,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=x,this.retainedQueryData={},this.collisionGroups=new ob(T),this.collisionCircleArrays={},this.prevPlacement=D,D&&(D.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(h,x,T,D,F=1){const z=T.getBucket(x),H=T.latestFeatureIndex;if(!z||!H||x.fqid!==z.layerIds[0])return;const Q=z.layers[0].layout,re=z.layers[0].paint,oe=T.collisionBoxArray,ge=Math.pow(2,this.transform.zoom-T.tileID.overscaledZ),me=T.tileSize/i.al,xe=T.tileID.toUnwrapped();this.transform.setProjection(z.projection);const Pe=(Me=T.tileID,He=z.getProjection(),Be=this.transform,He.name===this.projection?Be.calculateProjMatrix(Me.toUnwrapped()):nb(Be,He,Me));var Me,He,Be;const et=Q.get("text-pitch-alignment")==="map",ut=Q.get("text-rotation-alignment")==="map";x.compileFilter(x.options);const tt=x.dynamicFilter(),Mt=x.dynamicFilterNeedsFeature(),_t=this.transform.calculatePixelsToTileUnitsMatrix(T),kt=ln(Pe,T.tileID.canonical,et,ut,this.transform,z.getProjection(),_t);let xt=null;const pt=z.getProjection().createInversionMatrix(this.transform,T.tileID.canonical);if(et){const Ft=cn(Pe,T.tileID.canonical,et,ut,this.transform,z.getProjection(),_t);xt=i.aB([],this.transform.labelPlaneMatrix,Ft)}let Et=null;tt&&T.latestFeatureIndex&&(Et={unwrappedTileID:xe,dynamicFilter:tt,dynamicFilterNeedsFeature:Mt}),this.retainedQueryData[z.bucketInstanceId]=new ib(z.bucketInstanceId,H,z.sourceLayerIndex,z.index,T.tileID);const[Ht,Vt]=z.layers[0].layout.get("text-size-scale-range"),ts=i.aA(F,Ht,Vt),[ss,fs]=Q.get("icon-size-scale-range"),Bs=i.aA(F,ss,fs),Yt={bucket:z,layout:Q,paint:re,posMatrix:Pe,invMatrix:pt,mercatorCenter:[i.aF(this.transform.center.lng),i.aJ(this.transform.center.lat)],textLabelPlaneMatrix:kt,labelToScreenMatrix:xt,clippingData:Et,scale:ge,textPixelRatio:me,holdingForFade:T.holdingForFade(),collisionBoxArray:oe,partiallyEvaluatedTextSize:i.bK(z.textSizeData,this.transform.zoom,ts),partiallyEvaluatedIconSize:i.bK(z.iconSizeData,this.transform.zoom,Bs),collisionGroup:this.collisionGroups.get(z.sourceID),latestFeatureIndex:T.latestFeatureIndex};if(D)for(const Ft of z.sortKeyRanges){const{sortKey:ds,symbolInstanceStart:Jt,symbolInstanceEnd:Es}=Ft;h.push({sortKey:ds,symbolInstanceStart:Jt,symbolInstanceEnd:Es,parameters:Yt})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:z.symbolInstances.length,parameters:Yt})}attemptAnchorPlacement(h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Me,He,Be,et,ut,tt,Mt){const{textOffset0:_t,textOffset1:kt,crossTileID:xt}=Me,pt=[_t,kt],Et=pd(h,z,H,pt,Q),Ht=this.collisionIndex.placeCollisionBox(Be,Q,x,T,D,F,al(Et.x,Et.y,re,oe,this.transform.angle),Pe,ge,me,xe.predicate);if(ut){const Vt=Be.getSymbolInstanceIconSize(Mt,this.transform.zoom,Me.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(Be,Vt,ut,T,D,F,al(Et.x,Et.y,re,oe,this.transform.angle),Pe,ge,me,xe.predicate).box.length===0)return}if(Ht.box.length>0){let Vt;return this.prevPlacement&&this.prevPlacement.variableOffsets[xt]&&this.prevPlacement.placements[xt]&&this.prevPlacement.placements[xt].text&&(Vt=this.prevPlacement.variableOffsets[xt].anchor),this.variableOffsets[xt]={textOffset:pt,width:z,height:H,anchor:h,textScale:Q,prevAnchor:Vt},this.markUsedJustification(Be,h,Me,et),Be.allowVerticalPlacement&&(this.markUsedOrientation(Be,et,Me),this.placedOrientations[xt]=et),{shift:Et,placedGlyphBoxes:Ht}}}placeLayerBucketPart(h,x,T,D,F=1){const{bucket:z,layout:H,paint:Q,posMatrix:re,textLabelPlaneMatrix:oe,labelToScreenMatrix:ge,clippingData:me,textPixelRatio:xe,mercatorCenter:Pe,invMatrix:Me,holdingForFade:He,collisionBoxArray:Be,partiallyEvaluatedTextSize:et,partiallyEvaluatedIconSize:ut,collisionGroup:tt,latestFeatureIndex:Mt}=h.parameters,_t=H.get("text-optional"),kt=H.get("icon-optional"),xt=H.get("text-allow-overlap"),pt=H.get("icon-allow-overlap"),Et=H.get("text-rotation-alignment")==="map",Ht=H.get("icon-rotation-alignment")==="map",Vt=H.get("text-pitch-alignment")==="map",ts=Q.get("symbol-z-offset"),ss=H.get("symbol-elevation-reference")==="sea",fs=H.get("symbol-placement"),[Bs,Yt]=H.get("text-size-scale-range"),[Ft,ds]=H.get("icon-size-scale-range"),Jt=i.aA(F,Bs,Yt),Es=i.aA(F,Ft,ds),Qs=H.get("text-variable-anchor"),mr=Et&&fs!=="point",Ks=Ht&&fs!=="point",$s=Qs&&z.hasTextData(),Sr=z.hasIconTextFit()&&$s&&z.hasIconData();this.transform.setProjection(z.projection);const jr=$s||mr,lr=Ks||Sr;let fr=xt&&(pt||!z.hasIconData()||kt),Vr=pt&&(xt||!z.hasTextData()||_t);const jn=!ts.isConstant();!z.collisionArrays&&Be&&z.deserializeCollisionBoxes(Be),T&&D&&z.updateCollisionDebugBuffers(this.transform.zoom,Be,Jt,Es);const ma=(Er,za,vn)=>{const{crossTileID:Xa,numVerticalGlyphVertices:fi}=Er;let oi=null;if(me&&me.dynamicFilterNeedsFeature||jn){const jo=this.retainedQueryData[z.bucketInstanceId];oi=Mt.loadFeature({featureIndex:Er.featureIndex,bucketIndex:jo.bucketIndex,sourceLayerIndex:jo.sourceLayerIndex,layoutVertexArrayOffset:0});const Oo=oi.properties?oi.properties.worldview:null;if(z.localizable&&z.worldview&&typeof Oo=="string")if(Oo==="all")oi.properties.$localized=!0;else{if(!Oo.split(",").includes(z.worldview))return;oi.properties.$localized=!0,oi.properties.worldview=z.worldview}}if(me&&!(0,me.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:z.worldview},oi,this.retainedQueryData[z.bucketInstanceId].tileID.canonical,new i.P(Er.tileAnchorX,Er.tileAnchorY),this.transform.calculateDistanceTileData(me.unwrappedTileID)))return this.placements[Xa]=new si(!1,!1,!1,!0),void x.add(Xa);const Oa=ts.evaluate(oi,{});if(x.has(Xa))return;if(He)return void(this.placements[Xa]=new si(!1,!1,!1));let Rn=!1,Za=!1,fo=!0,Wi=!1,Qa=!1,Ca=null,Fn={box:null,offscreen:null,occluded:null},$i={box:null},Ao=null,ho=null,ji=null,ru=0,ed=0,jl=0;vn.textFeatureIndex?ru=vn.textFeatureIndex:Er.useRuntimeCollisionCircles&&(ru=Er.featureIndex),vn.verticalTextFeatureIndex&&(ed=vn.verticalTextFeatureIndex);const gd=z.elevationFeatures?z.elevationFeatures[Er.elevationFeatureIndex]:void 0,xd=jo=>{jo.tileID=this.retainedQueryData[z.bucketInstanceId].tileID;const Oo=this.transform.elevation;jo.elevation=ss?Oa:Oa+i.bV.getAtTileOffset(jo.tileID,new i.P(jo.tileAnchorX,jo.tileAnchorY),Oo,gd),jo.elevation+=Er.zOffset},Pc=vn.textBox;if(Pc){xd(Pc);const jo=ki=>{let Go=i.bL.horizontal;if(z.allowVerticalPlacement&&!ki&&this.prevPlacement){const go=this.prevPlacement.placedOrientations[Xa];go&&(this.placedOrientations[Xa]=go,Go=go,this.markUsedOrientation(z,Go,Er))}return Go},Oo=(ki,Go)=>{if(z.allowVerticalPlacement&&fi>0&&vn.verticalTextBox){for(const go of z.writingModes)if(go===i.bL.vertical?(Fn=Go(),$i=Fn):Fn=ki(),Fn&&Fn.box&&Fn.box.length)break}else Fn=ki()};if(Qs){let ki=Qs;if(this.prevPlacement&&this.prevPlacement.variableOffsets[Xa]){const mo=this.prevPlacement.variableOffsets[Xa];ki.indexOf(mo.anchor)>0&&(ki=ki.filter(hm=>hm!==mo.anchor),ki.unshift(mo.anchor))}const Go=(mo,hm,Db)=>{const Zm=z.getSymbolInstanceTextSize(et,Er,this.transform.zoom,za),Ob=(mo.x2-mo.x1)*Zm+2*mo.padding,Ov=(mo.y2-mo.y1)*Zm+2*mo.padding,Op=Er.hasIconTextFit&&!pt?hm:null;Op&&xd(Op);let Xf={box:[],offscreen:!1,occluded:!1};const Rv=xt?2*ki.length:ki.length;for(let yx=0;yx=ki.length,Er,za,z,Db,Op,et,ut);if(Qf&&(Xf=Qf.placedGlyphBoxes,Xf&&Xf.box&&Xf.box.length)){Rn=!0,Ca=Qf.shift;break}}return Xf};Oo(()=>Go(Pc,vn.iconBox,i.bL.horizontal),()=>{const mo=vn.verticalTextBox;return mo&&xd(mo),z.allowVerticalPlacement&&!(Fn&&Fn.box&&Fn.box.length)&&fi>0&&mo?Go(mo,vn.verticalIconBox,i.bL.vertical):{box:null,offscreen:null,occluded:null}}),Fn&&(Rn=Fn.box,fo=Fn.offscreen,Wi=Fn.occluded);const go=jo(!(!Fn||!Fn.box));if(!Rn&&this.prevPlacement){const mo=this.prevPlacement.variableOffsets[Xa];mo&&(this.variableOffsets[Xa]=mo,this.markUsedJustification(z,mo.anchor,Er,go))}}else{const ki=(Go,go)=>{const mo=z.getSymbolInstanceTextSize(et,Er,this.transform.zoom,za),hm=this.collisionIndex.placeCollisionBox(z,mo,Go,Pe,Me,jr,new i.P(0,0),xt,xe,re,tt.predicate);return hm&&hm.box&&hm.box.length&&(this.markUsedOrientation(z,go,Er),this.placedOrientations[Xa]=go),hm};Oo(()=>ki(Pc,i.bL.horizontal),()=>{const Go=vn.verticalTextBox;return z.allowVerticalPlacement&&fi>0&&Go?(xd(Go),ki(Go,i.bL.vertical)):{box:null,offscreen:null,occluded:null}}),jo(!!(Fn&&Fn.box&&Fn.box.length))}}if(Ao=Fn,Rn=Ao&&Ao.box&&Ao.box.length>0,fo=Ao&&Ao.offscreen,Wi=Ao&&Ao.occluded,Er.useRuntimeCollisionCircles){const jo=Er.centerJustifiedTextSymbolIndex>=0?Er.centerJustifiedTextSymbolIndex:Er.verticalPlacedTextSymbolIndex,Oo=z.text.placedSymbolArray.get(jo),ki=i.bM(z.textSizeData,et,Oo),Go=H.get("text-padding");ho=this.collisionIndex.placeCollisionCircles(z,xt,Oo,jo,z.lineVertexArray,z.glyphOffsetArray,ki,re,oe,ge,T,Vt,tt.predicate,Er.collisionCircleDiameter*ki/i.bY,Go,this.retainedQueryData[z.bucketInstanceId].tileID),Rn=xt||ho.circles.length>0&&!ho.collisionDetected,fo=fo&&ho.offscreen,Wi=ho.occluded}if(vn.iconFeatureIndex&&(jl=vn.iconFeatureIndex),vn.iconBox){const jo=Oo=>{xd(Oo);const ki=Er.hasIconTextFit&&Ca?al(Ca.x,Ca.y,Et,Vt,this.transform.angle):new i.P(0,0),Go=z.getSymbolInstanceIconSize(ut,this.transform.zoom,Er.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(z,Go,Oo,Pe,Me,lr,ki,pt,xe,re,tt.predicate)};$i&&$i.box&&$i.box.length&&vn.verticalIconBox?(ji=jo(vn.verticalIconBox),Za=ji.box.length>0):(ji=jo(vn.iconBox),Za=ji.box.length>0),fo=fo&&ji.offscreen,Qa=ji.occluded}const vh=_t||Er.numHorizontalGlyphVertices===0&&fi===0,um=kt||Er.numIconVertices===0;if(vh||um?um?vh||(Za=Za&&Rn):Rn=Za&&Rn:Za=Rn=Za&&Rn,Rn&&Ao&&Ao.box&&this.collisionIndex.insertCollisionBox(Ao.box,H.get("text-ignore-placement"),z.bucketInstanceId,$i&&$i.box&&ed?ed:ru,tt.ID),Za&&ji&&this.collisionIndex.insertCollisionBox(ji.box,H.get("icon-ignore-placement"),z.bucketInstanceId,jl,tt.ID),ho&&(Rn&&this.collisionIndex.insertCollisionCircles(ho.circles,H.get("text-ignore-placement"),z.bucketInstanceId,ru,tt.ID),T)){const jo=z.bucketInstanceId;let Oo=this.collisionCircleArrays[jo];Oo===void 0&&(Oo=this.collisionCircleArrays[jo]=new fS);for(let ki=0;ki=0;--za){const vn=Er[za];ma(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 Er=z.getSortedIndexesByZOffset();for(let za=0;za=0&&(h.text.placedSymbolArray.get(F).crossTileID=ge>=0&&F!==ge?0:re),z>=0&&(h.text.placedSymbolArray.get(z).crossTileID=ge>=0&&z!==ge?0:re),H>=0&&(h.text.placedSymbolArray.get(H).crossTileID=ge>=0&&H!==ge?0:re),Q>=0&&(h.text.placedSymbolArray.get(Q).crossTileID=ge>=0&&Q!==ge?0:re)}markUsedOrientation(h,x,T){const D=x===i.bL.horizontal||x===i.bL.horizontalOnly?x:0,F=x===i.bL.vertical?x:0,{leftJustifiedTextSymbolIndex:z,centerJustifiedTextSymbolIndex:H,rightJustifiedTextSymbolIndex:Q,verticalPlacedTextSymbolIndex:re}=T,oe=h.text.placedSymbolArray;z>=0&&(oe.get(z).placedOrientation=D),H>=0&&(oe.get(H).placedOrientation=D),Q>=0&&(oe.get(Q).placedOrientation=D),re>=0&&(oe.get(re).placedOrientation=F)}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,F=x?x.opacities:{},z=x?x.variableOffsets:{},H=x?x.placedOrientations:{};for(const Q in this.placements){const re=this.placements[Q],oe=F[Q];oe?(this.opacities[Q]=new Cp(oe,D,re.text,re.icon,null,re.clipped),T=T||re.text!==oe.text.placed||re.icon!==oe.icon.placed):(this.opacities[Q]=new Cp(null,D,re.text,re.icon,re.skipFade,re.clipped),T=T||re.text||re.icon)}for(const Q in F){const re=F[Q];if(!this.opacities[Q]){const oe=new Cp(re,D,!1,!1);oe.isHidden()||(this.opacities[Q]=oe,T=T||re.text.placed||re.icon.placed)}}for(const Q in z)this.variableOffsets[Q]||!this.opacities[Q]||this.opacities[Q].isHidden()||(this.variableOffsets[Q]=z[Q]);for(const Q in H)this.placedOrientations[Q]||!this.opacities[Q]||this.opacities[Q].isHidden()||(this.placedOrientations[Q]=H[Q]);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 F=new Set;for(const z of x){const H=z.getBucket(h);H&&z.latestFeatureIndex&&h.fqid===H.layerIds[0]&&(this.updateBucketOpacities(H,F,z,z.collisionBoxArray,T,D,z.tileID,h.scope),H.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(H,z.tileID),H.elevationType==="road"&&H.updateRoadElevation(z.tileID.canonical),H.updateZOffset())}}updateBucketOpacities(h,x,T,D,F,z,H,Q){h.hasTextData()&&h.text.opacityVertexArray.clear(),h.hasIconData()&&h.icon.opacityVertexArray.clear(),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexArray.clear(),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexArray.clear();const re=h.layers[0].layout,oe=h.layers[0].paint,ge=!!h.layers[0].dynamicFilter(),me=new Cp(null,0,!1,!1,!0),xe=re.get("text-allow-overlap"),Pe=re.get("icon-allow-overlap"),Me=re.get("text-variable-anchor"),He=re.get("text-rotation-alignment")==="map",Be=re.get("text-pitch-alignment")==="map",et=oe.get("symbol-z-offset"),ut=re.get("symbol-elevation-reference")==="sea",tt=!et.isConstant(),Mt=new Cp(null,0,xe&&(Pe||!h.hasIconData()||re.get("icon-optional")),Pe&&(xe||!h.hasTextData()||re.get("text-optional")),!0);!h.collisionArrays&&D&&(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData())&&h.deserializeCollisionBoxes(D);const _t=(xt,pt,Et)=>{for(let Ht=0;Ht0||Ht>0,Qs=ts>0,mr=this.placedOrientations[Vt],Ks=mr===i.bL.vertical,$s=mr===i.bL.horizontal||mr===i.bL.horizontalOnly;!Es&&!Qs||Jt.isHidden()||kt++;let Sr=!1;if((Es||Qs)&&z)for(const jr of h.activeReplacements){if(i.bZ(jr,F,i.b_.Symbol,Q)||jr.min.x>ss||ss>jr.max.x||jr.min.y>fs||fs>jr.max.y)continue;const lr=i.b$(ss,fs,H.canonical,jr.footprintTileId.canonical);if(Sr=i.c0(lr,jr.footprint),Sr)break}if(Es){const jr=Sr?Ny:Jd(Jt.text);_t(h.text,Et,Ks?Ny:jr),_t(h.text,Ht,$s?Ny:jr);const lr=Jt.text.isHidden(),{leftJustifiedTextSymbolIndex:fr,centerJustifiedTextSymbolIndex:Vr,rightJustifiedTextSymbolIndex:jn,verticalPlacedTextSymbolIndex:ma}=pt,Ga=h.text.placedSymbolArray,Er=lr||Ks?1:0;fr>=0&&(Ga.get(fr).hidden=Er),Vr>=0&&(Ga.get(Vr).hidden=Er),jn>=0&&(Ga.get(jn).hidden=Er),ma>=0&&(Ga.get(ma).hidden=lr||$s?1:0);const za=this.variableOffsets[Vt];za&&this.markUsedJustification(h,za.anchor,pt,mr);const vn=this.placedOrientations[Vt];vn&&(this.markUsedJustification(h,"left",pt,vn),this.markUsedOrientation(h,vn,pt))}if(Qs){const jr=Sr?Ny:Jd(Jt.icon),{placedIconSymbolIndex:lr,verticalPlacedIconSymbolIndex:fr}=pt,Vr=h.icon.placedSymbolArray,jn=Jt.icon.isHidden()?1:0;lr>=0&&(_t(h.icon,ts,Ks?Ny:jr),Vr.get(lr).hidden=jn),fr>=0&&(_t(h.icon,pt.numVerticalIconVertices,$s?Ny:jr),Vr.get(fr).hidden=jn)}if(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData()){const jr=h.collisionArrays[xt];if(jr){let lr=new i.P(0,0),fr=!0;if(jr.textBox||jr.verticalTextBox){if(Me){const jn=this.variableOffsets[Vt];jn?(lr=pd(jn.anchor,jn.width,jn.height,jn.textOffset,jn.textScale),He&&lr._rotate(Be?this.transform.angle:-this.transform.angle)):fr=!1}ge&&(fr=!Jt.clipped),jr.textBox&&rx(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!fr||Ks,Ft,ut,lr.x,lr.y),jr.verticalTextBox&&rx(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!fr||$s,Ft,ut,lr.x,lr.y)}const Vr=fr&&!!(!$s&&jr.verticalIconBox);jr.iconBox&&rx(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,Vr,Ft,ut,pt.hasIconTextFit?lr.x:0,pt.hasIconTextFit?lr.y:0),jr.verticalIconBox&&rx(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,!Vr,Ft,ut,pt.hasIconTextFit?lr.x:0,pt.hasIconTextFit?lr.y:0)}}}if(h.fullyClipped=kt===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 rx(M,h,x,T,D,F,z){M.emplaceBack(h?1:0,x?1:0,F||0,z||0,T,D?1:0),M.emplaceBack(h?1:0,x?1:0,F||0,z||0,T,D?1:0),M.emplaceBack(h?1:0,x?1:0,F||0,z||0,T,D?1:0),M.emplaceBack(h?1:0,x?1:0,F||0,z||0,T,D?1:0)}const GM=Math.pow(2,25),lb=Math.pow(2,24),gS=Math.pow(2,17),KM=Math.pow(2,16),xS=Math.pow(2,9),Qd=Math.pow(2,8),Ff=Math.pow(2,1);function Jd(M){if(M.opacity===0&&!M.placed)return 0;if(M.opacity===1&&M.placed)return 4294967295;const h=M.placed?1:0,x=Math.floor(127*M.opacity);return x*GM+h*lb+x*gS+h*KM+x*xS+h*Qd+x*Ff+h}const Ny=0;class mv{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,F,z){const H=this._bucketParts;for(;this._currentTileIndexQ.sortKey-re.sortKey));this._currentPartIndex{const Q=i.o.now()-z;return!this._forceFullPlacement&&Q>2};for(;this._currentPlacementIndex>=0;){const Q=x[h[this._currentPlacementIndex]],re=this.placement.collisionIndex.transform.zoom;if(Q.type==="symbol"&&Q.visibility!=="none"&&(!Q.minzoom||Q.minzoom<=re)&&(!Q.maxzoom||Q.maxzoom>re)){const oe=Q,ge=oe.layout.get("symbol-z-elevate"),me=oe.layout.get("symbol-sort-key").constantOr(1)!==void 0,xe=oe.layout.get("symbol-z-order"),Pe=xe==="viewport-y"||xe==="auto"&&!(xe!=="viewport-y"&&me),Me=oe.layout.get("text-allow-overlap")||oe.layout.get("icon-allow-overlap")||oe.layout.get("text-ignore-placement")||oe.layout.get("icon-ignore-placement"),He=Pe&&Me,Be=this._inProgressLayer=this._inProgressLayer||new mv(oe),et=i.B(Q.source,Q.scope);if(Be.continuePlacement(ge||He?D[et]:T[et],this.placement,this._showCollisionBoxes,Q,H,F))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(h){return this.placement.commit(h),this.placement}}const am=512/i.al/2;class zf{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,F=h.canonical.y*i.al;for(let z=0;zHe-Be);for(const He of Me){const Be=this.crossTileIDs[He];if(this.keys[He]===oe&&!T.has(Be)){T.add(Be),re.crossTileID=Be;break}}}}}class Hl{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ZM{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],F={};for(const z in D){const H=D[z];H.tileID=H.tileID.unwrapTo(H.tileID.wrap+x),F[H.tileID.key]=H}this.indexes[T]=F}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 F=0;Fh.overscaledZ)for(const H in z){const Q=z[H];Q.tileID.isChildOf(h)&&Q.findMatches(x.symbolInstances,h,D)}else{const H=z[h.scaledTo(Number(F)).key];H&&H.findMatches(x.symbolInstances,h,D)}}for(let F=0;F{x[T]=!0});for(const T in this.layerIndexes)x[T]||delete this.layerIndexes[T]}}const Mp=771;class Dn{constructor(h,x,T,D){this.blendFunction=h,this.blendColor=x.toNonPremultipliedRenderColor(null),this.mask=T,this.blendEquation=D}}Dn.Replace=[1,0,1,0],Dn.disabled=new Dn(Dn.Replace,i.ao.transparent,[!1,!1,!1,!1]),Dn.unblended=new Dn(Dn.Replace,i.ao.transparent,[!0,!0,!0,!0]),Dn.alphaBlended=new Dn([1,Mp,1,Mp],i.ao.transparent,[!0,!0,!0,!0]),Dn.alphaBlendedNonPremultiplied=new Dn([770,Mp,770,Mp],i.ao.transparent,[!0,!0,!0,!0]),Dn.multiply=new Dn([774,0,774,0],i.ao.transparent,[!0,!0,!0,!0]),Dn.additive=new Dn([1,1,1,1],i.ao.transparent,[!0,!0,!0,!0]);class Ir{constructor(h,x,T){this.func=h,this.mask=x,this.range=T}}Ir.ReadOnly=!1,Ir.ReadWrite=!0,Ir.disabled=new Ir(519,Ir.ReadOnly,[0,1]);const yS=7680;class dn{constructor(h,x,T,D,F,z){this.test=h,this.ref=x,this.mask=T,this.fail=D,this.depthFail=F,this.pass=z}}dn.disabled=new dn({func:519,mask:0},0,0,yS,yS,yS);const pv=1029,vS=2305;class rn{constructor(h,x,T){this.enable=h,this.mode=x,this.frontFace=T}}function Tp(M,h){const x=i.ca(M,3);i.cc(M,h),i.cg(M,3,x)}function YM(M,h){const x=i.c7([]);return i.c8(x,x,-h),i.c9(x,x,-M),x}function _S(M,h){const x=[M[0],M[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,M);if(i.c6(D)<1e-15)return null;const F=Math.atan2(-D[1],D[0]);return YM(Math.atan2(Math.sqrt(M[0]*M[0]+M[1]*M[1]),-M[2]),F)}rn.disabled=new rn(!1,pv,vS),rn.backCCW=new rn(!0,pv,vS),rn.backCW=new rn(!0,pv,2304),rn.frontCW=new rn(!0,1028,2304),rn.frontCCW=new rn(!0,1028,vS);class eu{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,F=T||(this._elevation?this._elevation.getAtPointOrZero(i.ae.fromLngLat(h)):0),z=i.ae.fromLngLat(h,F),H=[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=_S(H,x)}setPitchBearing(h,x){this.orientation=YM(i.an(h),i.an(-x))}}class bS{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=YM(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 F=new Float64Array(16);return i.bq(F,[T,T,T]),i.br(F,F,D),F[10]*=x,F}getWorldToCamera(h,x){const T=new Float64Array(16),D=new Float64Array(4),F=this.position;return i.cb(D,this._orientation),i.c5(F,F,-h),i.cc(T,D),i.br(T,T,F),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 F=new Float64Array(16);return i.cd(F,h,x,T,D),F}getCameraToClipOrthographic(h,x,T,D,F,z){const H=new Float64Array(16);return i.ce(H,h,x,T,D,F,z),H}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 bS([...this.position],[...this.orientation])}}const vc={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class wS{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 wS(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Hm=15;class XM{constructor(h,x,T,D,F,z,H){this.tileSize=512,this._renderWorldCopies=F===void 0||F,this._minZoom=h||0,this._maxZoom=x||22,this._minPitch=T??0,this._maxPitch=D??60,this.setProjection(z),this.setMaxBounds(H),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 wS,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new bS,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 XM(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,F=0;for(let z=0;z{const He=i.cY(me,ge,xe,Pe,Me);Q.has(He)||(F.push(new i.aQ(ge,me,xe,Pe,Me)),Q.add(He))};for(let ge=0;geme.canonical.z)continue;const xe=me.canonical,Pe=me.overscaledZ,Me=me.wrap,He=1<0,ut=xe.y+10,Mt=me.wrap-(et?0:1),_t=me.wrap+(Be?0:1),kt=et?xe.x-1:He-1,xt=Be?xe.x+1:0;if(z)T[0]<0?(re(Pe,_t,xe.z,xt,xe.y),T[1]<0&&ut&&(re(Pe,Me,xe.z,xe.x,xe.y+1),re(Pe,_t,xe.z,xt,xe.y+1)),T[1]>0&&tt&&(re(Pe,Me,xe.z,xe.x,xe.y-1),re(Pe,_t,xe.z,xt,xe.y-1))):T[0]>0?(re(Pe,Mt,xe.z,kt,xe.y),T[1]<0&&ut&&(re(Pe,Me,xe.z,xe.x,xe.y+1),re(Pe,Mt,xe.z,kt,xe.y+1)),T[1]>0&&tt&&(re(Pe,Me,xe.z,xe.x,xe.y-1),re(Pe,Mt,xe.z,kt,xe.y-1))):T[1]<0&&ut?re(Pe,Me,xe.z,xe.x,xe.y+1):tt&&re(Pe,Me,xe.z,xe.x,xe.y-1);else{const pt=me.visibleQuadrants;1&pt&&(re(Pe,Mt,xe.z,kt,xe.y),tt&&(re(Pe,Me,xe.z,xe.x,xe.y-1),re(Pe,Mt,xe.z,kt,xe.y-1))),2&pt&&(re(Pe,_t,xe.z,xt,xe.y),tt&&(re(Pe,Me,xe.z,xe.x,xe.y-1),re(Pe,_t,xe.z,xt,xe.y-1))),4&pt&&(re(Pe,Mt,xe.z,kt,xe.y),ut&&(re(Pe,Me,xe.z,xe.x,xe.y+1),re(Pe,Mt,xe.z,kt,xe.y+1))),8&pt&&(re(Pe,_t,xe.z,xt,xe.y),ut&&(re(Pe,Me,xe.z,xe.x,xe.y+1),re(Pe,_t,xe.z,xt,xe.y+1)))}}const oe=[];for(const ge of F)F.some(me=>ge.isChildOf(me))||oe.push(ge);if(F=oe.filter(ge=>!h.some(me=>!!(ge.overscaledZ{const Be=He.canonical.x+.5-xe[0],et=He.canonical.y+.5-xe[1];return Be*Be+et*et{const kt=i.cY(ut,et,tt,Mt,_t);F.has(kt)||(D.push(new i.aQ(et,ut,tt,Mt,_t)),F.add(kt))},H=h.reduce((et,ut)=>Math.max(et,ut.overscaledZ),T),Q=1<{const tt=Math.floor(et[0]),Mt=Math.floor(et[1]),_t=(et[0]-tt)*i.al,kt=(et[1]-Mt)*i.al,xt=Math.floor(ut[0]),pt=Math.floor(ut[1]),Et=(ut[0]-xt)*i.al,Ht=(ut[1]-pt)*i.al;for(let Vt=-1;Vt<=1;Vt++){const ts=tt+Vt;if(!(ts<0||ts>=Q)){oe.x=_t-Vt*i.al,ge.x=Et-(ts-xt)*i.al;for(let ss=-1;ss<=1;ss++){const fs=Mt+ss;oe.y=kt-ss*i.al,ge.y=Ht-(fs-pt)*i.al,i.cZ(oe,ge,re)&&z(H,0,T,ts,fs)}}}},xe=x.points,Pe=xe[i.cv],Me=xe[i.cw],He=this._projectToGround(Pe,xe[i.cx]),Be=this._projectToGround(Me,xe[i.cy]);return me(Pe,He),me(Me,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(),F=D&&!h.isTerrainDEM,z=this.projection.name==="mercator";if(h.minzoom!==void 0&&xh.maxzoom&&(x=h.maxzoom);const H=this.locationCoordinate(this.center),Q=this.center.lat,re=1<{const Jt=new i.ae(Ft.x+25e-6,Ft.y,Ft.z),Es=new i.ae(Ft.x,Ft.y+25e-6,Ft.z),Qs=Ft.toLngLat(),mr=Jt.toLngLat(),Ks=Es.toLngLat(),$s=this.locationCoordinate(Qs),Sr=this.locationCoordinate(mr),jr=this.locationCoordinate(Ks),lr=Math.hypot(Sr.x-$s.x,Sr.y-$s.y),fr=Math.hypot(jr.x-$s.x,jr.y-$s.y);return Math.sqrt(lr*fr)*kt/25e-6},pt=Ft=>{const ds=Mt,Jt=_t;return{aabb:i.cF(this,re,0,0,0,Ft,Jt,ds,this.projection),zoom:0,x:0,y:0,minZ:Jt,maxZ:ds,wrap:Ft,fullyVisible:!1}},Et=[];let Ht=[];const Vt=x,ts=h.reparseOverscaled?T:x,ss=(He-this._centerAltitude)*Me,fs=Ft=>{if(!this._elevation||!Ft.tileID||!z)return;const ds=this._elevation.getMinMaxForTile(Ft.tileID),Jt=Ft.aabb;ds?(Jt.min[2]=ds.min,Jt.max[2]=ds.max,Jt.center[2]=(Jt.min[2]+Jt.max[2])/2):(Ft.shouldSplit=Yt(Ft),Ft.shouldSplit||(Jt.min[2]=Jt.max[2]=Jt.center[2]=this._centerAltitude))},Bs=(Ft,ds)=>{if(.707*ds{if(Ft.zoom=.9)return!0}else if(F&&(Es=Ft.aabb.distanceZ(Be)*Me),this.projection.isReprojectedInTileSpace&&T<=5){const fr=Math.pow(2,Ft.zoom),Vr=xt(new i.ae((Ft.x+.5)/fr,(Ft.y+.5)/fr));Qs=Vr>.85?1:Vr}if(!z&&!ge){const fr=Math.sqrt(ds*ds+Jt*Jt+Es*Es);let Vr=(1<0;){const Ft=Et.pop(),ds=Ft.x,Jt=Ft.y;let Es=Ft.fullyVisible;const Qs=()=>this.projection.name==="globe"&&(Ft.y===0||Ft.y===(1<>1),Sr={aabb:z?Ft.aabb.quadrant(mr):i.cF(this,re,Ft.zoom+1,Ks,$s,Ft.wrap,Ft.minZ,Ft.maxZ,this.projection),zoom:Ft.zoom+1,x:Ks,y:$s,wrap:Ft.wrap,fullyVisible:Es,tileID:void 0,shouldSplit:void 0,minZ:Ft.minZ,maxZ:Ft.maxZ};F&&!ge&&(Sr.tileID=new i.aQ(Ft.zoom+1===Vt?ts:Ft.zoom+1,Ft.wrap,Ft.zoom+1,Ks,$s),fs(Sr)),Et.push(Sr)}else{const mr=Ft.zoom===Vt?ts:Ft.zoom;if(h.minzoom&&h.minzoom>mr)continue;let Ks=0;if(!Es){let lr=et?Ft.aabb.intersectsPrecise(xe):Ft.aabb.intersectsPreciseFlat(xe);if(lr===0&&Qs()){const fr=new i.cD(Ft.zoom,ds,Jt);lr=i.cE(this,re,fr,!0).intersectsPrecise(xe)}if(lr===0)continue;if(h.calculateQuadrantVisibility)if(xe.containsPoint(Ft.aabb.center))Ks=15;else for(let fr=0;fr<4;fr++)Ft.aabb.quadrant(fr).intersects(xe)!==0&&(Ks|=1<{const Es=[0,0,0,1],Qs=[i.al,i.al,0,1],mr=this.calculateFogTileMatrix(Jt.tileID.toUnwrapped());i.aC(Es,Es,mr),i.aC(Qs,Qs,mr);const Ks=i.cG([],Es,Qs),$s=i.cH([],Es,Qs),Sr=i.c$(Ks,$s);if(Sr===0)return!0;let jr=!1;const lr=this._elevation;if(lr&&Sr>Ft&&ds!==0){const fr=this.calculateProjMatrix(Jt.tileID.toUnwrapped());let Vr;h.isTerrainDEM||(Vr=lr.getMinMaxForTile(Jt.tileID)),Vr||(Vr={min:_t,max:Mt});const jn=i.cI(this.rotation),ma=[jn[0]*i.al,jn[1]*i.al,Vr.max];i.af(ma,ma,fr),jr=(1-ma[1])*this.height*.5Ft.distanceSq-ds.distanceSq).map(Ft=>Ft.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 F=this.centerPoint;if(this.projection.name==="globe"){const H=this.worldSize;T=(x.x-F.x)/H,D=(x.y-F.y)/H}else{const H=this.pointCoordinate(x),Q=this.pointCoordinate(F);T=H.x-Q.x,D=H.y-Q.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],F=[h.x,h.y,1,1];i.aC(D,D,this.pixelMatrixInverse),i.aC(F,F,this.pixelMatrixInverse);const z=F[3];i.cK(D,D,1/D[3]),i.cK(F,F,1/z);const H=D[2],Q=F[2];return{p0:D,p1:F,t:H===Q?0:(T-H)/(Q-H)}}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,F=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(F,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,F=this.horizonLineFromTop();if(h.y>F)return this.pointCoordinate(h,x);const z=.02*F,H=h.clone();for(let Q=0;Q<10&&F-D>z;Q++){H.y=i.ak(D,F,.66);const re=this.projection.pointCoordinate3D(this,H.x,H.y);re?(F=H.y,T=re):D=H.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,F=this.pointLocation3D(new i.P(x,h)),z=this.pointLocation3D(new i.P(D,h)),H=this.pointLocation3D(new i.P(D,T)),Q=this.pointLocation3D(new i.P(x,T));let re=Math.min(F.lng,z.lng,H.lng,Q.lng),oe=Math.max(F.lng,z.lng,H.lng,Q.lng),ge=Math.min(F.lat,z.lat,H.lat,Q.lat),me=Math.max(F.lat,z.lat,H.lat,Q.lat);const xe=Math.pow(2,-this.zoom)/16*270,Pe=this.projection.name==="globe"?1:4,Me=(He,Be,et,ut,tt)=>{const Mt=(He+et)/2,_t=(Be+ut)/2,kt=new i.P(Mt,_t),{lng:xt,lat:pt}=this.pointLocation3D(kt),Et=Math.max(0,re-xt,ge-pt,xt-oe,pt-me);re=Math.min(re,xt),oe=Math.max(oe,xt),ge=Math.min(ge,pt),me=Math.max(me,pt),(ttxe)&&(Me(He,Be,Mt,_t,tt+1),Me(Mt,_t,et,ut,tt+1))};if(Me(x,h,D,h,1),Me(D,h,D,T,1),Me(D,T,x,T,1),Me(x,T,x,h,1),this.projection.name==="globe"){const[He,Be]=i.cM(this);He?(me=90,oe=180,re=-180):Be&&(ge=-90,oe=180,re=-180)}return new i.aI(new i.aT(re,ge),new i.aT(oe,me))}_getBoundsRectangular(h,x){const{top:T,left:D}=this._edgeInsets,F=this.height-this._edgeInsets.bottom,z=this.width-this._edgeInsets.right,H=new i.P(D,T),Q=new i.P(z,T),re=new i.P(z,F),oe=new i.P(D,F);let ge=this.pointCoordinate(H,h),me=this.pointCoordinate(Q,h);const xe=this.pointCoordinate(re,x),Pe=this.pointCoordinate(oe,x),Me=(He,Be)=>(Be.y-He.y)/(Be.x-He.x);return ge.y>1&&me.y>=0?ge=new i.ae((1-Pe.y)/Me(Pe,ge)+Pe.x,1):ge.y<0&&me.y<=1&&(ge=new i.ae(-Pe.y/Me(Pe,ge)+Pe.x,0)),me.y>1&&ge.y>=0?me=new i.ae((1-xe.y)/Me(xe,me)+xe.x,1):me.y<0&&ge.y<=1&&(me=new i.ae(-xe.y/Me(xe,me)+xe.x,0)),new i.aI().extend(this.coordinateLocation(ge)).extend(this.coordinateLocation(me)).extend(this.coordinateLocation(Pe)).extend(this.coordinateLocation(xe))}_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 F=D.dem.tree;T.min=Math.min(T.min,F.minimums[0]),T.max=Math.max(T.max,F.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.maxLngge&&(H=ge-re),ge-oexe&&(z=xe-Q),xe-me{for(let Yt=0;Yt<16;Yt++)ts[Yt]=i.ak(ss[Yt],fs[Yt],Bs)})(H,H,Q,i.d0(this.pitch>=Hm?1:this.pitch/Hm))}else H=Q;const re=i.cP([],Q,z);let oe=i.cP([],H,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(oe,oe,Et),i.aB(re,re,Et),this.inverseAdjustmentMatrix=i.cR(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=i.cS([],oe,[this.worldSize,this.worldSize,this.worldSize/F,1]),this.projMatrix=oe,this.invProjMatrix=i.bl(new Float64Array(16),this.projMatrix),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 ge=i.bl([],H);this.frustumCorners=i.cT.fromInvProjectionMatrix(ge,this.horizonLineFromTop(),this.height),this.cameraFrustum=i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!x);const me=new Float32Array(16);i.bA(me),i.cS(me,me,[1,-1,1]),i.cU(me,me,this._pitch),i.bB(me,me,this.angle);const xe=i.cd(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=i.bz(xe);const Pe=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;xe[8]=2*-h.x/this.width,xe[9]=2*(h.y+Pe)/this.height,this.skyboxMatrix=i.aB(me,xe,me);const Me=this.point,He=Me.x,Be=Me.y,et=this.width%2/2,ut=this.height%2/2,tt=Math.cos(this.angle),Mt=Math.sin(this.angle),_t=He-Math.round(He)+tt*et+Mt*ut,kt=Be-Math.round(Be)+tt*ut+Mt*et,xt=new Float64Array(oe);if(i.br(xt,xt,[_t>.5?_t-1:_t,kt>.5?kt-1:kt,0]),this.alignedProjMatrix=xt,oe=i.bC(),i.cS(oe,oe,[this.width/2,-this.height/2,1]),i.br(oe,oe,[1,-1,0]),this.labelPlaneMatrix=oe,oe=i.bC(),i.cS(oe,oe,[1,-1,1]),i.br(oe,oe,[-1,-1,0]),i.cS(oe,oe,[2/this.width,2/this.height,1]),this.glCoordMatrix=oe,this.pixelMatrix=i.aB(new Float64Array(16),this.labelPlaneMatrix,re),this._calcFogMatrices(),this._distanceTileDataCache={},oe=i.bl(new Float64Array(16),this.pixelMatrix),!oe)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=oe,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=i.cV(this);const 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=oe;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,F=[h,h,x];i.c5(F,F,D),i.c5(T,T,-1),i.cW(T,T,F);const z=i.bC();i.br(z,z,T),i.cS(z,z,F),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,F=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*x-h/this.worldSize*this._centerAltitude;return[D.x/this.worldSize-T[0]*F,D.y/this.worldSize-T[1]*F,h/this.worldSize*this._centerAltitude-T[2]*F]}_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 F=1;this.projection.wrap&&(this.center=this.center.wrap()),D>0&&(F=Math.min((x-T)/D,1)),this._camera.position=i.bH([],this._camera.position,h,F),this._updateStateFromCamera()}_updateStateFromCamera(){const h=this._camera.position,x=this._camera.forward(),{pitch:T,bearing:D}=this._camera.getPitchBearing(),F=i.cf(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,z=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.an(this._maxPitch)),H=Math.max((h[2]-F)/Math.cos(T),z),Q=this._zoomFromMercatorZ(H);i.bH(h,h,x,H),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(Q,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new i.ae(h[0],h[1],h[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(h){return Math.pow(2,h)*this.tileSize}_mercatorZfromZoom(h){return this.cameraToCenterDistance/this._worldSizeFromZoom(h)}_minimumHeightOverTerrain(){const h=Math.min(this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(h)}_zoomFromMercatorZ(h){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,h)*this.tileSize))}zoomFromMercatorZAdjusted(h){let x=0,T=i.cL,D=0,F=1/0;for(;T-x>1e-6&&T>x;){const z=x+.5*(T-x),H=this.tileSize*Math.pow(2,z),Q=this.getCameraToCenterDistance(this.projection,z,H),re=this.scaleZoom(Q/(Math.max(0,h)*this.tileSize)),oe=Math.abs(z-re);oere||me.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],F){const z=[x,T,D,1];i.aC(z,z,F);const H=z[3]=Math.max(z[3],1e-6);return z[0]/=H,z[1]/=H,z[2]/=H,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),F=h.pixelSpaceConversion(this.center.lat,T,D);let z=.5/Math.tan(.5*this._fov)*this.height*F;return this.isOrthographic&&(z=i.ak(1,z,i.d0(this.pitch>=Hm?1:this.pitch/Hm))),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 nx=(M,h)=>{if(h>0&&M.terrain&&i.w("Cutoff is currently disabled on terrain"),h<=0||M.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const x=M.transform,T=Math.max(Math.abs(x._zoom-(M.minCutoffZoom-1)),1),D=x.isLODDisabled(!1)?i.ah(60,45,x.pitch):i.ah(30,15,x.pitch),F=x._farZ-x._nearZ,z=h*x.height,H=((1-(Q=D))*x.cameraToCenterDistance+Q*(x._farZ+z))*T;var Q;return{shouldRenderCutoff:D<1,uniformValues:{u_cutoff_params:[x._nearZ,x._farZ,(H-x._nearZ)/F,(H-z-x._nearZ)/F]}}},im=2048;class cb{constructor(h,x){this.aabb=h,this.lastCascade=x}}class Lce{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 cb(x,null)}clear(){this.receivers={}}get(h){return this.receivers[h.key]}computeRequiredCascades(h,x,T){const D=i.d9.fromPoints(h.points);let F=0;for(const z in this.receivers){const H=this.receivers[z];if(!H||!D.intersectsAabb(H.aabb))continue;H.aabb.min=D.closestPoint(H.aabb.min),H.aabb.max=D.closestPoint(H.aabb.max);const Q=H.aabb.getCorners();for(let re=0;re1||me[1]<-1||me[1]>1){oe=!1;break}}if(H.lastCascade=re,F=Math.max(F,re),oe)break}}return F+1}}class fv{constructor(h){this.painter=h,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new Lce,this._depthMode=new Ir(h.context.gl.LEQUAL,Ir.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((Pe,Me)=>{const He=T.style._mergedLayers[Me];return Pe+(He.hasShadowPass()&&!He.isHidden(h.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled))return;const F=T.context,z=im,H=im;if(this._cascades.length===0||im!==this._cascades[0].texture.size[0]){this._cascades=[];for(let Pe=0;Pe<2;++Pe){const Me=T._shadowMapDebug,He=F.gl,Be=F.createFramebuffer(z,H,Me?1:0,"texture"),et=new i.T(F,{width:z,height:H,data:null},He.DEPTH_COMPONENT16);if(Be.depthAttachment.set(et.texture),Me){const ut=new i.T(F,{width:z,height:H,data:null},He.RGBA8);Be.colorAttachment0.set(ut.texture)}this._cascades.push({framebuffer:Be,texture:et,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cB,scale:0})}}this.shadowDirection=ub(x);let Q=0;if(h.elevation){const Pe=h.elevation,Me=[1e4,-1e4];Pe.visibleDemTiles.filter(He=>He.dem).forEach(He=>{const Be=He.dem.tree;Me[0]=Math.min(Me[0],Be.minimums[0]),Me[1]=Math.max(Me[1],Be.maximums[0])}),Me[0]!==1e4&&(Q=(Me[1]-Me[0])*Pe.exaggeration())}const re=1.5*h.cameraToCenterDistance,oe=3*re,ge=new Float64Array(16);for(let Pe=0;Pe=0)return{};const F=function(Q,re,oe){const ge=oe/(1<0&&(i.d8(F[1],F[1],[D[0]*z,0,0]),i.d8(F[2],F[2],[D[0]*z,0,0])),D[1]<0?(i.d8(F[0],F[0],[0,D[1]*z,0]),i.d8(F[1],F[1],[0,D[1]*z,0])):D[1]>0&&(i.d8(F[2],F[2],[0,D[1]*z,0]),i.d8(F[3],F[3],[0,D[1]*z,0]));const H={};return H.vertices=F,H.planes=[db(F[1],F[0],F[4]),db(F[2],F[1],F[5]),db(F[3],F[2],F[6]),db(F[0],F[3],F[7])],H}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 db(M,h,x){const T=i.av([],x,h),D=i.av([],M,h),F=i.bI([],T,D),z=i.ag(F);return z===0?[0,0,1,0]:(i.c5(F,F,1/z),[F[0],F[1],F[2],-i.bJ(F,h)])}function ub(M){const h=M.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 Bf(M,h,x){const T=h.properties.get("color-use-theme")==="none",D=h.properties.get("color"),F=h.properties.get("intensity"),z=h.properties.get("direction"),H=[z.x,z.y,z.z],Q=x.properties.get("color-use-theme")==="none",re=x.properties.get("color"),oe=x.properties.get("intensity"),ge=Math.max(i.bJ([0,0,1],H),0),me=[0,0,0];i.c5(me,re.toPremultipliedRenderColor(Q?null:M.getLut(h.scope)).toArray01Linear().slice(0,3),oe);const xe=[0,0,0];return i.c5(xe,D.toPremultipliedRenderColor(T?null:M.getLut(x.scope)).toArray01Linear().slice(0,3),ge*F),i.db([me[0]>0?me[0]/(me[0]+xe[0]):0,me[1]>0?me[1]/(me[1]+xe[1]):0,me[2]>0?me[2]/(me[2]+xe[2]):0])}function ax(M,h,x,T,D,F){const z=M.zoom,H=M.scale,Q=M.worldSize,re=1/Q,oe=M.aspect,ge=Math.sqrt(1+oe*oe)*Math.tan(.5*M.fovX),me=ge*ge,xe=T-x,Pe=T+x;let Me,He;me>xe/Pe?(Me=T,He=T*ge):(Me=.5*Pe*(1+me),He=.5*Math.sqrt(xe*xe+2*(T*T+x*x)*me+Pe*Pe*me*me));const Be=M.projection.pixelsPerMeter(M.center.lat,Q),et=M._camera.getCameraToWorldMercator(),ut=[0,0,-Me*re];i.af(ut,ut,et);let tt=He*re;const Mt=M._edgeInsets;if(!(Mt.left===0&&Mt.top===0&&Mt.right===0&&Mt.bottom===0||Mt.left===Mt.right&&Mt.top===Mt.bottom)){const Es=M._camera.getWorldToCamera(M.worldSize,M.projection.zAxisUnit==="meters"?Be:1),Qs=M._camera.getCameraToClipPerspective(M._fov,M.width/M.height,x,T);Qs[8]=2*-M.centerOffset.x/M.width,Qs[9]=2*M.centerOffset.y/M.height;const mr=new Float64Array(16);i.cP(mr,Qs,Es);const Ks=new Float64Array(16);i.bl(Ks,mr);const $s=i.cB.fromInvProjectionMatrix(Ks,Q,z,!0);for(const Sr of $s.points){const jr=((_t=Sr)[0]/=H,_t[1]/=H,_t[2]=i.cf(_t[2],M._center.lat),_t);tt=Math.max(tt,i.c6(i.da([],ut,jr)))}}var _t;tt*=D/(D-1);const kt=Math.acos(h[2]),xt=Math.atan2(-h[0],-h[1]),pt=new bS;pt.position=ut,pt.setPitchBearing(kt,xt);const Et=pt.getWorldToCamera(Q,Be),Ht=tt*Q,Vt=Math.min(M._mercatorZfromZoom(17)*Q*-2,-2*Ht),ts=pt.getCameraToClipOrthographic(-Ht,Ht,-Ht,Ht,Vt,(Ht+F*Be)/h[2]),ss=new Float64Array(16);i.aB(ss,ts,Et);const fs=i.d5(Math.floor(1e6*ut[0])/1e6*Q,Math.floor(1e6*ut[1])/1e6*Q,0),Bs=.5*D,Yt=[0,0,0];i.af(Yt,fs,ss),i.c5(Yt,Yt,Bs);const Ft=[Math.floor(Yt[0]),Math.floor(Yt[1]),Math.floor(Yt[2])],ds=[0,0,0];i.av(ds,Yt,Ft),i.c5(ds,ds,-1/Bs);const Jt=new Float64Array(16);return i.bA(Jt),i.br(Jt,Jt,ds),i.aB(ss,Jt,ss),[ss,Ht]}class Dce 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),F=new i.de(h,x,void 0,void 0,D);return F.computeBoundsAndApplyParent(),F}).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),F=[],z=[];for(const H of D){const Q=h[H];this.hasURLBeenRequested(Q)&&!T.forceReload||(this.modelByURL[Q]={modelId:H,scope:x},F.push(this.loadModel(H,Q)),z.push(H)),this.models[x][H]||(this.models[x][H]={model:null,numReferences:1})}this.numModelsLoading[x]=(this.numModelsLoading[x]||0)+z.length,Promise.allSettled(F).then(H=>{for(let Q=0;Q{this.fire(new i.y(new Error(`Could not load models: ${H.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:F,modelId:z}=this.modelByURL[D];this.models[F][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 F=this.modelUris[x][h];T||delete this.modelUris[x][h],delete this.modelByURL[F];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 QM=i.a6.colorTheme,Oce=new i.a9({data:new i.aa(QM.data)});function iD(M){if(!M.metadata||!M.metadata.content_area)return;const h=i.o.devicePixelRatio,{left:x,top:T,width:D,height:F}=M.metadata.content_area,z=x*h,H=T*h;return[z,H,z+D*h,H+F*h]}function oD(M){if(M)return M.map(([h,x])=>[h*i.o.devicePixelRatio,x*i.o.devicePixelRatio])}class JM{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 Xc))return h;const D=x.map(z=>this.sourceCache.getTile(z)),F=T.getImages(D,Array.from(this.pendingRequests));for(const[z,H]of F)h.set(i.I.from({name:z,iconsetId:this.id}),H),this.pendingRequests.delete(z);for(const z of this.pendingRequests)this.missingRequests.add(z);return this.pendingRequests.clear(),h}}const ix=(M,h)=>st(M,h&&h.filter(x=>x.identifier!=="source.canvas")),lD=i.aH(wa,["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"]),cD=i.aH(wa,["setCenter","setZoom","setBearing","setPitch"]),jS=new Set(["background","sky","slot","custom"]),ox={version:8,layers:[],sources:{}},hb={duration:300,delay:0};class om 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({},hb),this._buildingIndex=new sb(this),this.crossTileSymbolIndex=new Vm,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 Ne,this._hasDataDrivenEmissive=!1,this.dispatcher=x.dispatcher?x.dispatcher:new i.D(i.dh(),this),x.imageManager?this.imageManager=x.imageManager:(this.imageManager=new qe(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 Dce(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=om.registerForPluginStateChange(D=>{T.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:D.pluginStatus,pluginURL:D.pluginURL},(F,z)=>{if(i.dl(F),z&&z.every(H=>H))for(const H in T._sourceCaches){const Q=T._sourceCaches[H],re=Q.getSource().type;re!=="vector"&&re!=="geojson"||Q.reload()}})}),this.on("data",D=>{if(D.dataType!=="source"||D.sourceDataType!=="metadata")return;const F=this.getOwnSource(D.sourceId);if(F&&F.vectorLayerIds)for(const z in this._layers){const H=this._layers[z];H.source===F.id&&this._validateLayer(H)}})}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=(F,z)=>{try{z(null,this.setState(F,T))}catch(H){z(H,!1)}};if(typeof h=="string"){const F=this.map._requestManager.normalizeStyleURL(h),z=this.map._requestManager.transformRequest(F,i.R.Style);i.m(z,(H,Q)=>{H?this.fire(new i.y(H)):Q&&D(Q,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 F=this.map._requestManager.transformRequest(h,i.R.Style);this._request=i.m(F,(z,H)=>{if(this._request=null,z)this.fire(new i.y(z));else if(H)return this.importsCache.set(h,H),this._load(H,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(ox,!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 F of h){const z=this._createFragmentStyle(F),H=new Promise(oe=>{z.once("style.import.load",oe),z.once("error",oe)}).then(()=>this.mergeAll());if(D.push(H),this.resolvedImports.has(F.url)){z.loadEmpty();continue}const Q=F.data||this.importsCache.get(F.url);Q?(z.loadJSON(Q,{validate:x}),this._isInternalStyle(Q)&&(z.globalId=null)):F.url?z.loadURL(F.url,{validate:x}):z.loadEmpty();const re={style:z,id:F.id,config:F.config};if(T){const oe=this.fragments.findIndex(({id:ge})=>ge===T);this.fragments=this.fragments.slice(0,oe).concat(re).concat(this.fragments.slice(oe))}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 F=new om(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 F.setEventedParent(this.map,{style:F}),F}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle()}_isInternalStyle(h){return this.isRootStyle()&&(h.fragment||!!h.schema&&h.fragment!==!1)}_load(h,x){if(this._isInternalStyle(h)){const F=Object.assign({},ox,{imports:[{id:"basemap",data:h,url:""}]},h.center?{center:h.center}:{},h.bearing?{bearing:h.bearing}:{},h.pitch?{pitch:h.pitch}:{},h.zoom?{zoom:h.zoom}:{},h.light?{light:h.light}:{});return this._importedAsBasemap=!0,void this._load(F,x)}if(this.updateConfig(this._config,h.schema),x&&ix(this,Kt(h)))return;this._loaded=!0,this.stylesheet=i.dp(h);const T=()=>{for(const Q in h.sources)this.addSource(Q,h.sources[Q],{validate:!1,isInitialLoad:!0});if(h.iconsets)for(const Q in h.iconsets)this.addIconset(Q,h.iconsets[Q]);h.sprite?this._loadIconset(h.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&h.glyphs&&this.glyphManager.setURL(h.glyphs);const F=_y(this.stylesheet.layers);if(this._order=F.map(Q=>Q.id),this.stylesheet.light&&i.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(this.stylesheet.lights.length===1&&this.stylesheet.lights[0].type==="flat"){const Q=this.stylesheet.lights[0];this.light=new Bt(Q.properties,Q.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Bt(this.stylesheet.light)),this._layers={};for(const Q of F){const re=i.du(Q,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 oe=this.getOwnLayerSourceCache(re),ge=!!this.directionalLight&&this.directionalLight.shadowsEnabled();oe&&re.canCastShadows()&&ge&&(oe.castsShadows=!0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const z=this.stylesheet.terrain;z&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(z,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new i.z("data",{dataType:"style"}));const H=this.isRootStyle();h.imports?this._loadImports(h.imports,x).then(()=>{this._reloadImports(),this.fire(new i.z(H?"style.load":"style.import.load"))}).catch(Q=>{this.fire(new i.y(new Error("Failed to load imports",Q))),this.fire(new i.z(H?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new i.z(H?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const D=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(D){const F=this._evaluateColorThemeData(D);this._loadColorTheme(F).then(()=>{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,F,z,H,Q,re,oe;const ge={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(me=>{if(me.stylesheet){if(me.light!=null&&(h=me.light),me.stylesheet.lights)for(const xe of me.stylesheet.lights)xe.type==="ambient"&&me.ambientLight!=null&&(x=me.ambientLight),xe.type==="directional"&&me.directionalLight!=null&&(T=me.directionalLight);D=this._prioritizeTerrain(D,me.terrain,me.stylesheet.terrain),me.stylesheet.fog&&me.fog!=null&&(F=me.fog),me.stylesheet.snow&&me.snow!=null&&(z=me.snow),me.stylesheet.rain&&me.rain!=null&&(H=me.rain),me.stylesheet.camera!=null&&(oe=me.stylesheet.camera),me.stylesheet.projection!=null&&(Q=me.stylesheet.projection),me.stylesheet.transition!=null&&(re=me.stylesheet.transition),ge[me.scope]=me._styleColorTheme}}),this.light=h,this.ambientLight=x,this.directionalLight=T,this.fog=F,this.snow=z,this.rain=H,this._styleColorThemeForScope=ge,D===null?delete this.terrain:this.terrain=D,this.camera=oe||{"camera-projection":"perspective"},this.projection=Q||{name:"mercator"},this.transition=Object.assign({},hb,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 F in D._sourceCaches){const z=i.B(F,D.scope);h[z]=D._sourceCaches[F]}for(const F in D._otherSourceCaches){const z=i.B(F,D.scope);x[z]=D._otherSourceCaches[F]}for(const F in D._symbolSourceCaches){const z=i.B(F,D.scope);T[z]=D._symbolSourceCaches[F]}}),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 H of z._order){const Q=z._layers[H];if(Q.type==="slot"){const re=i.dq(H);if(h[re])continue;h[re]=[]}Q.slot&&h[Q.slot]?h[Q.slot].push(Q):x.push(Q)}}),this._mergedOrder=[];let D=-1;const F=(z=[])=>{for(const H of z)if(H.type==="slot"){const Q=i.dq(H.id);h[Q]&&F(h[Q]),this._mergedSlots.push(Q)}else{const Q=i.B(H.id,H.scope);this._mergedOrder.push(Q),T[Q]=H,H.is3D(!!this.terrain)&&(this._has3DLayers=!0,D=this._mergedOrder.length-1),H.type==="circle"&&(this._hasCircleLayers=!0),H.type==="symbol"&&(this._hasSymbolLayers=!0),H.type==="clip"&&(this._clipLayerPresent=!0)}};if(F(x),this._has3DLayers){const z={};for(let H=0;Hz[H]-z[Q])}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,F){const z=Object.assign({},T);for(const Q of Object.keys(QM))z[Q]===void 0&&(z[Q]=QM[Q].default);const H=new i.a8(Oce,x,new Map(D));return H.setTransitionOrValue(z,D),H.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 F="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(F)||(z=F+z);const H=i.I.from("mapbox-reserved-lut"),Q=new Image;Q.src=z,Q.onerror=()=>{this._styleColorTheme.lutLoading=!1,D(new Error("Failed to load image data"))},Q.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==x)return void T();this._styleColorTheme.lutLoading=!1;const{width:re,height:oe,data:ge}=i.o.getImageData(Q);if(oe>32)return void D(new Error("The height of the image must be less than or equal to 32 pixels."));if(re!==oe*oe)return void D(new Error("The width of the image must be equal to the height squared."));this.getImage(H)&&this.removeImage(H),this.addImage(H,{data:new i.q({width:re,height:oe},ge),pixelRatio:1,sdf:!1,usvg:!1,version:0});const me=this.imageManager.getImage(H,this.scope);me?(this._styleColorTheme.lut={image:me.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 F,z,H;const Q=i.o.devicePixelRatio>1?"@2x":"";let re=i.m(T.transformRequest(T.normalizeSpriteURL(x,Q,".json"),i.R.SpriteJSON),(me,xe)=>{re=null,H||(H=me,F=xe,ge())}),oe=i.n(T.transformRequest(T.normalizeSpriteURL(x,Q,".png"),i.R.SpriteImage),(me,xe)=>{oe=null,H||(H=me,z=xe,ge())});function ge(){if(H)D(H);else if(F&&z){const me=i.o.getImageData(z),xe={};for(const Pe in F){const{width:Me,height:He,x:Be,y:et,sdf:ut,pixelRatio:tt,stretchX:Mt,stretchY:_t,content:kt}=F[Pe],xt=new i.q({width:Me,height:He});i.q.copy(me,xt,{x:Be,y:et},{x:0,y:0},{width:Me,height:He},null),xe[Pe]={data:xt,pixelRatio:tt!==void 0?tt:1,sdf:ut!==void 0&&ut,stretchX:Mt,stretchY:_t,content:kt,usvg:!1,version:0}}D(null,xe)}}return{cancel(){re&&(re.cancel(),re=null),oe&&(oe.cancel(),oe=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 F in T)D.set(i.I.from(F),T[F]);this.addImages(D)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.z("data",{dataType:"style"}))})}addIconset(h,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 F=new JM(h,this.scope,T);this.imageManager.addImageProvider(F,this.scope)}removeIconset(h){this.imageManager.removeImageProvider(h,this.scope)}_loadIconset(h){if(!i.h(h)&&this.map._spriteFormat!=="icon_set"||this.map._spriteFormat==="raster")return void this._loadSprite(h);const x=this.map._spriteFormat==="auto";var T,D;this._spriteRequest=(D=(F,z)=>{if(this._spriteRequest=null,F)x?this._loadSprite(h):this.fire(new i.y(F));else if(z){const H=new Map;for(const Q in z)H.set(i.I.from(Q),z[Q]);this.addImages(H)}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),(F,z)=>{if(F)return void D(F);const H={},Q=i.dg(new i.bt(z));for(const re of Q.icons){const oe={version:1,pixelRatio:i.o.devicePixelRatio,content:iD(re),stretchX:re.metadata?oD(re.metadata.stretch_x_areas):void 0,stretchY:re.metadata?oD(re.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:re};H[re.name]=oe}D(null,H)}))}_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 F=h.getProgramIds();if(F)for(const z of F){const H=h.getDefaultProgramParams(z,x.zoom,this._styleColorTheme.lut);H&&(T.style=this,this.fog&&(T._fogVisible=!0,H.overrideFog=!0,T.getOrCreateProgram(z,H)),T._fogVisible=!1,H.overrideFog=!1,T.getOrCreateProgram(z,H),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(H.overrideRtt=!0,T.getOrCreateProgram(z,H)))}}}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 H=this._changes.getLayerUpdatesByScope();for(const Q in H){const{updatedIds:re,removedIds:oe}=H[Q];(re||oe)&&(this._updateWorkerLayers(Q,re,oe),D=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(h),this.light&&this.light.updateTransitions(h),this.ambientLight&&this.ambientLight.updateTransitions(h),this.directionalLight&&this.directionalLight.updateTransitions(h),this.fog&&this.fog.updateTransitions(h),this.snow&&this.snow.updateTransitions(h),this.rain&&this.rain.updateTransitions(h),this._changes.reset()}const F={};for(const H in this._mergedSourceCaches){const Q=this._mergedSourceCaches[H];F[H]=Q.used,Q.used=!1,Q.tileCoverLift=0}for(const H of this._mergedOrder){const Q=this._mergedLayers[H];if(Q.visibility!=="none"&&Q.recalculate(h,this._availableImages),!Q.isHidden(h.zoom)){const re=this.getLayerSourceCache(Q);re&&(re.used=!0,re.tileCoverLift=Math.max(re.tileCoverLift,Q.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(Q,h)}):this.precompilePrograms(Q,h))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&D&&this.mergeLayers();const z=this.imageManager.getPendingImageProviders();for(const H of z)H.sourceCache.used=!0;for(const H in F){const Q=this._mergedSourceCaches[H];F[H]!==Q.used&&Q.getSource().fire(new i.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:Q.getSource().id}))}this.light&&this.light.recalculate(h),this.terrain&&this.terrain.recalculate(h),this.fog&&this.fog.recalculate(h),this.snow&&this.snow.recalculate(h),this.rain&&this.rain.recalculate(h),this.z=h.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),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(),ix(this,Kt(h)))return!1;(h=i.dp(h)).layers=_y(h.layers);const T=function(z,H){if(!z)return[{command:wa.setStyle,args:[H]}];let Q=[];try{if(!i.by(z.version,H.version))return[{command:wa.setStyle,args:[H]}];if(i.by(z.center,H.center)||Q.push({command:wa.setCenter,args:[H.center]}),i.by(z.zoom,H.zoom)||Q.push({command:wa.setZoom,args:[H.zoom]}),i.by(z.bearing,H.bearing)||Q.push({command:wa.setBearing,args:[H.bearing]}),i.by(z.pitch,H.pitch)||Q.push({command:wa.setPitch,args:[H.pitch]}),i.by(z.sprite,H.sprite)||Q.push({command:wa.setSprite,args:[H.sprite]}),i.by(z.glyphs,H.glyphs)||Q.push({command:wa.setGlyphs,args:[H.glyphs]}),i.by(z.imports,H.imports)||function(xe=[],Pe=[],Me){Pe=Pe||[];const He=(xe=xe||[]).map(by),Be=Pe.map(by),et=xe.reduce(wy,{}),ut=Pe.reduce(wy,{}),tt=He.slice();let Mt,_t,kt,xt;for(Mt=0,_t=0;Mt{xe.source&&re[xe.source]?Q.push({command:wa.removeLayer,args:[xe.id]}):ge.push(xe)});let me=z.terrain;me&&re[me.source]&&(Q.push({command:wa.setTerrain,args:[void 0]}),me=void 0),Q=Q.concat(oe),i.by(me,H.terrain)||Q.push({command:wa.setTerrain,args:[H.terrain]}),function(xe,Pe,Me){Pe=Pe||[];const He=(xe=xe||[]).map(by),Be=Pe.map(by),et=xe.reduce(wy,{}),ut=Pe.reduce(wy,{}),tt=He.slice(),Mt=Object.create(null);let _t,kt,xt,pt,Et,Ht,Vt;for(_t=0,kt=0;_t!(z.command in cD));if(T.length===0)return!1;const D=T.filter(z=>!(z.command in lD));if(D.length>0)throw new Error(`Unimplemented: ${D.map(z=>z.command).join(", ")}.`);const F=[];return T.forEach(z=>{F.push(this[z.command](...z.args))}),x&&Promise.all(F).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($r,`sources.${h}`,x,null,T))return;this.map&&this.map._collectResourceTiming&&(x.collectResourceTiming=!0);const D=_l(h,x,this.dispatcher,this);D.scope=this.scope,D.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(D.id),source:D.serialize(),sourceId:D.id}));const F=z=>{const H=(z?"symbol:":"other:")+D.id,Q=i.B(H,this.scope),re=this._sourceCaches[H]=new hl(Q,D,z);(z?this._symbolSourceCaches:this._otherSourceCaches)[D.id]=re,re.onAdd(this.map)};F(!1),x.type!=="vector"&&x.type!=="geojson"||F(!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(([F,z])=>z.type==="source"&&z.source===h);if(D)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while iconset "${D[0]}" is using it.`)))}const T=this.getOwnSourceCaches(h);for(const D of T){const F=i.dq(D.id);delete this._sourceCaches[F],this._changes.discardSourceCacheUpdate(D.id),D.fire(new i.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:D.getSource().id})),D.setEventedParent(null),D.clearTiles()}return delete this._otherSourceCaches[h],delete this._symbolSourceCaches[h],this.mergeSources(),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 F=T[D];if(F.state!=="loaded"&&F.state!=="errored")return!1}}return!0}setLights(h){if(this._checkLoaded(),!h)return delete this.ambientLight,void delete this.directionalLight;const x=this._getTransitionParameters();for(const F of h){if(this._validate(nn,"lights",F))return;switch(F.type){case"ambient":if(this.ambientLight){const z=this.ambientLight;z.set(F),z.updateTransitions(x)}else this.ambientLight=new ba(F,$o||($o=new i.a9({color:new i.aa(i.a6.properties_light_ambient.color),"color-use-theme":new i.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new i.aa(i.a6.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const z=this.directionalLight;z.set(F),z.updateTransitions(x)}else this.directionalLight=new ba(F,Wa||(Wa=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=me=>.2126*(me[0]<=.03928?me[0]/12.92:Math.pow((me[0]+.055)/1.055,2.4))+.7152*(me[1]<=.03928?me[1]/12.92:Math.pow((me[1]+.055)/1.055,2.4))+.0722*(me[2]<=.03928?me[2]/12.92:Math.pow((me[2]+.055)/1.055,2.4)),D=h.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),F=h.properties.get("intensity"),z=h.properties.get("direction"),H=1-i.d4(z.x,z.y,z.z)[2]/90,Q=T(D)*F*H,re=x.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),oe=x.properties.get("intensity"),ge=T(re)*oe;return Number(((Q+ge)/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:F})=>F===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,F="")=>`${D}::${F}`;this._featuresetSelectors={};for(const D in h){const F=this._featuresetSelectors[D]=[];for(const z of h[D].selectors){if(z.featureNamespace){const Q=this.getOwnLayer(z.layer);if(!Q){i.w(`Layer is undefined for selector: ${z.layer}`);continue}const re=T(Q.source,Q.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 H;if(z.properties)for(const Q in z.properties){const re=i.U(z.properties[Q]);re.result==="success"&&(H=H||{},H[Q]=re.value)}F.push({layerId:z.layer,namespace:z.featureNamespace,properties:H,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 F=[];for(const z of D[h].selectors){const H=T.getOwnLayer(z.layer);H&&F.push(H)}return F}getConfigProperty(h,x){const T=this.getFragmentStyle(h);if(!T)return null;const D=i.B(x,T.scope),F=T.options.get(D),z=F?F.value||F.default:null;return z?z.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(h,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 F=D.stylesheet.schema;if(!F||!F[x])return;const z=i.U(T);if(z.result!=="success")return void ix(this,z.value);const H=z.value.expression,Q=i.B(x,D.scope),re=D.options.get(Q);if(!re)return;let oe;const{minValue:ge,maxValue:me,stepValue:xe,type:Pe,values:Me}=F[x],He=i.U(F[x].default);He.result==="success"&&(oe=He.value.expression),oe?(this.options.set(Q,Object.assign({},re,{value:H,default:oe,minValue:ge,maxValue:me,stepValue:xe,type:Pe,values:Me})),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 F in T){const z=i.B(F,x.scope),H=x.options.get(z),Q=H?H.value||H.default:null;D[F]=Q?Q.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,F;const z=i.U(x[T].default);if(z.result==="success"&&(D=z.value.expression),h&&h[T]!==void 0){const me=i.U(h[T]);me.result==="success"&&(F=me.value.expression)}const{minValue:H,maxValue:Q,stepValue:re,type:oe,values:ge}=x[T];if(D){const me=i.B(T,this.scope);this.options.set(me,{default:D,value:F,minValue:H,maxValue:Q,stepValue:re,type:oe,values:ge})}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 F;if(h.type==="custom"){if(ix(this,i.dt(h)))return;F=i.du(h,this.scope,this._styleColorTheme.lut,this.options)}else{if(typeof h.source=="object"&&(this.addSource(D,h.source),h=i.dp(h),h=Object.assign(h,{source:D})),this._validate(nl,`layers.${D}`,h,{arrayIndex:-1},T))return;F=i.du(h,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(F),F.setEventedParent(this,{layer:{id:D}})}const z=i.B(F.source,F.scope);F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(z),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(z);let H=this._order.length;if(x){const ge=this._order.indexOf(x);if(ge===-1)return void this.fire(new i.y(new Error(`Layer with id "${x}" does not exist on this map.`)));F.slot===this._layers[x].slot?H=ge:i.w(`Layer with id "${x}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(H,0,D),this._layerOrderChanged=!0,this._layers[D]=F;const Q=this.getOwnLayerSourceCache(F),re=!!this.directionalLight&&this.directionalLight.shadowsEnabled();Q&&F.canCastShadows()&&re&&(Q.castsShadows=!0);const oe=this._changes.getRemovedLayer(F);if(oe&&F.source&&Q&&F.type!=="custom"){this._changes.discardLayerRemoval(F);const ge=i.B(F.source,F.scope);oe.type!==F.type?this._changes.updateSourceCache(ge,"clear"):(this._changes.updateSourceCache(ge,"reload"),Q.pause())}this._updateLayer(F),F.onAdd&&F.onAdd(this.map),F.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 F=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?F=z:i.w(`Layer with id "${x}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(F,0,h),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(h){this._checkLoaded();const 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 F=!1;for(const z in this._layers)if(this._layers[z].source===x.source&&this._layers[z].canCastShadows()){F=!0;break}D.castsShadows=F}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(mi,`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 F=this._checkLayer(h);if(F&&!i.by(F.getLayoutProperty(x),T)){if(T!=null&&(!D||D.validate!==!1)&&ix(F,dt.call(Kt,{key:`layers.${h}.layout.${x}`,layerType:F.type,objectKey:x,value:T,styleSpec:i.a6,style:{glyphs:!0,sprite:!0}})))return;F.setLayoutProperty(x,T),F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F.fqid),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F.fqid),this._updateLayer(F)}}setLayerProperty(h,x,T,D={}){this._checkLoaded();const F=this._checkLayer(h);F&&(x==="appearances"?(F.setAppearances(T),this._changes.setDirty()):F.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 F=this._checkLayer(h);if(!F||i.by(F.getPaintProperty(x),T)||T!=null&&(!D||D.validate!==!1)&&ix(F,Vl.call(Kt,{key:`layers.${h}.paint.${x}`,layerType:F.type,objectKey:x,value:T,styleSpec:i.a6})))return;const z=F.setPaintProperty(x,T);F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F.fqid),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F.fqid),z&&this._updateLayer(F),this._changes.updatePaintProperties(F)}getPaintProperty(h,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:Q,importId:re}=h.target,oe=this.getFragmentStyle(re),ge=oe.getFeaturesetLayers(Q);for(const{source:me,sourceLayer:xe}of ge)oe.setFeatureState({id:h.id,source:me,sourceLayer:xe},x)}else if("layerId"in h.target){const{layerId:Q}=h.target,re=this.getLayer(Q);this.setFeatureState({id:h.id,source:re.source,sourceLayer:re.sourceLayer},x)}return}const T=h.source,D=h.sourceLayer,F=this._checkSource(T);if(!F)return;const z=F.type;if(z==="geojson"&&D)return void this.fire(new i.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(z==="vector"&&!D)return void this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")));h.id===void 0&&this.fire(new i.y(new Error("The feature id parameter must be provided.")));const H=this.getOwnSourceCaches(T);for(const Q of H)Q.setFeatureState(D,h.id,x)}removeFeatureState(h,x){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:Q,importId:re}=h.target,oe=this.getFragmentStyle(re),ge=oe.getFeaturesetLayers(Q);for(const{source:me,sourceLayer:xe}of ge)oe.removeFeatureState({id:h.id,source:me,sourceLayer:xe},x)}else if("layerId"in h.target){const{layerId:Q}=h.target,re=this.getLayer(Q);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 F=D.type,z=F==="vector"?h.sourceLayer:void 0;if(F==="vector"&&!z)return void this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")));if(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 H=this.getOwnSourceCaches(T);for(const Q of H)Q.removeFeatureState(z,h.id,x)}getFeatureState(h){if(this._checkLoaded(),"target"in h){let F;if("featuresetId"in h.target){const{featuresetId:z,importId:H}=h.target,Q=this.getFragmentStyle(H),re=Q.getFeaturesetLayers(z);for(const{source:oe,sourceLayer:ge}of re){const me=Q.getFeatureState({id:h.id,source:oe,sourceLayer:ge});if(me&&!F)F=me;else if(!i.by(F,me))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,H=this.getLayer(z);F=this.getFeatureState({id:h.id,source:H.source,sourceLayer:H.sourceLayer})}return F}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=H=>this._mergedLayers[H].is3D(!!this.terrain),T=this.order,D={},F=[];for(let H=T.length-1;H>=0;H--){const Q=T[H];if(x(Q)){D[Q]=H;for(const re of h){const oe=re[Q];if(oe)for(const ge of oe)F.push(ge)}}}F.sort((H,Q)=>Q.intersectionZ-H.intersectionZ);const z=[];for(let H=T.length-1;H>=0;H--){const Q=T[H];if(x(Q))for(let re=F.length-1;re>=0;re--){const oe=F[re].feature;if(oe.layer&&D[oe.layer.id]{if(jS.has(oe.type))return;const ge=this.getOwnLayerSourceCache(oe),me=F[ge.id]=F[ge.id]||{sourceCache:ge,layers:{},has3DLayers:!1};oe.is3D(!!this.terrain)&&(me.has3DLayers=!0),me.layers[oe.fqid]=me.layers[oe.fqid]||{styleLayer:oe,targets:[]},me.layers[oe.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 oe of x.layers){const ge=this._layers[oe];if(!ge)return this.fire(new i.y(new Error(`The layer '${oe}' does not exist in the map's style and cannot be queried for features.`))),[];z(ge)}}else for(const oe in this._layers)z(this._layers[oe]);const H=this._queryRenderedFeatures(h,F,T),Q=this._flattenAndSortRenderedFeatures(H),re=[];for(const oe of Q)i.dw(oe.layer.id)===this.scope&&re.push(oe);return re}queryRenderedFeatureset(h,x,T){let D;x&&!Array.isArray(x)&&x.filter&&(this._validate(mi,"queryRenderedFeatures.filter",x.filter,null,x),D=i.b6(x.filter));const F="mock",z=[];if(x&&x.target)z.push(Object.assign({},x,{targetId:F,filter:D}));else{const oe=this.getFeaturesetDescriptors();for(const ge of oe)z.push({targetId:F,filter:D,target:ge});for(const{style:ge}of this.fragments){const me=ge.getFeaturesetDescriptors();for(const xe of me)z.push({targetId:F,filter:D,target:xe})}}const H=this.queryRenderedTargets(h,z,T),Q=[],re=new Set;for(const oe of H)for(const ge of oe.variants[F])ex(ge,oe,re)||Q.push(new i.dx(oe,ge));return Q}queryRenderedTargets(h,x,T){const D={},F=(H,Q,re,oe)=>{const ge=D[Q.id]=D[Q.id]||{sourceCache:Q,layers:{},has3DLayers:!1};if(ge.layers[H.fqid]=ge.layers[H.fqid]||{styleLayer:H,targets:[]},H.is3D(!!this.terrain)&&(ge.has3DLayers=!0),!oe)return re.uniqueFeatureID=!1,void ge.layers[H.fqid].targets.push(re);ge.layers[H.fqid].targets.push(Object.assign({},re,{namespace:oe.namespace,properties:oe.properties,uniqueFeatureID:oe.uniqueFeatureID}))};for(const H of x)if("featuresetId"in H.target){const{featuresetId:Q,importId:re}=H.target,oe=this.getFragmentStyle(re);if(!oe||!oe._featuresetSelectors)continue;const ge=oe._featuresetSelectors[Q];if(!ge){this.fire(new i.y(new Error(`The featureset '${Q}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const me of ge){const xe=oe.getOwnLayer(me.layerId);xe&&!jS.has(xe.type)&&F(xe,oe.getOwnLayerSourceCache(xe),H,me)}}else if("layerId"in H.target){const{layerId:Q}=H.target,re=this.getLayer(Q);if(!re||jS.has(re.type))continue;F(re,this.getLayerSourceCache(re),H)}const z=this._queryRenderedFeatures(h,D,T);return this._flattenAndSortRenderedFeatures(z)}_queryRenderedFeatures(h,x,T){const D=[],F=!!this.map._showQueryGeometry,z=Ji.createFromScreenPoints(h,T);for(const H in x){const Q=ov(z,x[H],this._availableImages,T,F);Object.keys(Q).length&&D.push(Q)}if(this.placement)for(const H in x){if(!x[H].sourceCache._onlySymbols)continue;const Q=lv(z.screenGeometry,x[H],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(Q).length&&D.push(Q)}return D}querySourceFeatures(h,x){const T=x&&x.filter;T&&this._validate(mi,"querySourceFeatures.filter",T,null,x);let D=[];const F=this.getOwnSourceCaches(h);for(const z of F)D=D.concat(cv(z,x));return D}addSourceType(h,x,T){return om.getSourceType(h)?T(new Error(`A source type called "${h}" already exists.`)):(om.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 F=!1;for(const H in h)if(!i.by(h[H],D[H])){F=!0;break}if(!F)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 H="terrain-dem-src";this.addSource(H,T.source),T=i.dp(T),T=Object.assign(T,{source:H})}const F=Object.assign({},T),z={};if(this.terrain&&D){F.source=this.terrain.get().source;const H=this.terrain?this.getFragmentStyle(this.terrain.scope):null;H&&(z.style=H.serialize())}if(this._validate(_a,"terrain",F,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 F=this.terrain,z=F.get();for(const H of Object.keys(i.a6.terrain))!T.hasOwnProperty(H)&&i.a6.terrain[H].default&&(T[H]=i.a6.terrain[H].default);for(const H in h)if(!i.by(h[H],z[H])){F.set(h,this.options),this.stylesheet.terrain=h;const Q=this._getTransitionParameters({duration:0});F.updateTransitions(Q),this.fire(new i.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(h){const 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 Wo(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 Qi(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 Ut(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,F={}){if(F&&F.validate===!1)return!1;const z=Object.assign({},this.serialize());return ix(this,h.call(Kt,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=ub(this.directionalLight));const T=new Set,D=new Set;for(const F in this._mergedLayers){const z=this._mergedLayers[F];z.type==="building"&&T.add(z.source),z.hasElevation()&&!D.has(z.source)&&D.add(z.source)}for(const F in this._mergedSourceCaches){const z=this._mergedSourceCaches[F],H=D.has(z._source.id);T.has(z._source.id)&&(z._source.reparseOverscaled=!1),z.update(h,void 0,void 0,x,H)}}_generateCollisionBoxes(){for(const h in this._sourceCaches){const x=this._sourceCaches[h];x.resume(),x.reload()}}_updatePlacement(h,x,T,D,F,z,H=!1){let Q=!1,re=!1;const oe={},ge={};for(const Me of this._mergedOrder){const He=this._mergedLayers[Me];if(He.type!=="symbol")continue;const Be=i.B(He.source,He.scope);let et=oe[Be];if(!et){const tt=this.getLayerSourceCache(He);if(!tt)continue;const Mt=tt.getRenderableIds(!0).map(_t=>tt.getTileByID(_t));ge[Be]=Mt.slice(),et=oe[Be]=Mt.sort((_t,kt)=>kt.tileID.overscaledZ-_t.tileID.overscaledZ||(_t.tileID.isLessThan(kt.tileID)?-1:1))}const ut=this.crossTileSymbolIndex.addLayer(He,et,x.center.lng,x.projection);Q=Q||ut}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),H=H||this._layerOrderChanged,this._layerOrderChanged&&this.fire(new i.z("neworder"));const me=!!(this.placement&&!x.equals(this.placement.transform)),xe=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!z||this.placement.lastReplacementSourceUpdateTime!==z.updateTime)),Pe=(me||xe||Q||this.placement&&this.placement.isStale())&&D===0;if((H||!this.pauseablePlacement||Pe||D!==0&&this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),x.zoom))&&(this.pauseablePlacement=new ic(x,this._mergedOrder,H||D===0,T,D,F,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,oe,ge,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.o.now()),re=!0),Q&&this.pauseablePlacement.placement.setStale()),re||Q){this._buildingIndex.onNewFrame(x.zoom);for(let Me=0;MeF===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:F})=>F===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 F=this.getImportIndex(x);if(F===-1)return this;const z=T[D],H=this.fragments[D];return T=T.filter(({id:Q})=>Q!==h),this.fragments=this.fragments.filter(({id:Q})=>Q!==h),this.stylesheet.imports=T.slice(0,F).concat(z).concat(T.slice(F)),this.fragments=this.fragments.slice(0,F).concat(H).concat(this.fragments.slice(F)),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 F=this.fragments[D];return F.style=this._createFragmentStyle(T[D]),F.style.on("style.import.load",()=>this.mergeAll()),F.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),F=this.stylesheet.imports||[];if(D===-1)return this;x?F[D].config=x:delete F[D].config;const z=this.fragments[D];T&&z.style.stylesheet&&(z.style.stylesheet.schema=T);const H=z.style.stylesheet&&z.style.stylesheet.schema;return z.config=x,z.style.updateConfig(x,H),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 H=x.images.map(Q=>i.I.toString(Q));z.setDependencies(x.tileID.key,x.type,H)}},F=i.B(x.source,x.scope);D(this._mergedOtherSourceCaches[F]),D(this._mergedSymbolSourceCaches[F]),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)}}om.getSourceType=function(M){return em[M]},om.setSourceType=function(M,h){em[M]=h},om.registerForPluginStateChange=i.dA;class dD 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(F,z,H,Q){let re=null,oe=Number.MAX_SAFE_INTEGER;if(Q<16)return null;for(const[ge,me]of Object.entries(F)){const xe=me.center;if(xe){const Pe=z.distanceTo(i.aT.convert(xe));Pe({id:z,name:T.floors[z].name,zIndex:T.floors[z].zIndex})).sort((z,H)=>H.zIndex-z.zIndex);this.fire(new i.z("selector-update",{selectedFloorId:D,activeFloorsVisible:this._activeFloorsVisible,floors:F}))}_updateActiveFloors(){const h=this._activeFloors;this._activeFloors=new Set,this._indoorState={selectedFloorId:this._selectedFloorId,lastActiveFloors:h,activeFloorsVisible:this._activeFloorsVisible},this._style.updateIndoorDependentLayers()}}var gv=` #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`,xv=` #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;}`,eT=` #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`,kS="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;}",fh=` #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`,NS=`#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`,Ys=`#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`,tT=`#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`,SS=`#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;}`,CS=`#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`,sT=`#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 mb=/#include\s+"([^"]+)"/g,Ap=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,rT=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,Sy=new Set(["ifdef","ifndef","elif","if","defined"]),Cy=new Set;cx(gv,Cy),cx(eT,Cy),cx(xv,Cy);const lx={"_prelude_fog.vertex.glsl":NS,"_prelude_terrain.vertex.glsl":fh,"_prelude_shadow.vertex.glsl":CS,"_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":Ys,"_prelude_shadow.fragment.glsl":sT,"_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":tT,"_prelude_raster_particle.glsl":SS},MS={};Sa("",fh),Sa(Ys,NS),Sa(sT,CS),Sa(tT,""),Sa(SS,"");const uD=Sa(xv,eT),TS=gv,Rce=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",TS,uD.fragmentSource].join(` `),hD=["precision highp float;",TS,uD.vertexSource].join(` `);var nT={background:Sa(`#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:Sa(`#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:Sa(`#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:Sa(`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:Sa(`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:Sa(`#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:Sa("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:Sa(`#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:Sa(`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:Sa("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:Sa("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:Sa("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:Sa(`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:Sa(`#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:Sa(`#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:Sa(`#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:Sa(`#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:Sa(`#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:Sa(`#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:Sa(`#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:Sa(`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:Sa(`#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:Sa(`#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:Sa(`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:Sa(`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:Sa(`#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:Sa(`#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:Sa(`#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:Sa(`#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:Sa(`#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:Sa("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:Sa("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:Sa(`#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:Sa(`#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:Sa(`#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:Sa("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:Sa(`#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 }`,kS),skyboxGradient:Sa(`#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 }`,kS),skyboxCapture:Sa(` 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:Sa(`#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:Sa(`#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:Sa(`#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:Sa(`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:Sa(`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:Sa("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:Sa("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:Sa("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:Sa("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 cx(M,h){const x=M.split(` `);for(let T of x){if(T=T.trimStart(),T[0]!=="#"||!T.includes("if")||T.startsWith("#endif"))continue;const D=T.match(rT);if(D)for(const F of D)Sy.has(F)||h.add(F)}}function Sa(M,h){const x=new Set,T=[],D=[];M=M.replace(mb,(z,H)=>(D.push(H),"")),h=h.replace(mb,(z,H)=>(T.push(H),""));let F=new Set(Cy);cx(M,F),cx(h,F);for(const z of[...T,...D])MS[z]||(MS[z]=new Set,cx(lx[z],MS[z])),F=new Set([...F,...MS[z]]);return{fragmentSource:M=M.replace(Ap,(z,H,Q,re,oe)=>(x.add(oe),H==="define"?` #ifndef HAS_UNIFORM_u_${oe} in ${Q} ${re} ${oe}; #else uniform ${Q} ${re} u_${oe}; #endif `:H==="initialize"?` #ifdef HAS_UNIFORM_u_${oe} ${Q} ${re} ${oe} = u_${oe}; #endif `:H==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${Q} ${re} ${oe}; #endif `:H==="initialize-attribute"?"":void 0)),vertexSource:h=h.replace(Ap,(z,H,Q,re,oe)=>{const ge=`MATERIAL_ATTRIBUTE_OFFSET_${oe}`,me=re==="float"?"vec2":re,xe=`GET_ATTRIBUTE_${me}(a_${oe}, materialInfo, ${ge})`,Pe=oe.match(/color/)?"color":me;return H==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${Q} ${re} a_${oe}; #endif `:x.has(oe)?H==="define"?` #ifndef HAS_UNIFORM_u_${oe} uniform lowp float u_${oe}_t; #if !defined(${ge}) in ${Q} ${me} a_${oe}; #endif out ${Q} ${re} ${oe}; #else uniform ${Q} ${re} u_${oe}; #endif `:H==="initialize"?Pe==="vec4"?` #ifndef HAS_UNIFORM_u_${oe} ${oe} = a_${oe}; #else ${Q} ${re} ${oe} = u_${oe}; #endif `:` #if !defined(HAS_UNIFORM_u_${oe}) #ifdef ${ge} ${oe} = unpack_mix_${Pe}(${xe}, u_${oe}_t); #else ${oe} = unpack_mix_${Pe}(a_${oe}, u_${oe}_t); #endif #else ${Q} ${re} ${oe} = u_${oe}; #endif `:H==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${Q} ${re} a_${oe}; out ${Q} ${re} ${oe}; #endif `:H==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} ${oe} = a_${oe}; #endif `:void 0:H==="define"?` #ifndef HAS_UNIFORM_u_${oe} uniform lowp float u_${oe}_t; #if !defined(${ge}) in ${Q} ${me} a_${oe}; #endif #else uniform ${Q} ${re} u_${oe}; #endif `:H==="define-instanced"?Pe==="mat4"?` #ifdef INSTANCED_ARRAYS in vec4 a_${oe}0; in vec4 a_${oe}1; in vec4 a_${oe}2; in vec4 a_${oe}3; #else uniform ${Q} ${re} u_${oe}; #endif `:` #ifdef INSTANCED_ARRAYS in ${Q} ${me} a_${oe}; #else uniform ${Q} ${re} u_${oe}; #endif `:H==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${oe} ${Q} ${re} ${oe} = a_${oe}; #endif `:Pe==="vec4"?` #ifndef HAS_UNIFORM_u_${oe} #ifdef ${ge} ${Q} ${re} ${oe} = ${xe}; #else ${Q} ${re} ${oe} = a_${oe}; #endif #else ${Q} ${re} ${oe} = u_${oe}; #endif `:` #ifndef HAS_UNIFORM_u_${oe} #ifdef ${ge} ${Q} ${re} ${oe} = unpack_mix_${Pe}(${xe}, u_${oe}_t); #else ${Q} ${re} ${oe} = unpack_mix_${Pe}(a_${oe}, u_${oe}_t); #endif #else ${Q} ${re} ${oe} = u_${oe}; #endif `}),usedDefines:F,vertexIncludes:T,fragmentIncludes:D}}class Fce{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,F,z,H,Q){this.context=h;let re=this.boundPaintVertexBuffers.length!==D.length;for(let ge=0;!re&&ge{const Mt=ut.paint.get("hillshade-shadow-color"),_t=ut.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",kt=ut.paint.get("hillshade-highlight-color"),xt=ut.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",pt=ut.paint.get("hillshade-accent-color"),Et=ut.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Ht=ut.paint.get("hillshade-emissive-strength");let Vt=i.an(ut.paint.get("hillshade-illumination-direction"));if(ut.paint.get("hillshade-illumination-anchor")==="viewport")Vt-=Be.transform.angle;else if(Be.style&&Be.style.enable3dLights()&&Be.style.directionalLight){const ss=Be.style.directionalLight.properties.get("direction"),fs=i.d4(ss.x,ss.y,ss.z);Vt=i.an(fs[1])}const ts=!Be.options.moving;return{u_matrix:tt||Be.transform.calculateProjMatrix(et.tileID.toUnwrapped(),ts),u_image:0,u_latrange:zce(0,et.tileID),u_light:[ut.paint.get("hillshade-exaggeration"),Vt],u_shadow:Mt.toPremultipliedRenderColor(_t?null:ut.lut),u_highlight:kt.toPremultipliedRenderColor(xt?null:ut.lut),u_emissive_strength:Ht,u_accent:pt.toPremultipliedRenderColor(Et?null:ut.lut)}})(M,x,T,M.terrain?h.projMatrix:null);M.uploadCommonUniforms(H,me,h.toUnwrapped());const{tileBoundsBuffer:Pe,tileBoundsIndexBuffer:Me,tileBoundsSegments:He}=M.getTileBoundsBuffers(x);me.draw(M,Q.TRIANGLES,D,F,z,rn.disabled,xe,T.id,Pe,Me,He)}function aT(M,h,x){if(!h.needsDEMTextureUpload)return;const T=M.context,D=T.gl;T.pixelStoreUnpackPremultiplyAlpha.set(!1),h.demTexture=h.demTexture||M.getTileTexture(x.stride);const F=x.getPixels();h.demTexture?h.demTexture.update(F,{premultiply:!1}):h.demTexture=new i.T(T,F,D.R32F,{premultiply:!1}),h.needsDEMTextureUpload=!1}function $ce(M,h,x){const T=M.context,D=T.gl;if(!h.dem)return;const F=h.dem;if(T.activeTexture.set(D.TEXTURE1),aT(M,h,F),!h.demTexture)return;h.demTexture.bind(D.NEAREST,D.CLAMP_TO_EDGE);const z=F.dim;T.activeTexture.set(D.TEXTURE0);let H=h.hillshadeFBO;if(!H){const me=new i.T(T,{width:z,height:z,data:null},D.RGBA8);me.bind(D.LINEAR,D.CLAMP_TO_EDGE),H=h.hillshadeFBO=T.createFramebuffer(z,z,1,"renderbuffer"),H.colorAttachment0.set(me.texture)}T.bindFramebuffer.set(H.framebuffer),T.viewport.set([0,0,z,z]);const{tileBoundsBuffer:Q,tileBoundsIndexBuffer:re,tileBoundsSegments:oe}=M.getMercatorTileBoundsBuffers(),ge=[];M.linearFloatFilteringSupported()&&ge.push("TERRAIN_DEM_FLOAT_FORMAT"),M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback"&&ge.push("USE_MRT1"),M.getOrCreateProgram("hillshadePrepare",{defines:ge}).draw(M,D.TRIANGLES,Ir.disabled,dn.disabled,Dn.unblended,rn.disabled,((me,xe)=>{const Pe=xe.stride,Me=i.bC();return i.ce(Me,0,i.al,-i.al,0,0,1),i.br(Me,Me,[0,-i.al,0]),{u_matrix:Me,u_image:1,u_dimension:[Pe,Pe],u_zoom:me.overscaledZ}})(h.tileID,F),x.id,Q,re,oe),h.needsHillshadePrepare=!1}class so{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 qce extends so{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 mD extends so{getDefault(){return 1}set(h){(h!==this.current||this.dirty)&&(this.gl.clearDepth(h),this.current=h,this.dirty=!1)}}class iT extends so{getDefault(){return 0}set(h){(h!==this.current||this.dirty)&&(this.gl.clearStencil(h),this.current=h,this.dirty=!1)}}class AS extends so{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 oT extends so{getDefault(){return!0}set(h){(h!==this.current||this.dirty)&&(this.gl.depthMask(h),this.current=h,this.dirty=!1)}}class My extends so{getDefault(){return 255}set(h){(h!==this.current||this.dirty)&&(this.gl.stencilMask(h),this.current=h,this.dirty=!1)}}class yv extends so{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 pb extends so{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 vv extends so{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 pD extends so{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 lT extends so{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 fD extends so{getDefault(){return this.gl.LESS}set(h){(h!==this.current||this.dirty)&&(this.gl.depthFunc(h),this.current=h,this.dirty=!1)}}class _v extends so{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 ES extends so{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 PS extends so{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 cT extends so{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 IS extends so{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 fb extends so{getDefault(){return this.gl.BACK}set(h){(h!==this.current||this.dirty)&&(this.gl.cullFace(h),this.current=h,this.dirty=!1)}}class gD extends so{getDefault(){return this.gl.CCW}set(h){(h!==this.current||this.dirty)&&(this.gl.frontFace(h),this.current=h,this.dirty=!1)}}let xD=class extends so{getDefault(){return null}set(M){(M!==this.current||this.dirty)&&(this.gl.useProgram(M),this.current=M,this.dirty=!1)}};class yD extends so{getDefault(){return this.gl.TEXTURE0}set(h){(h!==this.current||this.dirty)&&(this.gl.activeTexture(h),this.current=h,this.dirty=!1)}}class bv extends so{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 vD extends so{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 Uce extends so{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 Vce extends so{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 Hce extends so{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 dT extends so{getDefault(){return null}set(h){const x=this.gl;x.bindBuffer(x.ELEMENT_ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class uT extends so{getDefault(){return null}set(h){this.gl&&(h!==this.current||this.dirty)&&(this.gl.bindVertexArray(h),this.current=h,this.dirty=!1)}}class hT extends so{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 mT extends so{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 _D extends so{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 LS extends so{constructor(h,x){super(h),this.context=h,this.parent=x}getDefault(){return null}}class DS extends LS{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 wv extends LS{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 gb extends LS{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 bD extends wv{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const gh=(M,h,x,T)=>({u_matrix:M,u_image0:0,u_image1:1,u_skirt_height:h,u_ground_shadow_factor:x,u_emissive_texture_available:T}),OS=(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Me,He)=>({u_proj_matrix:Float32Array.from(M),u_globe_matrix:h,u_normalize_matrix:Float32Array.from(T),u_merc_matrix:x,u_zoom_transition:D,u_merc_center:F,u_image0:0,u_image1:1,u_frustum_tl:z,u_frustum_tr:H,u_frustum_br:Q,u_frustum_bl:re,u_globe_pos:oe,u_globe_radius:ge,u_viewport:me,u_grid_matrix:He?Float32Array.from(He):new Float32Array(9),u_skirt_height:xe,u_far_z_cutoff:Pe,u_emissive_texture_available:Me});function xb(M,h){return M!=null&&h!=null&&!(!M.hasData()||!h.hasData())&&M.demTexture!=null&&h.demTexture!=null&&M.tileID.key!==h.tileID.key}const $f=new class{constructor(){this.operations={}}newMorphing(M,h,x,T,D){if(M in this.operations){const F=this.operations[M];F.to.tileID.key!==x.tileID.key&&(F.queued=x)}else this.operations[M]={startTime:T,phase:0,duration:D,from:h,to:x,queued:null}}getMorphValuesForProxy(M){if(!(M in this.operations))return null;const h=this.operations[M];return{from:h.from,to:h.to,phase:h.phase}}update(M){for(const h in this.operations){const x=this.operations[h];for(x.phase=(M-x.startTime)/x.duration;x.phase>=1||!this._validOp(x);)if(!this._nextOp(x,M)){delete this.operations[h];break}}}_nextOp(M,h){return!!M.queued&&(M.from=M.to,M.to=M.queued,M.queued=null,M.phase=0,M.startTime=h,!0)}_validOp(M){return M.from.hasData()&&M.to.hasData()}},RS={0:null,1:"TERRAIN_VERTEX_MORPHING"};function FS(M,h,x){if(h===0)return 0;const T=h<1&&x===514?.25/h:1;return 6*Math.pow(1.5,22-M)*Math.max(h,1)*T}function pT(M,h){const x=1<({u_matrix:M});function vb(M,h,x,T,D){if(D>0){const F=i.o.now(),z=(F-M.timeAdded)/D,H=h?(F-h.timeAdded)/D:-1,Q=x.getSource(),re=T.coveringZoomLevel({tileSize:Q.tileSize,roundZoom:Q.roundZoom}),oe=!h||Math.abs(h.tileID.overscaledZ-re)>Math.abs(M.tileID.overscaledZ-re),ge=oe&&M.refreshedUponExpiration?1:i.aA(oe?z:1-H,0,1);return h?{opacity:1,mix:1-ge,isFading:z<1}:{opacity:ge,mix:0,isFading:z<1}}return{opacity:1,mix:0,isFading:!1}}class zS extends hl{constructor(h){const x=_l("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 fT extends hl{constructor(h){const x=_l("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((F,z)=>{if(F[z.key]="",!this._tiles[z.key]){const H=new sm(z,this._source.tileSize*z.overscaleFactor(),h.tileZoom,void 0,void 0,this._source.worldview);H.state="loaded",this._tiles[z.key]=H}return F},{});for(const F in this._tiles)F in D||(this.freeFBO(F),this._tiles[F].unloadVectorData(),delete this._tiles[F])}freeFBO(h){const 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 gT 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 xT extends i.bV{constructor(h,x){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=h,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[T,D,F]=function(Q){const re=new i.bd,oe=new i.b0,ge=131;re.reserve(17161),oe.reserve(33800);const me=i.al/128,xe=i.al+me/2,Pe=xe+me;for(let He=-me;Hexe||He<0||He>xe?24575:0,ut=i.aA(Math.round(Be),0,i.al),tt=i.aA(Math.round(He),0,i.al);re.emplaceBack(ut+et,tt)}const Me=(He,Be)=>{const et=Be*ge+He;oe.emplaceBack(et+1,et,et+ge),oe.emplaceBack(et+ge,et+ge+1,et+1)};for(let He=1;He<129;He++)for(let Be=1;Be<129;Be++)Me(Be,He);return[0,129].forEach(He=>{for(let Be=0;Be<130;Be++)Me(Be,He),Me(He,Be)}),[re,oe,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,F),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new fT(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 H=z.gl;this._overlapStencilMode=new dn({func:H.GEQUAL,mask:255},0,255,H.KEEP,H.KEEP,H.REPLACE),this._previousZoom=h.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=x,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new zS(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,F=h.terrain.drapeRenderMode===0,z=h.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=i.o.now();const H=h.terrain&&h.terrain.scope,Q=D.get("source"),re=F?this._mockSourceCache:h.getSourceCache(Q,H);if(!re)return void i.w(`Couldn't find terrain source "${Q}".`);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 oe=()=>{this.sourceCache.used&&i.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const ge=this.getScaledDemTileSize();this.sourceCache.update(x,ge,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,oe(),this._initializing=!0),oe(),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 F=h.zoom,z=this._style.terrain;if(!this._previousUpdateTimestamp)return z.getExaggeration(F);let H=F-this._previousZoom;const Q=this._previousUpdateTimestamp;let re=F;this._evaluationZoom!=null&&(re=this._evaluationZoom,Math.abs(F-re)>.5&&(H=.5*(F-re+H)),H*D<0&&(re+=H)),this._evaluationZoom=re;const oe=z.getExaggeration(re),ge=oe===z.getExaggeration(Math.max(0,re-.1));if(ge&&Math.abs(oe-this._exaggeration)<.01)return oe;let me=Math.min(.1,.00375*(this._updateTimestamp-Q));return(ge||oe<.1||Math.abs(H)<1e-4)&&(me=Math.min(.2,4*me)),i.ak(this._exaggeration,oe,me)}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(Q=>{const re=x.getTileByID(Q).tileID;return re.projMatrix=T.calculateProjMatrix(re.toUnwrapped()),re});(function(Q,re){const oe=re.transform.pointCoordinate(re.transform.getCameraPoint()),ge=new i.P(oe.x,oe.y);Q.sort((me,xe)=>{if(xe.overscaledZ-me.overscaledZ)return xe.overscaledZ-me.overscaledZ;const Pe=new i.P(me.canonical.x+(1<{this.proxyToSource[Q.key]={}}),this.terrainTileForTile={};const z=this._style._mergedSourceCaches;for(const Q in z){const re=z[Q];if(!re.used||(re!==this.sourceCache&&this.resetTileLookupCache(re.id),this._setupProxiedCoordsForOrtho(re,h[Q],F),re.usedForTerrain))continue;const oe=h[Q];re.getSource().reparseOverscaled&&this._assignTerrainTiles(oe)}this.proxiedCoords[x.id]=D.map(Q=>new gT(Q,Q.key,this.orthoMatrix)),this._assignTerrainTiles(D),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(F),this.renderingToTexture=!1;const H={};this._visibleDemTiles=[];for(const Q of this.proxyCoords){const re=this.terrainTileForTile[Q.key];if(!re)continue;const oe=re.tileID.key;oe in H||(this._visibleDemTiles.push(re),H[oe]=oe)}}_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],F=D.dem;!F||D.demTexture&&!D.needsDEMTextureUpload||(h.activeTexture.set(x.TEXTURE1),aT(this.painter,D,F))}}_prepareDemTileUniforms(h,x,T,D){if(!x||x.demTexture==null)return!1;const F=h.tileID.canonical,z=Math.pow(2,x.tileID.canonical.z-F.z),H=D||"";return T[`u_dem_tl${H}`]=[F.x*z%1,F.y*z%1],T[`u_dem_scale${H}`]=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 F=D.dem.tree.minimums[0];return F>0&&h++,T+F},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 F=this._emptyDEMTexture;return F?F.update(D,{premultiply:!1}):F=this._emptyDEMTexture=new i.T(h,D,x.R32F,{premultiply:!1}),F}setupElevationDraw(h,x,T){const D=this.painter.context,F=D.gl,z={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};z.u_exaggeration=this.exaggeration();let H=null,Q=null,re=1;if(T&&T.morphing&&this._useVertexMorphing){const xe=T.morphing.srcDemTile,Pe=T.morphing.dstDemTile;re=T.morphing.phase,xe&&Pe&&(this._prepareDemTileUniforms(h,xe,z,"_prev")&&(Q=xe),this._prepareDemTileUniforms(h,Pe,z)&&(H=Pe))}const oe=xe=>xe&&xe.demTexture&&this.painter.linearFloatFilteringSupported()?F.LINEAR:F.NEAREST;let ge=null;var me;if(this.enabled?Q&&H?(ge=H.demTexture,D.activeTexture.set(F.TEXTURE4),Q.demTexture.bind(oe(Q),F.CLAMP_TO_EDGE),z.u_dem_lerp=re):(H=this.terrainTileForTile[h.tileID.key],ge=this._prepareDemTileUniforms(h,H,z)?H.demTexture:this.emptyDEMTexture):ge=this.emptyDEMTexture,D.activeTexture.set(F.TEXTURE2),ge&&(z.u_dem_size=(me=ge).size[0]===1?1:me.size[0]-2,ge.bind(oe(H),F.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(T&&T.useDepthForOcclusion,x,z),T&&T.useMeterToDem&&H){const xe=(1<{if(Be===ss)return;const fs=[RS[ss],"PROJECTION_GLOBE_VIEW"];ut&&fs.push("CUSTOM_ANTIALIASING");const Bs=re.isTileAffectedByFog(ts);He=re.getOrCreateProgram("globeRaster",{defines:fs,overrideFog:Bs}),Be=ss},Mt=re.colorModeForRenderPass(),_t=new Ir(Me.LEQUAL,Ir.ReadWrite,re.depthRangeFor3D);$f.update(xe);const kt=i.dF(et),xt=[i.aF(et.center.lng),i.aJ(et.center.lat)],pt=re.globeSharedBuffers,Et=[et.width*i.o.devicePixelRatio,et.height*i.o.devicePixelRatio],Ht=Float32Array.from(et.globeMatrix),Vt={useDenormalizedUpVectorScale:!0};{const ts=re.transform,ss=FS(ts.zoom,oe.exaggeration(),oe.sourceCache._source.tileSize);Be=-1;const fs=Me.TRIANGLES;for(const Bs of me){const Yt=ge.getTile(Bs),Ft=dn.disabled,ds=oe.prevTerrainTileForTile[Bs.key],Jt=oe.terrainTileForTile[Bs.key];xb(ds,Jt)&&$f.newMorphing(Bs.key,ds,Jt,xe,250),jv(re,Yt.emissiveTexture),Pe.activeTexture.set(Me.TEXTURE0),Yt.texture&&Yt.texture.bind(Me.LINEAR,Me.CLAMP_TO_EDGE);const Es=$f.getMorphValuesForProxy(Bs.key),Qs=Es?1:0;Es&&Object.assign(Vt,{morphing:{srcDemTile:Es.from,dstDemTile:Es.to,phase:i.dD(Es.phase)}});const mr=i.dG(Bs.canonical),Ks=i.dH(mr.getCenter().lat),$s=i.dI(Bs.canonical,mr,Ks,ts.worldSize/ts._pixelsPerMercatorPixel),Sr=i.bk(i.dJ(Bs.canonical)),jr=re.emissiveMode==="mrt-fallback"?1:0,lr=OS(ts.expandedFarZProjMatrix,Ht,kt,Sr,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,jr,$s);if(tt(Bs,Qs),He&&(oe.setupElevationDraw(Yt,He,Vt),re.uploadCommonUniforms(Pe,He,Bs.toUnwrapped()),pt)){const[fr,Vr,jn]=pt.getGridBuffers(Ks,ss!==0);He.draw(re,fs,_t,Ft,Mt,rn.backCCW,lr,"globe_raster",fr,Vr,jn)}}}if(pt&&(re.renderDefaultNorthPole||re.renderDefaultSouthPole)){const ts=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];ut&&ts.push("CUSTOM_ANTIALIASING"),He=re.getOrCreateProgram("globeRaster",{defines:ts});for(const ss of me){const{x:fs,y:Bs,z:Yt}=ss.canonical,Ft=Bs===0,ds=Bs===(1<fr.draw(re,Me.TRIANGLES,_t,dn.disabled,Mt,rn.disabled,OS(et.expandedFarZProjMatrix,$s,$s,Sr,0,xt,et.frustumCorners.TL,et.frustumCorners.TR,et.frustumCorners.BR,et.frustumCorners.BL,et.globeCenterInViewSpace,et.globeRadius,Et,0,et._farZ,jr),"globe_pole_raster",Vr,Qs,mr);oe.setupElevationDraw(Ks,He,Vt),re.uploadCommonUniforms(Pe,He,ss.toUnwrapped()),Ft&&re.renderDefaultNorthPole&&lr(He,Jt),ds&&re.renderDefaultSouthPole&&($s=i.cS(i.bC(),$s,[1,-1,1]),lr(He,Es))}}}})(D,F,z,H,Q);else{const re=D.context,oe=re.gl;let ge,me;const xe=D.shadowRenderer,Pe=nx(D,D.longestCutoffRange),Me=Mt=>{if(me===Mt)return;const _t=[];_t.push(RS[Mt]),Pe.shouldRenderCutoff&&_t.push("RENDER_CUTOFF"),xe&&(_t.push("RENDER_SHADOWS","DEPTH_TEXTURE"),xe.useNormalOffset&&_t.push("NORMAL_OFFSET")),ge=D.getOrCreateProgram("terrainRaster",{defines:_t}),me=Mt},He=D.colorModeForRenderPass(),Be=new Ir(oe.LEQUAL,Ir.ReadWrite,D.depthRangeFor3D);$f.update(Q);const et=D.transform,ut=FS(et.zoom,F.exaggeration(),F.sourceCache._source.tileSize);let tt=[0,0,0];if(xe){const Mt=D.style.directionalLight,_t=D.style.ambientLight;Mt&&_t&&(tt=Bf(D.style,Mt,_t))}{me=-1;const Mt=oe.TRIANGLES,[_t,kt]=[F.gridIndexBuffer,F.gridSegments];for(const xt of H){const pt=z.getTile(xt),Et=dn.disabled,Ht=F.prevTerrainTileForTile[xt.key],Vt=F.terrainTileForTile[xt.key];xb(Ht,Vt)&&$f.newMorphing(xt.key,Ht,Vt,Q,250),jv(D,pt.emissiveTexture),re.activeTexture.set(oe.TEXTURE0),pt.texture&&pt.texture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE);const ts=$f.getMorphValuesForProxy(xt.key),ss=ts?1:0;let fs;ts&&(fs={morphing:{srcDemTile:ts.from,dstDemTile:ts.to,phase:i.dD(ts.phase)}});const Bs=D.emissiveMode==="mrt-fallback"?1:0,Yt=gh(xt.projMatrix,pT(xt.canonical,et.renderWorldCopies)?ut/10:ut,tt,Bs);if(Me(ss),!ge)continue;F.setupElevationDraw(pt,ge,fs);const Ft=xt.toUnwrapped();xe&&xe.setupShadows(Ft,ge),D.uploadCommonUniforms(re,ge,Ft,null,Pe),ge.draw(D,Mt,Be,Et,He,rn.backCCW,Yt,"terrain_raster",F.gridBuffer,_t,kt)}}}}(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,F=this.proxiedCoords[D.id],z=this._drapedRenderBatches.shift(),H=x.style.order,Q=[];this._updateFBOs(x.emissiveMode==="mrt-fallback");let re=0;for(const oe of F){const ge=D.getTileByID(oe.proxyTileKey),me=D.proxyCachedFBO[oe.key]?D.proxyCachedFBO[oe.key][h]:void 0,xe=me!==void 0?D.renderCache[me]:this.pool[re++],Pe=me!==void 0;if(ge.texture=xe.tex,ge.emissiveTexture=xe.emissiveTex,Pe&&!xe.dirty){Q.push(ge.tileID);continue}T.bindFramebuffer.set(xe.fb.framebuffer);const Me=T.gl;let He;Me.drawBuffers(x.emissiveMode==="mrt-fallback"?[Me.COLOR_ATTACHMENT0,Me.COLOR_ATTACHMENT1]:[Me.COLOR_ATTACHMENT0]),this.renderedToTile=!1,xe.dirty&&(T.clear({color:i.ao.transparent,stencil:0}),xe.dirty=!1);for(let Be=z.start;Be<=z.end;++Be){const et=x.style._mergedLayers[H[Be]];if(et.isHidden(x.transform.zoom))continue;const ut=x.style.getLayerSourceCache(et),tt=ut?this.proxyToSource[oe.key][ut.id]:[oe];if(!tt)continue;const Mt=tt;T.viewport.set([0,0,xe.fb.width,xe.fb.height]),He!==(ut?ut.id:null)&&(this._setupStencil(xe,tt,et,ut),He=ut?ut.id:null),x.renderLayer(x,ut,et,Mt)}if(Me.drawBuffers([Me.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const Be of this._pendingGroundEffectLayers){const et=x.style._mergedLayers[H[Be]];if(et.isHidden(x.transform.zoom))continue;const ut=x.style.getLayerSourceCache(et),tt=ut?this.proxyToSource[oe.key][ut.id]:[oe];if(!tt)continue;const Mt=tt;T.viewport.set([0,0,xe.fb.width,xe.fb.height]),He!==(ut?ut.id:null)&&(this._setupStencil(xe,tt,et,ut),He=ut?ut.id:null),x.renderLayer(x,ut,et,Mt)}this.renderedToTile?(xe.dirty=!0,Q.push(ge.tileID)):Pe||--re,re===5&&(re=0,this.renderToBackBuffer(Q))}return this.renderToBackBuffer(Q),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 F=0;FT}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(F=>F.dem).map(F=>{const z=F.tileID,H=1<(F.t!==null?F.t:Number.MAX_VALUE)-(z.t!==null?z.t:Number.MAX_VALUE));for(const F of D){if(F.t==null)return null;const z=F.tile.dem.tree.raycast(F.minx,F.miny,F.maxx,F.maxy,h,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 F=h.createFramebuffer(T[0],T[1],1,null);let z;return F.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),F.createColorAttachment(h,1),F.colorAttachment1.set(z.texture)),F.depthAttachment=new bD(h,F.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=h.createRenderbuffer(h.gl.DEPTH_STENCIL,T[0],T[1]),this._stencilRef=0,F.depthAttachment.set(this._sharedDepthStencil),h.clear({stencil:0})):F.depthAttachment.set(this._sharedDepthStencil),h.extTextureFilterAnisotropic&&x.texParameterf(x.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax),{fb:F,tex:D,emissiveTex:z,dirty:!1}}_updateFBOs(h){if(this._emissiveTexture!==h){for(const 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,F=D.gl,z=this.drapeBufferSize;if(x){const H=new i.T(D,{width:z[0],height:z[1],data:null},F.R8);H.bind(F.LINEAR,F.CLAMP_TO_EDGE),h.emissiveTex=H,T.createColorAttachment(D,1),T.colorAttachment1.set(H.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;TQ>H.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 H=0;H=0;z--){const H=T[z];if(x.getTileByID(H.key),x.proxyCachedFBO[H.key]!==void 0){const Q=h[H.key],re=this.proxyToSource[H.key];let oe=0;for(const ge in re){const me=re[ge],xe=Q[ge];if(!xe||xe.length!==me.length||me.some((Pe,Me)=>Pe!==xe[Me]||D[ge]&&D[ge].hasOwnProperty(Pe.key))){oe=-1;break}++oe}for(const ge in x.proxyCachedFBO[H.key])x.renderCache[x.proxyCachedFBO[H.key][ge]].dirty=oe<0||oe!==Object.values(Q).length}}const F=[...this._drapedRenderBatches];F.sort((z,H)=>H.end-H.start-(z.end-z.start));for(const z of F)for(const H of T){if(x.proxyCachedFBO[H.key])continue;let Q=x.renderCachePool.pop();Q===void 0&&x.renderCache.length<50&&(Q=x.renderCache.length,x.renderCache.push(this._createFBO())),Q!==void 0&&(x.proxyCachedFBO[H.key]={},x.proxyCachedFBO[H.key][z.start]=Q,x.renderCache[Q].dirty=!0)}this._tilesDirty={}}_setupStencil(h,x,T,D){if(!D||!this._sourceTilesOverlap[D.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const F=this.painter.context,z=F.gl;if(x.length<=1)return void(this._overlapStencilType=!1);let H;if(T.isTileClipped())H=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);H=1,this._overlapStencilMode.test={func:z.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+H>255&&(F.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=H,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):dn.disabled}_renderTileClippingMasks(h,x){const T=this.painter,D=this.painter.context,F=D.gl;T._tileClippingMaskIDs={},D.setColorMode(Dn.disabled),D.setDepthMode(Ir.disabled);const z=T.getOrCreateProgram("clippingMask");for(const H of h){const Q=T._tileClippingMaskIDs[H.key]=--x;z.draw(T,F.TRIANGLES,Ir.disabled,new dn({func:F.ALWAYS,mask:0},Q,255,F.KEEP,F.KEEP,F.REPLACE),Dn.disabled,rn.disabled,yb(H.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,F=i.cf(1,x.center.lat),z=[D[0],D[1],D[2]/F,0],H=i.da([],T.slice(0,3),z);i.aw(H,H);const Q=this.raycast(z,H,this._exaggeration);return Q!==null&&Q?(i.bH(z,z,H,Q),z[3]=z[2],z[2]*=F,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]=[],F=this.proxyCoords;for(let Q=0;Qoe.overscaledZ-re.overscaledZ)}_setupProxiedCoordsForImageSource(h,x,T){if(!h.getSource().loaded())return;const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords,z=h.getSource(),H=z.tileID;if(!H)return;const Q=new i.P(H.x,H.y)._div(1<(ge.min.x=Math.min(ge.min.x,me.x-Q.x),ge.min.y=Math.min(ge.min.y,me.y-Q.y),ge.max.x=Math.max(ge.max.x,me.x-Q.x),ge.max.y=Math.max(ge.max.y,me.y-Q.y),ge),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),oe=(ge,me)=>{const xe=ge.wrap+ge.canonical.x/(1<He+re.max.x||Pe+MeBe+re.max.y};for(let ge=0;gez.key===x.tileID.key);if(F)return F}if(x.tileID.key!==h.key){const F=h.canonical.z-x.tileID.canonical.z;let z,H,Q;D=i.bC();const re=x.tileID.wrap-h.wrap<0?(z=i.al>>F,H=z*((x.tileID.canonical.x<=ge){const me=h.canonical.z-ge;x.getSource().reparseOverscaled?(H=Math.max(h.canonical.z+2,x.transform.tileZoom),z=new i.aQ(H,h.wrap,ge,h.canonical.x>>me,h.canonical.y>>me)):me!==0&&(H=ge,z=new i.aQ(H,h.wrap,ge,h.canonical.x>>me,h.canonical.y>>me))}z.key!==h.key&&(re.push(z.key),T=x.getTile(z))}const oe=ge=>{re.forEach(me=>{D[me]=ge}),re.length=0};for(H-=1;H>=Q&&(!T||!T.hasData());H--){T&&oe(T.tileID.key);const ge=z.calculateScaledKey(H);if(T=x.getTileByID(ge),T&&T.hasData())break;const me=D[ge];if(me===null)break;me===void 0?re.push(ge):T=x.getTileByID(me)}return oe(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 kv(M,h,x){const T=function(H,Q,re){const oe=i.bJ(Q,H),ge=i.bJ(re,[.2126,.7152,.0722]),me=(Pe,Me,He)=>(1-He)*Pe+He*Me,xe=me(1-.3*Math.min(ge,1),1,Math.min(oe+1,1));return me(.92,1,Math.asin(i.aA(Q[2],-1,1))/Math.PI+.5)*xe}(M,[0,0,1],h),D=[0,0,0];i.c5(D,x.slice(0,3),T);const F=[0,0,0];i.c5(F,h.slice(0,3),M[2]);const z=[0,0,0];return i.d8(z,D,F),i.db(z)}const Wce=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Gce=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class wD{static cacheKey(h,x,T,D){const F=[x];D&&F.push(D.cacheKey);for(const z of T)h.usedDefines.has(z)&&F.push(z);return F.join("/")}constructor(h,x,T,D,F,z){const H=h.gl;this.program=H.createProgram(),this.configuration=D,this.name=x,this.fixedDefines=[...z];const Q=`#version 300 es ${(D?D.defines():[]).concat(z.map(Me=>`#define ${Me}`)).join(` `)}`,re=[Q,Rce];for(const Me of T.fragmentIncludes)re.push(lx[Me]);re.push(T.fragmentSource);const oe=re.join(` `),ge=[Q,hD];for(const Me of T.vertexIncludes)ge.push(lx[Me]);this.forceManualRenderingForInstanceIDShaders=h.forceManualRenderingForInstanceIDShaders&&T.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&ge.push("uniform int u_instanceID;"),ge.push(T.vertexSource);let me=ge.join(` `);this.forceManualRenderingForInstanceIDShaders&&(me=me.replaceAll("gl_InstanceID","u_instanceID"));const xe=H.createShader(H.FRAGMENT_SHADER);if(H.isContextLost())return void(this.failedToCreate=!0);H.shaderSource(xe,oe),H.compileShader(xe),H.attachShader(this.program,xe);const Pe=H.createShader(H.VERTEX_SHADER);H.isContextLost()?this.failedToCreate=!0:(H.shaderSource(Pe,me),H.compileShader(Pe),H.attachShader(this.program,Pe),this.attributes={},H.linkProgram(this.program),H.deleteShader(Pe),H.deleteShader(xe),this.fixedUniforms=F(h),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=D?D.getUniforms(h):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(Me=>({u_instanceID:new i.ch(Me)}))(h)),(z.includes("TERRAIN")||x.includes("symbol")||x.includes("circle"))&&(this.terrainUniforms=(Me=>({u_dem:new i.ch(Me),u_dem_prev:new i.ch(Me),u_dem_tl:new i.ck(Me),u_dem_scale:new i.cj(Me),u_dem_tl_prev:new i.ck(Me),u_dem_scale_prev:new i.cj(Me),u_dem_size:new i.cj(Me),u_dem_lerp:new i.cj(Me),u_exaggeration:new i.cj(Me),u_depth:new i.ch(Me),u_depth_size_inv:new i.ck(Me),u_depth_range_unpack:new i.ck(Me),u_occluder_half_size:new i.cj(Me),u_occlusion_depth_offset:new i.cj(Me),u_meter_to_dem:new i.cj(Me),u_label_plane_matrix_inv:new i.cl(Me)}))(h)),z.includes("GLOBE")&&(this.globeUniforms=(Me=>({u_tile_tl_up:new i.ci(Me),u_tile_tr_up:new i.ci(Me),u_tile_br_up:new i.ci(Me),u_tile_bl_up:new i.ci(Me),u_tile_up_scale:new i.cj(Me)}))(h)),z.includes("FOG")&&(this.fogUniforms=(Me=>({u_fog_matrix:new i.cl(Me),u_fog_range:new i.ck(Me),u_fog_color:new i.d3(Me),u_fog_horizon_blend:new i.cj(Me),u_fog_vertical_limit:new i.ck(Me),u_fog_temporal_offset:new i.cj(Me),u_frustum_tl:new i.ci(Me),u_frustum_tr:new i.ci(Me),u_frustum_br:new i.ci(Me),u_frustum_bl:new i.ci(Me),u_globe_pos:new i.ci(Me),u_globe_radius:new i.cj(Me),u_globe_transition:new i.cj(Me),u_is_globe:new i.ch(Me),u_viewport:new i.ck(Me)}))(h)),z.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(Me=>({u_cutoff_params:new i.d3(Me)}))(h)),z.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(Me=>({u_lighting_ambient_color:new i.ci(Me),u_lighting_directional_dir:new i.ci(Me),u_lighting_directional_color:new i.ci(Me),u_ground_radiance:new i.ci(Me)}))(h)),z.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(Me=>({u_light_matrix_0:new i.cl(Me),u_light_matrix_1:new i.cl(Me),u_fade_range:new i.ck(Me),u_shadow_normal_offset:new i.ci(Me),u_shadow_intensity:new i.cj(Me),u_shadow_texel_size:new i.cj(Me),u_shadow_map_resolution:new i.cj(Me),u_shadow_direction:new i.ci(Me),u_shadow_bias:new i.ci(Me),u_shadowmap_0:new i.ch(Me),u_shadowmap_1:new i.ch(Me)}))(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,F,z,H,Q,re,oe){const ge=h.options.wireframe;if(ge.terrain===!1&&ge.layers2D===!1&&ge.layers3D===!1)return;const me=h.context;if(!(!(!ge.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!ge.layers2D||h._terrain&&h._terrain.renderingToTexture||!Wce.includes(this.name))||!(!ge.layers3D||!Gce.includes(this.name))))return;const xe=me.gl,Pe=h.wireframeDebugCache.getLinesFromTrianglesBuffer(h.frameCounter,F,me);if(!Pe)return;const Me=[...this.fixedDefines,"DEBUG_WIREFRAME"],He=h.getOrCreateProgram(this.name,{config:this.configuration,defines:Me});me.program.set(He.program);const Be=(tt,Mt,_t)=>{if(Mt[tt]&&_t[tt])for(const kt in Mt[tt])_t[tt][kt]&&_t[tt][kt].set(_t.program,kt,Mt[tt][kt].current)};re&&re.setUniforms(He.program,me,He.binderUniforms,H,{zoom:Q}),Be("fixedUniforms",this,He),Be("terrainUniforms",this,He),Be("globeUniforms",this,He),Be("fogUniforms",this,He),Be("lightsUniforms",this,He),Be("shadowUniforms",this,He),Pe.bind(),me.setColorMode(new Dn([xe.ONE,xe.ONE_MINUS_SRC_ALPHA,xe.ZERO,xe.ONE],i.ao.transparent,[!0,!0,!0,!1])),me.setDepthMode(new Ir(x.func===xe.LESS?xe.LEQUAL:x.func,Ir.ReadOnly,x.range)),me.setStencilMode(dn.disabled);const et=3*z.primitiveLength*2,ut=3*z.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const tt=oe||1;for(let Mt=0;Mt1?xe.drawElementsInstanced(xe.LINES,et,xe.UNSIGNED_SHORT,ut,oe):xe.drawElements(xe.LINES,et,xe.UNSIGNED_SHORT,ut);F.bind(),me.program.set(this.program),me.setDepthMode(x),me.setStencilMode(T),me.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,F,z,H,Q,re,oe,ge,me,xe,Pe,Me,He){const Be=h.context,et=Be.gl;if(this.failedToCreate)return;Be.program.set(this.program),Be.setDepthMode(T),Be.setStencilMode(D),Be.setColorMode(F),Be.setCullFace(z);for(const[xt,pt]of this.fixedUniformsEntries)pt.set(this.program,xt,H[xt]);Pe&&Pe.setUniforms(this.program,Be,this.binderUniforms,me,{zoom:xe});const ut={[et.POINTS]:1,[et.LINES]:2,[et.TRIANGLES]:3,[et.LINE_STRIP]:1}[x];this.checkUniforms(Q,"RENDER_SHADOWS",this.shadowUniforms);const tt=Me||[],Mt=Pe?Pe.getPaintVertexBuffers():[],_t=x===et.TRIANGLES&&oe,kt=He&&He>0?1:void 0;for(const xt of ge.get()){const pt=xt.vaos||(xt.vaos={});if((pt[Q]||(pt[Q]=new Fce)).bind(Be,this,re,Mt,oe,xt.vertexOffset,tt,kt),this.forceManualRenderingForInstanceIDShaders){const Et=He||1;for(let Ht=0;Ht1?et.drawElementsInstanced(x,xt.primitiveLength*ut,et.UNSIGNED_SHORT,xt.primitiveOffset*ut*2,He):oe?et.drawElements(x,xt.primitiveLength*ut,et.UNSIGNED_SHORT,xt.primitiveOffset*ut*2):et.drawArrays(x,xt.vertexOffset,xt.vertexLength);_t&&this._drawDebugWireframe(h,T,D,F,oe,xt,me,xe,Pe,He)}}}function jD(M,h,x=0){const T=Math.pow(2,h.tileID.overscaledZ),D=h.tileSize*Math.pow(2,M.transform.tileZoom)/T,F=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,M.transform.tileZoom),u_pixel_coord_upper:[F>>16,z>>16],u_pixel_coord_lower:[65535&F,65535&z],u_pattern_transition:x}}const BS={terrain:0,flat:1},Kce=i.bC(),$S=(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Me,He,Be)=>{const et=h.style.light,ut=et.properties.get("position"),tt=[ut.x,ut.y,ut.z],Mt=i.dO();et.properties.get("anchor")==="viewport"&&(i.dP(Mt,-h.transform.angle),i.dQ(tt,tt,Mt));const _t=et.properties.get("color").toPremultipliedRenderColor(null),kt=h.transform,xt={u_matrix:M,u_lightpos:tt,u_lightintensity:et.properties.get("intensity"),u_lightcolor:[_t.r,_t.g,_t.b],u_vertical_gradient:+x,u_opacity:T,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Kce,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:BS[re],u_base_type:BS[oe],u_ao:D,u_edge_radius:F,u_width_scale:z,u_flood_light_color:Pe,u_vertical_scale:Me,u_flood_light_intensity:He,u_ground_shadow_factor:Be};return kt.projection.name==="globe"&&(xt.u_tile_id=[H.canonical.x,H.canonical.y,1<({u_matrix:M,u_edge_radius:h,u_width_scale:x,u_vertical_scale:T,u_height_type:BS[D],u_base_type:BS[F]}),kD=(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Me,He,Be)=>{const et=$S(M,h,x,T,D,F,z,H,re,oe,ge,me,xe,Pe,Me,He,1,[0,0,0]),ut={u_height_factor:-Math.pow(2,H.overscaledZ)/Q.tileSize/8};return Object.assign(et,jD(h,Q,Be),ut)},Nv=(M,h,x,T,D,F,z,H,Q,re,oe)=>({u_matrix:h,u_opacity:x,u_ao_pass:T?1:0,u_meter_to_tile:D,u_ao:F,u_flood_light_intensity:z,u_flood_light_color:H,u_attenuation:Q,u_edge_radius:re,u_fb:0,u_fb_size:oe,u_dynamic_offset:1}),vT=(M,h,x)=>({u_matrix:M,u_emissive_strength:h,u_ground_shadow_factor:x}),_T=(M,h,x,T,D,F=0)=>Object.assign(vT(M,h,D),jD(x,T,F)),ND=(M,h,x,T)=>({u_matrix:M,u_world:x,u_emissive_strength:h,u_ground_shadow_factor:T}),bT=(M,h,x,T,D,F,z=0)=>Object.assign(_T(M,h,x,T,F,z),{u_world:D}),dx=(M,h)=>({u_matrix:M,u_ground_shadow_factor:h}),Ty=(M,h,x,T,D)=>({u_matrix:M,u_camera_pos:[h[0],h[1],h[2]],u_depth_bias:x,u_height_scale:T,u_reset_depth:D}),qS=(M,h,x,T,D,F,z,H,Q)=>({u_matrix:M,u_normal_matrix:h,u_opacity:x,u_faux_facade_ao_intensity:T,u_camera_pos:D,u_tile_to_meter:F,u_facade_emissive_chance:z,u_flood_light_color:H,u_flood_light_intensity:Q}),SD=M=>({u_matrix:M}),ux=M=>({u_matrix:M}),wT=(M,h,x,T,D,F,z,H)=>{const Q=i.al/F.tileSize;return{u_matrix:M,u_inv_rot_matrix:h,u_camera_to_center_distance:x.getCameraToCenterDistance(H),u_extrude_scale:[x.pixelsToGLUnits[0]/Q,x.pixelsToGLUnits[1]/Q],u_zoom_transition:T,u_tile_id:z,u_merc_center:D}},_b=(M,h,x=1)=>({u_matrix:M,u_color:h,u_overlay:0,u_overlay_scale:x}),CD=i.bC(),MD=(M,h,x,T,D,F,z)=>{const H=M.transform,Q=H.projection.name==="globe",re=Q?i.dR(H.zoom,h.canonical)*H._pixelsPerMercatorPixel:i.ay(x,1,F),oe={u_matrix:h.projMatrix,u_extrude_scale:re,u_intensity:z,u_inv_rot_matrix:CD,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(Q){oe.u_inv_rot_matrix=T,oe.u_merc_center=D,oe.u_tile_id=[h.canonical.x,h.canonical.y,1<({u_matrix:M,u_normalize_matrix:h,u_globe_matrix:x,u_merc_matrix:T,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:re,u_fade_t:oe.mix,u_opacity:oe.opacity*ge.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:ge.paint.get("raster-brightness-min"),u_brightness_high:ge.paint.get("raster-brightness-max"),u_saturation_factor:i.dT(ge.paint.get("raster-saturation")),u_contrast_factor:i.dS(ge.paint.get("raster-contrast")),u_spin_weights:AD(ge.paint.get("raster-hue-rotate")),u_perspective_transform:me,u_raster_elevation:xe,u_zoom_transition:z,u_merc_center:H,u_cutoff_params:Q,u_colorization_mix:US(i.dU,Me,Be),u_colorization_offset:VS(i.dU,He,Be),u_color_ramp:Pe,u_texture_offset:[ut/(et+2*ut),et/(et+2*ut)],u_texture_res:[et+2*ut,et+2*ut],u_emissive_strength:tt});function AD(M){M*=Math.PI/180;const h=Math.sin(M),x=Math.cos(M);return[(2*x+1)/3,(-Math.sqrt(3)*h-x+1)/3,(Math.sqrt(3)*h-x+1)/3]}const Ep=.05,Zce=(M,h,x,T,D,F,z,H,Q,re,oe,ge)=>({u_matrix:M,u_normalize_matrix:h,u_globe_matrix:x,u_merc_matrix:T,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:re,u_fade_t:oe.mix,u_opacity:oe.opacity,u_image0:0,u_image1:1,u_raster_elevation:ge,u_zoom_transition:z,u_merc_center:H,u_cutoff_params:Q}),Yce=(M,h,x,T,D,F,z,H,Q,re)=>({u_particle_texture:M,u_particle_texture_side_len:h,u_tile_offset:x,u_velocity:T,u_color_ramp:F,u_velocity_res:D,u_max_speed:z,u_uv_offset:H,u_data_scale:[255*Q[0],255*Q[1]],u_data_offset:re,u_particle_pos_scale:1.1,u_particle_pos_offset:[Ep,Ep]}),ED=(M,h,x,T,D,F,z,H,Q,re)=>({u_particle_texture:M,u_particle_texture_side_len:h,u_velocity:x,u_velocity_res:T,u_max_speed:D,u_speed_factor:F,u_reset_rate:z,u_rand_seed:Math.random(),u_uv_offset:H,u_data_scale:[255*Q[0],255*Q[1]],u_data_offset:re,u_particle_pos_scale:1.1,u_particle_pos_offset:[Ep,Ep]}),PD=i.bC(),HS=(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Me,He,Be,et,ut,tt,Mt,_t,kt)=>{const xt=D.transform,pt={u_is_size_zoom_constant:+(M==="constant"||M==="source"),u_is_size_feature_constant:+(M==="constant"||M==="camera"),u_size_t:h?h.uSizeT:0,u_size:h?h.uSize:0,u_camera_to_center_distance:xt.getCameraToCenterDistance(et),u_rotate_symbol:+x,u_aspect_ratio:xt.width/xt.height,u_fade_change:D.options.fadeDuration?D.symbolFadeChange:1,u_matrix:F,u_label_plane_matrix:z,u_coord_matrix:H,u_is_text:+re,u_elevation_from_sea:Q?1:0,u_pitch_with_map:+T,u_texsize:oe,u_texsize_icon:ge,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:PD,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:PD,u_up_vector:[0,-1,0],u_color_adj_mat:Mt,u_icon_transition:_t||0,u_gamma_scale:T?D.transform.getCameraToCenterDistance(et)*Math.cos(D.terrain?0:D.transform._pitch):1,u_device_pixel_ratio:i.o.devicePixelRatio,u_is_halo:1,u_scale_factor:kt||1,u_ground_shadow_factor:ut,u_inv_matrix:i.bl(i.bC(),z),u_normal_scale:tt,u_lutTexture:vc.LUT};return et.name==="globe"&&(pt.u_tile_id=[xe.canonical.x,xe.canonical.y,1<({u_matrix:M,u_emissive_strength:h,u_opacity:x,u_color:T}),hx=(M,h,x,T,D,F,z,H,Q)=>Object.assign(function(re,oe,ge,me,xe,Pe){const{width:Me,height:He}=me.imageManager.getPixelSize(oe),Be=Math.pow(2,Pe.tileID.overscaledZ),et=Pe.tileSize*Math.pow(2,me.transform.tileZoom)/Be,ut=et*(Pe.tileID.canonical.x+Pe.tileID.wrap*Be),tt=et*Pe.tileID.canonical.y;return{u_image:0,u_pattern_tl:ge.tl,u_pattern_br:ge.br,u_texsize:[Me,He],u_pattern_size:ge.displaySize,u_pattern_units_to_pixels:xe?[me.transform.width,-1*me.transform.height]:[1/i.ay(Pe,1,me.transform.tileZoom),1/i.ay(Pe,1,me.transform.tileZoom)],u_pixel_coord_upper:[ut>>16,tt>>16],u_pixel_coord_lower:[65535&ut,65535&tt]}}(0,F,z,T,H,Q),{u_matrix:M,u_emissive_strength:h,u_opacity:x}),Sv=new Float32Array(i.bA([])),Ay=(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe=[0,0,0],Pe,Me,He)=>{const Be=D.style.light,et=Be.properties.get("position"),ut=[-et.x,-et.y,et.z],tt=i.dO();Be.properties.get("anchor")==="viewport"&&(i.dP(tt,-D.transform.angle),i.dQ(ut,ut,tt));const Mt=oe.alphaMode==="MASK",_t=Be.properties.get("color").toNonPremultipliedRenderColor(null),kt=me.paint.get("model-ambient-occlusion-intensity"),xt=me.paint.get("model-color").constantOr(i.ao.white).toNonPremultipliedRenderColor(null);return xt.a=me.paint.get("model-color-mix-intensity").constantOr(0),He&&(xt.r=He[0],xt.g=He[1],xt.b=He[2],xt.a=He[3]),Me&&(xt.r=Me.color.r,xt.g=Me.color.g,xt.b=Me.color.b,xt.a=Me.colorMix,ge=Me.emissionStrength,F*=Me.opacity),{u_matrix:M,u_lighting_matrix:h,u_normal_matrix:x,u_node_matrix:T||Sv,u_lightpos:ut,u_lightintensity:Be.properties.get("intensity"),u_lightcolor:[_t.r,_t.g,_t.b],u_camera_pos:xe,u_opacity:F,u_baseTextureIsAlpha:0,u_alphaMask:+Mt,u_alphaCutoff:oe.alphaCutoff,u_baseColorFactor:z.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:H.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:Q,u_roughnessFactor:re,u_baseColorTexture:vc.BaseColor,u_metallicRoughnessTexture:vc.MetallicRoughness,u_normalTexture:vc.Normal,u_occlusionTexture:vc.Occlusion,u_emissionTexture:vc.Emission,u_lutTexture:vc.LUT,u_color_mix:xt.toArray01(),u_aoIntensity:kt,u_emissive_strength:ge,u_occlusionTextureTransform:Pe||[0,0,0,0]}},jT=(M,h=Sv,x=Sv)=>({u_matrix:M,u_instance:h,u_node_matrix:x}),WS={fillExtrusion:M=>({u_matrix:new i.cl(M),u_lightpos:new i.ci(M),u_lightintensity:new i.cj(M),u_lightcolor:new i.ci(M),u_vertical_gradient:new i.cj(M),u_opacity:new i.cj(M),u_edge_radius:new i.cj(M),u_width_scale:new i.cj(M),u_ao:new i.ck(M),u_height_type:new i.ch(M),u_base_type:new i.ch(M),u_tile_id:new i.ci(M),u_zoom_transition:new i.cj(M),u_inv_rot_matrix:new i.cl(M),u_merc_center:new i.ck(M),u_up_dir:new i.ci(M),u_height_lift:new i.cj(M),u_flood_light_color:new i.ci(M),u_vertical_scale:new i.cj(M),u_flood_light_intensity:new i.cj(M),u_ground_shadow_factor:new i.ci(M)}),fillExtrusionDepth:M=>({u_matrix:new i.cl(M),u_edge_radius:new i.cj(M),u_width_scale:new i.cj(M),u_vertical_scale:new i.cj(M),u_height_type:new i.ch(M),u_base_type:new i.ch(M)}),fillExtrusionPattern:M=>({u_matrix:new i.cl(M),u_lightpos:new i.ci(M),u_lightintensity:new i.cj(M),u_lightcolor:new i.ci(M),u_vertical_gradient:new i.cj(M),u_height_factor:new i.cj(M),u_edge_radius:new i.cj(M),u_width_scale:new i.cj(M),u_ao:new i.ck(M),u_height_type:new i.ch(M),u_base_type:new i.ch(M),u_tile_id:new i.ci(M),u_zoom_transition:new i.cj(M),u_inv_rot_matrix:new i.cl(M),u_merc_center:new i.ck(M),u_up_dir:new i.ci(M),u_height_lift:new i.cj(M),u_image:new i.ch(M),u_texsize:new i.ck(M),u_pixel_coord_upper:new i.ck(M),u_pixel_coord_lower:new i.ck(M),u_tile_units_to_pixels:new i.cj(M),u_opacity:new i.cj(M),u_pattern_transition:new i.cj(M)}),fillExtrusionGroundEffect:M=>({u_matrix:new i.cl(M),u_opacity:new i.cj(M),u_ao_pass:new i.cj(M),u_meter_to_tile:new i.cj(M),u_ao:new i.ck(M),u_flood_light_intensity:new i.cj(M),u_flood_light_color:new i.ci(M),u_attenuation:new i.cj(M),u_edge_radius:new i.cj(M),u_fb:new i.ch(M),u_fb_size:new i.cj(M),u_dynamic_offset:new i.cj(M)}),fill:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_ground_shadow_factor:new i.ci(M)}),fillPattern:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_image:new i.ch(M),u_texsize:new i.ck(M),u_pixel_coord_upper:new i.ck(M),u_pixel_coord_lower:new i.ck(M),u_tile_units_to_pixels:new i.cj(M),u_ground_shadow_factor:new i.ci(M),u_pattern_transition:new i.cj(M)}),fillOutline:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_world:new i.ck(M),u_ground_shadow_factor:new i.ci(M)}),fillOutlinePattern:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_world:new i.ck(M),u_image:new i.ch(M),u_texsize:new i.ck(M),u_pixel_coord_upper:new i.ck(M),u_pixel_coord_lower:new i.ck(M),u_tile_units_to_pixels:new i.cj(M),u_ground_shadow_factor:new i.ci(M),u_pattern_transition:new i.cj(M)}),building:M=>({u_matrix:new i.cl(M),u_normal_matrix:new i.cl(M),u_opacity:new i.cj(M),u_faux_facade_ao_intensity:new i.cj(M),u_camera_pos:new i.ci(M),u_tile_to_meter:new i.cj(M),u_facade_emissive_chance:new i.cj(M),u_flood_light_color:new i.ci(M),u_flood_light_intensity:new i.cj(M)}),buildingBloom:M=>({u_matrix:new i.cl(M)}),buildingDepth:M=>({u_matrix:new i.cl(M)}),elevatedStructuresDepth:M=>({u_matrix:new i.cl(M),u_depth_bias:new i.cj(M)}),elevatedStructures:M=>({u_matrix:new i.cl(M),u_ground_shadow_factor:new i.ci(M)}),elevatedStructuresDepthReconstruct:M=>({u_matrix:new i.cl(M),u_camera_pos:new i.ci(M),u_depth_bias:new i.cj(M),u_height_scale:new i.cj(M),u_reset_depth:new i.cj(M)}),circle:i.dY,collisionBox:M=>({u_matrix:new i.cl(M),u_inv_rot_matrix:new i.cl(M),u_camera_to_center_distance:new i.cj(M),u_extrude_scale:new i.ck(M),u_zoom_transition:new i.cj(M),u_merc_center:new i.ck(M),u_tile_id:new i.ci(M)}),collisionCircle:M=>({u_matrix:new i.cl(M),u_inv_matrix:new i.cl(M),u_camera_to_center_distance:new i.cj(M),u_viewport_size:new i.ck(M)}),debug:M=>({u_color:new i.dB(M),u_matrix:new i.cl(M),u_overlay:new i.ch(M),u_overlay_scale:new i.cj(M)}),clippingMask:M=>({u_matrix:new i.cl(M)}),heatmap:M=>({u_extrude_scale:new i.cj(M),u_intensity:new i.cj(M),u_matrix:new i.cl(M),u_inv_rot_matrix:new i.cl(M),u_merc_center:new i.ck(M),u_tile_id:new i.ci(M),u_zoom_transition:new i.cj(M),u_up_dir:new i.ci(M)}),heatmapTexture:M=>({u_image:new i.ch(M),u_color_ramp:new i.ch(M),u_opacity:new i.cj(M)}),hillshade:M=>({u_matrix:new i.cl(M),u_image:new i.ch(M),u_latrange:new i.ck(M),u_light:new i.ck(M),u_shadow:new i.dB(M),u_highlight:new i.dB(M),u_emissive_strength:new i.cj(M),u_accent:new i.dB(M)}),hillshadePrepare:M=>({u_matrix:new i.cl(M),u_image:new i.ch(M),u_dimension:new i.ck(M),u_zoom:new i.cj(M)}),line:i.dX,linePattern:i.dW,raster:M=>({u_matrix:new i.cl(M),u_normalize_matrix:new i.cl(M),u_globe_matrix:new i.cl(M),u_merc_matrix:new i.cl(M),u_grid_matrix:new i.dC(M),u_tl_parent:new i.ck(M),u_scale_parent:new i.cj(M),u_fade_t:new i.cj(M),u_opacity:new i.cj(M),u_image0:new i.ch(M),u_image1:new i.ch(M),u_brightness_low:new i.cj(M),u_brightness_high:new i.cj(M),u_saturation_factor:new i.cj(M),u_contrast_factor:new i.cj(M),u_spin_weights:new i.ci(M),u_perspective_transform:new i.ck(M),u_raster_elevation:new i.cj(M),u_zoom_transition:new i.cj(M),u_merc_center:new i.ck(M),u_cutoff_params:new i.d3(M),u_colorization_mix:new i.d3(M),u_colorization_offset:new i.cj(M),u_color_ramp:new i.ch(M),u_texture_offset:new i.ck(M),u_texture_res:new i.ck(M),u_emissive_strength:new i.cj(M)}),rasterParticle:M=>({u_matrix:new i.cl(M),u_normalize_matrix:new i.cl(M),u_globe_matrix:new i.cl(M),u_merc_matrix:new i.cl(M),u_grid_matrix:new i.dC(M),u_tl_parent:new i.ck(M),u_scale_parent:new i.cj(M),u_fade_t:new i.cj(M),u_opacity:new i.cj(M),u_image0:new i.ch(M),u_image1:new i.ch(M),u_raster_elevation:new i.cj(M),u_zoom_transition:new i.cj(M),u_merc_center:new i.ck(M),u_cutoff_params:new i.d3(M)}),rasterParticleTexture:M=>({u_texture:new i.ch(M),u_opacity:new i.cj(M)}),rasterParticleDraw:M=>({u_particle_texture:new i.ch(M),u_particle_texture_side_len:new i.cj(M),u_tile_offset:new i.ck(M),u_velocity:new i.ch(M),u_color_ramp:new i.ch(M),u_velocity_res:new i.ck(M),u_max_speed:new i.cj(M),u_uv_offset:new i.ck(M),u_data_scale:new i.ck(M),u_data_offset:new i.cj(M),u_particle_pos_scale:new i.cj(M),u_particle_pos_offset:new i.ck(M)}),rasterParticleUpdate:M=>({u_particle_texture:new i.ch(M),u_particle_texture_side_len:new i.cj(M),u_velocity:new i.ch(M),u_velocity_res:new i.ck(M),u_max_speed:new i.cj(M),u_speed_factor:new i.cj(M),u_reset_rate:new i.cj(M),u_rand_seed:new i.cj(M),u_uv_offset:new i.ck(M),u_data_scale:new i.ck(M),u_data_offset:new i.cj(M),u_particle_pos_scale:new i.cj(M),u_particle_pos_offset:new i.ck(M)}),symbol:M=>({u_is_size_zoom_constant:new i.ch(M),u_is_size_feature_constant:new i.ch(M),u_size_t:new i.cj(M),u_size:new i.cj(M),u_camera_to_center_distance:new i.cj(M),u_rotate_symbol:new i.ch(M),u_aspect_ratio:new i.cj(M),u_fade_change:new i.cj(M),u_matrix:new i.cl(M),u_label_plane_matrix:new i.cl(M),u_coord_matrix:new i.cl(M),u_is_text:new i.ch(M),u_elevation_from_sea:new i.ch(M),u_pitch_with_map:new i.ch(M),u_texsize:new i.ck(M),u_texsize_icon:new i.ck(M),u_texture:new i.ch(M),u_texture_icon:new i.ch(M),u_gamma_scale:new i.cj(M),u_device_pixel_ratio:new i.cj(M),u_tile_id:new i.ci(M),u_zoom_transition:new i.cj(M),u_inv_rot_matrix:new i.cl(M),u_merc_center:new i.ck(M),u_camera_forward:new i.ci(M),u_tile_matrix:new i.cl(M),u_up_vector:new i.ci(M),u_ecef_origin:new i.ci(M),u_is_halo:new i.ch(M),u_icon_transition:new i.cj(M),u_color_adj_mat:new i.cl(M),u_scale_factor:new i.cj(M),u_ground_shadow_factor:new i.ci(M),u_inv_matrix:new i.cl(M),u_normal_scale:new i.cj(M),u_lutTexture:new i.ch(M)}),background:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_opacity:new i.cj(M),u_color:new i.dB(M)}),backgroundPattern:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_opacity:new i.cj(M),u_image:new i.ch(M),u_pattern_tl:new i.ck(M),u_pattern_br:new i.ck(M),u_texsize:new i.ck(M),u_pattern_size:new i.ck(M),u_pixel_coord_upper:new i.ck(M),u_pixel_coord_lower:new i.ck(M),u_pattern_units_to_pixels:new i.ck(M)}),terrainRaster:M=>({u_matrix:new i.cl(M),u_image0:new i.ch(M),u_image1:new i.ch(M),u_skirt_height:new i.cj(M),u_ground_shadow_factor:new i.ci(M),u_emissive_texture_available:new i.cj(M)}),skybox:M=>({u_matrix:new i.cl(M),u_sun_direction:new i.ci(M),u_cubemap:new i.ch(M),u_opacity:new i.cj(M),u_temporal_offset:new i.cj(M)}),skyboxGradient:M=>({u_matrix:new i.cl(M),u_color_ramp:new i.ch(M),u_center_direction:new i.ci(M),u_radius:new i.cj(M),u_opacity:new i.cj(M),u_temporal_offset:new i.cj(M)}),skyboxCapture:M=>({u_matrix_3f:new i.dC(M),u_sun_direction:new i.ci(M),u_sun_intensity:new i.cj(M),u_color_tint_r:new i.d3(M),u_color_tint_m:new i.d3(M),u_luminance:new i.cj(M)}),globeRaster:M=>({u_proj_matrix:new i.cl(M),u_globe_matrix:new i.cl(M),u_normalize_matrix:new i.cl(M),u_merc_matrix:new i.cl(M),u_zoom_transition:new i.cj(M),u_merc_center:new i.ck(M),u_image0:new i.ch(M),u_image1:new i.ch(M),u_grid_matrix:new i.dC(M),u_skirt_height:new i.cj(M),u_far_z_cutoff:new i.cj(M),u_frustum_tl:new i.ci(M),u_frustum_tr:new i.ci(M),u_frustum_br:new i.ci(M),u_frustum_bl:new i.ci(M),u_globe_pos:new i.ci(M),u_globe_radius:new i.cj(M),u_viewport:new i.ck(M),u_emissive_texture_available:new i.cj(M)}),globeAtmosphere:M=>({u_frustum_tl:new i.ci(M),u_frustum_tr:new i.ci(M),u_frustum_br:new i.ci(M),u_frustum_bl:new i.ci(M),u_horizon:new i.cj(M),u_transition:new i.cj(M),u_fadeout_range:new i.cj(M),u_atmosphere_fog_color:new i.d3(M),u_high_color:new i.d3(M),u_space_color:new i.d3(M),u_temporal_offset:new i.cj(M),u_horizon_angle:new i.cj(M)}),model:M=>({u_matrix:new i.cl(M),u_lighting_matrix:new i.cl(M),u_normal_matrix:new i.cl(M),u_node_matrix:new i.cl(M),u_lightpos:new i.ci(M),u_lightintensity:new i.cj(M),u_lightcolor:new i.ci(M),u_camera_pos:new i.ci(M),u_opacity:new i.cj(M),u_baseColorFactor:new i.d3(M),u_emissiveFactor:new i.d3(M),u_metallicFactor:new i.cj(M),u_roughnessFactor:new i.cj(M),u_baseTextureIsAlpha:new i.ch(M),u_alphaMask:new i.ch(M),u_alphaCutoff:new i.cj(M),u_baseColorTexture:new i.ch(M),u_metallicRoughnessTexture:new i.ch(M),u_normalTexture:new i.ch(M),u_occlusionTexture:new i.ch(M),u_emissionTexture:new i.ch(M),u_lutTexture:new i.ch(M),u_color_mix:new i.d3(M),u_aoIntensity:new i.cj(M),u_emissive_strength:new i.cj(M),u_occlusionTextureTransform:new i.d3(M)}),modelDepth:M=>({u_matrix:new i.cl(M),u_instance:new i.cl(M),u_node_matrix:new i.cl(M)}),groundShadow:M=>({u_matrix:new i.cl(M),u_ground_shadow_factor:new i.ci(M)}),stars:M=>({u_matrix:new i.cl(M),u_up:new i.ci(M),u_right:new i.ci(M),u_intensity_multiplier:new i.cj(M)}),snowParticle:M=>({u_modelview:new i.cl(M),u_projection:new i.cl(M),u_time:new i.cj(M),u_cam_pos:new i.ci(M),u_velocityConeAperture:new i.cj(M),u_velocity:new i.cj(M),u_horizontalOscillationRadius:new i.cj(M),u_horizontalOscillationRate:new i.cj(M),u_boxSize:new i.cj(M),u_billboardSize:new i.cj(M),u_simpleShapeParameters:new i.ck(M),u_screenSize:new i.ck(M),u_thinningCenterPos:new i.ck(M),u_thinningShape:new i.ci(M),u_thinningAffectedRatio:new i.cj(M),u_thinningParticleOffset:new i.cj(M),u_particleColor:new i.d3(M),u_direction:new i.ci(M)}),rainParticle:M=>({u_modelview:new i.cl(M),u_projection:new i.cl(M),u_time:new i.cj(M),u_cam_pos:new i.ci(M),u_texScreen:new i.ch(M),u_velocityConeAperture:new i.cj(M),u_velocity:new i.cj(M),u_boxSize:new i.cj(M),u_rainDropletSize:new i.ck(M),u_distortionStrength:new i.cj(M),u_rainDirection:new i.ci(M),u_color:new i.d3(M),u_screenSize:new i.ck(M),u_thinningCenterPos:new i.ck(M),u_thinningShape:new i.ci(M),u_thinningAffectedRatio:new i.cj(M),u_thinningParticleOffset:new i.cj(M),u_shapeDirectionalPower:new i.cj(M),u_shapeNormalPower:new i.cj(M),u_mode:new i.cj(M)}),vignette:M=>({u_vignetteShape:new i.ci(M),u_vignetteColor:new i.d3(M)}),occlusion:M=>({u_matrix:new i.cl(M),u_anchorPos:new i.ci(M),u_screenSizePx:new i.ck(M),u_occluderSizePx:new i.ck(M),u_color:new i.d3(M)})};class Wm{constructor(h,x,T,D){this.id=Wm.uniqueIdxCounter,Wm.uniqueIdxCounter++,this.context=h;const F=h.gl;this.buffer=F.createBuffer(),this.dynamicDraw=!!T,this.context.unbindVAO(),h.bindElementBuffer.set(this.buffer),F.bufferData(F.ELEMENT_ARRAY_BUFFER,x.arrayBuffer,this.dynamicDraw?F.DYNAMIC_DRAW:F.STATIC_DRAW),this.dynamicDraw||D||x.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(h){this.id=Wm.uniqueIdxCounter,Wm.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)}}Wm.uniqueIdxCounter=0;const kT={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class ID{constructor(h,x,T,D,F,z){this.length=x.length,this.attributes=T,this.itemSize=x.bytesPerElement,this.dynamicDraw=D,this.instanceCount=z,this.context=h;const H=h.gl;this.buffer=H.createBuffer(),h.bindVertexBuffer.set(this.buffer),H.bufferData(H.ARRAY_BUFFER,x.arrayBuffer,this.dynamicDraw?H.DYNAMIC_DRAW:H.STATIC_DRAW),this.dynamicDraw||F||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(F,T)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class LD{constructor(h,x,T,D,F){this.context=h,this.width=x,this.height=T;const z=this.framebuffer=h.gl.createFramebuffer();D>0&&(this.colorAttachment0=new DS(h,z,0)),D>1&&(this.colorAttachment1=new DS(h,z,1)),F&&(this.depthAttachmentType=F,this.depthAttachment=F==="renderbuffer"?new wv(h,z):new gb(h,z))}createColorAttachment(h,x){x===0?this.colorAttachment0=new DS(h,this.framebuffer,0):x===1&&(this.colorAttachment1=new DS(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 Cv{constructor(h,x){this.gl=h,this.clearColor=new qce(this),this.clearDepth=new mD(this),this.clearStencil=new iT(this),this.colorMask=new AS(this),this.depthMask=new oT(this),this.stencilMask=new My(this),this.stencilFunc=new yv(this),this.stencilOp=new pb(this),this.stencilTest=new vv(this),this.depthRange=new pD(this),this.depthTest=new lT(this),this.depthFunc=new fD(this),this.blend=new _v(this),this.blendFunc=new ES(this),this.blendColor=new PS(this),this.blendEquation=new cT(this),this.cullFace=new IS(this),this.cullFaceSide=new fb(this),this.frontFace=new gD(this),this.program=new xD(this),this.activeTexture=new yD(this),this.viewport=new bv(this),this.bindFramebuffer=new vD(this),this.bindRenderbuffer=new Uce(this),this.bindTexture=new Vce(this),this.bindVertexBuffer=new Hce(this),this.bindElementBuffer=new dT(this),this.bindVertexArrayOES=new uT(this),this.pixelStoreUnpack=new hT(this),this.pixelStoreUnpackPremultiplyAlpha=new mT(this),this.pixelStoreUnpackFlipY=new _D(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 Wm(this,h,x,T)}createVertexBuffer(h,x,T,D,F){return new ID(this,h,x,T,D,F)}createRenderbuffer(h,x,T){const D=this.gl,F=D.createRenderbuffer();return this.bindRenderbuffer.set(F),D.renderbufferStorage(D.RENDERBUFFER,h,x,T),this.bindRenderbuffer.set(null),F}createFramebuffer(h,x,T,D){return new LD(this,h,x,T,D)}clear({color:h,depth:x,stencil:T,colorMask:D}){const F=this.gl;let z=0;h&&(z|=F.COLOR_BUFFER_BIT,this.clearColor.set(h.toNonPremultipliedRenderColor(null)),this.colorMask.set(D||[!0,!0,!0,!0])),x!==void 0&&(z|=F.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(x),this.depthMask.set(!0)),T!==void 0&&(z|=F.STENCIL_BUFFER_BIT,this.clearStencil.set(T),this.stencilMask.set(255)),F.clear(z)}setCullFace(h){h.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(h.mode),this.frontFace.set(h.frontFace))}setDepthMode(h){h.func!==this.gl.ALWAYS||h.mask?(this.depthTest.set(!0),this.depthFunc.set(h.func),this.depthMask.set(h.mask),this.depthRange.set(h.range)):this.depthTest.set(!1)}setStencilMode(h){h.test.func!==this.gl.ALWAYS||h.mask?(this.stencilTest.set(!0),this.stencilMask.set(h.mask),this.stencilOp.set([h.fail,h.depthFail,h.pass]),this.stencilFunc.set({func:h.test.func,ref:h.ref,mask:h.test.mask})):this.stencilTest.set(!1)}setColorMode(h){i.by(h.blendFunction,Dn.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 Ey;function vr(M,h,x,T,D,F,z){const H=M.context,Q=H.gl,re=M.transform,oe=[i.aF(re.center.lng),i.aJ(re.center.lat)],ge=x.layout.get("symbol-placement"),me=x.layout.get("text-variable-anchor"),xe=x.layout.get("icon-rotation-alignment")==="map",Pe=x.layout.get("text-rotation-alignment")==="map",Me=ge!=="point",He=[];let Be=0,et=0;for(let pt=0;pt0){const lr=i.bC(),fr=Ks;i.cP(lr,Vt.placementInvProjMatrix,re.glCoordMatrix),i.cP(lr,lr,Vt.placementViewportMatrix),He.push({circleArray:Sr,circleOffset:et,transform:fr,invTransform:lr,projection:Vt.getProjection()}),Be+=Sr.length/4,et=Be}if(!$s)continue;M.terrain&&M.terrain.setupElevationDraw(Ht,mr);const jr=Es?[Et.canonical.x,Et.canonical.y,1<=0&&(xe[ut.associatedIconIndex]={x:Vt,y:ts,z:ss,angle:ds})}else Um(_t,ge)}if(re){me.clear();const et=M.icon.placedSymbolArray;for(let ut=0;ut{let Ca=[0,0,0];if(Qa){const Fn=M.style.directionalLight,$i=M.style.ambientLight;Fn&&$i&&(Ca=Bf(M.style,Fn,$i))}return Ca},za=Qa=>{pt.depthOcclusionForSymbolsAndCircles&&(x.hasOcclusionOpacityProperties||M.terrain)&&(Qa.push("DEPTH_D24"),Qa.push("DEPTH_OCCLUSION"))},vn=Qa=>{x.lut&&!_t&&(x.lut.texture||(x.lut.texture=new i.d$(M.context,x.lut.image,[x.lut.image.height,x.lut.image.height,x.lut.image.height],kt.gl.RGBA8)),kt.activeTexture.set(kt.gl.TEXTURE0+vc.LUT),x.lut.texture&&x.lut.texture.bind(kt.gl.LINEAR,kt.gl.CLAMP_TO_EDGE),Qa.push("APPLY_LUT_ON_GPU"))},Xa=()=>{const Qa=Et&&x.layout.get("symbol-placement")!=="point",Ca=[];za(Ca),vn(Ca);const Fn=Qa||jn,$i=$s.elevationType==="road",Ao=M.shadowRenderer,ho=$i&&Vt&&!!Ao&&Ao.enabled,ji=Er(ho),ru=$i&&Vt&&!M.terrain?Yt:Bs,ed=x.paint.get("icon-image-cross-fade");M.terrainRenderModeElevated()&&Vt&&Ca.push("PITCH_WITH_MAP_TERRAIN"),Sr&&(Ca.push("PROJECTION_GLOBE_VIEW"),Fn&&Ca.push("PROJECTED_POS_ON_VIEWPORT")),ed>0&&$s.hasAnySecondaryIcon&&Ca.push("ICON_TRANSITION"),!$s.icon.zOffsetVertexBuffer||$i&&M.terrain||Ca.push("Z_OFFSET"),Be===0&&et===0&&ut===0&&tt===1||Ca.push("COLOR_ADJUSTMENT"),$s.sdfIcons&&Ca.push("RENDER_SDF"),ho&&Ca.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),$i&&Vt&&!M.terrain&&$s.icon.orientationVertexBuffer&&Ca.push("ELEVATED_ROADS");const jl=$s.icon.programConfigurations.get(x.id),gd=M.getOrCreateProgram("symbol",{config:jl,defines:Ca}),xd=Ks.imageAtlasTexture?Ks.imageAtlasTexture.size:[0,0],Pc=$s.iconSizeData,vh=i.bK(Pc,pt.zoom),um=Vt||!pt.isOrthographic,Su=Ws(lr,Ks.tileID.canonical,Vt,Et,pt,$s.getProjection(),fr),jo=cn(lr,Ks.tileID.canonical,Vt,Et,pt,$s.getProjection(),fr),Oo=M.translatePosMatrix(jo,Ks,H,re,!0),ki=M.translatePosMatrix(lr,Ks,H,re),Go=Fn?wb:Su,go=Et&&!Vt&&!Qa;let mo=Qs;!Jt&&!pt.mercatorFromTransition||Et||(mo=qf(pt));const hm=Sr?mo:Qs,Db=x.getColorAdjustmentMatrix(Be,et,ut,tt),Zm=HS(Pc.kind,vh,go,Vt,M,ki,Go,Oo,Mt,!1,xd,[0,0],0,mr,jr,Ft,ma,hm,$s.getProjection(),ji,Ga,Db,ed,null),Ob=Ks.imageAtlasTexture?Ks.imageAtlasTexture:null,Ov=x.layout.get("icon-size").constantOr(0)!==1||$s.iconsNeedLinear,Op=$s.sdfIcons||M.options.rotating||M.options.zooming||Ov||um?xt.LINEAR:xt.NEAREST,Xf=$s.sdfIcons&&x.paint.get("icon-halo-width").constantOr(1)!==0,Rv=M.terrain&&Vt&&Qa?i.bl(i.bC(),Su):wb;if(Qa&&$s.icon){const yx=i.bV.getAtTileOffsetFunc(mr,pt.center.lat,pt.worldSize,$s.getProjection()),Qf=ln(lr,Ks.tileID.canonical,Vt,Et,pt,$s.getProjection(),fr),Ym=x.layout.get("icon-size-scale-range"),Jf=i.aA(M.scaleFactor,Ym[0],Ym[1]);Rf($s,lr,M,!1,Qf,jo,Vt,Me,yx,mr,Jf)}return{program:gd,buffers:$s.icon,uniformValues:Zm,atlasTexture:Ob,atlasTextureIcon:null,atlasInterpolation:Op,atlasInterpolationIcon:null,isSDF:$s.sdfIcons,hasHalo:Xf,depthMode:ru,tile:Ks,renderWithShadows:ho,labelPlaneMatrixInv:Rv}},fi=()=>{const Qa=Ht&&x.layout.get("symbol-placement")!=="point",Ca=[],Fn=Qa||ds||jn,$i=$s.elevationType==="road",Ao=M.shadowRenderer,ho=$i&&ts&&!!Ao&&Ao.enabled,ji=Er(ho),ru=$i&&ts&&!M.terrain?Yt:Bs;M.terrainRenderModeElevated()&&ts&&Ca.push("PITCH_WITH_MAP_TERRAIN"),Sr&&(Ca.push("PROJECTION_GLOBE_VIEW"),Fn&&Ca.push("PROJECTED_POS_ON_VIEWPORT")),!$s.text.zOffsetVertexBuffer||$i&&M.terrain||Ca.push("Z_OFFSET"),$s.iconsInText&&Ca.push("RENDER_TEXT_AND_SYMBOL"),Ca.push("RENDER_SDF"),ho&&Ca.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),$i&&ts&&!M.terrain&&$s.text.orientationVertexBuffer&&Ca.push("ELEVATED_ROADS"),za(Ca);const ed=$s.text.programConfigurations.get(x.id),jl=M.getOrCreateProgram("symbol",{config:ed,defines:Ca});let gd,xd=[0,0],Pc=null;const vh=$s.textSizeData;$s.iconsInText&&(xd=Ks.imageAtlasTexture?Ks.imageAtlasTexture.size:[0,0],Pc=Ks.imageAtlasTexture?Ks.imageAtlasTexture:null,gd=ts||!pt.isOrthographic||M.options.rotating||M.options.zooming||vh.kind==="composite"||vh.kind==="camera"?xt.LINEAR:xt.NEAREST);const um=Ks.glyphAtlasTexture?Ks.glyphAtlasTexture.size:[0,0],Su=x.layout.get("text-size-scale-range"),jo=i.aA(M.scaleFactor,Su[0],Su[1]),Oo=i.bK(vh,pt.zoom,jo),ki=Ws(lr,Ks.tileID.canonical,ts,Ht,pt,$s.getProjection(),fr),Go=cn(lr,Ks.tileID.canonical,ts,Ht,pt,$s.getProjection(),fr),go=M.translatePosMatrix(Go,Ks,Q,oe,!0),mo=M.translatePosMatrix(lr,Ks,Q,oe),hm=Fn?wb:ki,Db=Ht&&!ts&&!Qa;let Zm=Qs;!Jt&&!pt.mercatorFromTransition||Ht||(Zm=qf(pt));const Ob=HS(vh.kind,Oo,Db,ts,M,mo,hm,go,Mt,!0,um,xd,0,mr,jr,Ft,ma,Sr?Zm:Qs,$s.getProjection(),ji,Ga,null,null,jo),Ov=Ks.glyphAtlasTexture?Ks.glyphAtlasTexture:null,Op=xt.LINEAR,Xf=x.paint.get("text-halo-width").constantOr(1)!==0,Rv=M.terrain&&ts&&Qa?i.bl(i.bC(),ki):wb;if(Qa&&$s.text){const yx=i.bV.getAtTileOffsetFunc(mr,pt.center.lat,pt.worldSize,$s.getProjection()),Qf=ln(lr,Ks.tileID.canonical,ts,Ht,pt,$s.getProjection(),fr);Rf($s,lr,M,!0,Qf,Go,ts,He,yx,mr,jo)}return{program:jl,buffers:$s.text,uniformValues:Ob,atlasTexture:Ov,atlasTextureIcon:Pc,atlasInterpolation:Op,atlasInterpolationIcon:gd,isSDF:!0,hasHalo:Xf,depthMode:ru,tile:Ks,renderWithShadows:ho,labelPlaneMatrixInv:Rv}},oi=$s.icon.segments.get().length,Oa=$s.text.segments.get().length,Rn=oi&&!z.onlyText?Xa():null,Za=Oa&&!z.onlyIcons?fi():null,fo=x.paint.get("icon-opacity").constantOr(1),Wi=x.paint.get("text-opacity").constantOr(1);if(ss&&$s.canOverlap){fs=!0;const Qa=fo&&!z.onlyText?$s.icon.segments.get():[],Ca=Wi&&!z.onlyIcons?$s.text.segments.get():[];for(const Fn of Qa)Es.push({segments:new i.bg([Fn]),sortKey:Fn.sortKey,state:Rn});for(const Fn of Ca)Es.push({segments:new i.bg([Fn]),sortKey:Fn.sortKey,state:Za})}else z.onlyText||Es.push({segments:fo?$s.icon.segments:new i.bg([]),sortKey:0,state:Rn}),z.onlyIcons||Es.push({segments:Wi?$s.text.segments:new i.bg([]),sortKey:0,state:Za})}fs&&Es.sort((mr,Ks)=>mr.sortKey-Ks.sortKey);for(const mr of Es){const Ks=mr.state;if(Ks)if(M.terrain?M.terrain.setupElevationDraw(Ks.tile,Ks.program,{useDepthForOcclusion:pt.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Ks.labelPlaneMatrixInv}):M.setupDepthForOcclusion(pt.depthOcclusionForSymbolsAndCircles,Ks.program),kt.activeTexture.set(xt.TEXTURE0),Ks.atlasTexture&&Ks.atlasTexture.bind(Ks.atlasInterpolation,xt.CLAMP_TO_EDGE,!0),Ks.atlasTextureIcon&&(kt.activeTexture.set(xt.TEXTURE1),Ks.atlasTextureIcon&&Ks.atlasTextureIcon.bind(Ks.atlasInterpolationIcon,xt.CLAMP_TO_EDGE,!0)),Ks.renderWithShadows&&M.shadowRenderer.setupShadows(Ks.tile.tileID.toUnwrapped(),Ks.program,"vector-tile"),M.uploadCommonLightUniforms(M.context,Ks.program),Ks.hasHalo){const $s=Ks.uniformValues;$s.u_is_halo=1,NT(Ks.buffers,mr.segments,x,M,Ks.program,Ks.depthMode,D,F,$s,2),$s.u_is_halo=0}else{if(Ks.isSDF){const $s=Ks.uniformValues;Ks.hasHalo&&($s.u_is_halo=1,NT(Ks.buffers,mr.segments,x,M,Ks.program,Ks.depthMode,D,F,$s,1)),$s.u_is_halo=0}NT(Ks.buffers,mr.segments,x,M,Ks.program,Ks.depthMode,D,F,Ks.uniformValues,1)}}}function NT(M,h,x,T,D,F,z,H,Q,re){const oe=[M.dynamicLayoutVertexBuffer,M.opacityVertexBuffer,M.iconTransitioningVertexBuffer,M.globeExtVertexBuffer,M.zOffsetVertexBuffer,M.orientationVertexBuffer];D.draw(T,T.context.gl.TRIANGLES,F,z,H,rn.disabled,Q,x.id,M.layoutVertexBuffer,M.indexBuffer,h,x.paint,T.transform.zoom,M.programConfigurations.get(x.id),oe,re)}function DD(M,h){const x=1<=Hm?1:xe.pitch/Hm))),2*Pe}(M.transform),re=M.transform.getFreeCameraOptions().position,oe="elevatedStructuresDepthReconstruct",ge=M.getOrCreateProgram(oe,{defines:["DEPTH_RECONSTRUCTION"]}),me=M.getOrCreateProgram(oe);for(const xe of T){const Pe=h.getTile(xe),Me=Pe.getBucket(x);if(!Me)continue;const He=Me.elevatedStructures;if(!He)continue;const Be=Me.elevationBufferData.heightRange,et=DD(xe.toUnwrapped(),re),ut=M.translatePosMatrix(xe.projMatrix,Pe,x.paint.get("fill-translate"),x.paint.get("fill-translate-anchor"));let tt,Mt,_t,kt;if(D==="initialize"){if(!Be||Be.min>=1||He.depthSegments.segments[0].primitiveLength===0)continue;tt=Ty(ut,et,Q,1,0),Mt=z,_t=He.depthSegments,kt=ge}else if(D==="reset"){if(!Be||Be.min>=0||He.maskSegments.segments[0].primitiveLength===0)continue;tt=Ty(ut,et,0,0,1),Mt=H,_t=He.maskSegments,kt=ge}else if(D==="geometry"){if(He.depthSegments.segments[0].primitiveLength===0)continue;tt=Ty(ut,et,Q,1,0),Mt=z,_t=He.depthSegments,kt=me}kt.draw(M,F.TRIANGLES,Mt,dn.disabled,Dn.disabled,rn.disabled,tt,x.id,He.vertexBuffer,He.indexBuffer,_t,x.paint,M.transform.zoom)}}function KS(M,h,x,T){const{painter:D,sourceCache:F,layer:z,coords:H,colorMode:Q,elevationType:re,terrainEnabled:oe,pass:ge}=M,me=D.context.gl,xe=z.paint.get("fill-pattern"),Pe=z.paint.get("fill-pattern-cross-fade"),Me=xe.constantOr(null);let He=re;re!=="road"||h&&!oe||(He="none");const Be=He==="road",et=M.painter.shadowRenderer,ut=Be&&!!et&&et.enabled,tt=new Ir(D.context.gl.LEQUAL,Ir.ReadOnly,D.depthRangeFor3D);let Mt=[0,0,0];if(ut){const pt=D.style.directionalLight,Et=D.style.ambientLight;pt&&Et&&(Mt=Bf(D.style,pt,Et))}const _t=xe&&xe.constantOr(1),kt=D.terrain&&D.terrain.renderingToTexture,xt=(pt,Et)=>{let Ht,Vt,ts,ss,fs;Et?(Ht=_t&&!z.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",ts=me.LINES):(Ht=_t?"fillPattern":"fill",ts=me.TRIANGLES);for(const Bs of H){const Yt=F.getTile(Bs);if(_t&&!Yt.patternsLoaded())continue;const Ft=Yt.getBucket(z);if(!Ft)continue;const ds=h?Ft.elevationBufferData:Ft.bufferData;if(ds.isEmpty())continue;D.prepareDrawTile();const Jt=ds.programConfigurations.get(z.id),Es=D.isTileAffectedByFog(Bs),Qs=[],mr=[];Be&&(Qs.push("ELEVATED_ROADS"),mr.push(ds.elevatedLayoutVertexBuffer)),ut&&Qs.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),kt&&x&&Qs.push("USE_MRT1"),_t&&(D.context.activeTexture.set(me.TEXTURE0),Yt.imageAtlasTexture&&Yt.imageAtlasTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE),Jt.updatePaintBuffers());let Ks=!1;if(Me&&Yt.imageAtlas){const fr=Yt.imageAtlas,Vr=i.e3.from(Me),jn=Vr.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),ma=Vr.getSecondary(),Ga=fr.patternPositions.get(jn),Er=ma?fr.patternPositions.get(ma.scaleSelf(i.o.devicePixelRatio).toString()):null;Ks=!!Ga&&!!Er,Ga&&Jt.setConstantPatternPositions(Ga,Er)}Pe>0&&(Ks||Jt.getPatternTransitionVertexBuffer("fill-pattern"))&&Qs.push("FILL_PATTERN_TRANSITION");const $s=D.getOrCreateProgram(Ht,{config:Jt,overrideFog:Es,defines:Qs}),Sr=D.translatePosMatrix(Bs.projMatrix,Yt,z.paint.get("fill-translate"),z.paint.get("fill-translate-anchor"));ut&&et.setupShadows(Yt.tileID.toUnwrapped(),$s,"vector-tile");const jr=z.paint.get("fill-emissive-strength");if(Et){ss=ds.lineIndexBuffer,fs=ds.lineSegments;const fr=D.terrain&&D.terrain.renderingToTexture?D.terrain.drapeBufferSize:[me.drawingBufferWidth,me.drawingBufferHeight];Vt=Ht==="fillOutlinePattern"&&_t?bT(Sr,jr,D,Yt,fr,Mt,Pe):ND(Sr,jr,fr,Mt)}else ss=ds.indexBuffer,fs=ds.triangleSegments,Vt=_t?_T(Sr,jr,D,Yt,Mt,Pe):vT(Sr,jr,Mt);D.uploadCommonUniforms(D.context,$s,Bs.toUnwrapped());let lr=pt;(re==="road"&&!oe||re==="offset")&&(lr=tt),$s.draw(D,ts,lr,T||D.stencilModeForClipping(Bs),Q,rn.disabled,Vt,z.id,ds.layoutVertexBuffer,ss,fs,z.paint,D.transform.zoom,Jt,mr)}};D.renderPass===ge&&xt(D.depthModeForSublayer(1,D.renderPass==="opaque"?Ir.ReadWrite:Ir.ReadOnly),!1),He==="none"&&D.renderPass==="translucent"&&z.paint.get("fill-antialias")&&xt(D.depthModeForSublayer(z.getPaintProperty("fill-outline-color")?2:0,Ir.ReadOnly),!0)}function ZS(M,h,x,T,D,F,z,H){x.resetLayerRenderingStats(M);const Q=M.context,re=Q.gl,oe=M.transform,ge=x.paint.get("fill-extrusion-pattern"),me=x.paint.get("fill-extrusion-pattern-cross-fade"),xe=ge.constantOr(null),Pe=ge.constantOr(1),Me=x.paint.get("fill-extrusion-opacity"),He=M.style.enable3dLights(),Be=x.paint.get(He&&!Pe?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),et=[x.paint.get("fill-extrusion-ambient-occlusion-intensity"),Be],ut=x.layout.get("fill-extrusion-edge-radius"),tt=ut>0&&!x.paint.get("fill-extrusion-rounded-roof"),Mt=tt?0:ut,_t=oe.projection.name==="globe"?i.eb():0,kt=oe.projection.name==="globe",xt=kt?i.aj(oe.zoom):0,pt=[i.aF(oe.center.lng),i.aJ(oe.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),Vt=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,fs=x.paint.get("fill-extrusion-height-alignment"),Bs=x.paint.get("fill-extrusion-base-alignment"),Yt=nx(M,x.paint.get("fill-extrusion-cutoff-fade-range")),Ft=[];let ds;kt&&Ft.push("PROJECTION_GLOBE_VIEW"),et[0]>0&&Ft.push("FAUX_AO"),tt&&Ft.push("ZERO_ROOF_RADIUS"),H&&Ft.push("HAS_CENTROID"),Vt>0&&Ft.push("FLOOD_LIGHT"),Yt.shouldRenderCutoff&&Ft.push("RENDER_CUTOFF"),ss&&Ft.push("RENDER_WALL_MODE");const Jt=M.renderPass==="shadow",Es=M.shadowRenderer,Qs=Jt&&!!Es,mr=Jt?rn.disabled:rn.backCCW;M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0);let Ks=[0,0,0];if(Es){const jr=M.style.directionalLight,lr=M.style.ambientLight;jr&&lr&&(Ks=Bf(M.style,jr,lr)),Jt||(Ft.push("RENDER_SHADOWS","DEPTH_TEXTURE"),Es.useNormalOffset&&Ft.push("NORMAL_OFFSET")),ds=Ft.concat(["SHADOWS_SINGLE_CASCADE"])}const $s=Qs?"fillExtrusionDepth":Pe?"fillExtrusionPattern":"fillExtrusion",Sr=x.getLayerRenderingStats();for(const jr of T){const lr=h.getTile(jr),fr=lr.getBucket(x);if(!fr||fr.projection.name!==oe.projection.name)continue;let Vr=!1;Es&&(Vr=Es.getMaxCascadeForTile(jr.toUnwrapped())===0);const jn=M.isTileAffectedByFog(jr),ma=fr.programConfigurations.get(x.id);let Ga=!1;if(xe&&lr.imageAtlas){const Oa=lr.imageAtlas,Rn=i.e3.from(xe),Za=Rn.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),fo=Rn.getSecondary(),Wi=Oa.patternPositions.get(Za),Qa=fo?Oa.patternPositions.get(fo.scaleSelf(i.o.devicePixelRatio).toString()):null;Ga=!!Wi&&!!Qa,Wi&&ma.setConstantPatternPositions(Wi,Qa)}me>0&&(Ga||ma.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Ft.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Er=M.getOrCreateProgram($s,{config:ma,defines:Vr?ds:Ft,overrideFog:jn});if(M.terrain&&M.terrain.setupElevationDraw(lr,Er,{useMeterToDem:!0}),!fr.centroidVertexBuffer){const Oa=Er.getAttributeLocation(re,"a_centroid_pos");Oa!==-1&&re.vertexAttrib2f(Oa,0,0)}!Jt&&Es&&Es.setupShadows(lr.tileID.toUnwrapped(),Er,"vector-tile"),Pe&&(M.context.activeTexture.set(re.TEXTURE0),lr.imageAtlasTexture&&lr.imageAtlasTexture.bind(re.LINEAR,re.CLAMP_TO_EDGE),ma.updatePaintBuffers());const za=x.paint.get("fill-extrusion-vertical-gradient"),vn=1/fr.tileToMeter;let Xa;if(Jt&&Es){if(Vf(lr.tileID,fr.maxHeight,M))continue;const Oa=Es.calculateShadowPassMatrixFromTile(lr.tileID.toUnwrapped());Xa=yT(Oa,Mt,vn,ts,fs,Bs)}else{const Oa=M.translatePosMatrix(jr.expandedProjMatrix,lr,x.paint.get("fill-extrusion-translate"),x.paint.get("fill-extrusion-translate-anchor")),Rn=oe.projection.createInversionMatrix(oe,jr.canonical);Xa=Pe?kD(Oa,M,za,Me,et,Mt,vn,jr,lr,_t,fs,Bs,xt,pt,Rn,Ht,ts,me):$S(Oa,M,za,Me,et,Mt,vn,jr,_t,fs,Bs,xt,pt,Rn,Ht,ts,Vt,Ks)}M.uploadCommonUniforms(Q,Er,jr.toUnwrapped(),null,Yt);let fi=fr.segments;if(oe.projection.name==="mercator"&&!Jt&&(fi=fr.getVisibleSegments(lr.tileID,M.terrain,M.transform.getFrustum(0)),!fi.get().length))continue;if(Sr)if(Jt)for(const Oa of fi.get())Sr.numRenderedVerticesInShadowPass+=Oa.primitiveLength;else for(const Oa of fi.get())Sr.numRenderedVerticesInTransparentPass+=Oa.primitiveLength;const oi=[];(M.terrain||H)&&oi.push(fr.centroidVertexBuffer),kt&&oi.push(fr.layoutVertexExtBuffer),ss&&oi.push(fr.wallVertexBuffer),Er.draw(M,Q.gl.TRIANGLES,D,F,z,mr,Xa,x.id,fr.layoutVertexBuffer,fr.indexBuffer,fi,x.paint,M.transform.zoom,ma,oi)}M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!1)}class ST{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function Uf(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Me,He,Be,et,ut){const tt=h.context,Mt=tt.gl,_t=h.transform,kt=h.transform.zoom,xt=[],pt=M.translate,Et=M.translateAnchor,Ht=M.edgeRadius,Vt=nx(h,M.cutoffFadeRange);oe==="clear"?(xt.push("CLEAR_SUBPASS"),ut&&(xt.push("CLEAR_FROM_TEXTURE"),tt.activeTexture.set(Mt.TEXTURE0),ut.bind(Mt.LINEAR,Mt.CLAMP_TO_EDGE))):oe==="sdf"?xt.push("SDF_SUBPASS"):oe==="emissive"&&(xt.push("USE_MRT1"),tt.activeTexture.set(Mt.TEXTURE0),ut.bind(Mt.LINEAR,Mt.CLAMP_TO_EDGE)),Be&&xt.push("HAS_CENTROID"),Vt.shouldRenderCutoff&&xt.push("RENDER_CUTOFF");const ts=(ss,fs,Bs,Yt,Ft)=>{let ds=xt;fs.groundRadiusBuffer!=null&&(ds=xt.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const Jt=fs.programConfigurations.get(T.id),Es=h.isTileAffectedByFog(ss),Qs=h.getOrCreateProgram("fillExtrusionGroundEffect",{config:Jt,defines:ds,overrideFog:Es}),mr=Nv(h,Yt,ge,re,Ft,[me,xe*Ft],Pe,Me,He,kt>=17?0:Ht*Ft,ut?ut.size[0]:0),Ks=[];Be&&Ks.push(fs.hiddenByLandmarkVertexBuffer),fs.groundRadiusBuffer!=null&&Ks.push(fs.groundRadiusBuffer),h.uploadCommonUniforms(tt,Qs,ss.toUnwrapped(),null,Vt),Qs.draw(h,tt.gl.TRIANGLES,F,z,H,Q,mr,T.id,fs.vertexBuffer,fs.indexBuffer,Bs,T.paint,kt,Jt,Ks)};for(const ss of D){const fs=x.getTile(ss),Bs=fs.getBucket(T);if(!Bs||Bs.projection.name!==_t.projection.name||!Bs.groundEffect||Bs.groundEffect&&!Bs.groundEffect.hasData())continue;const Yt=Bs.groundEffect,Ft=1/Bs.tileToMeter;{const ds=h.translatePosMatrix(ss.projMatrix,fs,pt,Et),Jt=Yt.getDefaultSegment();ts(ss,Yt,Jt,ds,Ft)}if(et)for(let ds=0;ds<4;ds++){const Jt=i.e9[ds](ss),Es=x.getTile(Jt);if(!Es)continue;const Qs=Es.getBucket(T);if(!Qs||Qs.projection.name!==_t.projection.name||!Qs.groundEffect||Qs.groundEffect&&!Qs.groundEffect.hasData())continue;const mr=Qs.groundEffect;let Ks,$s;ds===0?(Ks=[-i.al,0,0],$s=1):ds===1?(Ks=[i.al,0,0],$s=0):ds===2?(Ks=[0,-i.al,0],$s=3):(Ks=[0,i.al,0],$s=2);const Sr=mr.regionSegments[$s];if(!Sr)continue;const jr=new Float32Array(16);i.br(jr,ss.projMatrix,Ks),ts(ss,mr,Sr,h.translatePosMatrix(jr,fs,pt,Et),Ft)}}}function Xce(M,h,x,T,D,F,z){T.centroidVertexArray.length===0&&T.createCentroidsBuffer();const H=F?F.findDEMTileFor(x):null;if(!(H&&H.dem||z))return;F&&H&&H.dem&&T.selfDEMTileTimestamp!==H.dem._timestamp&&(T.borderDoneWithNeighborZ=[-1,-1,-1,-1],T.selfDEMTileTimestamp=H.dem._timestamp);const Q=Be=>new i.P(Math.ceil((Be+i.ed)*i.ee),0),re=Be=>{const et=h.getSource().minzoom,ut=Mt=>{const _t=h.getTileByID(Mt);if(_t&&_t.hasData())return _t.getBucket(D)},tt=[0,-1,1];for(const Mt of tt){if(Be.overscaledZ+Mt(oe[0]=Math.min(Be.min.y,et.min.y),oe[1]=Math.max(Be.max.y,et.max.y),oe[2]=i.al-et.min.x>Be.max.x?et.min.x-i.al:Be.max.x,oe),me=(Be,et)=>(oe[0]=Math.min(Be.min.x,et.min.x),oe[1]=Math.max(Be.max.x,et.max.x),oe[2]=i.al-et.min.y>Be.max.y?et.min.y-i.al:Be.max.y,oe),xe=[(Be,et)=>ge(Be,et),(Be,et)=>ge(et,Be),(Be,et)=>me(Be,et),(Be,et)=>me(et,Be)],Pe=(Be,et,ut,tt,Mt,_t,kt)=>{if(!F)return 0;const xt=[[_t?ut:Be,_t?Be:ut,0],[_t?ut:et,_t?et:ut,0]],pt=kt<0?i.al+kt:kt,Et=[_t?pt:(Be+et)/2,_t?(Be+et)/2:pt,0];return ut===0&&kt<0||ut!==0&&kt>0?F.getForTilePoints(Mt,[Et],!0,tt):xt.push(Et),F.getForTilePoints(x,xt,!0,H),Math.max(xt[0][2],xt[1][2],Et[2])/F.exaggeration()};for(let Be=0;Be<4;Be++){const et=T.borderFeatureIndices[Be];if(et.length===0)continue;const ut=i.e9[Be](x),tt=re(ut);if(!(tt&&tt instanceof i.ea))continue;const Mt=F?F.findDEMTileFor(ut):null;if(!(Mt&&Mt.dem||z)||(F&&Mt&&Mt.dem&&T.borderDEMTileTimestamp[Be]!==Mt.dem._timestamp&&(T.borderDoneWithNeighborZ[Be]=-1,T.borderDEMTileTimestamp[Be]=Mt.dem._timestamp),T.borderDoneWithNeighborZ[Be]===tt.canonical.z))continue;tt.centroidVertexArray.length===0&&tt.createCentroidsBuffer();const _t=(Be<2?1:5)-Be,kt=tt.borderDoneWithNeighborZ[_t]!==T.canonical.z,xt=tt.borderFeatureIndices[_t];let pt=0;if(T.canonical.z!==tt.canonical.z){for(const Et of et)T.showCentroid(T.featuresOnBorder[Et]);if(kt)for(const Et of xt)tt.showCentroid(tt.featuresOnBorder[Et]);T.borderDoneWithNeighborZ[Be]=tt.canonical.z,tt.borderDoneWithNeighborZ[_t]=T.canonical.z}for(const Et of et){const Ht=T.featuresOnBorder[Et],Vt=T.centroidData[Ht.centroidDataIndex],ts=Ht.borders[Be];let ss;for(;ptts[0]+3||fs[0]>ts[0]-3)break;tt.showCentroid(ss),pt++}if(ss&&ptts[1]-3)&&(Bs++,++pt!==xt.length);)ss=tt.featuresOnBorder[xt[pt]];ss=tt.featuresOnBorder[xt[fs]];let Yt=!1;if(Bs>=1){const Jt=ss.borders[_t];Math.abs(ts[0]-Jt[0])<3&&Math.abs(ts[1]-Jt[1])<3&&(Bs=1,Yt=!0,pt=fs+1)}else if(Bs===0){T.showCentroid(Ht);continue}const Ft=tt.centroidData[ss.centroidDataIndex];z&&Yt&&(((Me=Vt).flags|(He=Ft).flags)&i.ec?(Me.flags|=i.ec,He.flags|=i.ec):(Me.flags&=~i.ec,He.flags&=~i.ec));const ds=Ht.intersectsCount()>1||ss.intersectsCount()>1;if(Bs>1)pt=fs,Vt.centroidXY=Ft.centroidXY=new i.P(0,0);else if(Mt&&Mt.dem&&!ds){const Jt=xe[Be](Vt,Ft),Es=Be%2?i.al-1:0,Qs=Pe(Jt[0],Math.min(i.al-1,Jt[1]),Es,Mt,ut,Be<2,Jt[2]);Vt.centroidXY=Ft.centroidXY=Q(Qs)}else ds?Vt.centroidXY=Ft.centroidXY=new i.P(0,0):(Vt.centroidXY=T.encodeBorderCentroid(Ht),Ft.centroidXY=tt.encodeBorderCentroid(ss));T.writeCentroidToBuffer(Vt),tt.writeCentroidToBuffer(Ft)}else T.showCentroid(Ht)}T.borderDoneWithNeighborZ[Be]=tt.canonical.z,tt.borderDoneWithNeighborZ[_t]=T.canonical.z}var Me,He;(T.needsCentroidUpdate||!T.centroidVertexBuffer&&T.centroidVertexArray.length!==0)&&T.uploadCentroid(M)}const Vu=[1,0,0],CT=[0,1,0],tu=[0,0,1];function Vf(M,h,x){const T=x.transform,D=x.shadowRenderer;if(!D)return!0;const F=M.toUnwrapped(),z=T.tileSize*D._cascades[x.currentShadowCascade].scale;let H=h;if(T.elevation){const Me=T.elevation.getMinMaxForTile(M);Me&&(H+=Me.max)}const Q=[...D.shadowDirection];Q[2]=-Q[2];const re=D.computeSimplifiedTileShadowVolume(F,H,z,Q);if(!re)return!1;const oe=[Vu,CT,tu,Q,[Q[0],0,Q[2]],[0,Q[1],Q[2]]],ge=T.projection.name==="globe",me=T.scaleZoom(z),xe=i.cB.fromInvProjectionMatrix(T.invProjMatrix,T.worldSize,me,!ge),Pe=D.getCurrentCascadeFrustum();return xe.intersectsPrecise(re.vertices,re.planes,oe)===0||Pe.intersectsPrecise(re.vertices,re.planes,oe)===0}function kb(M){const{painter:h,source:x,layer:T,coords:D}=M;let F=M.defines;const z=h.context,H=h.renderPass==="shadow",Q=h.renderPass==="light-beam",re=h.shadowRenderer,oe=i.ef(h.transform.center.lat,h.transform.zoom),ge=nx(h,T.paint.get("building-cutoff-fade-range"));ge.shouldRenderCutoff&&(F=F.concat("RENDER_CUTOFF")),M.floodLightIntensity>0&&(F=F.concat("FLOOD_LIGHT"));for(const me of D){const xe=x.getTile(me),Pe=xe.getBucket(T);if(!Pe)continue;re&&re.getMaxCascadeForTile(me.toUnwrapped())===0&&(F=F.concat("SHADOWS_SINGLE_CASCADE"));const Me=Pe.programConfigurations.get(T.id);let He,Be,et,ut=h.translatePosMatrix(me.expandedProjMatrix,xe,[0,0],"map");if(ut=i.cS(i.bC(),ut,[1,1,M.verticalScale]),H&&re){if(Vf(xe.tileID,Pe.maxHeight*oe,h))continue;let Mt=re.calculateShadowPassMatrixFromTile(xe.tileID.toUnwrapped());Mt=i.cS(i.bC(),Mt,[1,1,M.verticalScale]),et=ux(Mt),He=Be=h.getOrCreateProgram("buildingDepth",{config:Me,defines:F,overrideFog:!1})}else if(Q)He=Be=h.getOrCreateProgram("buildingBloom",{config:Me,defines:F,overrideFog:!1}),et=SD(ut);else{const Mt=h.transform.calculatePosMatrix(me.toUnwrapped(),h.transform.worldSize);i.cS(Mt,Mt,[1,1,M.verticalScale]);const _t=i.bC();i.cS(_t,Mt,[1,-1,1/oe]),i.bl(_t,_t),i.eg(_t,_t);const kt=h.transform.getFreeCameraOptions().position,xt=1<{if(Q){const kt=Mt.entranceBloom;_t.draw(h,z.gl.TRIANGLES,M.depthMode,dn.disabled,M.blendMode,rn.disabled,et,T.id,kt.layoutVertexBuffer,kt.indexBuffer,kt.segmentsBucket,T.paint,h.transform.zoom,Me,[kt.layoutAttenuationBuffer,kt.layoutColorBuffer])}else{const kt=Mt.segmentsBucket;let xt=[Mt.layoutNormalBuffer,Mt.layoutCentroidBuffer,Mt.layoutColorBuffer,Mt.layoutFloodLightDataBuffer];Mt.layoutFacadePaintBuffer&&(xt=xt.concat([Mt.layoutFacadeDataBuffer,Mt.layoutFacadeVerticalRangeBuffer,Mt.layoutFacadePaintBuffer])),_t.draw(h,z.gl.TRIANGLES,M.depthMode,dn.disabled,M.blendMode,H?rn.disabled:rn.backCW,et,T.id,Mt.layoutVertexBuffer,Mt.indexBuffer,kt,T.paint,h.transform.zoom,Me,xt)}};h.uploadCommonUniforms(z,Be,me.toUnwrapped(),null,ge),Pe.buildingWithoutFacade&&tt(Pe.buildingWithoutFacade,Be),Pe.buildingWithFacade&&(He!==Be&&h.uploadCommonUniforms(z,He,me.toUnwrapped(),null,ge),tt(Pe.buildingWithFacade,He))}}function YS(M,h,x,T,D,F,z,H,Q,re,oe,ge,me){const xe=M.context.gl,Pe=M.depthModeForSublayer(1,Ir.ReadOnly,xe.LEQUAL,!0),Me=.1*(1-(He=oe))+3*He;var He;const Be=M._showOverdrawInspector,et=ge,ut=new ST;Be||Uf(ut,M,h,x,T,Pe,new dn({func:xe.ALWAYS,mask:255},255,255,xe.KEEP,xe.KEEP,xe.REPLACE),new Dn([xe.ONE,xe.ONE,xe.ONE,xe.ONE],i.ao.transparent,[!1,!1,!1,!0],xe.MIN),rn.disabled,D,"sdf",F,z,H,Q,re,Me,et,!1);{const tt=Be?dn.disabled:new dn({func:xe.EQUAL,mask:255},255,255,xe.KEEP,xe.DECR,xe.DECR),Mt=Be?M.colorModeForRenderPass():new Dn([xe.ONE_MINUS_DST_ALPHA,xe.DST_ALPHA,xe.ONE,xe.ONE],i.ao.transparent,[!0,!0,!0,!0]);Uf(ut,M,h,x,T,Pe,tt,Mt,rn.disabled,D,"color",F,z,H,Q,re,Me,et,!1)}}function XS(M){return[M[0]*i.eh,M[1]*i.eh,M[2]*i.eh,0]}function Nb(M,h,x,T,D,F,z,H,Q){const re=T.getSource(),oe=x.globeSharedBuffers;if(!oe)return;let ge,me,xe;if(h&&(ge=T.getTile(h)),re instanceof i.aU?(me=re.texture,xe=i.dK(0,0,x.transform)):ge&&h&&(me=ge.texture,xe=i.dK(h.canonical.z,h.canonical.x,x.transform)),!me||!xe)return;M||(xe=i.cS(i.bC(),xe,[1,-1,1]));const Pe=x.context,Me=Pe.gl,He=D.paint.get("raster-resampling")==="nearest"?Me.NEAREST:Me.LINEAR,Be=x.colorModeForDrapableLayerRenderPass(F),et=z.defines;et.push("GLOBE_POLES");const ut=new Ir(Me.LEQUAL,Ir.ReadWrite,x.depthRangeFor3D),tt=Float32Array.from(x.transform.expandedFarZProjMatrix),Mt=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0))));x.terrain&&x.terrain.prepareDrawTile(),Pe.activeTexture.set(Me.TEXTURE0),me.bind(He,Me.CLAMP_TO_EDGE),Pe.activeTexture.set(Me.TEXTURE1),me.bind(He,Me.CLAMP_TO_EDGE),"useMipmap"in me&&Pe.extTextureFilterAnisotropic&&x.transform.pitch>20&&Me.texParameterf(Me.TEXTURE_2D,Pe.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,Pe.extTextureFilterAnisotropicMax);const[_t,kt,xt,pt]=h?oe.getPoleBuffers(h.canonical.z,!1):oe.getPoleBuffers(0,!0),Et=D.paint.get("raster-elevation");let Ht;M?(Ht=_t,x.renderDefaultNorthPole=Et!==0):(Ht=kt,x.renderDefaultSouthPole=Et!==0);const Vt=XS(z.mix),ts=((fs,Bs,Yt,Ft,ds,Jt,Es,Qs,mr,Ks,$s,Sr,jr)=>TD(fs,Bs,Yt,new Float32Array(16),new Float32Array(9),[0,0],Ft,[0,0],[0,0,0,0],1,{opacity:1,mix:0},Jt,[0,0],Qs,2,Ks,$s,Sr,1,0,jr))(tt,Mt,xe,i.aj(x.transform.zoom),0,D,0,Et,0,Vt,z.offset,z.range,F),ss=x.getOrCreateProgram("raster",{defines:et});x.uploadCommonUniforms(Pe,ss,null),ss.draw(x,Me.TRIANGLES,ut,Q,Be,H,ts,D.id,Ht,xt,pt)}function OD(M){const h=M._nearZ,x=M.projection.farthestPixelDistance(M),T=x-h,D=.2*M.height,F=h+D;return[h,x,(F-D-h)/T,(F-h)/T]}function Hf(M,h,x,T){if(M)return h instanceof Xc&&M instanceof Jc?h.getTextureDescriptor(M,x,!0):{texture:M.texture,mix:XS(T.mix),offset:T.offset,buffer:0,tileSize:1}}var Di=i.ei([{name:"a_index",type:"Int16",components:1}]);class QS{constructor(h,x,T,D){const F={width:T[0],height:T[1],data:null},z=h.gl;this.targetColorTexture=new i.T(h,F,z.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new i.T(h,F,z.RGBA8,{useMipmap:!1}),this.context=h,this.updateParticleTexture(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 F=new i.ej;F.reserve(D);for(let z=0;z0){const Vt=i.bj(x.canonical,Q),ts=i.el(Vt);me=i.aB(new Float32Array(16),Q.globeMatrix,ts),i.aB(me,Q.projMatrix,me)}const xe=i.bC();xe[12]+=2*D/(i.o.devicePixelRatio*Q.width),xe[13]+=2*F/(i.o.devicePixelRatio*Q.height),i.aB(me,xe,me);const Pe=M.getOrCreateProgram("debug",{defines:ge}),Me=h.getTileByID(x.key);M.terrain&&M.terrain.setupElevationDraw(Me,Pe);const He=Ir.disabled,Be=dn.disabled,et=M.colorModeForRenderPass(),ut="$debug";H.activeTexture.set(re.TEXTURE0),M.emptyTexture.bind(re.LINEAR,re.CLAMP_TO_EDGE),oe?Me._makeGlobeTileDebugBuffers(M.context,Q):Me._makeDebugTileBoundsBuffers(M.context,Q.projection);const tt=Me._tileDebugBuffer||M.debugBuffer,Mt=Me._tileDebugIndexBuffer||M.debugIndexBuffer,_t=Me._tileDebugSegments||M.debugSegments;if(Pe.draw(M,re.LINE_STRIP,He,Be,et,rn.disabled,_b(me,T.toPremultipliedRenderColor(null)),ut,tt,Mt,_t,null,null,null,[Me._globeTileDebugBorderBuffer]),z){const Vt=Me.latestRawTileData,ts=Math.floor((Vt&&Vt.byteLength||0)/1024);let ss=x.canonical.toString();x.overscaledZ!==x.canonical.z&&(ss+=` => ${x.overscaledZ}`),ss+=` ${Me.state}`,ss+=` ${ts}kb`,function(fs,Bs){fs.initDebugOverlayCanvas();const Yt=fs.debugOverlayCanvas,Ft=fs.context.gl,ds=fs.debugOverlayCanvas.getContext("2d");ds.clearRect(0,0,Yt.width,Yt.height),ds.shadowColor="white",ds.shadowBlur=2,ds.lineWidth=1.5,ds.strokeStyle="white",ds.textBaseline="top",ds.font="bold 36px Open Sans, sans-serif",ds.fillText(Bs,5,5),ds.strokeText(Bs,5,5),fs.debugOverlayTexture.update(Yt),fs.debugOverlayTexture.bind(Ft.LINEAR,Ft.CLAMP_TO_EDGE)}(M,ss)}const kt=h.getTile(x).tileSize,xt=512/Math.min(kt,512)*(x.overscaledZ/Q.zoom)*.5,pt=Me._tileDebugTextBuffer||M.debugBuffer,Et=Me._tileDebugTextIndexBuffer||M.quadTriangleIndexBuffer,Ht=Me._tileDebugTextSegments||M.debugSegments;Pe.draw(M,re.TRIANGLES,He,Be,Dn.alphaBlended,rn.disabled,_b(me,i.ao.transparent.toPremultipliedRenderColor(null),xt),ut,pt,Et,Ht,null,null,null,[Me._globeTileDebugTextBuffer])}function Ly(M,h,x,T){Gt(M,0,h+x/2,M.transform.width,x,T)}function wo(M,h,x,T){Gt(M,h-x/2,0,x,M.transform.height,T)}function Gt(M,h,x,T,D,F){const z=M.context,H=z.gl;H.enable(H.SCISSOR_TEST),H.scissor(h*i.o.devicePixelRatio,x*i.o.devicePixelRatio,T*i.o.devicePixelRatio,D*i.o.devicePixelRatio),z.clear({color:F}),H.disable(H.SCISSOR_TEST)}const $D=i.ei([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:JS}=$D;function Pp(M,h,x,T){M.emplaceBack(h,x,T)}class eC{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,JS),this.indexBuffer=h.createIndexBuffer(this.indices),this.segment=i.bg.simpleSegment(0,0,36,12)}}function Dy(M,h,x,T,D,F){const z=M.context.gl,H=h.paint.get("sky-atmosphere-color"),Q=h.paint.get("sky-atmosphere-halo-color"),re=h.paint.get("sky-atmosphere-sun-intensity"),oe=((ge,me,xe,Pe,Me)=>({u_matrix_3f:ge,u_sun_direction:me,u_sun_intensity:xe,u_color_tint_r:[Pe.r,Pe.g,Pe.b,Pe.a],u_color_tint_m:[Me.r,Me.g,Me.b,Me.a],u_luminance:5e-5}))(i.eo(i.dO(),T),D,re,H.toPremultipliedRenderColor(null),Q.toPremultipliedRenderColor(null));z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+F,h.skyboxTexture,0),x.draw(M,z.TRIANGLES,Ir.disabled,dn.disabled,Dn.unblended,rn.frontCW,oe,"skyboxCapture",h.skyboxGeometry.vertexBuffer,h.skyboxGeometry.indexBuffer,h.skyboxGeometry.segment)}const qD=i.ei([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Mv{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,qD.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 Qce=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 Jce{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class UD{constructor(h){this.colorModeAlphaBlendedWriteRGB=new Dn([1,Mp,1,Mp],i.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Dn([1,0,1,0],i.ao.transparent,[!1,!1,!1,!0]),this.params=new Jce,this.updateNeeded=!0}update(h){const x=h.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Mv(x);const T=this.params.sizeRange,D=this.params.intensityRange,F=function(oe){const ge=i.eq(30),me=[];for(let xe=0;xe{const xt=F.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];kt&&xt.push("ALPHA_PASS");const pt=h.getOrCreateProgram("globeAtmosphere",{defines:xt}),Et=((Vt,ts,ss,fs,Bs,Yt,Ft,ds,Jt,Es,Qs,mr)=>({u_frustum_tl:Vt,u_frustum_tr:ts,u_frustum_br:ss,u_frustum_bl:fs,u_horizon:Bs,u_transition:Yt,u_fadeout_range:Ft,u_atmosphere_fog_color:ds.toArray01(),u_high_color:Jt.toArray01(),u_space_color:Es.toArray01(),u_temporal_offset:Qs,u_horizon_angle:mr}))(F.frustumCorners.TL,F.frustumCorners.TR,F.frustumCorners.BR,F.frustumCorners.BL,F.frustumCorners.horizon,H,He,oe,me,Pe,et,Mt);h.uploadCommonUniforms(T,pt);const Ht=this.atmosphereBuffer;Ht&&pt.draw(h,D.TRIANGLES,z,dn.disabled,kt?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,rn.backCW,Et,kt?"atmosphere_glow_alpha":"atmosphere_glow",Ht.vertexBuffer,Ht.indexBuffer,Ht.segments)};_t(!1),_t(!0)}drawStars(h,x){const T=i.aA(x.properties.get("star-intensity"),0,1);if(T===0)return;const D=h.context,F=D.gl,z=h.transform,H=h.getOrCreateProgram("stars"),Q=i.c7([]);i.c9(Q,Q,-z._pitch),i.c8(Q,Q,-z.angle),i.c9(Q,Q,i.an(z._center.lat)),i.et(Q,Q,-i.an(z._center.lng));const re=i.cc(new Float32Array(16),Q),oe=i.aB([],z.starsProjMatrix,re),ge=i.eo([],re),me=i.eu([],ge),xe=[0,1,0];i.dQ(xe,xe,me),i.c5(xe,xe,this.params.sizeMultiplier);const Pe=[1,0,0];i.dQ(Pe,Pe,me),i.c5(Pe,Pe,this.params.sizeMultiplier);const Me=(He=xe,Be=Pe,et=T,{u_matrix:Float32Array.from(oe),u_up:He,u_right:Be,u_intensity_multiplier:et});var He,Be,et;h.uploadCommonUniforms(D,H),this.starsVx&&this.starsIdx&&H.draw(h,F.TRIANGLES,Ir.disabled,dn.disabled,this.colorModeAlphaBlendedWriteRGB,rn.disabled,Me,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class tC{constructor(){this.visibleTiles=[]}updateBorders(h,x){const T=[],D=[],F=h._getRenderableCoordinates(!1,!0);for(const Q of F){const re=h.getTile(Q);if(!re.hasData())continue;const oe=re.getBucket(x);oe&&(oe.isEmpty()||(T.push(Q.key),D.push({bucket:oe,tileID:Q.canonical})))}let z=T.length!==this.visibleTiles.length;if(!z){T.sort();for(let Q=0;QQ.tileID.z-re.tileID.z||Q.tileID.x-re.tileID.x||Q.tileID.y-re.tileID.y);for(const Q of D){const re=new Array,oe=new Array,ge=Q.bucket;for(const me of ge.featuresOnBorder)H.has(me.featureId)?oe.push(me.footprintIndex):(H.add(me.featureId),re.push(me.footprintIndex));ge.updateFootprintHiddenFlags(re,i.ev,!1),ge.updateFootprintHiddenFlags(oe,i.ev,!0)}}}function sC(M,h){const x=[...M],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 rC(M,h,x,T,D){const F=x.material,z=T.context,{baseColorTexture:H,metallicRoughnessTexture:Q}=F.pbrMetallicRoughness,{normalTexture:re,occlusionTexture:oe,emissionTexture:ge}=F;function me(Pe,Me,He){if(Pe&&(M.push(Me),z.activeTexture.set(z.gl.TEXTURE0+He),Pe.gfxTexture)){const{minFilter:Be,magFilter:et,wrapS:ut,wrapT:tt}=Pe.sampler;Pe.gfxTexture.bindExtraParam(Be,et,ut,tt)}}me(H,"HAS_TEXTURE_u_baseColorTexture",vc.BaseColor),me(Q,"HAS_TEXTURE_u_metallicRoughnessTexture",vc.MetallicRoughness),me(re,"HAS_TEXTURE_u_normalTexture",vc.Normal),me(oe,"HAS_TEXTURE_u_occlusionTexture",vc.Occlusion),me(ge,"HAS_TEXTURE_u_emissionTexture",vc.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+vc.LUT),D.texture&&D.texture.bind(z.gl.LINEAR,z.gl.CLAMP_TO_EDGE),M.push("APPLY_LUT_ON_GPU")),x.texcoordBuffer&&(M.push("HAS_ATTRIBUTE_a_uv_2f"),h.push(x.texcoordBuffer)),x.colorBuffer&&(M.push(x.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),h.push(x.colorBuffer)),x.normalBuffer&&(M.push("HAS_ATTRIBUTE_a_normal_3f"),h.push(x.normalBuffer)),x.pbrBuffer&&(M.push("HAS_ATTRIBUTE_a_pbr"),M.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),h.push(x.pbrBuffer)),F.alphaMode!=="OPAQUE"&&F.alphaMode!=="MASK"||M.push("UNPREMULT_TEXTURE_IN_SHADER"),F.defined||M.push("DIFFUSE_SHADED");const xe=T.shadowRenderer;xe&&(M.push("RENDER_SHADOWS","DEPTH_TEXTURE"),xe.useNormalOffset&&M.push("NORMAL_OFFSET"))}function nC(M,h,x,T,D,F){const z=M.modelOpacity,H=h.context,Q=new Ir(h.context.gl.LEQUAL,M.isLightMesh?Ir.ReadOnly:Ir.ReadWrite,h.depthRangeFor3D),re=h.transform,oe=M.mesh,ge=oe.material,me=ge.pbrMetallicRoughness,xe=h.style.fog;let Pe;Pe=h.transform.projection.zAxisUnit==="pixels"?[...M.nodeModelMatrix]:i.aB([],T.zScaleMatrix,M.nodeModelMatrix),i.aB(Pe,T.negCameraPosMatrix,Pe);const Me=i.bl([],Pe);i.eg(Me,Me);const He=x.paint.get("model-color-use-theme").constantOr("default")==="none",Be=x.paint.get("model-emissive-strength").constantOr(0),et=Ay(new Float32Array(M.worldViewProjection),new Float32Array(Pe),new Float32Array(Me),null,h,z,me.baseColorFactor,ge.emissiveFactor,me.metallicFactor,me.roughnessFactor,ge,Be,x,void 0,void 0,M.materialOverride,M.modelColor),ut={defines:[]},tt=[],Mt=h.shadowRenderer;Mt&&(Mt.useNormalOffset=!1),rC(ut.defines,tt,oe,h,He?null:x.lut);let _t=null;if(xe){const pt=sC(M.nodeModelMatrix,h.transform);if(_t=new Float32Array(pt),re.projection.name!=="globe"){const Et=oe.aabb.min,Ht=oe.aabb.max,[Vt,ts]=xe.getOpacityForBounds(pt,Et[0],Et[1],Ht[0],Ht[1]);ut.overrideFog=Vt>=xs||ts>=xs}}const kt=nx(h,x.paint.get("model-cutoff-fade-range"));kt.shouldRenderCutoff&&ut.defines.push("RENDER_CUTOFF");const xt=h.getOrCreateProgram("model",ut);h.uploadCommonUniforms(H,xt,null,_t,kt),h.renderPass!=="shadow"&&Mt&&Mt.setupShadowsFromMatrix(M.nodeModelMatrix,xt),xt.draw(h,H.gl.TRIANGLES,Q,D,F,oe.material.doubleSided?rn.disabled:rn.backCCW,et,x.id,oe.vertexBuffer,oe.indexBuffer,oe.segments,x.paint,h.transform.zoom,void 0,tt)}function Sb(M,h){return M.style._importedAsBasemap?"basemap":h.scope}function Oy(M,h,x,T,D,F,z,H,Q,re){const oe=M.transform,ge=!!h.isGeometryBloom&&h.isGeometryBloom;if(ge&&M.renderPass==="shadow")return;const me=oe.projection.name==="globe"?i.eD(x,oe):[...x];i.aB(me,me,h.globalMatrix);const xe=i.aB([],T,me);if(h.meshes)for(const Pe of h.meshes){const Me=H.get(Pe.material.name);if(Me&&Me.opacity<=0)continue;if(Pe.material.alphaMode!=="BLEND"){z.push({mesh:Pe,depth:0,modelIndex:D,worldViewProjection:xe,nodeModelMatrix:me,isLightMesh:ge,materialOverride:Me,modelOpacity:Q,modelColor:re});continue}const He=i.af([],Pe.centroid,xe);!oe.isOrthographic&&He[2]<=0||F.push({mesh:Pe,depth:He[2],modelIndex:D,worldViewProjection:xe,nodeModelMatrix:me,isLightMesh:ge,materialOverride:Me,modelOpacity:Q,modelColor:re})}if(h.children)for(const Pe of h.children)Oy(M,Pe,x,T,D,F,z,H,Q,re)}function Gm(M,h,x,T){const D=x.shadowRenderer;if(!D)return;const F=D.getShadowPassDepthMode(),z=D.getShadowPassColorMode(),H=D.calculateShadowPassMatrixFromMatrix(h),Q=jT(H);x.getOrCreateProgram("modelDepth",{defines:x._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(x,x.context.gl.TRIANGLES,F,dn.disabled,z,rn.disabled,Q,T.id,M.vertexBuffer,M.indexBuffer,M.segments,T.paint,x.transform.zoom,void 0,void 0)}function VD(M,h,x,T,D,F){for(const z of D){const H=Object.assign({},T);H.part=z;const Q={type:"Unknown",id:h,properties:H},re={orientation:M.paint.get("model-rotation").evaluate(Q,x)};F.set(z,re)}}function HD(M,h,x,T,D,F){for(const z of D){const H=Object.assign({},T);H.part=z;const Q={type:"Unknown",id:h,properties:H},re={color:M.paint.get("model-color").evaluate(Q,x),colorMix:M.paint.get("model-color-mix-intensity").evaluate(Q,x),opacity:M.paint.get("model-opacity").evaluate(Q,x),emissionStrength:M.paint.get("model-emissive-strength").evaluate(Q,x)};F.set(z,re)}}function WD(M,h,x,T,D){let F=!1;for(const H of T)H.modelOpacity!==1&&(nC(H,M,h,D[H.modelIndex],dn.disabled,Dn.disabled),F=!0);for(const H of T)nC(H,M,h,D[H.modelIndex],H.modelOpacity!==1?M.stencilModeFor3D():dn.disabled,M.colorModeForRenderPass());F&&M.resetStencilClippingMasks();const z=Dn.additive;for(const H of x)nC(H,M,h,D[H.modelIndex],dn.disabled,H.isLightMesh?z:M.colorModeForRenderPass())}function GD(M,h,x){const T=h.updateZoomBasedPaintProperties(),D=function(F,z,H){let Q,re,oe,ge=F.terrain?F.terrain.exaggeration():0;if(F.terrain&&ge>0){const me=F.terrain,xe=me.findDEMTileFor(H);xe&&xe.dem?Q=i.eF.create(me,H,xe):ge=0}if(ge===0&&(z.terrainElevationMin=0,z.terrainElevationMax=0),ge===z.validForExaggeration&&(ge===0||Q&&Q._demTile&&Q._demTile.tileID===z.validForDEMTile.id&&Q._dem._timestamp===z.validForDEMTile.timestamp))return!1;for(const me in z.instancesPerModel){const xe=z.instancesPerModel[me];for(let Pe=0;Pere&&(re=xe.max)}const oe=i.aA(T.x,F,z)-T.x,ge=i.aA(T.y,H,Q)-T.y,me=i.cf(re,h.center.lat)-T.z;return h._zoomFromMercatorZ(Math.sqrt(oe*oe+ge*ge+me*me))}function KD(M,h,x,T,D,F,z){const H=M.context,Q=M.renderPass==="shadow",re=M.shadowRenderer,oe=Q&&re?re.getShadowPassDepthMode():new Ir(H.gl.LEQUAL,Ir.ReadWrite,M.depthRangeFor3D),ge=M.isTileAffectedByFog(F),me=M.transform.projection.name==="globe";if(x.meshes)for(const xe of x.meshes){const Pe=me?[]:["MODEL_POSITION_ON_GPU"],Me=[];let He,Be,et;const ut=!me&&T.instancedDataArray.length>20;ut&&Pe.push("INSTANCED_ARRAYS");const tt=nx(M,h.paint.get("model-cutoff-fade-range"));if(tt.shouldRenderCutoff&&Pe.push("RENDER_CUTOFF"),Q&&re)He=M.getOrCreateProgram("modelDepth",{defines:Pe}),Be=jT(z.shadowTileMatrix,z.shadowTileMatrix,Float32Array.from(x.globalMatrix)),et=re.getShadowPassColorMode();else{rC(Pe,Me,xe,M,h.paint.get("model-color-use-theme").constantOr("default")==="none"?null:h.lut),He=M.getOrCreateProgram("model",{defines:Pe,overrideFog:ge});const _t=xe.material,kt=_t.pbrMetallicRoughness,xt=h.paint.get("model-opacity").constantOr(1),pt=h.paint.get("model-emissive-strength").constantOr(0);Be=Ay(F.expandedProjMatrix,Float32Array.from(x.globalMatrix),new Float32Array(16),null,M,xt,kt.baseColorFactor,_t.emissiveFactor,kt.metallicFactor,kt.roughnessFactor,_t,pt,h,D),re&&(z.shadowUniformsInitialized?He.setShadowUniformValues(H,re.getShadowUniformValues()):(re.setupShadows(F.toUnwrapped(),He,"model-tile"),z.shadowUniformsInitialized=!0)),et=tt.shouldRenderCutoff||xt<1||_t.alphaMode!=="OPAQUE"?Dn.alphaBlended:Dn.unblended}M.uploadCommonUniforms(H,He,F.toUnwrapped(),null,tt);const Mt=xe.material.doubleSided?rn.disabled:rn.backCCW;if(ut)Me.push(T.instancedDataBuffer),He.draw(M,H.gl.TRIANGLES,oe,dn.disabled,et,Mt,Be,h.id,xe.vertexBuffer,xe.indexBuffer,xe.segments,h.paint,M.transform.zoom,void 0,Me,T.instancedDataArray.length);else{const _t=Q?"u_instance":"u_normal_matrix";for(let kt=0;ktQ[1]?z:Q,F[0]=x.max[0],z=i.aC(i.eG(),F,D),H=z[1]Q[1]?z:Q,F[1]=x.min[1],z=i.aC(i.eG(),F,D),H=z[1]Q[1]?z:Q;const re=i.aA(T[0],0,1),oe=100*h.pixelsPerMeter*i.aA(T[1],0,1),ge=i.aA(T[2],0,1),me=i.eH(i.eG(),H,Q,re),xe=Math.tan(.5*h.fovX),Pe=-me[2]*xe;if(oe===0)return me[1]<-Math.abs(Pe)?ge:1;const Me=(-Math.abs(Pe)-me[1])/oe,He=(et,ut,tt)=>(1-tt)*et+tt*ut,Be=i.aA(He(1,ge,Me),ge,1);return He(1,Be,i.aA((h.pitch-20)/20,0,1))}class ZD{}class px{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(h,x,T){{const ge=this._storage.get(x.id);if(ge)return ge.lastUsedFrameIdx=h,ge.buf}const D=T.gl,F=D.getBufferParameter(D.ELEMENT_ARRAY_BUFFER,D.BUFFER_SIZE),z=new ArrayBuffer(F),H=new Int16Array(z);D.getBufferSubData(D.ELEMENT_ARRAY_BUFFER,0,new Int16Array(z));const Q=new i.eJ;for(let ge=0;ge30&&(T.buf.destroy(),this._storage.delete(x))}destroy(){for(const[h,x]of this._storage)x.buf.destroy(),this._storage.delete(h)}}class Tv{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const Av=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 Wf{constructor(h){this.revealStart=11,this.revealRange=2}}const TT=i.ei([{type:"Float32",name:"a_pos_2f",components:2}]);class AT{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,H=new i.b0;z.emplaceBack(-1,-1),z.emplaceBack(1,-1),z.emplaceBack(1,1),z.emplaceBack(-1,1),H.emplaceBack(0,1,2),H.emplaceBack(0,2,3),this.vignetteVx=h.context.createVertexBuffer(z,TT.members),this.vignetteIdx=h.context.createIndexBuffer(H)}const D=i.bg.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){h.uploadCommonUniforms(h.context,T);const z={u_vignetteShape:(F={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:F.vignetteColor};T.draw(h,h.context.gl.TRIANGLES,Ir.disabled,dn.disabled,Dn.alphaBlended,rn.disabled,z,"vignette",this.vignetteVx,this.vignetteIdx,D)}var F}}class ET{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(h,x){const T=h.getFreeCameraOptions().position,D=T.toAltitude(),F=T.toLngLat(),z=i.an(F.lng),H=i.an(F.lat),Q=h.pixelsPerMeter/x,re=z*i.eM,oe=i.eM*Math.log(Math.tan(Math.PI/4+H/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 ge=-this._offsetYPrev+oe,me=-this._elevationPrev+D;this._accumulatedOffsetX+=(-this._offsetXPrev+re)*Q,this._accumulatedOffsetY+=ge*Q,this._accumulatedElevation+=me*Q,this._offsetXPrev=re,this._offsetYPrev=oe,this._elevationPrev=D}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function aC(M,h){return[-(M[0]-Math.floor(M[0]/h)*h),-(M[1]-Math.floor(M[1]/h)*h),-(M[2]-Math.floor(M[2]/h)*h)]}function xh(M){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=xh(this.particlesCount),D=new i.eN,F=new i.b0;let z=0;const H=i.eq(1323123451230);for(let Q=0;QT)return;const D=ku(0,1,x.revealStart,x.revealStart+x.revealRange,T);if(!this.particlesVx||!this.particlesIdx)return;const F=structuredClone(this._params);let z=[-F.direction.x,F.direction.y,-100];i.aw(z,z);const H=structuredClone(this._vignetteParams);H.strength*=D,F.overrideStyleParameters||(F.intensity=h.style.rain.state.density,F.timeFactor=h.style.rain.state.intensity,F.color=structuredClone(h.style.rain.state.color),z=structuredClone(h.style.rain.state.direction),F.screenThinning.intensity=h.style.rain.state.centerThinning,F.dropletSizeX=h.style.rain.state.dropletSize[0],F.dropletSizeYScale=h.style.rain.state.dropletSize[1]/h.style.rain.state.dropletSize[0],F.distortionStrength=100*h.style.rain.state.distortionStrength,H.strength=1,H.color=structuredClone(h.style.rain.state.vignetteColor));const Q=this.updateOnRender(h,F.timeFactor),re=h.context,oe=re.gl,ge=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},oe.RGBA8)),F.distortionStrength>0&&(re.activeTexture.set(oe.TEXTURE0),this.screenTexture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE),oe.copyTexSubImage2D(oe.TEXTURE_2D,0,0,0,0,0,h.width,h.height));const me=h.getOrCreateProgram("rainParticle");h.uploadCommonUniforms(re,me),re.activeTexture.set(oe.TEXTURE0),this.screenTexture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE);const xe=[F.color.r,F.color.g,F.color.b,F.color.a],Pe=(Me,He)=>{const Be=aC(this._movement.getPosition(),Me),et=F.dropletSizeX,ut=F.dropletSizeX*F.dropletSizeYScale,tt=h.width/2,Mt=h.height/2,_t=ku(0,F.screenThinning.start,0,1,F.screenThinning.intensity),kt=ku(.001,F.screenThinning.range,0,1,F.screenThinning.intensity),xt=ku(0,F.screenThinning.particleOffset,0,1,F.screenThinning.intensity),pt=(Et={modelview:Q.modelviewMatrix,projection:Q.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Be,velocityConeAperture:F.velocityConeAperture,velocity:F.velocity,boxSize:Me,rainDropletSize:[et,ut],distortionStrength:F.distortionStrength,rainDirection:z,color:xe,screenSize:[ge.width,ge.height],thinningCenterPos:[tt,Mt],thinningShape:[_t,kt,Math.pow(10,F.screenThinning.fadePower)],thinningAffectedRatio:F.screenThinning.affectedRatio,thinningParticleOffset:xt,shapeDirectionalPower:F.shapeDirPower,shapeNormalPower:F.shapeNormalPower,mode:He?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(F.intensity*this.particlesCount),Vt=i.bg.simpleSegment(0,0,4*Ht,2*Ht);me.draw(h,oe.TRIANGLES,Ir.disabled,dn.disabled,Dn.alphaBlended,rn.disabled,pt,"rain_particles",this.particlesVx,this.particlesIdx,Vt)};F.distortionStrength>0&&Pe(F.boxSize,!0),Pe(F.boxSize,!1),this._vignette.draw(h,H)}}const PT=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 IT extends Ry{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 Wf("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=xh(this.particlesCount),D=new i.eO,F=new i.b0;let z=0;const H=i.eq(1323123451230);for(let Q=0;Qz)return;const H=ku(0,1,F.revealStart,F.revealStart+F.revealRange,z);D.strength*=H,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 Q=this.updateOnRender(h,x.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const re=h.context,oe=re.gl,ge=h.transform,me=h.getOrCreateProgram("snowParticle");h.uploadCommonUniforms(re,me),((xe,Pe,Me)=>{const He=aC(this._movement.getPosition(),xe),Be=ge.width/2,et=ge.height/2,ut=ku(0,Me.screenThinning.start,0,1,Me.screenThinning.intensity),tt=ku(.001,Me.screenThinning.range,0,1,Me.screenThinning.intensity),Mt=ku(0,Me.screenThinning.particleOffset,0,1,Me.screenThinning.intensity),_t=(kt={modelview:Q.modelviewMatrix,projection:Q.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:He,velocityConeAperture:Me.velocityConeAperture,velocity:Me.velocity,horizontalOscillationRadius:Me.horizontalOscillationRadius,horizontalOscillationRate:Me.horizontalOscillationRate,boxSize:xe,billboardSize:1*Me.billboardSize,simpleShapeParameters:[Me.shapeFadeStart,Me.shapeFadePower],screenSize:[ge.width,ge.height],thinningCenterPos:[Be,et],thinningShape:[ut,tt,Math.pow(10,Me.screenThinning.fadePower)],thinningAffectedRatio:Me.screenThinning.affectedRatio,thinningParticleOffset:Mt,color:[Me.color.r,Me.color.g,Me.color.b,Me.color.a],direction:T},{u_modelview:Float32Array.from(kt.modelview),u_projection:Float32Array.from(kt.projection),u_time:kt.time,u_cam_pos:kt.camPos,u_velocityConeAperture:kt.velocityConeAperture,u_velocity:kt.velocity,u_horizontalOscillationRadius:kt.horizontalOscillationRadius,u_horizontalOscillationRate:kt.horizontalOscillationRate,u_boxSize:kt.boxSize,u_billboardSize:kt.billboardSize,u_simpleShapeParameters:kt.simpleShapeParameters,u_screenSize:kt.screenSize,u_thinningCenterPos:kt.thinningCenterPos,u_thinningShape:kt.thinningShape,u_thinningAffectedRatio:kt.thinningAffectedRatio,u_thinningParticleOffset:kt.thinningParticleOffset,u_particleColor:kt.color,u_direction:kt.direction});var kt;const xt=Math.round(Me.intensity*this.particlesCount),pt=i.bg.simpleSegment(0,0,4*xt,2*xt);this.particlesVx&&this.particlesIdx&&me.draw(h,oe.TRIANGLES,Ir.disabled,dn.disabled,Dn.alphaBlended,rn.disabled,_t,"snow_particles",this.particlesVx,this.particlesIdx,pt)})(x.boxSize,0,x),this._vignette.draw(h,D)}}const fx={symbol:function(M,h,x,T,D){if(M.renderPass!=="translucent")return;const F=dn.disabled,z=M.colorModeForRenderPass(),H=x.layout.get("text-variable-anchor"),Q=x.layout.get("text-size-scale-range"),re=i.aA(M.scaleFactor,Q[0],Q[1]);H&&function(me,xe,Pe,Me,He,Be,et,ut){const tt=xe.transform,Mt=He==="map",_t=Be==="map";for(const kt of me){const xt=Me.getTile(kt),pt=xt.getBucket(Pe);if(!pt||!pt.text||!pt.text.segments.get().length)continue;const Et=i.bK(pt.textSizeData,tt.zoom,ut),Ht=rm(kt,pt.getProjection(),tt),Vt=tt.calculatePixelsToTileUnitsMatrix(xt),ts=Ws(Ht,xt.tileID.canonical,_t,Mt,tt,pt.getProjection(),Vt),ss=pt.hasIconTextFit()&&pt.hasIconData();Et&&Zr(pt,Mt,_t,et,tt,ts,kt,Math.pow(2,tt.zoom-xt.tileID.overscaledZ),Et,ss)}}(T,M,x,h,x.layout.get("text-rotation-alignment"),x.layout.get("text-pitch-alignment"),D,re);const oe=x.paint.get("icon-opacity").constantOr(1)!==0,ge=x.paint.get("text-opacity").constantOr(1)!==0;x.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(oe||ge)?jb(M,h,x,T,F,z):(oe&&jb(M,h,x,T,F,z,{onlyIcons:!0}),ge&&jb(M,h,x,T,F,z,{onlyText:!0})),h.map.showCollisionBoxes&&(vr(M,h,x,T,x.paint.get("text-translate"),x.paint.get("text-translate-anchor"),!0),vr(M,h,x,T,x.paint.get("icon-translate"),x.paint.get("icon-translate-anchor"),!1))},circle:function(M,h,x,T){if(M.renderPass!=="translucent")return;const D=x.paint.get("circle-opacity"),F=x.paint.get("circle-stroke-width"),z=x.paint.get("circle-stroke-opacity"),H=x.layout.get("circle-sort-key").constantOr(1)!==void 0,Q=x.paint.get("circle-emissive-strength");if(D.constantOr(1)===0&&(F.constantOr(1)===0||z.constantOr(1)===0))return;const re=M.context,oe=re.gl,ge=M.transform,me=!(!M.terrain||!M.terrain.enabled),xe=x.layout.get("circle-elevation-reference"),Pe=M.depthModeForSublayer(0,Ir.ReadOnly),Me=new Ir(M.context.gl.LEQUAL,Ir.ReadOnly,M.depthRangeFor3D),He=xe==="none"||me?Pe:Me,Be=dn.disabled,et=M.colorModeForDrapableLayerRenderPass(Q),ut=ge.projection.name==="globe",tt=[i.aF(ge.center.lng),i.aJ(ge.center.lat)],Mt=[];for(let kt=0;ktkt.sortKey-xt.sortKey);const _t={useDepthForOcclusion:ge.depthOcclusionForSymbolsAndCircles};for(const kt of Mt){const{programConfiguration:xt,program:pt,layoutVertexBuffer:Et,dynamicBuffers:Ht,indexBuffer:Vt,uniformValues:ts,tile:ss}=kt.state,fs=kt.segments;M.terrain&&M.terrain.setupElevationDraw(ss,pt,_t),M.uploadCommonUniforms(re,pt,ss.tileID.toUnwrapped()),pt.draw(M,oe.TRIANGLES,He,Be,et,rn.disabled,ts,x.id,Et,Vt,fs,x.paint,ge.zoom,xt,Ht)}},heatmap:function(M,h,x,T){if(x.paint.get("heatmap-opacity")!==0)if(M.renderPass==="offscreen"){const D=M.context,F=D.gl,z=dn.disabled,H=new Dn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!0,!0,!0,!0]);(function(xe,Pe,Me,He){const Be=xe.gl,et=Pe.width*He,ut=Pe.height*He;xe.activeTexture.set(Be.TEXTURE1),xe.viewport.set([0,0,et,ut]);let tt=Me.heatmapFbo;if(!tt||tt&&(tt.width!==et||tt.height!==ut)){tt&&tt.destroy();const Mt=Be.createTexture();Be.bindTexture(Be.TEXTURE_2D,Mt),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),tt=Me.heatmapFbo=xe.createFramebuffer(et,ut,1,null),function(_t,kt,xt,pt,Et,Ht){const Vt=_t.gl;Vt.texImage2D(Vt.TEXTURE_2D,0,_t.extRenderToTextureHalfFloat?Vt.RGBA16F:Vt.RGBA,Et,Ht,0,Vt.RGBA,_t.extRenderToTextureHalfFloat?Vt.HALF_FLOAT:Vt.UNSIGNED_BYTE,null),pt.colorAttachment0.set(xt)}(xe,0,Mt,tt,et,ut)}else Be.bindTexture(Be.TEXTURE_2D,tt.colorAttachment0.get()),xe.bindFramebuffer.set(tt.framebuffer)})(D,M,x,M.transform.projection.name==="globe"?.5:.25),D.clear({color:i.ao.transparent});const Q=M.transform,re=Q.projection.name==="globe",oe=re?["PROJECTION_GLOBE_VIEW"]:[],ge=re?rn.frontCCW:rn.disabled,me=[i.aF(Q.center.lng),i.aJ(Q.center.lat)];for(let xe=0;xe({u_image:0,u_color_ramp:1,u_opacity:ge.paint.get("heatmap-opacity")}))(0,F),F.id,D.viewportBuffer,D.quadTriangleIndexBuffer,D.viewportSegments,F.paint,D.transform.zoom)}(M,x))},line:function(M,h,x,T){if(M.renderPass!=="translucent")return;const D=x.paint.get("line-opacity"),F=x.paint.get("line-width");if(D.constantOr(1)===0||F.constantOr(1)===0)return;const z=x.paint.get("line-emissive-strength").isConstant(),H=x.paint.get("line-emissive-strength").constantOr(0),Q=x.paint.get("line-occlusion-opacity"),re=x.layout.get("line-elevation-reference"),oe=x.layout.get("line-width-unit")==="meters",ge=re==="sea",me=!(!M.terrain||!M.terrain.enabled),xe=M.context,Pe=xe.gl;if(x.hasElevatedBuckets&&M.transform.projection.name==="globe")return;const Me=x.layout.get("line-cross-slope"),He=Me!==void 0,Be=Me<1,et=M.colorModeForDrapableLayerRenderPass(z?H:null),ut=M.terrain&&M.terrain.renderingToTexture,tt=ut?1:i.o.devicePixelRatio,Mt=x.paint.get("line-dasharray"),_t=Mt.constantOr(1),kt=x.layout.get("line-cap"),xt=Mt.constantOr(null),pt=kt.constantOr(null),Et=x.paint.get("line-pattern"),Ht=Et.constantOr(1),Vt=x.paint.get("line-pattern-cross-fade"),ts=Et.constantOr(null),ss=x.paint.get("line-opacity").constantOr(1);let fs=!Ht&&ss!==1||M.depthOcclusion&&Q>0&&Q<1;const Bs=x.paint.get("line-gradient"),Yt=Ht?"linePattern":"line",Ft=i.e2(x);let ds;if(ut&&M.terrain&&M.terrain.clipOrMaskOverlapStencilType()&&(fs=!1),Q!==0&&M.depthOcclusion){const mr=x.paint._values["line-opacity"];mr&&mr.value&&mr.value.kind==="constant"?ds=mr.value:i.w(`Occlusion opacity for layer ${x.id} is supported only when line-opacity isn't data-driven.`)}F.value.kind!=="constant"&&F.value.isLineProgressConstant===!1&&Ft.push("VARIABLE_LINE_WIDTH"),ut&&(M.emissiveMode!=="dual-source-blending"||z?M.emissiveMode==="mrt-fallback"&&Ft.push("USE_MRT1"):Ft.push("DUAL_SOURCE_BLENDING"));const Jt=(mr,Ks,$s,Sr,jr,lr)=>{for(const fr of mr){const Vr=h.getTile(fr);if(Ht&&!Vr.patternsLoaded())continue;const jn=Vr.getBucket(x);if(!jn||jn.elevationType!=="none"&&!jr||jn.elevationType==="none"&&jr)continue;M.prepareDrawTile();const ma=[...Ks],Ga=M.shadowRenderer,Er=jn.elevationType==="road"&&!!Ga&&Ga.enabled;let za=[0,0,0];if(Er){const Fn=M.style.directionalLight,$i=M.style.ambientLight;Fn&&$i&&(za=Bf(M.style,Fn,$i)),ma.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const vn=jn.programConfigurations.get(x.id);let Xa=!1;if(ts&&Vr.imageAtlas){const Fn=i.e3.from(ts),$i=Fn.getPrimary().scaleSelf(tt).toString(),Ao=Vr.imageAtlas.patternPositions.get($i),ho=Fn.getSecondary(),ji=ho?Vr.imageAtlas.patternPositions.get(ho.scaleSelf(tt).toString()):null;Xa=!!Ao&&!!ji,Ao&&vn.setConstantPatternPositions(Ao,ji)}Vt>0&&(Xa||vn.getPatternTransitionVertexBuffer("line-pattern"))&&ma.push("LINE_PATTERN_TRANSITION");const fi=M.isTileAffectedByFog(fr),oi=M.getOrCreateProgram(Yt,{config:vn,defines:ma,overrideFog:fi});if(!Ht&&xt&&pt&&Vr.lineAtlas){const Fn=Vr.lineAtlas.getDash(xt,pt);Fn&&vn.setConstantPatternPositions(Fn)}Er&&Ga.setupShadows(Vr.tileID.toUnwrapped(),oi,"vector-tile");let[Oa,Rn]=x.paint.get("line-trim-offset");(pt==="round"||pt==="square")&&Oa!==Rn&&(Oa===0&&(Oa-=1),Rn===1&&(Rn+=1));const Za=ut?fr.projMatrix:null,fo=oe?1/jn.tileToMeter/i.ay(Vr,1,M.transform.zoom):1,Wi=oe?1/jn.tileToMeter/i.ay(Vr,1,Math.floor(M.transform.zoom)):1,Qa=Ht?i.e4(M,Vr,x,Za,tt,fo,Wi,[Oa,Rn],za,Vt):i.e5(M,Vr,x,Za,jn.lineClipsArray.length,tt,fo,Wi,[Oa,Rn],za);if(Bs){const Fn=jn.gradients[x.id];let $i=Fn.texture;if(x.gradientVersion!==Fn.version){let Ao=256;if(x.stepInterpolant){const ho=h.getSource().maxzoom,ji=fr.canonical.z===ho?Math.ceil(1<{ds!=null&&(ds.value=ss*Q),oi.draw(M,Pe.TRIANGLES,$s,Fn,et,rn.disabled,Qa,x.id,jn.layoutVertexBuffer,jn.indexBuffer,jn.segments,x.paint,M.transform.zoom,vn,[jn.layoutVertexBuffer2,jn.patternVertexBuffer,jn.zOffsetVertexBuffer]),ds!=null&&(ds.value=ss)};if(fs&&!jr){const Fn=M.stencilModeForClipping(fr).ref;Fn===0&&ut&&xe.clear({stencil:0});const $i={func:Pe.EQUAL,mask:255};Qa.u_alpha_discard_threshold=.8,Ca(new dn($i,Fn,255,Pe.KEEP,Pe.KEEP,Pe.INVERT)),Qa.u_alpha_discard_threshold=0,Ca(new dn($i,Fn,255,Pe.KEEP,Pe.KEEP,Pe.KEEP))}else Qa.u_alpha_discard_threshold=fs&&jr&&lr?.8:0,Ca(jr?Sr:M.stencilModeForClipping(fr))}};let Es=M.depthModeForSublayer(0,Ir.ReadOnly);const Qs=new Ir(M.depthOcclusion?Pe.GREATER:Pe.LEQUAL,Ir.ReadOnly,M.depthRangeFor3D);if(x.hasNonElevatedBuckets){const mr=!ut&&M.terrain;Q!==0&&mr?i.w(`Occlusion opacity for layer ${x.id} is supported on terrain only if the layer has line-z-offset enabled.`):mr?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${x.id}.`):Jt(T,Ft,Es,dn.disabled,!1,!0)}if(x.hasElevatedBuckets){re==="hd-road-markup"?me||(Es=Qs,Ft.push("ELEVATED_ROADS")):(Ft.push("ELEVATED"),Es=Qs,He&&Ft.push(Be?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),ge&&Ft.push("ELEVATION_REFERENCE_SEA"));const mr=fs?M.stencilModeFor3D():dn.disabled;M.forceTerrainMode=!0,Jt(T,Ft,Es,mr,!0,!0),fs&&Jt(T,Ft,Es,mr,!0,!1),M.forceTerrainMode=!1}fs&&(M.resetStencilClippingMasks(),ut&&xe.clear({stencil:0})),Q===0||M.depthOcclusion||ut||M.layersWithOcclusionOpacity.push(M.currentLayer)},fill:function(M,h,x,T){const D=x.paint.get("fill-color"),F=x.paint.get("fill-opacity");if(F.constantOr(1)===0)return;const z=x.paint.get("fill-emissive-strength"),H=M.colorModeForDrapableLayerRenderPass(z),Q=x.paint.get("fill-pattern"),re=M.opaquePassEnabledForLayer()&&!Q.constantOr(1)&&D.constantOr(i.ao.transparent).a===1&&F.constantOr(0)===1?"opaque":"translucent";let oe="none";x.layout.get("fill-elevation-reference")!=="none"?oe="road":x.paint.get("fill-z-offset").constantOr(1)!==0&&(oe="offset");const ge=!(!M.terrain||!M.terrain.enabled),me={painter:M,sourceCache:h,layer:x,coords:T,colorMode:H,elevationType:oe,terrainEnabled:ge,pass:re};if(M.renderPass==="shadow")return void(M.shadowRenderer&&oe==="road"&&!ge&&function(Pe){const{painter:Me,sourceCache:He,layer:Be,coords:et}=Pe,ut=Me.context.gl,tt=Pe.painter.shadowRenderer;for(const Mt of et){const _t=He.getTile(Mt),kt=_t.getBucket(Be);if(!kt)continue;const xt=kt.elevatedStructures;if(!xt||!xt.shadowCasterSegments||xt.shadowCasterSegments.segments[0].primitiveLength===0)continue;Me.prepareDrawTile();const pt=kt.bufferData.programConfigurations.get(Be.id),Et=Me.isTileAffectedByFog(Mt),Ht=Me.getOrCreateProgram("elevatedStructuresDepth",{config:pt,overrideFog:Et}),Vt=tt.calculateShadowPassMatrixFromTile(_t.tileID.toUnwrapped());Me.uploadCommonUniforms(Me.context,Ht,Mt.toUnwrapped());const ts={u_matrix:Vt,u_depth_bias:0};Ht.draw(Me,ut.TRIANGLES,tt.getShadowPassDepthMode(),dn.disabled,tt.getShadowPassColorMode(),rn.disabled,ts,Be.id,xt.vertexBuffer,xt.indexBuffer,xt.shadowCasterSegments,Be.paint,Me.transform.zoom,pt)}}(me));const xe=M.emissiveMode==="mrt-fallback";if(oe!=="offset"){if(KS(me,!1,xe),oe==="road"){const Pe=!ge&&M.renderPass==="translucent";Pe&&GS(M,h,x,T,"geometry"),KS(me,!0,xe,dn.disabled),Pe&&function(Me){const{painter:He,sourceCache:Be,layer:et,coords:ut,colorMode:tt}=Me,Mt=He.context.gl,_t=Me.painter.shadowRenderer,kt=!!_t&&_t.enabled,xt=new Ir(He.context.gl.LEQUAL,Ir.ReadOnly,He.depthRangeFor3D);let pt=[0,0,0];if(kt){const Ht=He.style.directionalLight,Vt=He.style.ambientLight;Ht&&Vt&&(pt=Bf(He.style,Ht,Vt))}const Et=Ht=>{for(const Vt of ut){const ts=Be.getTile(Vt),ss=ts.getBucket(et);if(!ss)continue;const fs=ss.elevatedStructures;if(!fs)continue;let Bs,Yt;if(Ht?(Bs=fs.renderableBridgeSegments,Yt=fs.bridgeProgramConfigurations.get(et.id)):(Bs=fs.renderableTunnelSegments,Yt=fs.tunnelProgramConfigurations.get(et.id)),!Bs||Bs.segments[0].primitiveLength===0)continue;Yt.updatePaintBuffers(),He.prepareDrawTile();const Ft=He.isTileAffectedByFog(Vt),ds=[];kt&&ds.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const Jt=He.getOrCreateProgram("elevatedStructures",{config:Yt,overrideFog:Ft,defines:ds}),Es=He.translatePosMatrix(Vt.projMatrix,ts,et.paint.get("fill-translate"),et.paint.get("fill-translate-anchor"));kt&&_t.setupShadows(ts.tileID.toUnwrapped(),Jt,"vector-tile");const Qs=dx(Es,pt);He.uploadCommonUniforms(He.context,Jt,Vt.toUnwrapped()),Jt.draw(He,Mt.TRIANGLES,xt,dn.disabled,tt,rn.backCCW,Qs,et.id,fs.vertexBuffer,fs.indexBuffer,Bs,et.paint,He.transform.zoom,Yt,[fs.vertexBufferNormal])}};Et(!0),Et(!1)}(me)}}else KS(me,!1,xe,M.stencilModeFor3D())},"fill-extrusion":function(M,h,x,T){const D=x.paint.get("fill-extrusion-opacity"),F=M.context,z=F.gl,H=M.terrain,Q=H&&H.renderingToTexture;if(D===0)return;const re=M.emissiveMode==="mrt-fallback",oe=M.conflationActive&&M.style.isLayerClipped(x,h.getSource()),ge=M.style.order.indexOf(x.fqid);if(oe&&function(me,xe,Pe,Me,He){for(const Be of Me){const et=xe.getTile(Be).getBucket(Pe);et&&(et.updateReplacement(Be,me.replacementSource,He),et.uploadCentroid(me.context))}}(M,h,x,T,ge),H||oe)for(const me of T){const xe=h.getTile(me).getBucket(x);xe&&Xce(M.context,h,me,xe,x,H,oe)}if(M.renderPass==="shadow"&&M.shadowRenderer){const me=M.shadowRenderer;if(H&&D<.65&&x._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof i.ad)return;const xe=me.getShadowPassDepthMode(),Pe=me.getShadowPassColorMode();ZS(M,h,x,T,xe,dn.disabled,Pe,oe)}else if(M.renderPass==="translucent"){const me=!x.paint.get("fill-extrusion-pattern").constantOr(1),xe=x.paint.get("fill-extrusion-color").constantOr(i.ao.white);if(!Q&&xe.a!==0){const Pe=new Ir(M.context.gl.LEQUAL,Ir.ReadWrite,M.depthRangeFor3D);D===1&&me?ZS(M,h,x,T,Pe,dn.disabled,Dn.unblended,oe):(ZS(M,h,x,T,Pe,dn.disabled,Dn.disabled,oe),ZS(M,h,x,T,Pe,M.stencilModeFor3D(),M.colorModeForRenderPass(),oe),M.resetStencilClippingMasks())}if(M.style.enable3dLights()&&me&&(!H&&M.transform.projection.name!=="globe"||Q)){const Pe=x.paint.get("fill-extrusion-opacity"),Me=x.paint.get("fill-extrusion-ambient-occlusion-intensity"),He=x.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),Be=x.paint.get("fill-extrusion-flood-light-intensity"),et=x.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",ut=x.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(et?null:x.lut).toArray01().slice(0,3),tt=Me>0&&He>0,Mt=Be>0,_t=(pt,Et,Ht)=>(1-Ht)*pt+Ht*Et,kt=new ST;kt.translate=x.paint.get("fill-extrusion-translate"),kt.translateAnchor=x.paint.get("fill-extrusion-translate-anchor"),kt.edgeRadius=x.layout.get("fill-extrusion-edge-radius"),kt.cutoffFadeRange=x.paint.get("fill-extrusion-cutoff-fade-range");const xt=pt=>{const Et=M.depthModeForSublayer(1,Ir.ReadOnly,z.LEQUAL,!0),Ht=x.paint.get(pt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Vt=_t(.1,3,Ht),ts=M._showOverdrawInspector;if(!ts){const ss=new dn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),fs=new Dn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);Uf(kt,M,h,x,T,Et,ss,fs,rn.disabled,pt,"sdf",Pe,Me,He,Be,ut,Vt,oe,!1)}{const ss=ts?dn.disabled:new dn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),fs=ts?M.colorModeForRenderPass():new Dn([z.ONE_MINUS_DST_ALPHA,z.DST_ALPHA,z.ONE,z.ONE],i.ao.transparent,[!0,!0,!0,!0]);Uf(kt,M,h,x,T,Et,ss,fs,rn.disabled,pt,"color",Pe,Me,He,Be,ut,Vt,oe,!1)}};if(Q){const pt=()=>{const Ht=H.drapeBufferSize[0],Vt=H.drapeBufferSize[1];let ts=H.framebufferCopyTexture;return ts&&(!ts||ts.size[0]===Ht&&ts.size[1]===Vt)||(ts&&ts.destroy(),ts=H.framebufferCopyTexture=new i.T(F,new i.q({width:Ht,height:Vt}),z.RGBA8)),ts.bind(z.LINEAR,z.CLAMP_TO_EDGE),z.copyTexSubImage2D(z.TEXTURE_2D,0,0,0,0,0,Ht,Vt),ts},Et=(Ht,Vt,ts)=>{const ss=M.depthModeForSublayer(1,Ir.ReadOnly,z.LEQUAL,!1),fs=x.paint.get(Ht?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Bs=_t(.1,3,fs);{const Yt=new Dn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0]);Uf(kt,M,h,x,T,ss,dn.disabled,Yt,rn.disabled,Ht,"clear",Pe,Me,He,Be,ut,Bs,oe,Vt)}{const Yt=new dn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),Ft=new Dn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);Uf(kt,M,h,x,T,ss,Yt,Ft,rn.disabled,Ht,"sdf",Pe,Me,He,Be,ut,Bs,oe,Vt)}re&&!Ht&&(ts=pt());{const Yt=Ht?z.ZERO:z.ONE_MINUS_DST_ALPHA,Ft=new dn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),ds=new Dn([Yt,z.DST_ALPHA,z.ONE_MINUS_DST_ALPHA,z.ZERO],i.ao.transparent,[!0,!0,!0,!0]);Uf(kt,M,h,x,T,ss,Ft,ds,rn.disabled,Ht,"color",Pe,Me,He,Be,ut,Bs,oe,Vt)}if(!re||Ht){const Yt=new Dn([z.ONE,z.ONE,z.ONE,Ht?z.ZERO:z.ONE],i.ao.transparent,[!1,!1,!1,!0],Ht?z.FUNC_ADD:z.MAX);Uf(kt,M,h,x,T,ss,dn.disabled,Yt,rn.disabled,Ht,"clear",Pe,Me,He,Be,ut,Bs,oe,Vt,ts)}else{z.drawBuffers([z.NONE,z.COLOR_ATTACHMENT1]);const Yt=new dn({func:z.EQUAL,mask:255},254,255,z.KEEP,z.DECR,z.DECR),Ft=new Dn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!0,!1,!1,!1],z.MAX);Uf(kt,M,h,x,T,ss,Yt,Ft,rn.disabled,Ht,"emissive",Pe,Me,He,Be,ut,Bs,oe,Vt,ts),z.drawBuffers([z.COLOR_ATTACHMENT0])}};if(tt||Mt){let Ht;M.prepareDrawTile(),re&&!tt||(Ht=pt()),tt&&Et(!0,!1,Ht),Mt&&Et(!1,!0,Ht)}}else tt&&xt(!0),Mt&&xt(!1),(tt||Mt)&&M.resetStencilClippingMasks()}}},building:function(M,h,x,T){M.currentLayer0&&F>0,re=!0;const oe=x.paint.get("building-vertical-scale");if(oe<=0)return;M.shadowRenderer||(re=!1);const ge=M.conflationActive&&M.style.isLayerClipped(x,h.getSource()),me=M.style.order.indexOf(x.fqid);if(function(xe,Pe,Me,He,Be,et){for(const ut of et){const tt=Pe.getTile(ut).getBucket(Me);tt&&(Be&&tt.updateReplacement(ut,xe.replacementSource,He),tt.uploadUpdatedIndexBuffer(xe.context))}}(M,h,x,me,ge,T),function(xe,Pe,Me,He){for(const Be of He){const et=Pe.getTile(Be).getBucket(Me);et&&et.needsEvaluation()&&et.uploadUpdatedColorBuffer(xe.context)}}(M,h,x,T),x.resetLayerRenderingStats(M),M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0),M.renderPass==="shadow"&&M.shadowRenderer){const xe=M.shadowRenderer,Pe=[],Me=xe.getShadowPassDepthMode();kb({painter:M,source:h,layer:x,coords:T,defines:Pe,blendMode:xe.getShadowPassColorMode(),depthMode:Me,opacity:H,verticalScale:oe,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(M.renderPass==="translucent"){let xe=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];re&&(xe=xe.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),M.shadowRenderer&&M.shadowRenderer.useNormalOffset&&(xe=xe.concat("NORMAL_OFFSET"));const Pe=x.paint.get("building-facade-emissive-chance"),Me=x.paint.get("building-ambient-occlusion-intensity"),He=x.paint.get("building-flood-light-intensity"),Be=x.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",et=x.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(Be?null:x.lut).toArray01().slice(0,3),ut=x.paint.get("building-flood-light-ground-attenuation"),tt=He>0,Mt=new Ir(M.context.gl.LEQUAL,Ir.ReadWrite,M.depthRangeFor3D);H<1&&kb({painter:M,source:h,layer:x,coords:T,defines:xe,blendMode:Dn.disabled,depthMode:Mt,opacity:H,verticalScale:oe,facadeEmissiveChance:Pe,facadeAOIntensity:Me,floodLightIntensity:He,floodLightColor:et,depthOnly:!0});const _t=M.colorModeForRenderPass();kb({painter:M,source:h,layer:x,coords:T,defines:xe,blendMode:_t,depthMode:Mt,opacity:H,verticalScale:oe,facadeEmissiveChance:Pe,facadeAOIntensity:Me,floodLightIntensity:He,floodLightColor:et}),Q&&YS(M,h,x,T,!0,H,D,F,He,et,z,ge),tt&&YS(M,h,x,T,!1,H,D,F,He,et,ut,ge)}else if(M.renderPass==="light-beam"){const xe=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],Pe=new Ir(M.context.gl.LEQUAL,Ir.ReadOnly,M.depthRangeFor3D);kb({painter:M,source:h,layer:x,coords:T,defines:xe,blendMode:Dn.alphaBlended,depthMode:Pe,opacity:H,verticalScale:oe,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!1),M.resetStencilClippingMasks()},hillshade:function(M,h,x,T){if(M.renderPass!=="offscreen"&&M.renderPass!=="translucent"||M.style.disableElevatedTerrain)return;const D=M.context,F=M.terrain&&M.terrain.renderingToTexture,[z,H]=M.renderPass!=="translucent"||F?[{},T]:M.stencilConfigForOverlap(T);for(const Q of H){const re=h.getTile(Q);if(re.needsHillshadePrepare&&M.renderPass==="offscreen")$ce(M,re,x);else if(M.renderPass==="translucent"){const oe=M.depthModeForSublayer(0,Ir.ReadOnly),ge=x.paint.get("hillshade-emissive-strength"),me=M.colorModeForDrapableLayerRenderPass(ge),xe=F&&M.terrain?M.terrain.stencilModeForRTTOverlap(Q):z[Q.overscaledZ];Bce(M,Q,re,x,oe,xe,me)}}D.viewport.set([0,0,M.width,M.height]),M.resetStencilClippingMasks()},raster:function(M,h,x,T,D,F){if(M.renderPass!=="translucent"||x.paint.get("raster-opacity")===0)return;const z=M.transform.projection.name==="globe",H=x.paint.get("raster-elevation")!==0,Q=H&&z;if(M.renderElevatedRasterBackface&&!Q)return;const re=M.context,oe=re.gl,ge=h.getSource(),me=function(_t,kt,xt,pt,Et){const Ht=kt.paint.get("raster-color"),Vt=_t.type==="raster-array",ts=[],ss=kt.paint.get("raster-resampling"),fs=kt.paint.get("raster-color-mix");let Bs=kt.paint.get("raster-color-range");const Yt=[fs[0],fs[1],fs[2],0],Ft=fs[3];let ds=ss==="nearest"?pt.NEAREST:pt.LINEAR;if(Vt&&(ts.push("RASTER_ARRAY"),Ht||ts.push("RASTER_COLOR"),ss==="linear"&&ts.push("RASTER_ARRAY_LINEAR"),ds=pt.NEAREST,!Bs&&_t.rasterLayers)){const Jt=_t.rasterLayers.find(({id:Es})=>Es===kt.sourceLayer);Jt&&Jt.fields&&Jt.fields.range&&(Bs=Jt.fields.range)}if(Bs=Bs||[0,1],Ht){ts.push("RASTER_COLOR"),xt.activeTexture.set(pt.TEXTURE2),kt.updateColorRamp(Bs);let Jt=kt.colorRampTexture;Jt||(Jt=kt.colorRampTexture=new i.T(xt,kt.colorRamp,pt.RGBA8)),Jt.bind(pt.LINEAR,pt.CLAMP_TO_EDGE)}return Et&&ts.push("USE_MRT1"),{mix:Yt,range:Bs,offset:Ft,defines:ts,resampling:ds}}(ge,x,re,oe,M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback");if(ge instanceof i.aU&&!T.length&&!z)return;const xe=x.paint.get("raster-emissive-strength"),Pe=M.colorModeForDrapableLayerRenderPass(xe),Me=M.terrain&&M.terrain.renderingToTexture,He=!M.options.moving,Be=x.paint.get("raster-resampling")==="nearest"?oe.NEAREST:oe.LINEAR;if(ge instanceof i.aU&&!T.length&&(ge.onNorthPole||ge.onSouthPole)){const _t=H?M.stencilModeFor3D():dn.disabled;return void Nb(!!ge.onNorthPole,null,M,h,x,xe,me,rn.disabled,_t)}if(!T.length)return;const[et,ut]=ge instanceof i.aU||Me?[{},T]:M.stencilConfigForOverlap(T),tt=ut[ut.length-1].overscaledZ;Q&&me.defines.push("PROJECTION_GLOBE_VIEW"),H&&me.defines.push("RENDER_CUTOFF");const Mt=(_t,kt,xt)=>{for(const pt of _t){const Et=pt.toUnwrapped(),Ht=h.getTile(pt);if(Me&&(!Ht||!Ht.hasData()))continue;re.activeTexture.set(oe.TEXTURE0);const Vt=Hf(Ht,ge,x,me);if(!Vt||!Vt.texture)continue;const{texture:ts,mix:ss,offset:fs,tileSize:Bs,buffer:Yt}=Vt;let Ft,ds;Me?(Ft=Ir.disabled,ds=pt.projMatrix):H?(Ft=new Ir(oe.LEQUAL,Ir.ReadWrite,M.depthRangeFor3D),ds=z?Float32Array.from(M.transform.expandedFarZProjMatrix):M.transform.calculateProjMatrix(Et,He)):(Ft=M.depthModeForSublayer(pt.overscaledZ-tt,x.paint.get("raster-opacity")===1?Ir.ReadWrite:Ir.ReadOnly,oe.LESS),ds=M.transform.calculateProjMatrix(Et,He));const Jt=M.terrain&&Me?M.terrain.stencilModeForRTTOverlap(pt):et[pt.overscaledZ],Es=F?0:x.paint.get("raster-fade-duration");Ht.registerFadeDuration(Es);const Qs=h.findLoadedParent(pt,0),mr=vb(Ht,Qs,h,M.transform,Es);let Ks,$s;!mr.isFading&&Ht.refreshedUponExpiration&&(Ht.refreshedUponExpiration=!1),M.terrain&&M.terrain.prepareDrawTile(),re.activeTexture.set(oe.TEXTURE0),ts.bind(Be,oe.CLAMP_TO_EDGE),re.activeTexture.set(oe.TEXTURE1),Qs?(Qs.texture&&Qs.texture.bind(Be,oe.CLAMP_TO_EDGE),Ks=Math.pow(2,Qs.tileID.overscaledZ-Ht.tileID.overscaledZ),$s=[Ht.tileID.canonical.x*Ks%1,Ht.tileID.canonical.y*Ks%1]):ts.bind(Be,oe.CLAMP_TO_EDGE),"useMipmap"in ts&&re.extTextureFilterAnisotropic&&M.transform.pitch>20&&oe.texParameterf(oe.TEXTURE_2D,re.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,re.extTextureFilterAnisotropicMax);const Sr=M.transform;let jr;const lr=H?OD(Sr):[0,0,0,0];let fr,Vr,jn,ma,Ga,Er=0;if(Q&&ge instanceof i.aU&&ge.coordinates.length>3)fr=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0)))),Vr=Float32Array.from(Sr.globeMatrix),jn=Float32Array.from(i.dF(Sr)),ma=[i.aF(Sr.center.lng),i.aJ(Sr.center.lat)],jr=ge.elevatedGlobePerspectiveTransform,Ga=ge.elevatedGlobeGridMatrix||new Float32Array(9);else if(Q){const fi=i.dG(pt.canonical);Er=i.dH(fi.getCenter().lat),fr=Float32Array.from(i.bk(i.dJ(pt.canonical))),Vr=Float32Array.from(Sr.globeMatrix),jn=Float32Array.from(i.dF(Sr)),ma=[i.aF(Sr.center.lng),i.aJ(Sr.center.lat)],jr=[0,0],Ga=Float32Array.from(i.dI(pt.canonical,fi,Er,Sr.worldSize/Sr._pixelsPerMercatorPixel))}else jr=ge instanceof i.aU?ge.perspectiveTransform:[0,0],fr=new Float32Array(16),Vr=new Float32Array(9),jn=new Float32Array(16),ma=[0,0],Ga=new Float32Array(9);const za=TD(ds,fr,Vr,jn,Ga,$s||[0,0],i.aj(M.transform.zoom),ma,lr,Ks||1,mr,x,jr,H?x.paint.get("raster-elevation"):0,2,ss,fs,me.range,Bs,Yt,xe),vn=M.isTileAffectedByFog(pt),Xa=M.getOrCreateProgram("raster",{defines:me.defines,overrideFog:vn});if(M.uploadCommonUniforms(re,Xa,Et),ge instanceof i.aU){const fi=ge.elevatedGlobeVertexBuffer,oi=ge.elevatedGlobeIndexBuffer;if(Me||!z)ge.boundsBuffer&&ge.boundsSegments&&Xa.draw(M,oe.TRIANGLES,Ft,dn.disabled,Pe,rn.disabled,za,x.id,ge.boundsBuffer,M.quadTriangleIndexBuffer,ge.boundsSegments);else if(fi&&oi){const Oa=Sr.zoom<=i.c_?ge.elevatedGlobeSegments:ge.getSegmentsForLongitude(Sr.center.lng);Oa&&Xa.draw(M,oe.TRIANGLES,Ft,dn.disabled,Pe,kt,za,x.id,fi,oi,Oa)}}else if(Q){Ft=new Ir(oe.LEQUAL,Ir.ReadOnly,M.depthRangeFor3D);const fi=M.globeSharedBuffers;if(fi){const[oi,Oa,Rn]=fi.getGridBuffers(Er,!1);Xa.draw(M,oe.TRIANGLES,Ft,xt||Jt,M.colorModeForRenderPass(),kt,za,x.id,oi,Oa,Rn)}}else{const{tileBoundsBuffer:fi,tileBoundsIndexBuffer:oi,tileBoundsSegments:Oa}=M.getTileBoundsBuffers(Ht);Xa.draw(M,oe.TRIANGLES,Ft,Jt,Pe,rn.disabled,za,x.id,fi,oi,Oa)}}if(!(ge instanceof i.aU)&&Q)for(const pt of _t){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[Jt](ts));Yt.push(ts);const Ft=ts.canonical.x,ds=ts.canonical.y;for(const Jt of Yt){const Es=tt.getTile(Et?Jt.wrapped():Jt);if(!Es)continue;const Qs=Es.rasterParticleState;if(!Qs)continue;const mr=Jt.canonical.x+(1<kt.tileID)),xe&&(re.activeTexture.set(oe.TEXTURE0),M.imageManager.bind(M.context,x.scope));const _t=[];if(M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback"&&_t.push("USE_MRT1"),Q){const kt=M.getOrCreateProgram(ut,{overrideFog:!1,overrideRtt:!0,defines:_t}),xt=new Float32Array(i.bA([])),pt=new i.aQ(0,0,0,0,0),Et=xe?hx(xt,H,z,M,0,x.scope,Pe,Q,{tileID:pt,tileSize:me}):bb(xt,H,z,D.toPremultipliedRenderColor(F?null:x.lut));kt.draw(M,oe.TRIANGLES,Be,He,et,rn.disabled,Et,x.id,M.viewportBuffer,M.quadTriangleIndexBuffer,M.viewportSegments)}else for(const kt of Mt){const xt=M.isTileAffectedByFog(kt),pt=M.getOrCreateProgram(ut,{overrideFog:xt,defines:_t}),Et=kt.toUnwrapped(),Ht=T?kt.projMatrix:M.transform.calculateProjMatrix(Et);M.prepareDrawTile();const Vt=h?h.getTile(kt):tt?tt[kt.key]:new sm(kt,me,ge.zoom,M),ts=xe?hx(Ht,H,z,M,0,x.scope,Pe,Q,{tileID:kt,tileSize:me}):bb(Ht,H,z,D.toPremultipliedRenderColor(F?null:x.lut));M.uploadCommonUniforms(re,pt,Et);const{tileBoundsBuffer:ss,tileBoundsIndexBuffer:fs,tileBoundsSegments:Bs}=M.getTileBoundsBuffers(Vt);pt.draw(M,oe.TRIANGLES,Be,He,et,rn.disabled,ts,x.id,ss,fs,Bs)}},sky:function(M,h,x){const T=M._atmosphere?i.aj(M.transform.zoom):1,D=x.paint.get("sky-opacity")*T;if(D===0)return;const F=M.context,z=x.paint.get("sky-type"),H=new Ir(F.gl.LEQUAL,Ir.ReadOnly,[0,1]),Q=M.frameCounter/1e3%1;z==="atmosphere"?M.renderPass==="offscreen"?x.needsSkyboxCapture(M)&&(function(re,oe,ge,me){const xe=re.context,Pe=xe.gl;let Me=oe.skyboxFbo;if(!Me){Me=oe.skyboxFbo=xe.createFramebuffer(32,32,1,null),oe.skyboxGeometry=new eC(xe),oe.skyboxTexture=xe.gl.createTexture(),Pe.bindTexture(Pe.TEXTURE_CUBE_MAP,oe.skyboxTexture),Pe.texParameteri(Pe.TEXTURE_CUBE_MAP,Pe.TEXTURE_WRAP_S,Pe.CLAMP_TO_EDGE),Pe.texParameteri(Pe.TEXTURE_CUBE_MAP,Pe.TEXTURE_WRAP_T,Pe.CLAMP_TO_EDGE),Pe.texParameteri(Pe.TEXTURE_CUBE_MAP,Pe.TEXTURE_MIN_FILTER,Pe.LINEAR),Pe.texParameteri(Pe.TEXTURE_CUBE_MAP,Pe.TEXTURE_MAG_FILTER,Pe.LINEAR);for(let ut=0;ut<6;++ut)Pe.texImage2D(Pe.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,Pe.RGBA,32,32,0,Pe.RGBA,Pe.UNSIGNED_BYTE,null)}xe.bindFramebuffer.set(Me.framebuffer),xe.viewport.set([0,0,32,32]);const He=oe.getCenter(re,!0),Be=re.getOrCreateProgram("skyboxCapture"),et=new Float64Array(16);i.bA(et),i.en(et,et,.5*-Math.PI),Dy(re,oe,Be,et,He,0),i.bA(et),i.en(et,et,.5*Math.PI),Dy(re,oe,Be,et,He,1),i.bA(et),i.cU(et,et,.5*-Math.PI),Dy(re,oe,Be,et,He,2),i.bA(et),i.cU(et,et,.5*Math.PI),Dy(re,oe,Be,et,He,3),i.bA(et),Dy(re,oe,Be,et,He,4),i.bA(et),i.en(et,et,Math.PI),Dy(re,oe,Be,et,He,5),xe.viewport.set([0,0,re.width,re.height])}(M,x),x.markSkyboxValid(M)):M.renderPass==="sky"&&function(re,oe,ge,me,xe){const Pe=re.context,Me=Pe.gl,He=re.transform,Be=re.getOrCreateProgram("skybox");Pe.activeTexture.set(Me.TEXTURE0),Me.bindTexture(Me.TEXTURE_CUBE_MAP,oe.skyboxTexture);const et=((ut,tt,Mt,_t,kt)=>({u_matrix:ut,u_sun_direction:tt,u_cubemap:0,u_opacity:_t,u_temporal_offset:kt}))(He.skyboxMatrix,oe.getCenter(re,!1),0,me,xe);re.uploadCommonUniforms(Pe,Be),Be.draw(re,Me.TRIANGLES,ge,dn.disabled,re.colorModeForRenderPass(),rn.backCW,et,"skybox",oe.skyboxGeometry.vertexBuffer,oe.skyboxGeometry.indexBuffer,oe.skyboxGeometry.segment)}(M,x,H,D,Q):z==="gradient"&&M.renderPass==="sky"&&function(re,oe,ge,me,xe){const Pe=re.context,Me=Pe.gl,He=re.transform,Be=re.getOrCreateProgram("skyboxGradient");oe.skyboxGeometry||(oe.skyboxGeometry=new eC(Pe)),Pe.activeTexture.set(Me.TEXTURE0);let et=oe.colorRampTexture;et||(et=oe.colorRampTexture=new i.T(Pe,oe.colorRamp,Me.RGBA8)),et.bind(Me.LINEAR,Me.CLAMP_TO_EDGE);const ut=((tt,Mt,_t,kt,xt)=>({u_matrix:tt,u_color_ramp:0,u_center_direction:Mt,u_radius:i.an(_t),u_opacity:kt,u_temporal_offset:xt}))(He.skyboxMatrix,oe.getCenter(re,!1),oe.paint.get("sky-gradient-radius"),me,xe);re.uploadCommonUniforms(Pe,Be),Be.draw(re,Me.TRIANGLES,ge,dn.disabled,re.colorModeForRenderPass(),rn.backCW,ut,"skyboxGradient",oe.skyboxGeometry.vertexBuffer,oe.skyboxGeometry.indexBuffer,oe.skyboxGeometry.segment)}(M,x,H,D,Q)},custom:function(M,h,x,T){const D=M.context,F=x.implementation;if(!M.transform.projection.unsupportedLayers||!M.transform.projection.unsupportedLayers.includes("custom")||M.terrain&&(M.terrain.renderingToTexture||M.renderPass==="offscreen")&&x.isDraped(h)){if(M.renderPass==="offscreen"){const z=F.prerender;if(z){if(M.setCustomLayerDefaults(),D.setColorMode(M.colorModeForRenderPass()),M.transform.projection.name==="globe"){const H=M.transform.pointMerc;z.call(F,D.gl,M.transform.customLayerMatrix(),M.transform.getProjection(),M.transform.globeToMercatorMatrix(),i.aj(M.transform.zoom),[H.x,H.y],M.transform.pixelsPerMeterRatio)}else z.call(F,D.gl,M.transform.customLayerMatrix());D.setDirty(),M.setBaseState()}}else if(M.renderPass==="translucent"){if(M.terrain&&M.terrain.renderingToTexture){const H=F.renderToTile;if(H){const Q=T[0].canonical,re={x:Q.x+T[0].wrap*(F.wrapTileId?0:1<{re&&(re.useNormalOffset=!0,oe||(re.enabled=!0))},me=h.getSource();if(M.renderPass==="light-beam"&&me.type!=="batched-model")return;if(me.type==="vector"||me.type==="geojson")return function(tt,Mt,_t,kt,xt){const pt=tt.transform,Et=pt.projection.name==="globe",Ht=pt.getFreeCameraOptions().position;if(!tt.modelManager)return;const Vt=tt.modelManager;_t.modelManager=Vt;const ts=tt.shadowRenderer;if(!_t._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const ss=_t._unevaluatedLayout._values["model-id"],fs=Object.assign({},_t.layout.get("model-id").parameters),Bs=tt.style.order.indexOf(_t.fqid),Yt=_t.paint.get("model-opacity").constantOr(1);for(const Ft of kt){const ds=Mt.getTile(Ft).getBucket(_t);if(!ds||ds.projection.name!==pt.projection.name)continue;const Jt=ds.getModelUris();if(Jt&&!ds.modelsRequested&&(Vt.addModelsFromBucket(Jt,xt),ds.modelsRequested=!0),Et)fs.zoom=Ft.overscaledZ;else{const lr=su(Ft,pt);fs.zoom=lr}const Es=ss.possiblyEvaluate(fs);if(GD(tt,ds,Ft),Ip.shadowUniformsInitialized=!1,Ip.useSingleShadowCascade=!!ts&&ts.getMaxCascadeForTile(Ft.toUnwrapped())===0,tt.renderPass==="shadow"&&ts){if(tt.currentShadowCascade===1&&ds.isInsideFirstShadowMapFrustum)continue;const lr=pt.calculatePosMatrix(Ft.toUnwrapped(),pt.worldSize);if(Ip.tileMatrix.set(lr),Ip.shadowTileMatrix=Float32Array.from(ts.calculateShadowPassMatrixFromMatrix(lr)),Ip.aabb.min=[0,0,0],Ip.aabb.max[0]=Ip.aabb.max[1]=i.al,Ip.aabb.max[2]=0,ede(ds,Ip,tt,_t.scope))continue}const Qs=1<0&&tt.style.isLayerClipped(_t,Mt.getSource())&&ds.updateReplacement(Ft,tt.replacementSource,Bs,_t.scope)&&(ds.uploaded=!1,ds.upload(tt.context));let Ks=0;const $s=new Array,Sr=new Array,jr=new Array;for(let lr in ds.instancesPerModel){const fr=ds.instancesPerModel[lr];fr.features.length>0&&!Et&&(lr=Es.evaluate(fr.features[0].feature,{}));const Vr=Vt.getModel(lr,xt);if(Vr||Vt.hasURLBeenRequested(lr)||ds.modelUris.includes(lr)||(ds.modelUris.push(lr),ds.modelsRequested=!1),Vr&&Vr.uploaded)if(Et){const jn=i.c5([],[Ht.x,Ht.y,Ht.z],tt.transform.worldSize);i.ew(jn,jn);for(let ma=0;ma0&&za.elevationUpdate(lr.terrain,ma,Er,Vr.source),za.needsReEvaluation(lr,Ga,Vr)&&za.evaluate(Vr))}})(tt,Mt,_t,kt),function(){let lr,fr,Vr;$s?(lr=kt.length-1,fr=-1,Vr=-1):(lr=0,fr=kt.length,Vr=1);const jn=new Float64Array(16),ma=i.cA(),Ga=new i.P(0,0);for(let Er=lr;Er!==fr;Er+=Vr){const za=kt[Er],vn=Mt.getTile(za).getBucket(_t);if(!vn||!vn.uploaded)continue;let Xa=!1;Ht&&(Xa=Ht.getMaxCascadeForTile(za.toUnwrapped())===0);const fi=pt.calculatePosMatrix(za.toUnwrapped(),pt.worldSize),oi=vn.modelTraits;!Qs&&$s&&(i.bl(jn,fi),i.af(ma,ts,jn),Ga.x=ma[0],Ga.y=ma[1]);const Oa=[];vn.setFilter(_t.filter);for(const Rn of vn.getNodesInfo()){if(Rn.hiddenByReplacement||!Rn.node.meshes)continue;const Za=Rn.node;let fo=0;tt.terrain&&Za.elevation&&(fo=Za.elevation*tt.terrain.exaggeration());const Wi=(()=>{const gd=Rn.aabb;return Es.min=[...gd.min],Es.max=[...gd.max],Es.min[2]+=fo,Es.max[2]+=fo,i.af(Es.min,Es.min,fi),i.af(Es.max,Es.max,fi),Es})(),Qa=Rn.evaluatedScale;if(Qa[0]<=1&&Qa[1]<=1&&Qa[2]<=1&&Wi.intersects(mr)===0)continue;if(!Qs&&$s){const gd=.16666666666666666;Rn.cameraCollisionOpacity=ts[0]>Wi.min[0]&&ts[0]Wi.min[1]&&ts[1]!$s||Rn.opacity===1&&Za.opacity===1?Rn.depthZa.depth?-1:1);for(const Rn of Oa){const Za=Rn.nodeInfo,fo=Za.node;let Wi=i.aB([],Yt,Rn.tileModelMatrix);i.aB(Wi,fs,Wi);const Qa=i.bl([],Wi);i.eg(Qa,Qa),i.cS(Qa,Qa,Cb),Wi=i.aB(Wi,Wi,fo.globalMatrix);const Ca=tt.renderPass==="light-beam",Fn=_t.paint.get("model-color-use-theme").constantOr("default")==="none",$i=oi&i.eI.HasMapboxMeshFeatures,Ao=$i?0:Za.evaluatedRMEA[0][2];for(let ho=0;ho=xs||mo>=xs}}const Pc=ji.material;let vh;Pc.occlusionTexture&&Pc.occlusionTexture.offsetScale&&(vh=Pc.occlusionTexture.offsetScale,jl.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const um=tt.getOrCreateProgram("model",jl);!Qs&&Ht&&Ht.setupShadowsFromMatrix(Rn.tileModelMatrix,um,Ht.useNormalOffset),tt.uploadCommonUniforms(xt,um,null,xd);const Su=Pc.pbrMetallicRoughness;Su.metallicFactor=.9,Su.roughnessFactor=.5;const jo=Ay(new Float32Array(ed),new Float32Array(Wi),new Float32Array(Qa),new Float32Array(fo.globalMatrix),tt,Rn.opacity,Su.baseColorFactor,Pc.emissiveFactor,Su.metallicFactor,Su.roughnessFactor,Pc,Ao,_t,[0,0,0],vh);!ru&&(Za.hasTranslucentParts||Rn.opacity<1)&&um.draw(tt,xt.gl.TRIANGLES,ds,dn.disabled,Dn.disabled,rn.backCCW,jo,_t.id,ji.vertexBuffer,ji.indexBuffer,ji.segments,_t.paint,tt.transform.zoom,void 0,gd),um.draw(tt,xt.gl.TRIANGLES,ru?Jt:ds,dn.disabled,ru||Rn.opacity<1||Za.hasTranslucentParts?Dn.alphaBlended:Dn.unblended,rn.backCCW,jo,_t.id,ji.vertexBuffer,ji.indexBuffer,ji.segments,_t.paint,tt.transform.zoom,void 0,gd)}}}}()}(M,h,x,T),void ge();if(me.type!=="model")return;const xe=me.getModels(),Pe=[],Me=M.transform.getFreeCameraOptions().position,He=i.c5([],[Me.x,Me.y,Me.z],M.transform.worldSize);i.ew(He,He);const Be=[],et=[];let ut=0;for(const tt of xe){const Mt=h.getFeatureState("",tt.id),_t={type:"Unknown",id:tt.id,properties:tt.featureProperties},kt=x.paint.get("model-rotation").evaluate(_t,Mt),xt=x.paint.get("model-scale").evaluate(_t,Mt),pt=x.paint.get("model-translation").evaluate(_t,Mt),Et=x.paint.get("model-opacity").evaluate(_t,Mt);VD(x,tt.id,Mt,tt.featureProperties,tt.nodeOverrideNames,tt.nodeOverrides),HD(x,tt.id,Mt,tt.featureProperties,tt.materialOverrideNames,tt.materialOverrides),tt.nodeOverrides.size>0&&tt.computeBoundsAndApplyParent(),tt.computeModelMatrix(M,kt,xt,pt,H,z,!1);const Ht=i.bA([]),Vt=i.ef(tt.position.lat,M.transform.zoom),ts=i.bq([],[1,1,1/Vt]);i.br(Ht,Ht,He),Pe.push({zScaleMatrix:ts,negCameraPosMatrix:Ht});for(const ss of tt.nodes)Oy(M,ss,tt.matrix,M.transform.expandedFarZProjMatrix,ut,Be,et,tt.materialOverrides,Et);ut++}if(Be.sort((tt,Mt)=>Mt.depth-tt.depth),M.renderPass!=="shadow")WD(M,x,Be,et,Pe),ge();else{for(const tt of et)Gm(tt.mesh,tt.nodeModelMatrix,M,x);for(const tt of Be)Gm(tt.mesh,tt.nodeModelMatrix,M,x);ge()}}},oC={line:function(M,h,x){if(M.hasElevatedBuckets=!1,M.hasNonElevatedBuckets=!1,M._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||M._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(h){const T=h.getVisibleCoordinates();for(const D of T){const F=h.getTile(D).getBucket(M);if(F&&(F.elevationType!=="none"?M.hasElevatedBuckets=!0:M.hasNonElevatedBuckets=!0,M.hasElevatedBuckets&&M.hasNonElevatedBuckets))break}}}else M.hasNonElevatedBuckets=!0},model:function(M,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,Sb(x,M)));if(T.type==="batched-model"||T.type!=="model")return;const D=T.getModels();for(const F of D)F.upload(x.context)},raster:function(M,h,x){const T=h.getSource();if(!(T instanceof Xc&&T.loaded()))return;const D=M.sourceLayer||T.rasterLayerIds&&T.rasterLayerIds[0];if(!D)return;const F=M.paint.get("raster-array-band")||T.getInitialBand(D);if(F==null)return;const z=h.getIds().map(H=>h.getTileByID(H));for(const H of z)H.updateNeeded(M.id,F)&&T.prepareTile(H,D,M.id,F)},"raster-particle":function(M,h,x){const T=h.getSource();if(!(T instanceof Xc&&T.loaded()))return;const D=M.sourceLayer||T.rasterLayerIds&&T.rasterLayerIds[0];if(!D)return;const F=M.paint.get("raster-particle-array-band")||T.getInitialBand(D);if(F==null)return;const z=h.getIds().map(H=>h.getTileByID(H));for(const H of z)H.updateNeeded(M.id,F)&&T.prepareTile(H,D,M.id,F)}},yh={fill:GS},lC={fill:function(M,h,x,T){if(!x.layout||x.layout.get("fill-elevation-reference")==="none"||x.paint.get("fill-opacity").constantOr(1)===0)return;const D=M.context.gl,F=new Ir(D.LEQUAL,Ir.ReadOnly,M.depthRangeFor3D),z=new dn({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),H=M.transform.getFreeCameraOptions().position,Q=M.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const re of T){const oe=h.getTile(re),ge=oe.getBucket(x);if(!ge)continue;const me=ge.elevatedStructures;if(!me||me.depthSegments.segments[0].primitiveLength===0)continue;const xe=DD(re.toUnwrapped(),H),Pe=M.translatePosMatrix(re.projMatrix,oe,x.paint.get("fill-translate"),x.paint.get("fill-translate-anchor")),Me=Ty(Pe,xe,0,1,0);Q.draw(M,D.TRIANGLES,F,z,Dn.disabled,rn.disabled,Me,x.id,me.vertexBuffer,me.indexBuffer,me.depthSegments,x.paint,M.transform.zoom)}}};class cC{constructor(h,x,T,D,F){this.context=new Cv(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 Q of z)this._debugParams.enabledLayers[Q]=!0;for(const Q of z);this.occlusionParams=new Tv,this.setup(),this.numSublayers=hl.maxUnderzooming+hl.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 fv(this),this._wireframeDebugCache=new px,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const H=new i.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new i.T(this.context,H,h.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=D,this.worldview=F,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 xT(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 F=T+.78*(D-T);this.transform.fogCullDistSq=F*F}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(h){h&&!this._terrain&&(this._terrain=new xT(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 F=new i.b1;F.emplaceBack(0,0,0,0),F.emplaceBack(i.al,0,i.al,0),F.emplaceBack(0,i.al,0,i.al),F.emplaceBack(i.al,i.al,i.al,i.al),this.mercatorBoundsBuffer=h.createVertexBuffer(F,i.bi.members),this.mercatorBoundsSegments=i.bg.simpleSegment(0,0,4,2);const z=new i.b0;z.emplaceBack(0,1,2),z.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=h.createIndexBuffer(z);const H=new i.be;for(const re of[0,1,3,2,0])H.emplaceBack(re);this.debugIndexBuffer=h.createIndexBuffer(H),this.emptyTexture=new i.T(h,new i.q({width:1,height:1},Uint8Array.of(0,0,0,0)),h.gl.RGBA8),this.identityMat=i.bC();const Q=this.context.gl;this.stencilClearMode=new dn({func:Q.ALWAYS,mask:0},0,255,Q.ZERO,Q.ZERO,Q.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(h){return h._makeTileBoundsBuffers(this.context,this.transform.projection),h._tileBoundsBuffer?{tileBoundsBuffer:h._tileBoundsBuffer,tileBoundsIndexBuffer:h._tileBoundsIndexBuffer,tileBoundsSegments:h._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const h=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,h.TRIANGLES,Ir.disabled,this.stencilClearMode,Dn.disabled,rn.disabled,yb(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 H=!1;for(const Q of T)if(this._tileClippingMaskIDs[Q.key]===void 0){H=!0;break}if(!H)return}this.currentStencilSource=x.id;const D=this.context,F=D.gl;this.nextStencilID+T.length>256&&this.clearStencil(),D.setColorMode(Dn.disabled),D.setDepthMode(Ir.disabled);const z=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const H of T){const Q=x.getTile(H),re=this._tileClippingMaskIDs[H.key]=this.nextStencilID++,{tileBoundsBuffer:oe,tileBoundsIndexBuffer:ge,tileBoundsSegments:me}=this.getTileBoundsBuffers(Q);z.draw(this,F.TRIANGLES,Ir.disabled,new dn({func:F.ALWAYS,mask:0},re,255,F.KEEP,F.KEEP,F.REPLACE),Dn.disabled,rn.disabled,yb(H.projMatrix),"$clipping",oe,ge,me)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const h=this.nextStencilID++,x=this.context.gl;return new dn({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 dn({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,H)=>H.overscaledZ-z.overscaledZ),D=T[T.length-1].overscaledZ,F=T[0].overscaledZ-D+1;if(F>1){this.currentStencilSource=void 0,this.nextStencilID+F>256&&this.clearStencil();const z={};for(let H=0;Hthis._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,F=!(!this.terrain||!this.terrain.enabled),z=()=>this.style._getOrder(F).filter(Yt=>{const Ft=D[Yt];return!(Ft.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[Ft.type]});let H=z(),Q=!1,re=!1,oe=null,ge=0,me=!1;for(const Yt of H){const Ft=D[Yt];Ft.visibility!=="none"&&(Ft.type==="circle"?Q=!0:Ft.type==="building"?(oe=Ft,++ge):Ft.type==="symbol"&&(Ft.hasOcclusionOpacityProperties?re=!0:Q=!0))}this.updateEmissiveMode();let xe=H.map(Yt=>D[Yt]);const Pe=this.style._mergedSourceCaches;this.imageManager=h.imageManager,this.modelManager=h.modelManager,this.symbolFadeChange=h.placement.symbolFadeChange(i.o.now()),this.imageManager.beginFrame();for(const Yt in Pe){const Ft=Pe[Yt];Ft.used&&(Ft.prepare(this.context),Ft.getSource().usedInConflation&&++ge)}let Me=!1;for(const Yt of xe)Yt.isHidden(this.transform.zoom)||(Yt.type==="clip"&&(Me=!0),this.prepareLayer(Yt));const He={},Be={},et={},ut={},tt={};for(const Yt in Pe){const Ft=Pe[Yt];He[Yt]=Ft.getVisibleCoordinates(),Be[Yt]=He[Yt].slice().reverse(),et[Yt]=Ft.getVisibleCoordinates(!0).reverse(),ut[Yt]=Ft.getShadowCasterCoordinates(),tt[Yt]=Ft.sortCoordinatesByDistance(He[Yt])}const Mt=Yt=>{const Ft=this.style.getLayerSourceCache(Yt);return Ft&&Ft.used?Ft.getSource():null};if(ge||Me||this._clippingActiveLastFrame){const Yt=[],Ft=[];let ds=0;for(const Jt of xe)this.isSourceForClippingOrConflation(Jt,Mt(Jt))&&(Yt.push(Jt),Ft.push(ds)),ds++;if(Yt&&(Me||Yt.length>1)||this._clippingActiveLastFrame){Me=!1;const Jt=[];for(let Es=0;Es0){const Jt=Mt(Ft);Jt&&(this.minCutoffZoom=Math.max(Jt.minzoom,this.minCutoffZoom)),Ft.minzoom&&(this.minCutoffZoom=Math.max(Ft.minzoom,this.minCutoffZoom))}Ft.is3D(F)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Yt),this._lastOcclusionLayer=Yt)}const _t=this.style&&this.style.fog;_t?(this._fogVisible=_t.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=_t.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(et),this.opaquePassCutoff=0,H=z(),xe=H.map(Yt=>D[Yt]));const kt=this._shadowRenderer;if(kt){kt.updateShadowParameters(this.transform,this.style.directionalLight);for(const Yt in Pe)for(const Ft of He[Yt]){let ds={min:0,max:0};this.terrain&&(ds=this.terrain.getMinMaxForTile(Ft)||ds),kt.addShadowReceiver(Ft.toUnwrapped(),ds.min,ds.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 UD(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 IT(this)),!xt&&this._snow&&(this._snow.destroy(),delete this._snow),pt&&!this._rain&&(this._rain=new iC(this)),!pt&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),oe){this.buildingTileBorderManager||(this.buildingTileBorderManager=new tC);const Yt=this.style.getLayerSourceCache(oe);this.buildingTileBorderManager.updateBorders(Yt,oe)}if(!ot.has(this.context.gl))return;this.renderPass="offscreen";for(const Yt of xe){const Ft=h.getLayerSourceCache(Yt);if(!Yt.hasOffscreenPass()||Yt.isHidden(this.transform.zoom))continue;const ds=Ft?Be[Ft.id]:void 0;(Yt.type==="custom"||Yt.type==="raster"||Yt.type==="raster-particle"||Yt.isSky()||ds&&ds.length)&&this.renderLayer(this,Ft,Yt,ds)}this.depthRangeFor3D=[0,1-(xe.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,ut)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const Et=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Ht=(()=>{if(x.showOverdrawInspector)return i.ao.black;const Yt=this.style.fog;if(Yt&&this.transform.projection.supportsFog){const Ft=this.style.getLut(Yt.scope);if(!Et){const ds=Yt.properties.get("color-use-theme")==="none",Jt=Yt.properties.get("color").toNonPremultipliedRenderColor(ds?null:Ft).toArray01();return new i.ao(...Jt)}if(Et){const ds=Yt.properties.get("space-color-use-theme")==="none",Jt=Yt.properties.get("space-color").toNonPremultipliedRenderColor(ds?null:Ft).toArray01();return new i.ao(...Jt)}}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=H.length-1;this.currentLayer>=0;this.currentLayer--){const Yt=xe[this.currentLayer],Ft=h.getLayerSourceCache(Yt);if(Yt.isSky())continue;const ds=Ft?(Yt.is3D(F)?tt:Be)[Ft.id]:void 0;this._renderTileClippingMasks(Yt,Ft,ds),this.renderLayer(this,Ft,Yt,ds)}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&&Yt.hasShadowPass()&&--ts==0){{this.clearStencil(),this.resetStencilClippingMasks();const ds=this.currentLayer;for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const ds=this.currentLayer;this.depthOcclusion=!0;for(const Jt of this.layersWithOcclusionOpacity){this.currentLayer=Jt;const Es=xe[this.currentLayer],Qs=h.getLayerSourceCache(Es),mr=Qs?Be[Qs.id]:void 0;this.terrain||this._renderTileClippingMasks(Es,Qs,Qs?He[Qs.id]:void 0),this.renderLayer(this,Qs,Es,mr)}this.depthOcclusion=!1,this.currentLayer=ds,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let Yt=null;xe.forEach(Ft=>{const ds=h.getLayerSourceCache(Ft);ds&&!Ft.isHidden(this.transform.zoom)&&ds.getVisibleCoordinates().length&&(!Yt||Yt.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,F=[];return this.style&&this.style.enable3dLights()&&(h==="globeRaster"||h==="terrainRaster"?(F.push("LIGHTING_3D_MODE"),F.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):D||F.push("LIGHTING_3D_MODE")),this.renderPass==="shadow"&&(this._shadowMapDebug||F.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(F.push("TERRAIN"),this.linearFloatFilteringSupported()&&F.push("TERRAIN_DEM_FLOAT_FORMAT")),this.transform.projection.name==="globe"&&F.push("GLOBE"),!this._fogVisible||D||x!==void 0&&!x||F.push("FOG","FOG_DITHERING"),D&&F.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&F.push("OVERDRAW_INSPECTOR"),F}getOrCreateProgram(h,x){this.cache=this.cache||{};const T=x&&x.defines||[],D=x&&x.config,F=this.currentGlobalDefines(h,x&&x.overrideFog,x&&x.overrideRtt).concat(T),z=wD.cacheKey(nT[h],h,F,D);return this.cache[z]||(this.cache[z]=new wD(this.context,h,nT[h],D,WS[h],F)),this.cache[z]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const h=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(h.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new i.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(h,x){if(this.style.enable3dLights()){const T=this.style.directionalLight,D=this.style.ambientLight;if(T&&D){const F=((z,H,Q)=>{const re=z.properties.get("direction"),oe=z.properties.get("color-use-theme")==="none",ge=z.properties.get("color").toNonPremultipliedRenderColor(oe?null:Q.getLut(z.scope)).toArray01(),me=z.properties.get("intensity"),xe=H.properties.get("color-use-theme")==="none",Pe=H.properties.get("color").toNonPremultipliedRenderColor(xe?null:Q.getLut(H.scope)).toArray01(),Me=H.properties.get("intensity"),He=[re.x,re.y,re.z],Be=i.dN(Pe,Me),et=i.dN(ge,me);return{u_lighting_ambient_color:Be,u_lighting_directional_dir:He,u_lighting_directional_color:et,u_ground_radiance:kv(He,et,Be)}})(T,D,this.style);x.setLightsUniformValues(h,F)}}}uploadCommonUniforms(h,x,T,D,F){if(this.uploadCommonLightUniforms(h,x),this.terrain&&this.terrain.renderingToTexture)return;const z=this.style.fog;if(z){const H=z.getOpacity(this.transform.pitch),Q=((re,oe,ge,me,xe,Pe,Me,He,Be,et,ut,tt)=>{const Mt=re.transform,_t=oe.properties.get("color-use-theme")==="none",kt=oe.properties.get("color").toNonPremultipliedRenderColor(_t?null:re.style.getLut(oe.scope)).toArray01();kt[3]=me;const xt=re.frameCounter/1e3%1,[pt,Et]=oe.properties.get("vertical-range");return{u_fog_matrix:ge?Mt.calculateFogTileMatrix(ge):tt||re.identityMat,u_fog_range:oe.getFovAdjustedRange(Mt._fov),u_fog_color:kt,u_fog_horizon_blend:oe.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(pt,Et),Et],u_fog_temporal_offset:xt,u_frustum_tl:xe,u_frustum_tr:Pe,u_frustum_br:Me,u_frustum_bl:He,u_globe_pos:Be,u_globe_radius:et,u_viewport:ut,u_globe_transition:i.aj(Mt.zoom),u_is_globe:+(Mt.projection.name==="globe")}})(this,z,T,H,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,Q)}F&&x.setCutoffUniformValues(h,F.uniformValues)}setTileLoadedFlag(h){this.tileLoaded=h}saveCanvasCopy(){const h=this.canvasCopy();h&&(this.frameCopies.push(h),this.tileLoaded=!1)}canvasCopy(){const h=this.context.gl,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 sm(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,F=D.gl,z=!!T;var H;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(F.TEXTURE3),h&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(F.NEAREST,F.CLAMP_TO_EDGE),T.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],T.u_depth_range_unpack=[2/((H=this.depthRangeFor3D)[1]-H[0]),-1-2*H[0]/(H[1]-H[0])],T.u_occluder_half_size=.5*this.occlusionParams.occluderSize,T.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(F.NEAREST,F.CLAMP_TO_EDGE),D.activeTexture.set(F.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 dC(M,h){let x=!1,T=null;const D=()=>{T=null,x&&(M(),T=setTimeout(D,h),x=!1)};return()=>(x=!0,T||D(),T)}class LT{constructor(h){this._hashName=h&&encodeURIComponent(h),i.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=dC(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=bl(h);if(this._hashName){const T=this._hashName;let D=!1;const F=location.hash.slice(1).split("&").map(z=>{const H=z.split("=")[0];return H===T?(D=!0,`${H}=${x}`):z}).filter(z=>z);return D||F.push(`${T}=${x}`),`#${F.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 bl(M,h){const x=M.getCenter(),T=Math.round(100*M.getZoom())/100,D=Math.ceil((T*Math.LN2+Math.log(512/360/.5))/Math.LN10),F=Math.pow(10,D),z=Math.round(x.lng*F)/F,H=Math.round(x.lat*F)/F,Q=M.getBearing(),re=M.getPitch();let oe=h?`/${z}/${H}/${T}`:`${T}/${H}/${z}`;return(Q||re)&&(oe+="/"+Math.round(10*Q)/10),re&&(oe+=`/${Math.round(re)}`),oe}const Ev={linearity:.3,easing:i.eT(0,0,.3,1)},DT=Object.assign({deceleration:2500,maxSpeed:1400},Ev),OT=Object.assign({deceleration:20,maxSpeed:1400},Ev),Fy=Object.assign({deceleration:1e3,maxSpeed:360},Ev),RT=Object.assign({deceleration:1e3,maxSpeed:90},Ev);class FT{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:F}of this._inertiaBuffer)x.zoom+=F.zoomDelta||0,x.bearing+=F.bearingDelta||0,x.pitch+=F.pitchDelta||0,F.panDelta&&x.pan._add(F.panDelta),F.around&&(x.around=F.around),F.pinchAround&&(x.pinchAround=F.pinchAround);const T=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,D={};if(x.pan.mag()){const F=Lp(x.pan.mag(),T,Object.assign({},DT,h||{}));D.offset=x.pan.mult(F.amount/x.pan.mag()),D.center=this._map.transform.center,Pv(D,F)}if(x.zoom){const F=Lp(x.zoom,T,OT);D.zoom=this._map.transform.zoom+F.amount,Pv(D,F)}if(x.bearing){const F=Lp(x.bearing,T,Fy);D.bearing=this._map.transform.bearing+i.aA(F.amount,-179,179),Pv(D,F)}if(x.pitch){const F=Lp(x.pitch,T,RT);D.pitch=this._map.transform.pitch+F.amount,Pv(D,F)}if(D.zoom||D.bearing){const F=x.pinchAround===void 0?x.around:x.pinchAround;D.around=F?this._map.unproject(F):this._map.getCenter()}return this.clear(),D.noMoveStart=!0,D}}function Pv(M,h){(!M.duration||M.durationx.unproject(Q)),H=F.reduce((Q,re,oe,ge)=>Q.add(re.div(ge.length)),new i.P(0,0));super(h,{points:F,point:H,lngLats:z,lngLat:x.unproject(H),originalEvent:T}),this._defaultPrevented=!1}}class zT extends i.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(h,x){super("wheel",{originalEvent:x}),this._defaultPrevented=!1}}class uC{constructor(h,x){this._map=h,this._clickTolerance=x.clickTolerance}reset(){this._mousedownPos=void 0}wheel(h){return this._firePreventable(new zT(this._map,h))}mousedown(h,x){return this._mousedownPos=x,this._firePreventable(new Nu(h.type,this._map,h))}mouseup(h){this._map.fire(new Nu(h.type,this._map,h))}preclick(h){const x=new MouseEvent("preclick",h);this._map.fire(new Nu(x.type,this._map,x))}click(h,x){this._mousedownPos&&this._mousedownPos.dist(x)>=this._clickTolerance||(this.preclick(h),this._map.fire(new Nu(h.type,this._map,h)))}dblclick(h){return this._firePreventable(new Nu(h.type,this._map,h))}mouseover(h){this._map.fire(new Nu(h.type,this._map,h))}mouseout(h){this._map.fire(new Nu(h.type,this._map,h))}touchstart(h){return this._firePreventable(new gx(h.type,this._map,h))}touchmove(h){this._map.fire(new gx(h.type,this._map,h))}touchend(h){this._map.fire(new gx(h.type,this._map,h))}touchcancel(h){this._map.fire(new gx(h.type,this._map,h))}_firePreventable(h){if(this._map.fire(h),h.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class BT{constructor(h){this._map=h}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(h){this._map.fire(new Nu(h.type,this._map,h))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Nu("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(h){this._delayContextMenu?this._contextMenuEvent=h:this._map.fire(new Nu(h.type,this._map,h)),this._map.listens("contextmenu")&&h.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class hC{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,F=this._lastPos;if(!D||!F||F.equals(T)||!this._box&&T.dist(D){this._box&&(this._box.style.transform=`translate(${z}px,${Q}px)`,this._box.style.width=H-z+"px",this._box.style.height=re-Q+"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:F=>F.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 mC(M,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 F=new i.P(0,0);for(const z of D)F._add(z);return F.div(D.length)}(x),this.touches=mC(T,x)))}touchmove(h,x,T){if(this.aborted||!this.centroid)return;const D=mC(T,x);for(const F in this.touches){const z=D[F];(!z||z.dist(this.touches[F])>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 pC{constructor(h){this.singleTap=new YD(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 F=h.timeStamp-this.lastTime<500,z=!this.lastTap||this.lastTap.dist(D)<30;if(F&&z||this.reset(),this.count++,this.lastTime=h.timeStamp,this.lastTap=D,this.count===this.numTaps)return this.reset(),D}}}class XD{constructor(){this._zoomIn=new pC({numTouches:1,numTaps:2}),this._zoomOut=new pC({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),F=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})}):F?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:z=>z.easeTo({duration:300,zoom:z.getZoom()-1,around:z.unproject(F)},{originalEvent:h})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const QD={0:1,2:2},$T={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class fC{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=V(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,F){const z=QD[F];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=mC(T,x),F=new i.P(0,0),z=new i.P(0,0);let H=0;for(const re in D){const oe=D[re],ge=this._touches[re];ge&&(F._add(oe),z._add(oe.sub(ge)),H++,D[re]=oe)}if(this._touches=D,H{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class gC{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[F,z]=D,H=Mb(T,x,F),Q=Mb(T,x,z);if(!H||!Q)return;const re=this._aroundCenter?null:H.add(Q).div(2);return this._move([H,Q],re,h)}touchend(h,x,T){if(!this._firstTwoTouches)return;const[D,F]=this._firstTwoTouches,z=Mb(T,x,D),H=Mb(T,x,F);z&&H||(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 Mb(M,h,x){for(let T=0;TMath.abs(M.x)}class sde extends gC{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,xC(h[0].sub(h[1]))&&(this._valid=!1)}_move(h,x,T){const D=this._lastPoints;if(!D)return;const F=h[0].sub(D[0]),z=h[1].sub(D[1]);return this._map._cooperativeGestures&&!i.eU()&&T.touches.length<3||(this._valid=this.gestureBeginsVertically(F,z,T.timeStamp),!this._valid)?void 0:(this._lastPoints=h,this._active=!0,{pitchDelta:(F.y+z.y)/2*-.5})}gestureBeginsVertically(h,x,T){if(this._valid!==void 0)return this._valid;const D=h.mag()>=2,F=x.mag()>=2;if(!D&&!F)return;if(!D||!F)return this._firstMove==null&&(this._firstMove=T),T-this._firstMove<100&&void 0;const z=h.y>0==x.y>0;return xC(h)&&xC(x)&&z}}const rde={panStep:100,bearingStep:15,pitchStep:10};class nde{constructor(){const h=rde;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,F=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(),F=-1);break;case 39:h.shiftKey?T=1:(h.preventDefault(),F=1);break;case 38:h.shiftKey?D=1:(h.preventDefault(),z=-1);break;case 40:h.shiftKey?D=-1:(h.preventDefault(),z=1);break;default:return}return this._rotationDisabled&&(T=0,D=0),{cameraAnimation:H=>{const Q=H.getZoom();H.easeTo({duration:300,easeId:"keyboardHandler",easing:Tb,zoom:x?Math.round(Q)+x*(h.shiftKey?2:1):Q,bearing:H.getBearing()+T*this._bearingStep,pitch:H.getPitch()+D*this._pitchStep,offset:[-F*this._panStep,-z*this._panStep],center:H.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 Tb(M){return M*(2-M)}const VT=4.000244140625,HT=1/450;class yC{constructor(h,x){this._map=h,this._el=h.getCanvasContainer(),this._handler=x,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=HT,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%VT==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)>VT?this._wheelZoomRate:this._defaultZoomRate;let oe=2/(1+Math.exp(-Math.abs(this._delta*re)));this._delta<0&&oe!==0&&(oe=1/oe);const ge=x(),me=Math.pow(2,ge),xe=typeof this._targetZoom=="number"?h.zoomScale(this._targetZoom):me;this._targetZoom=Math.min(h.maxZoom,Math.max(h.minZoom,h.scaleZoom(xe*oe))),this._type==="wheel"&&(this._startZoom=ge,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const T=typeof this._targetZoom=="number"?this._targetZoom:x(),D=this._startZoom,F=this._easing;let z,H=!1;if(this._type==="wheel"&&D&&F){const re=Math.min((i.o.now()-this._lastWheelEventTime)/200,1),oe=F(re);z=i.ak(D,T,oe),re<1?this._frameId||(this._frameId=!0):H=!0}else z=T,H=!0;this._active=!0,H&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let Q=z-x();return Q*this._lastDelta<0&&(Q=0),{noInertia:!0,needsRenderFrame:!H,zoomDelta:Q,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,F=T.easing(D+.01)-T.easing(D),z=.27/Math.sqrt(F*F+1e-4)*.01,H=Math.sqrt(.0729-z*z);x=i.eT(z,H,.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=j("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class Gf{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 vC{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 wl{constructor(){this._tap=new pC({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],F=D.y-this._swipePoint.y;return this._swipePoint=D,h.preventDefault(),this._active=!0,{zoomDelta:F/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 Ab{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 _C{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 Eb=M=>M.zoom||M.drag||M.pitch||M.rotate;class ade extends i.z{}class Pb{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),F=i.d8([],x,i.c5([],i.av([],i.d8([],D,T),x),2));x[0]=F[0],x[1]=F[1]}return x}}function bC(M){return M.panDelta&&M.panDelta.mag()||M.zoomDelta||M.bearingDelta||M.pitchDelta}class ide{constructor(h,x){this._map=h,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new FT(h),this._bearingSnap=x.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Pb,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,F,z]of this._listeners){const H=D===document?this.handleWindowEvent:this.handleEvent;D.addEventListener(F,H,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 uC(x,h));const D=x.boxZoom=new hC(x,h);this._add("boxZoom",D);const F=new XD,z=new vC;x.doubleClickZoom=new Gf(z,F),this._add("tapZoom",F),this._add("clickZoom",z);const H=new wl;this._add("tapDragZoom",H);const Q=x.touchPitch=new sde(x);this._add("touchPitch",Q);const re=new qT(h),oe=new UT(h);x.dragRotate=new Ab(h,re,oe),this._add("mouseRotate",re,["mousePitch"]),this._add("mousePitch",oe,["mouseRotate"]);const ge=new JD(h),me=new eO(x,h);x.dragPan=new Dp(T,ge,me),this._add("mousePan",ge),this._add("touchPan",me,["touchZoom","touchRotate"]);const xe=new uo,Pe=new tde;x.touchZoomRotate=new _C(T,Pe,xe,H),this._add("touchRotate",xe,["touchPan","touchZoom"]),this._add("touchZoom",Pe,["touchPan","touchRotate"]),this._add("blockableMapEvent",new BT(x));const Me=x.scrollZoom=new yC(x,this);this._add("scrollZoom",Me,["mousePan"]);const He=x.keyboard=new nde;this._add("keyboard",He);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!!Eb(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,F={needsRenderFrame:!1},z={},H={},Q=h.touches?this._getMapTouches(h.touches):void 0,re=Q?U(this._el,Q):T?void 0:q(this._el,h);for(const{handlerName:me,handler:xe,allowed:Pe}of this._handlers){if(!xe.isEnabled())continue;let Me;this._blockedByActive(H,Pe,me)?xe.reset():xe[x||h.type]&&(Me=xe[x||h.type](h,re,Q),this.mergeHandlerResult(F,z,Me,me,D),Me&&Me.needsRenderFrame&&this._triggerRenderFrame()),(Me||xe.isActive())&&(H[me]=xe)}const oe={};for(const me in this._previousActiveHandlers)H[me]||(oe[me]=D);this._previousActiveHandlers=H,(Object.keys(oe).length||bC(F))&&(this._changes.push([F,z,oe]),this._triggerRenderFrame()),(Object.keys(H).length||bC(F))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:ge}=F;ge&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],ge(this._map))}mergeHandlerResult(h,x,T,D,F){if(!T)return;Object.assign(h,T);const z={handlerName:D,originalEvent:T.originalEvent||F};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,F,z]of this._changes)D.panDelta&&(h.panDelta=(h.panDelta||new i.P(0,0))._add(D.panDelta)),D.zoomDelta&&(h.zoomDelta=(h.zoomDelta||0)+D.zoomDelta),D.bearingDelta&&(h.bearingDelta=(h.bearingDelta||0)+D.bearingDelta),D.pitchDelta&&(h.pitchDelta=(h.pitchDelta||0)+D.pitchDelta),D.around!==void 0&&(h.around=D.around),D.aroundCoord!==void 0&&(h.aroundCoord=D.aroundCoord),D.pinchAround!==void 0&&(h.pinchAround=D.pinchAround),D.noInertia&&(h.noInertia=D.noInertia),Object.assign(x,F),Object.assign(T,z);this._updateMapTransform(h,x,T),this._changes=[]}_updateMapTransform(h,x,T){const D=this._map,F=D.transform,z=et=>[et.x,et.y,et.z];if((et=>{const ut=this._eventsInProgress.drag;return ut&&!this._handlersById[ut.handlerName].isActive()})()&&!bC(h)){const et=F.zoom;F.cameraElevationReference="sea",this._originalZoom!=null&&F._orthographicProjectionAtLowPitch&&F.projection.name!=="globe"&&F.pitch===0?(F.cameraElevationReference="ground",F.zoom=this._originalZoom):(F.recenterOnTerrain(),F.cameraElevationReference="ground"),et!==F.zoom&&this._map._update(!0)}if(F._isCameraConstrained&&D._stop(!0),!bC(h))return void this._fireEvents(x,T,!0);let{panDelta:H,zoomDelta:Q,bearingDelta:re,pitchDelta:oe,around:ge,aroundCoord:me,pinchAround:xe}=h;F._isCameraConstrained&&(Q>0&&(Q=0),F._isCameraConstrained=!1),xe!==void 0&&(ge=xe),(Q||(et=>x[et]&&!this._eventsInProgress[et])("drag"))&&ge&&(this._dragOrigin=z(F.pointCoordinate3D(ge)),this._originalZoom=F.zoom,this._trackingEllipsoid.setup(F._camera.position,this._dragOrigin)),F.cameraElevationReference="sea",D._stop(!0),ge=ge||D.transform.centerPoint,re&&(F.bearing+=re),oe&&(F.pitch+=oe),F._updateCameraState();const Pe=[0,0,0];if(H)if(F.projection.name==="mercator"){const et=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(ge).dir),ut=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(ge.sub(H)).dir);Pe[0]=ut[0]-et[0],Pe[1]=ut[1]-et[1]}else{const et=F.pointCoordinate(ge);if(F.projection.name==="globe"){H=H.rotate(-F.angle);const ut=F._pixelsPerMercatorPixel/F.worldSize;Pe[0]=-H.x*i.eW(i.a$(et.y))*ut,Pe[1]=-H.y*i.eW(F.center.lat)*ut}else{const ut=F.pointCoordinate(ge.sub(H));et&&ut&&(Pe[0]=ut.x-et.x,Pe[1]=ut.y-et.y)}}const Me=F.zoom,He=[0,0,0];if(Q){const et=z(me||F.pointCoordinate3D(ge)),ut={dir:i.aw([],i.av([],et,F._camera.position))};if(ut.dir[2]<0){const tt=F.zoomDeltaToMovement(et,Q);i.c5(He,ut.dir,tt)}}const Be=i.d8(Pe,Pe,He);F._translateCameraConstrained(Be),Q&&Math.abs(F.zoom-Me)>1e-4&&F.recenterOnTerrain(),F.cameraElevationReference="ground",this._map._update(),h.noInertia||this._inertia.record(h),this._fireEvents(x,T,!0)}_fireEvents(h,x,T){const D=Eb(this._eventsInProgress),F=Eb(h),z={};for(const oe in h){const{originalEvent:ge}=h[oe];this._eventsInProgress[oe]||(z[`${oe}start`]=ge),this._eventsInProgress[oe]=h[oe]}!D&&F&&this._fireEvent("movestart",F.originalEvent);for(const oe in z)this._fireEvent(oe,z[oe]);F&&this._fireEvent("move",F.originalEvent);for(const oe in h){const{originalEvent:ge}=h[oe];this._fireEvent(oe,ge)}const H={};let Q;for(const oe in this._eventsInProgress){const{handlerName:ge,originalEvent:me}=this._eventsInProgress[oe];this._handlersById[ge].isActive()||(delete this._eventsInProgress[oe],Q=x[ge]||me,H[`${oe}end`]=Q)}for(const oe in H)this._fireEvent(oe,H[oe]);const re=Eb(this._eventsInProgress);if(T&&(D||F)&&!re){this._updatingCamera=!0;const oe=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),ge=me=>me!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new ade("renderFrame",{timeStamp:h})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const wC="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class WT 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,F,z){const H=h.clone(),Q=this._extendCameraOptions(z);H.bearing=D,H.pitch=F;const re=i.aT.convert(x),oe=i.aT.convert(T),ge=.5*(re.lat+oe.lat),me=.5*(re.lng+oe.lng),xe=i.eZ(ge,me),Pe=i.aw([],xe),Me=i.aw([],i.bI([],Pe,[0,1,0])),He=i.bI([],Me,Pe),Be=[Me[0],Me[1],Me[2],0,He[0],He[1],He[2],0,Pe[0],Pe[1],Pe[2],0,0,0,0,1],et=[xe,i.eZ(re.lat,re.lng),i.eZ(oe.lat,re.lng),i.eZ(oe.lat,oe.lng),i.eZ(re.lat,oe.lng),i.eZ(ge,re.lng),i.eZ(ge,oe.lng),i.eZ(re.lat,me),i.eZ(oe.lat,me)];let ut=i.d9.fromPoints(et.map(Jt=>[i.bJ(Me,Jt),i.bJ(He,Jt),i.bJ(Pe,Jt)]));const tt=i.af([],ut.center,Be);i.e_(tt)===0&&i.e$(tt,0,0,1),i.aw(tt,tt),i.c5(tt,tt,i.aD),H.center=i.f0(tt);const Mt=H.getWorldToCameraMatrix(),_t=i.bl(new Float64Array(16),Mt);ut=i.d9.applyTransform(ut,i.aB([],Mt,Be));const kt=this._extendAABB(ut,H,Q,D);if(!kt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");ut=kt,i.af(tt,tt,Mt);const xt=.5*(ut.max[2]-ut.min[2]),pt=this._minimumAABBFrustumDistance(H,ut),Et=i.c5([],[0,0,1],xt),Ht=i.d8(Et,tt,Et),Vt=pt+(H.pitch===0?0:i.bG(tt,Ht)),ts=H.globeCenterInViewSpace,ss=i.av([],tt,[ts[0],ts[1],ts[2]]);i.aw(ss,ss),i.c5(ss,ss,Vt);const fs=i.d8([],tt,ss);i.af(fs,fs,_t);const Bs=i.eM/i.aD,Yt=i.ag(fs),Ft=i.cf(Math.max(Yt*Bs-i.eM,Number.EPSILON),0),ds=Math.min(H.zoomFromMercatorZAdjusted(Ft),Q.maxZoom);return ds>.5*(i.c_+i.cL)?(H.setProjection({name:"mercator"}),H.zoom=ds,this._cameraForBounds(H,x,T,D,F,z)):{center:H.center,zoom:ds,bearing:D,pitch:F}}_extendAABB(h,x,T,D){const F=.5*((T.padding.left||0)+(T.padding.right||0)),z=.5*((T.padding.top||0)+(T.padding.bottom||0)),H=z,Q=F,re=F,oe=z,ge=x.width-(Q+re),me=x.height-(H+oe),xe=i.av([],h.max,h.min),Pe=Math.min(ge/xe[0],me/xe[1]),Me=Math.min(x.scaleZoom(x.scale*Pe),T.maxZoom);if(isNaN(Me))return null;const He=x.scale/x.zoomScale(Me),Be=new i.d9([h.min[0]-Q*He,h.min[1]-oe*He,h.min[2]],[h.max[0]+re*He,h.max[1]+H*He,h.max[2]]),et=(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]-=et.x*He,Be.center[1]+=et.y*He,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,F,z){if(h.projection.name==="globe")return this._cameraForBoundsOnGlobe(h,x,T,D,F,z);const H=h.clone(),Q=this._extendCameraOptions(z);H.bearing=D,H.pitch=F;const re=i.aT.convert(x),oe=i.aT.convert(T),ge=new i.aT(re.lng,oe.lat),me=new i.aT(oe.lng,re.lat),xe=H.project(re),Pe=H.project(oe),Me=this.queryTerrainElevation(re),He=this.queryTerrainElevation(oe),Be=this.queryTerrainElevation(ge),et=this.queryTerrainElevation(me),ut=[[xe.x,xe.y,Math.min(Me||0,He||0,Be||0,et||0)],[Pe.x,Pe.y,Math.max(Me||0,He||0,Be||0,et||0)]];let tt=i.d9.fromPoints(ut);const Mt=H.getWorldToCameraMatrix(),_t=i.bl(new Float64Array(16),Mt);tt=i.d9.applyTransform(tt,Mt);const kt=this._extendAABB(tt,H,Q,D);if(!kt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");tt=kt;const xt=.5*i.av([],tt.max,tt.min)[2],pt=this._minimumAABBFrustumDistance(H,tt),Et=[0,0,1,0];i.aC(Et,Et,Mt),i.f1(Et,Et);const Ht=i.c5([],Et,pt+xt),Vt=i.d8([],tt.center,Ht);i.af(tt.center,tt.center,_t),i.af(Vt,Vt,_t);const ts=H.unproject(new i.P(tt.center[0],tt.center[1])),ss=i.f2(H.projection,ts),fs=Math.pow(2,ss),Bs=Math.min(H._zoomFromMercatorZ(Vt[2]*H.pixelsPerMeter*fs/H.worldSize),Q.maxZoom);return H.mercatorFromTransition&&Bs<.5*(i.c_+i.cL)?(H.setProjection({name:"globe"}),H.zoom=Bs,this._cameraForBounds(H,x,T,D,F,z)):{center:ts,zoom:Bs,bearing:D,pitch:F}}fitBounds(h,x,T){const D=this.cameraForBounds(h,x);return this._fitInternal(D,x,T)}fitScreenCoordinates(h,x,T,D,F){const z=i.P.convert(h),H=i.P.convert(x),Q=new i.P(Math.min(z.x,H.x),Math.min(z.y,H.y)),re=new i.P(Math.max(z.x,H.x),Math.max(z.y,H.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(z,H))return this;const oe=this.transform.pointLocation3D(Q),ge=this.transform.pointLocation3D(re),me=this.transform.pointLocation3D(new i.P(Q.x,re.y)),xe=this.transform.pointLocation3D(new i.P(re.x,Q.y)),Pe=[Math.min(oe.lng,ge.lng,me.lng,xe.lng),Math.min(oe.lat,ge.lat,me.lat,xe.lat)],Me=[Math.max(oe.lng,ge.lng,me.lng,xe.lng),Math.max(oe.lat,ge.lat,me.lat,xe.lat)],He=D&&D.pitch?D.pitch:this.getPitch(),Be=this._cameraForBounds(this.transform,Pe,Me,T,He,D);return this._fitInternal(Be,D,F)}_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,F=!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&&(F=!0,T.bearing=+h.bearing),"pitch"in h&&T.pitch!==+h.pitch&&(z=!0,T.pitch=+h.pitch);const H=typeof h.padding=="number"?this._extendPadding(h.padding):h.padding;if(h.padding!=null&&!T.isPaddingEqual(H))if(h.retainPadding===!1){const Q=T.clone();Q.padding=H,T.setLocationAtPoint(T.center,Q.centerPoint)}else T.padding=H;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)),F&&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(wC),this.transform.getFreeCameraOptions()}setFreeCameraOptions(h,x){const T=this.transform;if(!T.projection.supportsFreeCamera)return i.w(wC),this;this.stop();const D=T.zoom,F=T.pitch,z=T.bearing;T.setFreeCameraOptions(h);const H=D!==T.zoom,Q=F!==T.pitch,re=z!==T.bearing;return this.fire(new i.z("movestart",x)).fire(new i.z("move",x)),H&&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)),Q&&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(),F=this.getBearing(),z=this.getPitch(),H=this.getPadding(),Q="zoom"in h?+h.zoom:D,re="bearing"in h?this._normalizeBearing(h.bearing,F):F,oe="pitch"in h?+h.pitch:z,ge=this._extendPadding(h.padding),me=i.P.convert(h.offset);let xe,Pe,Me;if(T.projection.name==="globe"){const Et=i.ae.fromLngLat(T.center),Ht=me.rotate(-T.angle);Et.x+=Ht.x/T.worldSize,Et.y+=Ht.y/T.worldSize;const Vt=Et.toLngLat(),ts=i.aT.convert(h.center||Vt);this._normalizeCenter(ts),xe=T.centerPoint.add(Ht),Pe=new i.P(Et.x,Et.y).mult(T.worldSize),Me=new i.P(i.aF(ts.lng),i.aJ(ts.lat)).mult(T.worldSize).sub(Pe)}else{xe=T.centerPoint.add(me);const Et=T.pointLocation(xe),Ht=i.aT.convert(h.center||Et);this._normalizeCenter(Ht),Pe=T.project(Et),Me=T.project(Ht).sub(Pe)}const He=T.zoomScale(Q-D);let Be,et;h.around&&(Be=i.aT.convert(h.around),et=T.locationPoint(Be));const ut=this._zooming||Q!==D,tt=this._rotating||F!==re,Mt=this._pitching||oe!==z,_t=!T.isPaddingEqual(ge),kt=h.retainPadding===!1?T.clone():T,xt=Et=>Ht=>{if(ut&&(Et.zoom=i.ak(D,Q,Ht)),tt&&(Et.bearing=i.ak(F,re,Ht)),Mt&&(Et.pitch=i.ak(z,oe,Ht)),_t&&(kt.interpolatePadding(H,ge,Ht),xe=kt.centerPoint.add(me)),Be)Et.setLocationAtPoint(Be,et);else{const Vt=Et.zoomScale(Et.zoom-D),ts=Q>D?Math.min(2,He):Math.max(.5,He),ss=Math.pow(ts,1-Ht),fs=Et.unproject(Pe.add(Me.mult(Ht*ss)).mult(Vt));Et.setLocationAtPoint(Et.renderWorldCopies?fs.wrap():fs,xe)}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=ut,this._rotating=tt,this._pitching=Mt,this._padding=_t,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,F=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)),F&&this.fire(new i.z("pitchend",h)),this.fire(new i.z("moveend",h))}flyTo(h,x){if(this._prefersReducedMotion(h)){const Jt=i.aH(h,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(Jt,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(),F=this.getBearing(),z=this.getPitch(),H=this.getPadding(),Q="zoom"in h?i.aA(+h.zoom,T.minZoom,T.maxZoom):D,re="bearing"in h?this._normalizeBearing(h.bearing,F):F,oe="pitch"in h?+h.pitch:z,ge=this._extendPadding(h.padding),me=T.zoomScale(Q-D),xe=i.P.convert(h.offset);let Pe=T.centerPoint.add(xe);const Me=T.pointLocation(Pe),He=i.aT.convert(h.center||Me);this._normalizeCenter(He);const Be=T.project(Me),et=T.project(He).sub(Be);let ut=h.curve;const tt=Math.max(T.width,T.height),Mt=tt/me,_t=et.mag();if("minZoom"in h){const Jt=i.aA(Math.min(h.minZoom,D,Q),T.minZoom,T.maxZoom),Es=tt/T.zoomScale(Jt-D);ut=Math.sqrt(Es/_t*2)}const kt=ut*ut;function xt(Jt){const Es=(Mt*Mt-tt*tt+(Jt?-1:1)*kt*kt*_t*_t)/(2*(Jt?Mt:tt)*kt*_t);return Math.log(Math.sqrt(Es*Es+1)-Es)}function pt(Jt){return(Math.exp(Jt)-Math.exp(-Jt))/2}function Et(Jt){return(Math.exp(Jt)+Math.exp(-Jt))/2}const Ht=xt(0);let Vt=function(Jt){return Et(Ht)/Et(Ht+ut*Jt)},ts=function(Jt){return tt*((Et(Ht)*(pt(Es=Ht+ut*Jt)/Et(Es))-pt(Ht))/kt)/_t;var Es},ss=(xt(1)-Ht)/ut;if(Math.abs(_t)<1e-6||!isFinite(ss)){if(Math.abs(tt-Mt)<1e-6)return this.easeTo(h,x);const Jt=Mth.maxDuration&&(h.duration=0);const fs=F!==re,Bs=oe!==z,Yt=!T.isPaddingEqual(ge),Ft=h.retainPadding===!1?T.clone():T,ds=Jt=>Es=>{const Qs=Es*ss,mr=1/Vt(Qs);Jt.zoom=Es===1?Q:D+Jt.scaleZoom(mr),fs&&(Jt.bearing=i.ak(F,re,Es)),Bs&&(Jt.pitch=i.ak(z,oe,Es)),Yt&&(Ft.interpolatePadding(H,ge,Es),Pe=Ft.centerPoint.add(xe));const Ks=Es===1?He:Jt.unproject(Be.add(et.mult(ts(Qs))).mult(mr));return Jt.setLocationAtPoint(Jt.renderWorldCopies?Ks.wrap():Ks,Pe),Jt._updateCameraOnTerrain(),h.preloadOnly||this._fireMoveEvents(x),Jt};if(h.preloadOnly){const Jt=this._emulate(ds,h.duration,T);return this._preloadTiles(Jt),this}return this._zooming=!0,this._rotating=fs,this._pitching=Bs,this._padding=Yt,this._prepareEase(x,!1),this._ease(ds(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),F=[],z=h(T.clone());for(let H=0;H<=D;H++){const Q=z(H/D);F.push(Q.clone())}return F}_preloadTiles(h,x){}}class Ib{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=j("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=j("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",T);const D=j("span","mapboxgl-ctrl-icon",this._compactButton);return D.setAttribute("aria-hidden","true"),D.setAttribute("title",T),this._innerContainer=j("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,F,z)=>(F.value&&(D+=`${F.key}=${F.value}${zD.length-F.length),h=h.filter((D,F)=>{for(let z=F+1;z=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?h=[...this.options.customAttribution,...h]:h.unshift(this.options.customAttribution));const T=h.map(D=>function(F){const z=new DOMParser().parseFromString(F,"text/html");return Array.from(z.body.querySelectorAll("*")).forEach(H=>{const Q=H.textContent||"";if(H.tagName!=="A")return void H.replaceWith(z.createTextNode(Q));const re=H.getAttribute("href");if(!re||!/^(https?:|mailto:)/i.test(re))return void H.replaceWith(z.createTextNode(Q));const oe=z.createElement("a");oe.href=re,oe.textContent=Q,oe.rel="noopener nofollow";const ge=H.getAttribute("class");ge&&(oe.className=ge),H.replaceWith(oe)}),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 Lb{constructor(){i.aY(["_updateLogo","_updateCompact"],this)}onAdd(h){this._map=h,this._container=j("div","mapboxgl-ctrl");const x=j("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 Iv{constructor(){i.aY(["_onIndoorUpdate"],this)}onAdd(h){return this._map=h,this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",x=>this._onIndoorUpdate(x)),this._container}_createButton(h,x){const T=j("button",h,this._container);return T.type="button",T.addEventListener("click",x),T}_createSeparator(){return j("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)});j("span","mapboxgl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.classList.add("mapboxgl-ctrl-level-button","mapboxgl-ctrl-buildings-toggle"),this._model&&!this._model.activeFloorsVisible&&h.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(h),this._createSeparator()}_updateBuildingsButtonState(){const h=this._container.querySelector(".mapboxgl-ctrl-buildings-toggle");h&&this._model&&(this._model.activeFloorsVisible?h.classList.remove("mapboxgl-ctrl-level-button-selected"):h.classList.add("mapboxgl-ctrl-level-button-selected"))}addCurrentFloors(h,x){for(let T=0;T{this._map._selectIndoorFloor(D.id)});this._setButtonTitle(F,D.zIndex.toString()),this._model&&D.id===this._model.selectedFloorId&&x&&F.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(F),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 Yf={"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 xx extends i.z{constructor(h,x,T,D){const{point:F,lngLat:z,originalEvent:H,target:Q}=h;super(h.type,{point:F,lngLat:z,originalEvent:H,target:Q}),this.preventDefault=()=>{h.preventDefault()},this.id=x,this.interaction=T,this.feature=D}}class Km{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 F=this.interactionsByType.get(D)||new Map;D==="mouseenter"||D==="mouseleave"?(this.delegatedInteractions.size===0&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(h,x)):F.size===0&&this.map.on(D,this.handleType),F.size===0&&this.interactionsByType.set(D,F),F.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,F]of x)F.target&&T.push({targetId:D,target:F.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:F}]of this.prevHoveredFeatures)this.hoveredFeatures.has(D)||T.set(F.id,F);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(),F=!!x;x=x||this.queryTargets(h.point,D);let z=!1;const H=new Set;for(const Q of x){for(const[re,oe]of D){if(!oe.target)continue;const ge=Q.variants?Q.variants[re]:null;if(ge){for(const me of ge){if(ex(me,Q,H,re))continue;const xe=new i.dx(Q,me),Pe=Lf(me,Q,re);F&&xe.id!==void 0&&(xe.state=this.map.getFeatureState(xe));const Me=T?this.prevHoveredFeatures.get(Pe):null,He=new xx(h,re,oe,xe),Be=Me?Me.stop:oe.handler(He);if(T&&this.hoveredFeatures.set(Pe,{feature:Q,stop:Be}),Be!==!1){z=!0;break}}if(z)break}}if(z)break}if(!z)for(const[Q,re]of D){const{handler:oe,target:ge}=re;if(!ge&&oe(new xx(h,Q,re,null))!==!1)break}}}function ode(M,h){if(Array.isArray(M)&&Array.isArray(h)){const x=new Set(M),T=new Set(h);return x.size===T.size&&M.every(D=>T.has(D))}return i.by(M,h)}const lde={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"},cde={showCompass:!0,showZoom:!0,visualizePitch:!1};class dde{constructor(h,x,T=!1){this._clickTolerance=10,this.element=x,this.mouseRotate=new qT({clickTolerance:h.dragRotate._mouseRotate._clickTolerance}),this.map=h,T&&(this.mousePitch=new UT({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),F=D&&D.bearingDelta;if(F&&T.setBearing(T.getBearing()+F),this.mousePitch){const z=this.mousePitch.mousemoveWindow(h,x),H=z&&z.pitchDelta;H&&T.setPitch(T.getPitch()+H)}}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=U(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=U(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(M);if(T.x>=0&&T.y>=0&&T.x<=x.width&&T.y<=x.height)break;M.lng>x.center.lng?M.lng-=360:M.lng+=360}return M}const fd={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%)"},lm={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class jC 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:F=1,draggable:z=!1,clickTolerance:H=0,rotation:Q=lm.rotation,rotationAlignment:re=lm.rotationAlignment,pitchAlignment:oe=lm.pitchAlignment,occludedOpacity:ge=lm.occludedOpacity,altitude:me=lm.altitude}=h||{};this._anchor=T,this._color=D,this._scale=F,this._draggable=z,this._clickTolerance=H,this._rotation=Q,this._rotationAlignment=re,this._pitchAlignment=oe,this._occludedOpacity=ge,this._altitude=me,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",Me=>{Me.preventDefault()}),this._element.addEventListener("mousedown",Me=>{Me.preventDefault()});const xe=this._element.classList;for(const Me in fd)xe.remove(`mapboxgl-marker-anchor-${Me}`);xe.add(`mapboxgl-marker-anchor-${this._anchor}`);const Pe=h&&h.className?h.className.trim().split(/\s+/):[];xe.add(...Pe),this._popup=null}_createDefaultMarker(){const h=j("div"),x=w("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},h);if(this._altitude===0){const T=w("radialGradient",{id:"shadowGradient"},w("defs",{},x));w("stop",{offset:"10%","stop-opacity":.4},T),w("stop",{offset:"100%","stop-opacity":.05},T),w("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},x)}return w("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},x),w("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},x),w("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||lm.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 F=D.position.toLngLat();return F.distanceTo(T)<.9*F.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) ${fd[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 Q=x.getPitch();return Q?`rotateX(${Q}deg)`:""}const D=i.cX(i.f6(x.transform,this._lngLat)),F=h.sub(i.f7(x.transform)),z=Math.abs(F.x)+Math.abs(F.y);if(z===0)return"";const H=D/z;return`rotateX(${-F.y*H}deg) rotateY(${F.x*H}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 F=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(F);T=i.cX(Math.atan2(z.y,z.x))-90}else T=-x.getBearing();else if(D==="horizon"){const F=i.ah(4,6,x.getZoom()),z=i.f7(x.transform);z.y+=F*x.transform.height;const H=h.sub(z),Q=i.cX(Math.atan2(H.y,H.x));T=(Q>90?Q-270:Q+90)*(1-F)}return T+=this._rotation,T?`rotateZ(${T}deg)`:""}_update(h){cancelAnimationFrame(this._updateFrameId);const x=this._map;x&&(x.transform.renderWorldCopies&&(this._lngLat=GT(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 F=this._clickTolerance||x._clickTolerance;if(h.point.dist(T)M.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(M.minPitch!=null&&M.maxPitch!=null&&M.minPitch>M.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(M.minPitch!=null&&M.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(M.maxPitch!=null&&M.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(M.antialias&&i.f3(window)&&(M.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 XM(M.minZoom,M.maxZoom,M.minPitch,M.maxPitch,M.renderWorldCopies,null,null),M),this._repaint=!!M.repaint,this._interactive=M.interactive,this._minTileCacheSize=M.minTileCacheSize,this._maxTileCacheSize=M.maxTileCacheSize,this._failIfMajorPerformanceCaveat=M.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=M.preserveDrawingBuffer,this._antialias=M.antialias,this._trackResize=M.trackResize,this._bearingSnap=M.bearingSnap,this._refreshExpiredTiles=M.refreshExpiredTiles,this._fadeDuration=M.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=M.crossSourceCollisions,this._collectResourceTiming=M.collectResourceTiming,this._language=this._parseLanguage(M.language),this._worldview=M.worldview,this._renderTaskQueue=new Kf,this._domRenderTaskQueue=new Kf,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.b2(),this._locale=Object.assign({},Yf,M.locale),this._clickTolerance=M.clickTolerance,this._cooperativeGestures=M.cooperativeGestures,this._performanceMetricsCollection=M.performanceMetricsCollection,this._tessellationStep=M.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=M.precompilePrograms,this._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Zf(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=M.scaleFactor,this._requestManager=new Y(M.transformRequest,M.accessToken,M.testMode),this._silenceAuthErrors=!!M.testMode,this._contextCreateOptions=M.contextCreateOptions?Object.assign({},M.contextCreateOptions):{},typeof M.container=="string"){const x=document.getElementById(M.container);if(!x)throw new Error(`Container '${M.container.toString()}' not found.`);this._container=x}else{if(!(M.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=M.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."),M.maxBounds&&this.setMaxBounds(M.maxBounds),this._spriteFormat=M.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 ide(this,M),this._localFontFamily=M.localFontFamily,this._localIdeographFontFamily=M.localIdeographFontFamily,(M.style||!M.testMode)&&this.setStyle(M.style||i.e.DEFAULT_STYLE,{config:M.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),M.projection&&this.setProjection(M.projection),M.hash&&(this._hash=new LT(typeof M.hash=="string"&&M.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){h.center==null&&h.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:M.center,zoom:M.zoom,bearing:M.bearing,pitch:M.pitch});const x=M.bounds;x&&(this.resize(),this.fitBounds(x,Object.assign({},M.fitBoundsOptions,{duration:0})))}this.resize(),M.attributionControl&&this.addControl(new Ib({customAttribution:M.customAttribution})),this._logoControl=new Lb,this.addControl(this._logoControl,M.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 Km(this)}_getMapId(){return this._mapId}addControl(M,h){if(h===void 0&&(h=M.getDefaultPosition?M.getDefaultPosition():"top-right"),!M||!M.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=M.onAdd(this);this._controls.push(M);const T=this._controlPositions[h];return h.indexOf("bottom")!==-1?T.insertBefore(x,T.firstChild):T.appendChild(x),this}removeControl(M){if(!M||!M.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(M);return h>-1&&this._controls.splice(h,1),M.onRemove(this),this}hasControl(M){return this._controls.indexOf(M)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(M){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",M)).fire(new i.z("move",M)),this.fire(new i.z("resize",M)),h&&this.fire(new i.z("moveend",M)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(M){return this.transform.setMaxBounds(i.aI.convert(M)),this._update()}setMinZoom(M){if((M=M??-2)>=-2&&M<=this.transform.maxZoom)return this.transform.minZoom=M,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=M,this._update(),this.getZoom()>M?this.setZoom(M):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(M){if((M=M??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(M>=0&&M<=this.transform.maxPitch)return this.transform.minPitch=M,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(M>=this.transform.minPitch)return this.transform.maxPitch=M,this._update(),this.getPitch()>M?this.setPitch(M):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(M){return this._scaleFactor=M,this.painter.scaleFactor=M,this._scaleFactorChanged=!0,this.style._updateFilteredLayers(h=>h.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(M){return this.transform.renderWorldCopies=M,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(M){return M==="auto"?navigator.language:Array.isArray(M)?M.length===0?void 0:M.map(h=>h==="auto"?navigator.language:h):M}setLanguage(M){const h=this._parseLanguage(M);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(M){return this.style&&M!==this._worldview?(this._worldview=M,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(M){return this._lazyInitEmptyStyle(),M?typeof M=="string"&&(M={name:M}):M=null,this._useExplicitProjection=!!M,this._prioritizeAndUpdateProjection(M,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const M=this.transform,h=M.projection.name;let x;h==="globe"&&M.zoom>=i.cL?(M.setMercatorFromTransition(),x=!0):h==="mercator"&&M.zoom=i.cL?this.transform.setMercatorFromTransition():this.transform.setProjection(M),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(M,h){return this.transform.locationPoint3D(i.aT.convert(M),h)}unproject(M,h){return this.transform.pointLocation3D(i.P.convert(M),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(M,h,x){const T=D=>{let F=[];if(Array.isArray(h)){const z=h.filter(H=>this.getLayer(H));F=z.length?this.queryRenderedFeatures(D,{layers:z}):[]}else F=this.queryRenderedFeatures(D,{target:h});return F};if(M==="mouseenter"||M==="mouseover"){let D=!1;return{listener:x,targets:h,delegates:{mousemove:z=>{const H=T(z.point);H.length?D||(D=!0,x.call(this,new Nu(M,this,z.originalEvent,{features:H}))):D=!1},mouseout:()=>{D=!1}}}}if(M==="mouseleave"||M==="mouseout"){let D=!1;return{listener:x,targets:h,delegates:{mousemove:H=>{T(H.point).length?D=!0:D&&(D=!1,x.call(this,new Nu(M,this,H.originalEvent)))},mouseout:H=>{D&&(D=!1,x.call(this,new Nu(M,this,H.originalEvent)))}}}}{const D=F=>{const z=T(F.point);z.length&&(F.features=z,x.call(this,F),delete F.features)};return{listener:x,targets:h,delegates:{[M]:D}}}}on(M,h,x){if(typeof h=="function"||x===void 0)return super.on(M,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const T=this._createDelegatedListener(M,h,x);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[M]=this._delegatedListeners[M]||[],this._delegatedListeners[M].push(T);for(const D in T.delegates)this.on(D,T.delegates[D]);return this}once(M,h,x){if(typeof h=="function"||x===void 0)return super.once(M,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const T=this._createDelegatedListener(M,h,x);for(const D in T.delegates)this.once(D,T.delegates[D]);return this}off(M,h,x){if(typeof h=="function"||x===void 0)return super.off(M,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const T=this._delegatedListeners?this._delegatedListeners[M]:void 0;return T&&(D=>{for(let F=0;F{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(M,h)}else T&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=h.localIdeographFontFamily,this._localFontFamily=h.localFontFamily,this._updateStyle(M,h))}_getUIString(M){const h=this._locale[M];if(h==null)throw new Error(`Missing UI string '${M}'`);return h}_updateStyle(M,h){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),M){const x=Object.assign({},h);h&&h.config&&(x.initialConfig=h.config,delete x.config),this.style=new om(this,x).load(M),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new om(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(M){return M==null?(this.fire(new i.y(new Error("IDs can't be empty."))),!1):!i.dr(M)||(this.fire(new i.y(new Error(`IDs can't contain special symbols: "${M}".`))),!1)}_isTargetValid(M){return"featuresetId"in M?this._isValidId("importId"in M?M.importId:M.featuresetId):"layerId"in M&&this._isValidId(M.layerId)}_areTargetsValid(M){if(Array.isArray(M)){for(const h of M)if(!this._isValidId(h))return!1;return!0}return this._isTargetValid(M)}addSource(M,h){return this._isValidId(M)?(this._lazyInitEmptyStyle(),this.style.addSource(M,h),this._update(!0)):this}isSourceLoaded(M){return!!this._isValidId(M)&&!!this.style&&this.style._isSourceCacheLoaded(M)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(M,h,x){this._lazyInitEmptyStyle(),this.style.addSourceType(M,h,x)}removeSource(M){return this._isValidId(M)?(this.style.removeSource(M),this._updateTerrain(),this._update(!0)):this}getSource(M){return this._isValidId(M)?this.style.getOwnSource(M):null}addImage(M,h,{pixelRatio:x=1,sdf:T=!1,stretchX:D,stretchY:F,content:z}={}){this._lazyInitEmptyStyle();const H=i.I.from(M);if(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap){const{width:Q,height:re,data:oe}=i.o.getImageData(h);this.style.addImage(H,{data:new i.q({width:Q,height:re},oe),pixelRatio:x,stretchX:D,stretchY:F,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:Q,height:re}=h,oe=h;this.style.addImage(H,{data:new i.q({width:Q,height:re},new Uint8Array(oe.data)),pixelRatio:x,stretchX:D,stretchY:F,content:z,sdf:T,usvg:!1,version:0,userImage:oe}),oe.onAdd&&oe.onAdd(this,M)}}updateImage(M,h){this._lazyInitEmptyStyle();const x=i.I.from(M),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:F,height:z,data:H}=D;if(F===void 0||z===void 0)return void this.fire(new i.y(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(F!==(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 (${F}, ${z}) must be that same as the previous version of the image (${T.data.width}, ${T.data.height})`)));const Q=!(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap);let re=!1;T.usvg?(T.data=new i.q({width:F,height:z},new Uint8Array(H)),T.usvg=!1,T.icon=void 0,re=!0):T.data.replace(H,Q),this.style.updateImage(x,T,re)}hasImage(M){return M?!!this.style&&!!this.style.getImage(i.I.from(M)):(this.fire(new i.y(new Error("Missing required image id"))),!1)}removeImage(M){this.style.removeImage(i.I.from(M))}loadImage(M,h){i.n(this._requestManager.transformRequest(M,i.R.Image),(x,T)=>{h(x,T instanceof HTMLImageElement?i.o.getImageData(T):T)})}listImages(){return this.style.listImages().map(M=>M.name)}addModel(M,h){this._lazyInitEmptyStyle(),this.style.addModel(M,h)}hasModel(M){return M?this.style.hasModel(M):(this.fire(new i.y(new Error("Missing required model id"))),!1)}removeModel(M){this.style.removeModel(M)}listModels(){return this.style.listModels()}addLayer(M,h){return this._isValidId(M.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(M,h),this._update(!0)):this}getSlot(M){const h=this.getLayer(M);return h&&h.slot||null}setSlot(M,h){return this.style.setSlot(M,h),this.style.mergeLayers(),this._update(!0)}addImport(M,h){return this.style.addImport(M,h).catch(x=>this.fire(new i.y(new Error("Failed to add import",x)))),this}updateImport(M,h){return typeof h!="string"&&h.id!==M?(this.removeImport(M),this.addImport(h)):(this.style.updateImport(M,h),this._update(!0))}removeImport(M){return this.style.removeImport(M),this}moveImport(M,h){return this.style.moveImport(M,h),this._update(!0)}moveLayer(M,h){return this._isValidId(M)?(this.style.moveLayer(M,h),this._update(!0)):this}removeLayer(M){return this._isValidId(M)?(this.style.removeLayer(M),this._update(!0)):this}getLayer(M){if(!this._isValidId(M))return null;const h=this.style.getOwnLayer(M);return h?h.type==="custom"?h.implementation:h.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(M,h,x){return this._isValidId(M)?(this.style.setLayerZoomRange(M,h,x),this._update(!0)):this}setFilter(M,h,x={}){return this._isValidId(M)?(this.style.setFilter(M,h,x),this._update(!0)):this}getFilter(M){return this._isValidId(M)?this.style.getFilter(M):null}setPaintProperty(M,h,x,T={}){return this._isValidId(M)?(this.style.setPaintProperty(M,h,x,T),this._update(!0)):this}getPaintProperty(M,h){return this._isValidId(M)?this.style.getPaintProperty(M,h):null}setLayoutProperty(M,h,x,T={}){return this._isValidId(M)?(this.style.setLayoutProperty(M,h,x,T),this._update(!0)):this}getLayoutProperty(M,h){return this._isValidId(M)?this.style.getLayoutProperty(M,h):null}setLayerProperty(M,h,x,T={}){return this._isValidId(M)?(h==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(M,h,x,T),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(M){return this.style.setGlyphsUrl(M),this._update(!0)}getSchema(M){return this.style.getSchema(M)}setSchema(M,h){return this.style.setSchema(M,h),this._update(!0)}getConfig(M){return this.style.getConfig(M)}setConfig(M,h){return this.style.setConfig(M,h),this._update(!0)}getConfigProperty(M,h){return this.style.getConfigProperty(M,h)}setConfigProperty(M,h,x){return this.style.setConfigProperty(M,h,x),this._update(!0)}getFeaturesetDescriptors(M){return this.style.getFeaturesetDescriptors(M)}setLights(M){if(this._lazyInitEmptyStyle(),M&&M.length===1&&M[0].type==="flat"){const h=M[0];h.properties?this.style.setFlatLight(h.properties,h.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(M),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const M=this.style.getLights()||[];return M.length===0&&M.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),M}setLight(M,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:M}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(M){return this._lazyInitEmptyStyle(),!M&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(M),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(M){return this._lazyInitEmptyStyle(),this.style.setFog(M),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(M){return this._lazyInitEmptyStyle(),this.style.setSnow(M),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(M){return this._lazyInitEmptyStyle(),this.style.setRain(M),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(M){return this._lazyInitEmptyStyle(),this.style.setColorTheme(M),this._update(!0)}setImportColorTheme(M,h){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(M,h),this._update(!0)}setCamera(M){return this.style.setCamera(M),this._triggerCameraUpdate(M)}_triggerCameraUpdate(M){return this._update(this.transform.setOrthographicProjectionAtLowPitch(M["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(M){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.aT.convert(M),this.transform):0}setFeatureState(M,h){return M.source&&!this._isValidId(M.source)?this:(this.style.setFeatureState(M,h),this._update())}removeFeatureState(M,h){return M.source&&!this._isValidId(M.source)?this:(this.style.removeFeatureState(M,h),this._update())}getFeatureState(M){return M.source&&!this._isValidId(M.source)?null:this.style.getFeatureState(M)}_selectIndoorFloor(M){this.indoor.selectFloor(M)}_setIndoorActiveFloorsVisibility(M){this.indoor.setActiveFloorsVisibility(M)}_addIndoorControl(){this._indoorControl||(this._indoorControl=new Iv),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;const M=this._container.getBoundingClientRect().width||400,h=this._container.getBoundingClientRect().height||300;let x,T,D,F=this._container;for(;F&&(!T||!D);){const z=window.getComputedStyle(F).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])),F=F.parentElement}this._containerWidth=T?Math.abs(M/T):M,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 dD(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 M=this._container;M.classList.add("mapboxgl-map"),(this._missingCSSCanary=j("div","mapboxgl-canary",M)).style.visibility="hidden",this._detectMissingCSS();const h=this._canvasContainer=j("div","mapboxgl-canvas-container",M);this._canvas=j("canvas","mapboxgl-canvas",h),this._interactive&&(h.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const x=this._controlContainer=j("div","mapboxgl-control-container",M),T=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(D=>{T[D]=j("div",`mapboxgl-ctrl-${D}`,x)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(M,h){const x=i.o.devicePixelRatio||1;this._canvas.width=x*Math.ceil(M),this._canvas.height=x*Math.ceil(h),this._canvas.style.width=`${M}px`,this._canvas.style.height=`${h}px`}_addMarker(M){this._markers.push(M)}_removeMarker(M){const h=this._markers.indexOf(M);h!==-1&&this._markers.splice(h,1)}_addPopup(M){this._popups.push(M)}_removePopup(M){const h=this._popups.indexOf(M);h!==-1&&this._popups.splice(h,1)}_setupPainter(){const M=Object.assign({},b.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),h=this._canvas.getContext("webgl2",M);h?(rt(h,!0),this.painter=new cC(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(M){M.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.z("webglcontextlost",{originalEvent:M}))}_contextRestored(M){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:M}))}_onMapScroll(M){if(M.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(M){return this.style?(this._styleDirty=this._styleDirty||M,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(M){return this._update(),this._renderTaskQueue.add(M)}_cancelRenderFrame(M){this._renderTaskQueue.remove(M)}_requestDomTask(M){!this.loaded()||this.loaded()&&!this.isMoving()?M():this._domRenderTaskQueue.add(M)}_render(M){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(M),this._domRenderTaskQueue.run(M),this._removed)return;this._updateProjectionTransition();const F=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const re=this.transform.zoom,oe=this.transform.pitch,ge=i.o.now(),me=new i.ac(re,{now:ge,fadeDuration:F,pitch:oe,transition:this.style.transition,worldview:this._worldview});this.style.update(me)}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 H=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,F,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),H&&(this._placementDirty=H.needsRerender),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:F,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new i.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.mark(u.load),this.fire(new i.z("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),h){const re=i.o.now()-T;D.endQuery(x.TIME_ELAPSED_EXT),setTimeout(()=>{const oe=D.getQueryParameter(h,D.QUERY_RESULT)/1e6;D.deleteQuery(h),this.fire(new i.z("gpu-timing-frame",{cpuTime:re,gpuTime:oe}))},50)}if(this.listens("gpu-timing-layer")){const re=this.painter.collectGpuTimers();setTimeout(()=>{const oe=this.painter.queryGpuTimers(re);this.fire(new i.z("gpu-timing-layer",{layerTimes:oe}))},50)}if(this.listens("gpu-timing-deferred-render")){const re=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const oe=this.painter.queryGpuTimeDeferredRender(re);this.fire(new i.z("gpu-timing-deferred-render",{gpuTime:oe}))},50)}const Q=this._sourcesDirty||this._styleDirty||this._placementDirty||z;if(Q||this._repaint)this.triggerRepaint();else{const 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 oe=this._calculateSpeedIndex();this.fire(new i.z("speedindexcompleted",{speedIndex:oe})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||Q||(this._fullyLoaded=!0,p.mark(u.fullLoad),this._performanceMetricsCollection&&Dt(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(M){for(const h of this._markers)M&&!this.getRenderWorldCopies()&&(h._lngLat=h._lngLat.wrap()),h._update();for(const h of this._popups)!M||this.getRenderWorldCopies()||h._trackPointer||(h._lngLat=h._lngLat.wrap()),h._update()}_updateAverageElevation(M,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||M-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(M)){const D=this.transform.averageElevation;let F=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(F)?F=0:this._averageElevationLastSampledAt=M;const z=Math.abs(D-F);if(z>1){if(this._isInitialLoad||T)return this._averageElevation.jumpTo(F),x(F);this._averageElevation.easeTo(F,M,300)}else if(z>1e-4)return this._averageElevation.jumpTo(F),x(F)}return!!this._averageElevation.isEasing(M)&&x(this._averageElevation.getValue(M))}_authenticate(){Qe(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,M=>{if(M&&(M.message===te||M.status===401)){const h=this.painter.context.gl;rt(h,!1),this._logoControl instanceof Lb&&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/")))}}),_e(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&Te(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&Ae(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){ht(this._requestManager._customAccessToken)}_updateTerrain(){const M=this._isDragging();this.painter.updateTerrain(this.style,M)}_calculateSpeedIndex(){const M=this.painter.canvasCopy(),h=this.painter.getCanvasCopiesAndTimestamps();h.timeStamps.push(performance.now());const x=this.painter.context.gl,T=x.createFramebuffer();function D(F){x.framebufferTexture2D(x.FRAMEBUFFER,x.COLOR_ATTACHMENT0,x.TEXTURE_2D,F,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(M),h.canvasCopies.map(D),h.timeStamps)}_canvasPixelComparison(M,h,x){let T=x[1]-x[0];const D=M.length/4;for(let F=0;F{const x=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,x&&this._render(h)}))}_preloadTiles(M){const h=this.style?this.style.getSourceCaches():[];return i.bw(h,(x,T)=>x._preloadTiles(M,T),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(M){this._trackResize&&this.resize({originalEvent:M})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(M){this._showTileBoundaries!==M&&(this._showTileBoundaries=M,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(M){this._showParseStatus!==M&&(this._showParseStatus=M,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(M){this._showTerrainWireframe!==M&&(this._showTerrainWireframe=M,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(M){this._showLayers2DWireframe!==M&&(this._showLayers2DWireframe=M,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(M){this._showLayers3DWireframe!==M&&(this._showLayers3DWireframe=M,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(M){this._speedIndexTiming!==M&&(this._speedIndexTiming=M,this._update())}get showPadding(){return!!this._showPadding}set showPadding(M){this._showPadding!==M&&(this._showPadding=M,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(M){this._showCollisionBoxes!==M&&(this._showCollisionBoxes=M,this.style&&M?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(M){this._showOverdrawInspector!==M&&(this._showOverdrawInspector=M,this._update())}get repaint(){return!!this._repaint}set repaint(M){this._repaint!==M&&(this._repaint=M,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(M){this._vertices=M,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(M){this._showTileAABBs!==M&&(this._showTileAABBs=M,M&&this._update())}_setCacheLimits(M,h){i.f4(M,h)}get version(){return d}},NavigationControl:class{constructor(M={}){this.options=Object.assign({},cde,M),this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",h=>h.preventDefault()),this.options.showZoom&&(i.aY(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",h=>{this._map&&this._map.zoomIn({},{originalEvent:h})}),j("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",h=>{this._map&&this._map.zoomOut({},{originalEvent:h})}),j("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.aY(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",h=>{const x=this._map;x&&(this.options.visualizePitch?x.resetNorthPitch({},{originalEvent:h}):x.resetNorth({},{originalEvent:h}))}),this._compassIcon=j("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const M=this._map;if(!M)return;const h=M.getZoom(),x=h===M.getMaxZoom(),T=h===M.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 M=this._map;if(!M)return;const h=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(M.transform.pitch*(Math.PI/180)),.5)}) rotateX(${M.transform.pitch}deg) rotateZ(${M.transform.angle*(180/Math.PI)}deg)`:`rotate(${M.transform.angle*(180/Math.PI)}deg)`;M._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=h)})}onAdd(M){return this._map=M,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),M.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&M.on("pitch",this._rotateCompassArrow),M.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new dde(M,this._compass,this.options.visualizePitch)),this._container}onRemove(){const M=this._map;M&&(this._container.remove(),this.options.showZoom&&M.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&M.off("pitch",this._rotateCompassArrow),M.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(M,h){const x=j("button",M,this._container);return x.type="button",x.addEventListener("click",h),x}_setButtonTitle(M,h){if(!this._map)return;const x=this._map._getUIString(`NavigationControl.${h}`);M.setAttribute("aria-label",x),M.firstElementChild&&M.firstElementChild.setAttribute("title",x)}},GeolocateControl:class extends i.E{constructor(M={}){super();const h=navigator.geolocation;this.options=Object.assign({geolocation:h},ude,M),i.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=dC(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(M){return this._map=M,this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(M){const h=(x=!!this.options.geolocation)=>{this._supportsGeolocation=x,M(x)};this._supportsGeolocation!==void 0?M(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(x=>h(x.state!=="denied")).catch(()=>h()):h()}_isOutOfMapMaxBounds(M){const h=this._map.getMaxBounds(),x=M.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(M){if(this._map){if(this._isOutOfMapMaxBounds(M))return this._setErrorState(),this.fire(new i.z("outofmaxbounds",M)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=M,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(M),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(M),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.z("geolocate",Object.assign({coords:M.coords,timestamp:M.timestamp},M.toJSON?{toJSON:M.toJSON.bind(M)}:{}))),this._finish()}}_updateCamera(M){const h=new i.aT(M.coords.longitude,M.coords.latitude),x=M.coords.accuracy,T=this._map.getBearing(),D=Object.assign({bearing:T},this.options.fitBoundsOptions);this._map.fitBounds(h.toBounds(x),D,{geolocateSource:!0})}_updateMarker(M){if(M){const h=new i.aT(M.coords.longitude,M.coords.latitude);this._accuracyCircleMarker.setLngLat(h).addTo(this._map),this._userLocationDotMarker.setLngLat(h).addTo(this._map),this._accuracy=M.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const M=this._map.transform,h=i.cf(1,M._center.lat)*M.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(M){if(this._map){if(this.options.trackUserLocation)if(M.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(M.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",M)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(M){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",h=>h.preventDefault()),this._geolocateButton=j("button","mapboxgl-ctrl-geolocate",this._container),j("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",M===!1){i.w("Geolocation support is not available so the GeolocateControl will be disabled.");const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h)}else{const h=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=j("div","mapboxgl-user-location"),this._dotElement.appendChild(j("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(j("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new jC({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=j("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new jC({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(M){this._userLocationDotMarker&&(M.webkitCompassHeading?this._heading=M.webkitCompassHeading:M.absolute===!0&&(this._heading=-1*M.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 M;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(M={maximumAge:6e5,timeout:0},this._noTimeout=!0):(M=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,M),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 M=()=>{"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"&&M()}).catch(console.error):M()}_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:Ib,ScaleControl:class{constructor(M={}){this.options=Object.assign({},Lv,M),i.aY(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const M=this.options.maxWidth||100,h=this._map,x=h._containerHeight/2,T=h._containerWidth/2-M/2,D=h.unproject([T,x]),F=h.unproject([T+M,x]),z=D.distanceTo(F);if(this.options.unit==="imperial"){const H=3.2808*z;H>5280?this._setScale(M,H/5280,"mile"):this._setScale(M,H,"foot")}else this.options.unit==="nautical"?this._setScale(M,z/1852,"nautical-mile"):z>=1e3?this._setScale(M,z/1e3,"kilometer"):this._setScale(M,z,"meter")}_setScale(M,h,x){this._map._requestDomTask(()=>{const T=function(F){const z=Math.pow(10,`${Math.floor(F)}`.length-1);let H=F/z;return H=H>=10?10:H>=5?5:H>=3?3:H>=2?2:H>=1?1:function(Q){const re=Math.pow(10,Math.ceil(-Math.log(Q)/Math.LN10));return Math.round(Q*re)/re}(H),z*H}(h),D=T/h;this._container.innerHTML=x!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:x}).format(T):`${T} ${KT[x]}`,this._container.style.width=M*D+"px"})}onAdd(M){return this._map=M,this._language=M.getLanguage(),this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-scale",M.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(M){this._language=M,this._update()}setUnit(M){this.options.unit=M,this._update()}},FullscreenControl:class{constructor(M={}){this._fullscreen=!1,M&&M.container&&(M.container instanceof HTMLElement?this._container=M.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(M){return this._map=M,this._container||(this._container=this._map.getContainer()),this._controlContainer=j("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const M=this._fullscreenButton=j("button","mapboxgl-ctrl-fullscreen",this._controlContainer);j("span","mapboxgl-ctrl-icon",M).setAttribute("aria-hidden","true"),M.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const M=this._getTitle();this._fullscreenButton.setAttribute("aria-label",M),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",M)}_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:Iv,Popup:class extends i.E{constructor(M){super(),this.options=Object.assign(Object.create(cm),M),this._altitude=this.options.altitude,i.aY(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(M&&M.className?M.className.trim().split(/\s+/):[])}addTo(M){return this._map&&this.remove(),this._map=M,this.options.closeOnClick&&M.on("preclick",this._onClose),this.options.closeOnMove&&M.on("move",this._onClose),M.on("remove",this.remove),this._update(),M._addPopup(this),this._focusFirstElement(),this._trackPointer?(M.on("mousemove",this._onMouseEvent),M.on("mouseup",this._onMouseEvent),M._canvasContainer.classList.add("mapboxgl-track-pointer")):M.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 M=this._map;return M&&(M.off("move",this._update),M.off("move",this._onClose),M.off("preclick",this._onClose),M.off("click",this._onClose),M.off("remove",this.remove),M.off("mousemove",this._onMouseEvent),M.off("mouseup",this._onMouseEvent),M.off("drag",this._onMouseEvent),M._canvasContainer&&M._canvasContainer.classList.remove("mapboxgl-track-pointer"),M._removePopup(this),this._map=void 0),this.fire(new i.z("close")),this}getLngLat(){return this._lngLat}setLngLat(M){this._lngLat=i.aT.convert(M),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(M){return this._altitude=M,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const M=this._map;return M&&(M.off("move",this._update),M.on("mousemove",this._onMouseEvent),M.on("drag",this._onMouseEvent),M._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(M){return this.setDOMContent(document.createTextNode(M))}setHTML(M){const h=document.createDocumentFragment(),x=document.createElement("body");let T;for(x.innerHTML=M;T=x.firstChild,T;)h.appendChild(T);return this.setDOMContent(h)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(M){return this.options.maxWidth=M,this._update(),this}setDOMContent(M){let h=this._content;if(h)for(;h.hasChildNodes();)h.firstChild&&h.removeChild(h.firstChild);else h=this._content=j("div","mapboxgl-popup-content",this._container||void 0);if(h.appendChild(M),this.options.closeButton){const x=this._closeButton=j("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(M){return this._classList.add(M),this._updateClassList(),this}removeClassName(M){return this._classList.delete(M),this._updateClassList(),this}setOffset(M){return this.options.offset=M,this._update(),this}toggleClassName(M){let h;return this._classList.delete(M)?h=!1:(this._classList.add(M),h=!0),this._updateClassList(),h}_onMouseEvent(M){this._update(M.point)}_getAnchor(M){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,F=x.offsetHeight,z=T.xh.transform.width-D/2;if(T.y+Mh.transform.height-F){if(z)return"bottom-left";if(H)return"bottom-right"}return z?"left":H?"right":"bottom"}_updateClassList(){const M=this._container;if(!M)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"),M.className=h.join(" ")}_update(M){const h=this._map,x=this._content;if(!h||!this._lngLat&&!this._trackPointer||!x)return;let T=this._container;if(T||(T=this._container=j("div","mapboxgl-popup",h.getContainer()),this._tip=j("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=GT(this._lngLat,this._pos,h.transform)),!this._trackPointer||M){const D=this._pos=this._trackPointer&&M instanceof i.P?M:h.project(this._lngLat,this._altitude),F=zy(this.options.offset),z=this._anchor=this._getAnchor(F.y),H=zy(this.options.offset,z),Q=D.add(H).round();h._requestDomTask(()=>{this._container&&z&&(this._container.style.transform=`${fd[z]} translate(${Q.x}px,${Q.y}px)`)})}if(!this._marker&&h._showingGlobe()){const D=i.f5(h.transform,this._lngLat)?0:1;this._setOpacity(D)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const M=this._container.querySelector(dm);M&&M.focus()}_onClose(){this.remove()}_setOpacity(M){this._container&&(this._container.style.opacity=`${M}`),this._content&&(this._content.style.pointerEvents=M?"auto":"none")}},Marker:jC,Style:om,LngLat:i.aT,LngLatBounds:i.aI,Point:i.P,MercatorCoordinate:i.ae,FreeCameraOptions:eu,Evented:i.E,config:i.e,prewarm:i.f9,clearPrewarmedResources:i.f8,get accessToken(){return i.e.ACCESS_TOKEN},set accessToken(M){i.e.ACCESS_TOKEN=M},get baseApiUrl(){return i.e.API_URL},set baseApiUrl(M){i.e.API_URL=M},get workerCount(){return i.fi.workerCount},set workerCount(M){i.fi.workerCount=M},get maxParallelImageRequests(){return i.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(M){i.e.MAX_PARALLEL_IMAGE_REQUESTS=M},clearStorage(M){i.fh(M)},get workerUrl(){return i.fg.workerUrl},set workerUrl(M){i.fg.workerUrl=M},get workerClass(){return i.fg.workerClass},set workerClass(M){i.fg.workerClass=M},get workerParams(){return i.fg.workerParams},set workerParams(M){i.fg.workerParams=M},get dracoUrl(){return i.ff()},set dracoUrl(M){i.fe(M)},get meshoptUrl(){return i.fd()},set meshoptUrl(M){i.fc(M)},setNow:i.o.setNow,restoreNow:i.o.restoreNow}});var l=a;return l})})(wBe);var myt=wBe.exports;const qc=_o(myt);function gs({className:t,...s}){return e.jsx("div",{className:Pt("animate-pulse rounded-md bg-muted",t),...s})}const S5e={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},C5e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function pyt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function fyt({listings:t,isLoading:s}){const r=Dr(),n=S.useRef(null),a=S.useRef(null),o=S.useRef([]),[l,i]=S.useState(""),[d,u]=S.useState(!0);return S.useEffect(()=>{(async()=>{u(!0);try{const{data:v}=await G.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)})()},[]),S.useEffect(()=>{if(!n.current||!l||a.current)return;qc.accessToken=l;const f=t.filter(b=>b.latitude!=null&&b.longitude!=null);let v=[-98.5795,39.8283],_=4;if(f.length>0){const b=f.reduce((w,N)=>w+N.longitude,0)/f.length,j=f.reduce((w,N)=>w+N.latitude,0)/f.length;v=[b,j],_=f.length===1?12:10}return a.current=new qc.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:_,center:v}),a.current.addControl(new qc.NavigationControl,"top-right"),()=>{var b;(b=a.current)==null||b.remove(),a.current=null}},[l]),S.useEffect(()=>{if(!a.current||!l)return;o.current.forEach(v=>v.remove()),o.current=[];const f=t.filter(v=>v.latitude!=null&&v.longitude!=null);if(f.forEach(v=>{var I,L,R;const _=S5e[v.status]||"#10B981",b=((I=v.photos)==null?void 0:I.find($=>$.is_primary))||((L=v.photos)==null?void 0:L[0]),w=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 C=new qc.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${b!=null&&b.photo_url?``:""}
${pyt(v.price)}
${v.property_address||""}
${v.city}, ${v.state}
${C5e[v.status]||v.status} ${v.bedrooms?`${v.bedrooms} bed`:""} ${v.bathrooms?`${v.bathrooms} bath`:""}
${(R=v.agent)!=null&&R.name?`
Listed by ${v.agent.name}
`:""}
Click to view details →
`),A=new qc.Marker(N).setLngLat([v.longitude,v.latitude]).setPopup(C).addTo(a.current);o.current.push(A)}),f.length>1){const v=new qc.LngLatBounds;f.forEach(_=>v.extend([_.longitude,_.latitude])),a.current.fitBounds(v,{padding:60,maxZoom:13})}else f.length===1&&a.current.flyTo({center:[f[0].longitude,f[0].latitude],zoom:12})},[t,l]),S.useEffect(()=>(window.__navigateToPublicListing__=f=>{r(f)},()=>{delete window.__navigateToPublicListing__}),[r]),d||s?e.jsx(gs,{className:"w-full h-[500px] rounded-lg"}):!l||t.filter(f=>f.latitude!=null&&f.longitude!=null).length===0?null:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:Object.entries(S5e).map(([f,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:C5e[f]})]},f))}),e.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function ZI(t,[s,r]){return Math.min(r,Math.max(s,t))}function NL(t){const s=S.useRef({value:t,previous:t});return S.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var gyt=[" ","Enter","ArrowUp","ArrowDown"],xyt=[" ","Enter"],AN="Select",[voe,_oe,yyt]=cL(AN),[fM]=Ac(AN,[yyt,hy]),boe=hy(),[vyt,U_]=fM(AN),[_yt,byt]=fM(AN),kBe=t=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:o,value:l,defaultValue:i,onValueChange:d,dir:u,name:p,autoComplete:f,disabled:v,required:_,form:b}=t,j=boe(s),[w,N]=S.useState(null),[C,A]=S.useState(null),[I,L]=S.useState(!1),R=$_(u),[$,q]=xu({prop:n,defaultProp:a??!1,onChange:o,caller:AN}),[U,V]=xu({prop:l,defaultProp:i,onChange:d,caller:AN}),X=S.useRef(null),se=w?b||!!w.closest("form"):!0,[te,Y]=S.useState(new Set),de=Array.from(te).map(ie=>ie.props.value).join(";");return e.jsx(mL,{...j,children:e.jsxs(vyt,{required:_,scope:s,trigger:w,onTriggerChange:N,valueNode:C,onValueNodeChange:A,valueNodeHasChildren:I,onValueNodeHasChildrenChange:L,contentId:Gd(),value:U,onValueChange:V,open:$,onOpenChange:q,dir:R,triggerPointerDownPosRef:X,disabled:v,children:[e.jsx(voe.Provider,{scope:s,children:e.jsx(_yt,{scope:t.__scopeSelect,onNativeOptionAdd:S.useCallback(ie=>{Y(ae=>new Set(ae).add(ie))},[]),onNativeOptionRemove:S.useCallback(ie=>{Y(ae=>{const le=new Set(ae);return le.delete(ie),le})},[]),children:r})}),se?e.jsxs(KBe,{"aria-hidden":!0,required:_,tabIndex:-1,name:p,autoComplete:f,value:U,onChange:ie=>V(ie.target.value),disabled:v,form:b,children:[U===void 0?e.jsx("option",{value:""}):null,Array.from(te)]},de):null]})})};kBe.displayName=AN;var NBe="SelectTrigger",SBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=boe(r),l=U_(NBe,r),i=l.disabled||n,d=Pa(s,l.onTriggerChange),u=_oe(r),p=S.useRef("touch"),[f,v,_]=YBe(j=>{const w=u().filter(A=>!A.disabled),N=w.find(A=>A.value===l.value),C=XBe(w,j,N);C!==void 0&&l.onValueChange(C.value)}),b=j=>{i||(l.onOpenChange(!0),_()),j&&(l.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})};return e.jsx(oM,{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":ZBe(l.value)?"":void 0,...a,ref:d,onClick:Cr(a.onClick,j=>{j.currentTarget.focus(),p.current!=="mouse"&&b(j)}),onPointerDown:Cr(a.onPointerDown,j=>{p.current=j.pointerType;const w=j.target;w.hasPointerCapture(j.pointerId)&&w.releasePointerCapture(j.pointerId),j.button===0&&j.ctrlKey===!1&&j.pointerType==="mouse"&&(b(j),j.preventDefault())}),onKeyDown:Cr(a.onKeyDown,j=>{const w=f.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&v(j.key),!(w&&j.key===" ")&&gyt.includes(j.key)&&(b(),j.preventDefault())})})})});SBe.displayName=NBe;var CBe="SelectValue",MBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:l="",...i}=t,d=U_(CBe,r),{onValueNodeHasChildrenChange:u}=d,p=o!==void 0,f=Pa(s,d.onValueNodeChange);return Zc(()=>{u(p)},[u,p]),e.jsx(Qr.span,{...i,ref:f,style:{pointerEvents:"none"},children:ZBe(d.value)?e.jsx(e.Fragment,{children:l}):o})});MBe.displayName=CBe;var wyt="SelectIcon",TBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,children:n,...a}=t;return e.jsx(Qr.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});TBe.displayName=wyt;var jyt="SelectPortal",ABe=t=>e.jsx(rM,{asChild:!0,...t});ABe.displayName=jyt;var EN="SelectContent",EBe=S.forwardRef((t,s)=>{const r=U_(EN,t.__scopeSelect),[n,a]=S.useState();if(Zc(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?wm.createPortal(e.jsx(PBe,{scope:t.__scopeSelect,children:e.jsx(voe.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),o):null}return e.jsx(IBe,{...t,ref:s})});EBe.displayName=EN;var pg=10,[PBe,V_]=fM(EN),kyt="SelectContentImpl",Nyt=j_("SelectContent.RemoveScroll"),IBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:i,sideOffset:d,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:v,collisionPadding:_,sticky:b,hideWhenDetached:j,avoidCollisions:w,...N}=t,C=U_(EN,r),[A,I]=S.useState(null),[L,R]=S.useState(null),$=Pa(s,Te=>I(Te)),[q,U]=S.useState(null),[V,X]=S.useState(null),se=_oe(r),[te,Y]=S.useState(!1),de=S.useRef(!1);S.useEffect(()=>{if(A)return uoe(A)},[A]),loe();const ie=S.useCallback(Te=>{const[Fe,...Ae]=se().map(De=>De.ref.current),[We]=Ae.slice(-1),ht=document.activeElement;for(const De of Te)if(De===ht||(De==null||De.scrollIntoView({block:"nearest"}),De===Fe&&L&&(L.scrollTop=0),De===We&&L&&(L.scrollTop=L.scrollHeight),De==null||De.focus(),document.activeElement!==ht))return},[se,L]),ae=S.useCallback(()=>ie([q,A]),[ie,q,A]);S.useEffect(()=>{te&&ae()},[te,ae]);const{onOpenChange:le,triggerPointerDownPosRef:pe}=C;S.useEffect(()=>{if(A){let Te={x:0,y:0};const Fe=We=>{var ht,De;Te={x:Math.abs(Math.round(We.pageX)-(((ht=pe.current)==null?void 0:ht.x)??0)),y:Math.abs(Math.round(We.pageY)-(((De=pe.current)==null?void 0:De.y)??0))}},Ae=We=>{Te.x<=10&&Te.y<=10?We.preventDefault():A.contains(We.target)||le(!1),document.removeEventListener("pointermove",Fe),pe.current=null};return pe.current!==null&&(document.addEventListener("pointermove",Fe),document.addEventListener("pointerup",Ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Fe),document.removeEventListener("pointerup",Ae,{capture:!0})}}},[A,le,pe]),S.useEffect(()=>{const Te=()=>le(!1);return window.addEventListener("blur",Te),window.addEventListener("resize",Te),()=>{window.removeEventListener("blur",Te),window.removeEventListener("resize",Te)}},[le]);const[be,ye]=YBe(Te=>{const Fe=se().filter(ht=>!ht.disabled),Ae=Fe.find(ht=>ht.ref.current===document.activeElement),We=XBe(Fe,Te,Ae);We&&setTimeout(()=>We.ref.current.focus())}),we=S.useCallback((Te,Fe,Ae)=>{const We=!de.current&&!Ae;(C.value!==void 0&&C.value===Fe||We)&&(U(Te),We&&(de.current=!0))},[C.value]),ke=S.useCallback(()=>A==null?void 0:A.focus(),[A]),Ze=S.useCallback((Te,Fe,Ae)=>{const We=!de.current&&!Ae;(C.value!==void 0&&C.value===Fe||We)&&X(Te)},[C.value]),_e=n==="popper"?kge:LBe,Ce=_e===kge?{side:i,sideOffset:d,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:v,collisionPadding:_,sticky:b,hideWhenDetached:j,avoidCollisions:w}:{};return e.jsx(PBe,{scope:r,content:A,viewport:L,onViewportChange:R,itemRefCallback:we,selectedItem:q,onItemLeave:ke,itemTextRefCallback:Ze,focusSelectedItem:ae,selectedItemText:V,position:n,isPositioned:te,searchRef:be,children:e.jsx(vL,{as:Nyt,allowPinchZoom:!0,children:e.jsx(xL,{asChild:!0,trapped:C.open,onMountAutoFocus:Te=>{Te.preventDefault()},onUnmountAutoFocus:Cr(a,Te=>{var Fe;(Fe=C.trigger)==null||Fe.focus({preventScroll:!0}),Te.preventDefault()}),children:e.jsx(R_,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Te=>Te.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:e.jsx(_e,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:Te=>Te.preventDefault(),...N,...Ce,onPlaced:()=>Y(!0),ref:$,style:{display:"flex",flexDirection:"column",outline:"none",...N.style},onKeyDown:Cr(N.onKeyDown,Te=>{const Fe=Te.ctrlKey||Te.altKey||Te.metaKey;if(Te.key==="Tab"&&Te.preventDefault(),!Fe&&Te.key.length===1&&ye(Te.key),["ArrowUp","ArrowDown","Home","End"].includes(Te.key)){let We=se().filter(ht=>!ht.disabled).map(ht=>ht.ref.current);if(["ArrowUp","End"].includes(Te.key)&&(We=We.slice().reverse()),["ArrowUp","ArrowDown"].includes(Te.key)){const ht=Te.target,De=We.indexOf(ht);We=We.slice(De+1)}setTimeout(()=>ie(We)),Te.preventDefault()}})})})})})})});IBe.displayName=kyt;var Syt="SelectItemAlignedPosition",LBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=U_(EN,r),l=V_(EN,r),[i,d]=S.useState(null),[u,p]=S.useState(null),f=Pa(s,$=>p($)),v=_oe(r),_=S.useRef(!1),b=S.useRef(!0),{viewport:j,selectedItem:w,selectedItemText:N,focusSelectedItem:C}=l,A=S.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&j&&w&&N){const $=o.trigger.getBoundingClientRect(),q=u.getBoundingClientRect(),U=o.valueNode.getBoundingClientRect(),V=N.getBoundingClientRect();if(o.dir!=="rtl"){const ht=V.left-q.left,De=U.left-ht,Dt=$.left-De,he=$.width+Dt,Qe=Math.max(he,q.width),ot=window.innerWidth-pg,rt=ZI(De,[pg,Math.max(pg,ot-Qe)]);i.style.minWidth=he+"px",i.style.left=rt+"px"}else{const ht=q.right-V.right,De=window.innerWidth-U.right-ht,Dt=window.innerWidth-$.right-De,he=$.width+Dt,Qe=Math.max(he,q.width),ot=window.innerWidth-pg,rt=ZI(De,[pg,Math.max(pg,ot-Qe)]);i.style.minWidth=he+"px",i.style.right=rt+"px"}const X=v(),se=window.innerHeight-pg*2,te=j.scrollHeight,Y=window.getComputedStyle(u),de=parseInt(Y.borderTopWidth,10),ie=parseInt(Y.paddingTop,10),ae=parseInt(Y.borderBottomWidth,10),le=parseInt(Y.paddingBottom,10),pe=de+ie+te+le+ae,be=Math.min(w.offsetHeight*5,pe),ye=window.getComputedStyle(j),we=parseInt(ye.paddingTop,10),ke=parseInt(ye.paddingBottom,10),Ze=$.top+$.height/2-pg,_e=se-Ze,Ce=w.offsetHeight/2,Te=w.offsetTop+Ce,Fe=de+ie+Te,Ae=pe-Fe;if(Fe<=Ze){const ht=X.length>0&&w===X[X.length-1].ref.current;i.style.bottom="0px";const De=u.clientHeight-j.offsetTop-j.offsetHeight,Dt=Math.max(_e,Ce+(ht?ke:0)+De+ae),he=Fe+Dt;i.style.height=he+"px"}else{const ht=X.length>0&&w===X[0].ref.current;i.style.top="0px";const Dt=Math.max(Ze,de+j.offsetTop+(ht?we:0)+Ce)+Ae;i.style.height=Dt+"px",j.scrollTop=Fe-Ze+j.offsetTop}i.style.margin=`${pg}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,j,w,N,o.dir,n]);Zc(()=>A(),[A]);const[I,L]=S.useState();Zc(()=>{u&&L(window.getComputedStyle(u).zIndex)},[u]);const R=S.useCallback($=>{$&&b.current===!0&&(A(),C==null||C(),b.current=!1)},[A,C]);return e.jsx(Myt,{scope:r,contentWrapper:i,shouldExpandOnScrollRef:_,onScrollButtonChange:R,children:e.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:I},children:e.jsx(Qr.div,{...a,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});LBe.displayName=Syt;var Cyt="SelectPopperPosition",kge=S.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=pg,...o}=t,l=boe(r);return e.jsx(pL,{...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)"}})});kge.displayName=Cyt;var[Myt,V1e]=fM(EN,{}),Nge="SelectViewport",DBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=V_(Nge,r),l=V1e(Nge,r),i=Pa(s,o.onViewportChange),d=S.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(voe.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:Cr(a.onScroll,u=>{const p=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:v}=l;if(v!=null&&v.current&&f){const _=Math.abs(d.current-p.scrollTop);if(_>0){const b=window.innerHeight-pg*2,j=parseFloat(f.style.minHeight),w=parseFloat(f.style.height),N=Math.max(j,w);if(N0?I:0,f.style.justifyContent="flex-end")}}}d.current=p.scrollTop})})})]})});DBe.displayName=Nge;var OBe="SelectGroup",[Tyt,Ayt]=fM(OBe),Eyt=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Gd();return e.jsx(Tyt,{scope:r,id:a,children:e.jsx(Qr.div,{role:"group","aria-labelledby":a,...n,ref:s})})});Eyt.displayName=OBe;var RBe="SelectLabel",FBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Ayt(RBe,r);return e.jsx(Qr.div,{id:a.id,...n,ref:s})});FBe.displayName=RBe;var cne="SelectItem",[Pyt,zBe]=fM(cne),BBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=U_(cne,r),d=V_(cne,r),u=i.value===n,[p,f]=S.useState(o??""),[v,_]=S.useState(!1),b=Pa(s,C=>{var A;return(A=d.itemRefCallback)==null?void 0:A.call(d,C,n,a)}),j=Gd(),w=S.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(Pyt,{scope:r,value:n,disabled:a,textId:j,isSelected:u,onItemTextChange:S.useCallback(C=>{f(A=>A||((C==null?void 0:C.textContent)??"").trim())},[]),children:e.jsx(voe.ItemSlot,{scope:r,value:n,disabled:a,textValue:p,children:e.jsx(Qr.div,{role:"option","aria-labelledby":j,"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:Cr(l.onFocus,()=>_(!0)),onBlur:Cr(l.onBlur,()=>_(!1)),onClick:Cr(l.onClick,()=>{w.current!=="mouse"&&N()}),onPointerUp:Cr(l.onPointerUp,()=>{w.current==="mouse"&&N()}),onPointerDown:Cr(l.onPointerDown,C=>{w.current=C.pointerType}),onPointerMove:Cr(l.onPointerMove,C=>{var A;w.current=C.pointerType,a?(A=d.onItemLeave)==null||A.call(d):w.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Cr(l.onPointerLeave,C=>{var A;C.currentTarget===document.activeElement&&((A=d.onItemLeave)==null||A.call(d))}),onKeyDown:Cr(l.onKeyDown,C=>{var I;((I=d.searchRef)==null?void 0:I.current)!==""&&C.key===" "||(xyt.includes(C.key)&&N(),C.key===" "&&C.preventDefault())})})})})});BBe.displayName=cne;var CE="SelectItemText",$Be=S.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=t,l=U_(CE,r),i=V_(CE,r),d=zBe(CE,r),u=byt(CE,r),[p,f]=S.useState(null),v=Pa(s,N=>f(N),d.onItemTextChange,N=>{var C;return(C=i.itemTextRefCallback)==null?void 0:C.call(i,N,d.value,d.disabled)}),_=p==null?void 0:p.textContent,b=S.useMemo(()=>e.jsx("option",{value:d.value,disabled:d.disabled,children:_},d.value),[d.disabled,d.value,_]),{onNativeOptionAdd:j,onNativeOptionRemove:w}=u;return Zc(()=>(j(b),()=>w(b)),[j,w,b]),e.jsxs(e.Fragment,{children:[e.jsx(Qr.span,{id:d.textId,...o,ref:v}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?wm.createPortal(o.children,l.valueNode):null]})});$Be.displayName=CE;var qBe="SelectItemIndicator",UBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return zBe(qBe,r).isSelected?e.jsx(Qr.span,{"aria-hidden":!0,...n,ref:s}):null});UBe.displayName=qBe;var Sge="SelectScrollUpButton",VBe=S.forwardRef((t,s)=>{const r=V_(Sge,t.__scopeSelect),n=V1e(Sge,t.__scopeSelect),[a,o]=S.useState(!1),l=Pa(s,n.onScrollButtonChange);return Zc(()=>{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(WBe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop-d.offsetHeight)}}):null});VBe.displayName=Sge;var Cge="SelectScrollDownButton",HBe=S.forwardRef((t,s)=>{const r=V_(Cge,t.__scopeSelect),n=V1e(Cge,t.__scopeSelect),[a,o]=S.useState(!1),l=Pa(s,n.onScrollButtonChange);return Zc(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=d.scrollHeight-d.clientHeight,p=Math.ceil(d.scrollTop)d.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(WBe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop+d.offsetHeight)}}):null});HBe.displayName=Cge;var WBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=V_("SelectScrollButton",r),l=S.useRef(null),i=_oe(r),d=S.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return S.useEffect(()=>()=>d(),[d]),Zc(()=>{var p;const u=i().find(f=>f.ref.current===document.activeElement);(p=u==null?void 0:u.ref.current)==null||p.scrollIntoView({block:"nearest"})},[i]),e.jsx(Qr.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Cr(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:Cr(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:Cr(a.onPointerLeave,()=>{d()})})}),Iyt="SelectSeparator",GBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(Qr.div,{"aria-hidden":!0,...n,ref:s})});GBe.displayName=Iyt;var Mge="SelectArrow",Lyt=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=boe(r),o=U_(Mge,r),l=V_(Mge,r);return o.open&&l.position==="popper"?e.jsx(fL,{...a,...n,ref:s}):null});Lyt.displayName=Mge;var Dyt="SelectBubbleInput",KBe=S.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=S.useRef(null),o=Pa(n,a),l=NL(s);return S.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&p){const f=new Event("change",{bubbles:!0});p.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(Qr.select,{...r,style:{...H8e,...r.style},ref:o,defaultValue:s})});KBe.displayName=Dyt;function ZBe(t){return t===""||t===void 0}function YBe(t){const s=Vc(t),r=S.useRef(""),n=S.useRef(0),a=S.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=S.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return S.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,o]}function XBe(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=Oyt(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 Oyt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var Ryt=kBe,QBe=SBe,Fyt=MBe,zyt=TBe,Byt=ABe,JBe=EBe,$yt=DBe,e9e=FBe,t9e=BBe,qyt=$Be,Uyt=UBe,s9e=VBe,r9e=HBe,n9e=GBe;const tr=Ryt,sr=Fyt,Js=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(QBe,{ref:n,className:Pt("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...r,children:[s,e.jsx(zyt,{asChild:!0,children:e.jsx(Vo,{className:"h-4 w-4 opacity-50"})})]}));Js.displayName=QBe.displayName;const a9e=S.forwardRef(({className:t,...s},r)=>e.jsx(s9e,{ref:r,className:Pt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Rg,{className:"h-4 w-4"})}));a9e.displayName=s9e.displayName;const i9e=S.forwardRef(({className:t,...s},r)=>e.jsx(r9e,{ref:r,className:Pt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Vo,{className:"h-4 w-4"})}));i9e.displayName=r9e.displayName;const er=S.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx(Byt,{children:e.jsxs(JBe,{ref:a,className:Pt("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,...n,children:[e.jsx(a9e,{}),e.jsx($yt,{className:Pt("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(i9e,{})]})}));er.displayName=JBe.displayName;const Vyt=S.forwardRef(({className:t,...s},r)=>e.jsx(e9e,{ref:r,className:Pt("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));Vyt.displayName=e9e.displayName;const At=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(t9e,{ref:n,className:Pt("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Uyt,{children:e.jsx(ua,{className:"h-4 w-4"})})}),e.jsx(qyt,{children:s})]}));At.displayName=t9e.displayName;const Hyt=S.forwardRef(({className:t,...s},r)=>e.jsx(n9e,{ref:r,className:Pt("-mx-1 my-1 h-px bg-muted",t),...s}));Hyt.displayName=n9e.displayName;const Wyt=t=>Ct({queryKey:["public-listings",t],queryFn:async()=>{let s=G.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}}),o9e=t=>Ct({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=G.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}),l9e=()=>Ot({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 G.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:p}=await G.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(p)throw p;const{error:f}=await G.functions.invoke("process-listing-lead",{body:{leadId:u.id}});return f&&console.error("Error processing lead:",f),u}}),Gyt=()=>Ot({mutationFn:async t=>{const{error:s}=await G.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),Kyt={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"},Zyt={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function c9e(){const[t,s]=S.useState(""),[r,n]=S.useState(!1),[a,o]=S.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=Wyt({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=f=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(f),u=()=>{o({status:"",propertyType:"",minPrice:"",maxPrice:""}),s("")},p=t||a.status||a.propertyType||a.minPrice||a.maxPrice;return e.jsxs(e.Fragment,{children:[e.jsxs(ah,{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(vo,{to:"/public/listings",className:"flex items-center",children:e.jsx("img",{src:bBe,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(${hyt})`},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(fn,{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:f=>s(f.target.value),className:"pl-12 h-14 md:h-16 text-base md:text-lg border-0 focus-visible:ring-0 rounded-none bg-white"})]}),e.jsx(K,{className:"h-14 md:h-16 px-6 md:px-8 rounded-none bg-blue-600 hover:bg-blue-700",children:e.jsx(fn,{className:"h-5 w-5 md:h-6 md:w-6"})})]}),e.jsx("div",{className:"flex justify-center mt-6",children:e.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>n(!r),className:"gap-2 bg-white/90 hover:bg-white text-gray-700 shadow-lg",children:[e.jsx(EP,{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:f=>o({...a,status:f==="all"?"":f}),children:[e.jsx(Js,{className:"bg-white",children:e.jsx(sr,{placeholder:"Any status"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"Any status"}),Object.entries(M5e).map(([f,v])=>e.jsx(At,{value:f,children:v},f))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Property Type"}),e.jsxs(tr,{value:a.propertyType||"all",onValueChange:f=>o({...a,propertyType:f==="all"?"":f}),children:[e.jsx(Js,{className:"bg-white",children:e.jsx(sr,{placeholder:"Any type"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"Any type"}),Object.entries(Zyt).map(([f,v])=>e.jsx(At,{value:f,children:v},f))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Min Price"}),e.jsx(Re,{type:"number",placeholder:"No min",value:a.minPrice,onChange:f=>o({...a,minPrice:f.target.value}),className:"bg-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Max Price"}),e.jsx(Re,{type:"number",placeholder:"No max",value:a.maxPrice,onChange:f=>o({...a,maxPrice:f.target.value}),className:"bg-white"})]})]}),p&&e.jsx("div",{className:"flex justify-end mt-4",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:u,className:"gap-1 text-gray-500",children:[e.jsx(Ur,{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(fyt,{listings:l,isLoading:i})]})}),e.jsx("section",{className:"py-8",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4",children:i?e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5",children:[...Array(8)].map((f,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(f=>{var j,w,N;const v=((j=f.photos)==null?void 0:j.find(C=>C.is_primary))||((w=f.photos)==null?void 0:w[0]),b=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${f.slug||f.id}`:`/public/listing/${f.slug||f.id}`;return e.jsx(vo,{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:f.property_address||f.city,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Un,{className:"h-12 w-12 text-gray-300"})}),e.jsx(at,{className:`absolute top-2 left-2 ${Kyt[f.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:M5e[f.status]}),e.jsx("button",{className:"absolute top-2 right-2 p-2 rounded-full bg-white/80 hover:bg-white transition-colors",onClick:C=>C.preventDefault(),children:e.jsx(Si,{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(f.price)}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-700 mb-2",children:[f.bedrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.bedrooms}),e.jsx("span",{className:"text-gray-500",children:"bds"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),f.bathrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.bathrooms}),e.jsx("span",{className:"text-gray-500",children:"ba"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),f.square_footage&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.square_footage.toLocaleString()}),e.jsx("span",{className:"text-gray-500",children:"sqft"})]})]}),f.property_address&&e.jsx("p",{className:"text-sm text-gray-700 truncate",children:f.property_address}),e.jsxs("p",{className:"text-sm text-gray-500 truncate",children:[f.city,", ",f.state]}),f.agent&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100",children:[e.jsx("p",{className:"text-xs text-gray-500 truncate",children:f.agent.name}),((N=f.agent.brokerage)==null?void 0:N.name)&&e.jsx("p",{className:"text-xs text-gray-400 truncate",children:f.agent.brokerage.name})]})]})]})},f.id)})})]}):e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-4 rounded-full bg-gray-100 flex items-center justify-center",children:e.jsx(Un,{className:"h-10 w-10 text-gray-400"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"No listings found"}),e.jsx("p",{className:"text-gray-500 mb-6",children:p?"Try adjusting your search or filters":"Check back soon for new listings"}),p&&e.jsx(K,{variant:"outline",onClick:u,children:"Clear filters"})]})})}),e.jsx("footer",{className:"bg-gray-900 text-white py-10 mt-auto",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("img",{src:U1e,alt:"LevelUp",className:"h-6"})}),e.jsxs("p",{className:"text-gray-400 text-sm",children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"text-gray-400 hover:text-white text-sm transition-colors",children:"relevelup.com"})]})})})]})]})}const Ee=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Ee.displayName="Card";const Lt=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("flex flex-col space-y-1.5 p-6",t),...s}));Lt.displayName="CardHeader";const zt=S.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:Pt("text-2xl font-semibold leading-none tracking-tight",t),...s}));zt.displayName="CardTitle";const yr=S.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));yr.displayName="CardDescription";const Oe=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("p-6 pt-0",t),...s}));Oe.displayName="CardContent";const UP=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("flex items-center p-6 pt-0",t),...s}));UP.displayName="CardFooter";var Yyt="Label",d9e=S.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())}}));d9e.displayName=Yyt;var u9e=d9e;const Xyt=XN("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ve=S.forwardRef(({className:t,...s},r)=>e.jsx(u9e,{ref:r,className:Pt(Xyt(),t),...s}));ve.displayName=u9e.displayName;const dne="/assets/levelup-logo-color-D3mY9gCJ.png";function Qyt(){const t=vu(),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(c9e,{}):n.startsWith("public/")?null:e.jsx(Jyt,{slug:n})}function Jyt({slug:t}){return e.jsx(s0t,{slug:t})}const e0t={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},t0t={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},T5e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function s0t({slug:t}){var U,V;const{data:s,isLoading:r}=o9e(t),n=l9e(),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState(""),[p,f]=S.useState(""),[v,_]=S.useState(!1),[b,j]=S.useState(!1),[w,N]=S.useState(null),C=X=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(X),A=async X=>{if(X.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:p.trim()}),j(!0),fe.success("Thanks! The agent will be in touch soon.")}catch(se){console.error("Lead submission error:",se),fe.error(`Failed to submit: ${se.message||"Please try again"}`)}finally{_(!1)}}},I=(s==null?void 0:s.photos)||[],L=I.find(X=>X.is_primary)||I[0],R=()=>{w!==null&&N(w===0?I.length-1:w-1)},$=()=>{w!==null&&N(w===I.length-1?0:w+1)};if(r)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(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:dne,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Un,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing may no longer be available."}),e.jsx(K,{asChild:!0,children:e.jsx("a",{href:"/",children:"Browse All Listings"})})]})]});const 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(ah,{children:[e.jsxs("title",{children:[q," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${C(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft":""} ${T5e[s.property_type]} in ${s.city}, ${s.state}. ${((U=s.description)==null?void 0:U.slice(0,150))||""}`}),e.jsx("meta",{property:"og:title",content:q}),e.jsx("meta",{property:"og:description",content:`${C(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA in ${s.city}, ${s.state}`}),e.jsx("meta",{property:"og:type",content:"website"}),L&&e.jsx("meta",{property:"og:image",content:L.photo_url})]}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("a",{href:"/",className:"flex items-center gap-2",children:e.jsx("img",{src:dne,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(Ua,{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((X,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:X.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"]})]},X.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx(at,{className:`${e0t[s.status]} text-white border-0`,children:t0t[s.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:C(s.price)}),s.property_address&&e.jsx("p",{className:"text-xl font-medium",children:s.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(Ai,{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(N0,{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(Vx,{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(Zx,{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(on,{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(at,{variant:"secondary",children:[e.jsx(Aa,{className:"h-3 w-3 mr-1"}),T5e[s.property_type]]}),s.lot_size&&e.jsxs(at,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&e.jsx(at,{variant:"secondary",children:"HOA"})]}),s.description&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"About This Property"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})]}),s.agent_notes&&s.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.agent_notes})]}),s.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:s.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[s.agent&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Xi,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-semibold text-lg",children:s.agent.name}),((V=s.agent.brokerage)==null?void 0:V.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.agent.brokerage.name})]})]}),e.jsxs(Ee,{className:"border-primary",children:[e.jsx(Lt,{children:e.jsx(zt,{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(_r,{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(ve,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Re,{id:"firstName",type:"text",placeholder:"John",value:a,onChange:X=>o(X.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Re,{id:"lastName",type:"text",placeholder:"Doe",value:l,onChange:X=>i(X.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email *"}),e.jsx(Re,{id:"email",type:"email",placeholder:"you@example.com",value:d,onChange:X=>u(X.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone"}),e.jsx(Re,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:p,onChange:X=>f(X.target.value)})]}),e.jsx(K,{type:"submit",className:"w-full",disabled: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(vs,{open:w!==null,onOpenChange:()=>N(null),children:e.jsxs(ys,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(Ss,{className:"sr-only",children:e.jsx(Ns,{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(Ur,{className:"h-5 w-5"})}),w!==null&&I[w]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:I[w].photo_url,alt:`Photo ${w+1}`,className:"w-full max-h-[80vh] object-contain"}),I.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:R,className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(zl,{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(Ha,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm",children:[w+1," / ",I.length]})]})]})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function woe({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 h9e=t=>Ct({queryKey:["agent-card-public",t],queryFn:async()=>{if(!t)throw new Error("No slug provided");const{data:s,error:r}=await G.from("agent_cards").select("*").eq("slug",t).eq("is_published",!0).single();if(r)throw r;const{data:n}=await G.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 G.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 G.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 G.storage.from("avatars").list(`${s.user_id}`);if(d&&d.length>0){const{data:u}=G.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}),r0t=()=>Ct({queryKey:["agent-cards-admin"],queryFn:async()=>{const{data:t,error:s}=await G.from("agent_cards").select("*").order("created_at",{ascending:!1});if(s)throw s;return t}}),n0t=t=>Ct({queryKey:["agent-card",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("agent_cards").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),m9e=()=>{const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.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"]}),fe.success("Agent card created")},onError:s=>fe.error(s.message)})},p9e=()=>{const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.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"]}),fe.success("Agent card updated")},onError:s=>fe.error(s.message)})},ao=async(t,s,r,n)=>{const a=new URLSearchParams(window.location.search);await G.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:{}})},a0t=async(t,s)=>{const{error:r}=await G.from("agent_card_leads").insert({card_id:t,...s});if(r)throw r},f9e=t=>Ct({queryKey:["agent-card-analytics",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.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 G.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 joe({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=S.useState(""),[i,d]=S.useState(""),[u,p]=S.useState(""),[f,v]=S.useState(""),[_,b]=S.useState(""),[j,w]=S.useState(!1),N=async C=>{if(C.preventDefault(),!o.trim()){fe.error("Please enter your name");return}w(!0);try{await a0t(r,{lead_type:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:_.trim()||void 0,intent:f||void 0}),ao(r,"lead_submitted",n),G.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:f||void 0}}).catch(A=>console.error("Card lead notify failed:",A)),fe.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(""),p(""),v(""),b("")}catch{fe.error("Something went wrong. Please try again.")}finally{w(!1)}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-md rounded-2xl",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{htmlFor:"lead-name",children:"Name *"}),e.jsx(Re,{id:"lead-name",value:o,onChange:C=>l(C.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lead-phone",children:"Phone"}),e.jsx(Re,{id:"lead-phone",type:"tel",value:u,onChange:C=>p(C.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lead-email",children:"Email"}),e.jsx(Re,{id:"lead-email",type:"email",value:i,onChange:C=>d(C.target.value),placeholder:"you@example.com"})]}),n==="booking"&&e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lead-intent",children:"I'm looking to..."}),e.jsxs(tr,{value:f,onValueChange:v,children:[e.jsx(Js,{children:e.jsx(sr,{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(ve,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),e.jsx(Re,{id:"lead-message",value:_,onChange:C=>b(C.target.value),placeholder:n==="referral"?"Their name, phone, situation...":"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full rounded-2xl",disabled:j,children:j?"Sending...":"Submit"})]})]})})}const i0t=t=>Ct({queryKey:["card-blocks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.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}),o0t=t=>Ct({queryKey:["card-blocks-all",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("card_blocks").select("*").eq("card_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),l0t=()=>{const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.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]}),fe.success("Block added")},onError:s=>fe.error(s.message)})},c0t=()=>{const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.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"]}),fe.success("Block updated")},onError:s=>fe.error(s.message)})},d0t=()=>{const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("card_blocks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),fe.success("Block removed")},onError:s=>fe.error(s.message)})};function u0t(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 h0t(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 m0t={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 p0t({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=h0t(r.video_url),o=n||!!a,l=n?u0t(r.video_url):a||r.video_url;return e.jsx("div",{className:m0t[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 f0t={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 g0t({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=S.useState(0);if(n.length===0)return null;const l=f0t[s],i=n[a];return e.jsxs("div",{className:l.container,children:[e.jsxs("div",{className:l.card,children:[e.jsx(_5,{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(zl,{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(Ha,{className:"h-4 w-4"})})]})]})}const x0t={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 y0t({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=x0t[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const v0t={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 _0t({block:t,cardId:s,variant:r}){const a=t.config.links||[];if(a.length===0)return null;const o=v0t[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:()=>ao(s,"button_click",`custom_link_${l.label}`),className:o.link,children:[e.jsx("span",{children:l.label}),e.jsx(sn,{className:`h-4 w-4 ${o.icon}`})]},i))})}const Tge={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 b0t({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 w0t={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 j0t({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=w0t[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=Tge[l.platform.toLowerCase()];return!d||!l.url?null:e.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ao(s,"button_click",`social_${l.platform}`),className:o.linkClass,title:d.label,children:e.jsx(b0t,{path:d.icon,color:d.color})},i)})})]})}function koe({cardId:t,variant:s}){const{data:r}=i0t(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(p0t,{block:l,variant:s},l.id);case"testimonials":return e.jsx(g0t,{block:l,variant:s},l.id);case"specialties":return e.jsx(y0t,{block:l,variant:s},l.id);case"custom_links":return e.jsx(_0t,{block:l,cardId:t,variant:s},l.id);default:return null}}),o&&e.jsx(j0t,{block:o,cardId:t,variant:s})]})}async function k0t(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 Noe(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 k0t(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),fe.success("Contact saved!")}function S0t({card:t}){var N;const[s,r]=S.useState(!1),[n,a]=S.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{ao(t.id,"button_click",C),A()},d=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:fe.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:fe.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.email?window.location.href=`mailto:${t.profile.email}`:fe.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),ao(t.id,"button_click","book"))},v=()=>{var C,A;ao(t.id,"contact_saved"),Noe({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(A=t.profile)==null?void 0:A.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(ao(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),fe.success("Link copied!")},b=()=>{a("referral"),r(!0),ao(t.id,"button_click","refer")},j=()=>{a("connect"),r(!0),ao(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-white to-slate-50",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(gn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Ea,{src:t.avatar_url||void 0,alt:o}),e.jsx(xn,{className:"text-2xl font-semibold bg-primary text-primary-foreground",children:l})]}),e.jsx("h1",{className:"text-2xl font-bold text-slate-900 mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-primary mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-slate-500 mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-slate-400 mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-slate-600 italic leading-relaxed max-w-xs mx-auto",children:['"',t.positioning_statement,'"']})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs(K,{onClick: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(Zn,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Call"})]}),e.jsxs(K,{onClick:u,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(oo,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Text"})]}),e.jsxs(K,{onClick:p,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(_r,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),e.jsxs(K,{onClick:f,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[e.jsx(on,{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(woe,{card:t,variant:"standard"}),e.jsx(koe,{cardId:t.id,variant:"standard"}),e.jsxs("div",{className:"space-y-2 mb-6",children:[t.show_save_contact&&e.jsxs(K,{variant:"ghost",onClick:v,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(xi,{className:"h-4 w-4 mr-3 text-primary"}),"Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs(K,{variant:"ghost",onClick:()=>{ao(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(K,{variant:"ghost",onClick:b,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(hr,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),e.jsxs(K,{variant:"ghost",onClick:j,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(xc,{className:"h-4 w-4 mr-3 text-primary"}),"Connect with Me"]}),e.jsxs(K,{variant:"ghost",onClick:_,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(cd,{className:"h-4 w-4 mr-3 text-primary"}),"Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((C,A)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ao(t.id,"button_click",`social_${C.platform}`),className:"h-10 w-10 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-lg transition-colors",children:w[C.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),e.jsx(joe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function C0t({card:t}){var N;const[s,r]=S.useState(!1),[n,a]=S.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{ao(t.id,"button_click",C),A()},d=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:fe.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:fe.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.email?window.location.href=`mailto:${t.profile.email}`:fe.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),ao(t.id,"button_click","book"))},v=()=>{var C,A;ao(t.id,"contact_saved"),Noe({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(A=t.profile)==null?void 0:A.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(ao(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),fe.success("Link copied!")},b=()=>{a("referral"),r(!0),ao(t.id,"button_click","refer")},j=()=>{a("connect"),r(!0),ao(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-[#0f1419] via-[#1a1f2e] to-[#0f1419]",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsx("div",{className:"w-16 h-0.5 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] mx-auto mb-8"}),e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(gn,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[e.jsx(Ea,{src:t.avatar_url||void 0,alt:o}),e.jsx(xn,{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:Zn,label:"Call",handler:d},{icon:oo,label:"Text",handler:u},{icon:_r,label:"Email",handler:p}].map(({icon:C,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(C,{className:"h-5 w-5 text-[#c9a84c]"}),e.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children:A})]},A))}),e.jsxs("button",{onClick:f,className:"w-full h-12 text-base font-semibold rounded-xl mb-6 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] text-[#0f1419] hover:opacity-90 transition-opacity flex items-center justify-center gap-2",children:[e.jsx(on,{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(woe,{card:t,variant:"luxury"}),e.jsx(koe,{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(xi,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{ao(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(hr,{className:"h-4 w-4 text-[#c9a84c]"})," Refer a Friend"]}),e.jsxs("button",{onClick:j,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(xc,{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(cd,{className:"h-4 w-4 text-[#c9a84c]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((C,A)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ao(t.id,"button_click",`social_${C.platform}`),className:"h-10 w-10 rounded-full bg-[#1e2636] border border-[#c9a84c]/20 hover:border-[#c9a84c]/50 flex items-center justify-center text-lg transition-colors",children:w[C.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),e.jsx(joe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function M0t({card:t}){var A,I,L,R;const[s,r]=S.useState(!1),[n,a]=S.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:((R=t.bold_theme_colors)==null?void 0:R.button)||"#ff5722"},d=($,q)=>{const U=parseInt($.replace("#",""),16),V=Math.max(0,(U>>16)-q),X=Math.max(0,(U>>8&255)-q),se=Math.max(0,(U&255)-q);return`#${(V<<16|X<<8|se).toString(16).padStart(6,"0")}`};d(i.accent,25),d(i.dark,-20),d(i.button,25);const u=($,q)=>{ao(t.id,"button_click",$),q()},p=()=>u("call",()=>{var $;($=t.profile)!=null&&$.phone?window.location.href=`tel:${t.profile.phone}`:fe.error("Phone number not available")}),f=()=>u("text",()=>{var $;($=t.profile)!=null&&$.phone?window.location.href=`sms:${t.profile.phone}`:fe.error("Phone number not available")}),v=()=>u("email",()=>{var $;($=t.profile)!=null&&$.email?window.location.href=`mailto:${t.profile.email}`:fe.error("Email not available")}),_=()=>{t.booking_url?u("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),ao(t.id,"button_click","book"))},b=()=>{var $,q;ao(t.id,"contact_saved"),Noe({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})},j=async()=>{if(ao(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),fe.success("Link copied!")},w=()=>{a("referral"),r(!0),ao(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),ao(t.id,"button_click","connect")},C={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:i.accent},children:[e.jsxs("div",{className:"px-5 pt-10 pb-14 text-center relative",style:{backgroundColor:i.dark},children:[t.show_photo&&e.jsxs(gn,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${i.accent}`},children:[e.jsx(Ea,{src:t.avatar_url||void 0,alt:o}),e.jsx(xn,{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:Zn,label:"Call",handler:p},{icon:oo,label:"Text",handler:f},{icon:_r,label:"Email",handler:v}].map(({icon:$,label:q,handler:U})=>e.jsxs("button",{onClick:U,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(on,{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(woe,{card:t,variant:"bold"}),e.jsx(koe,{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(xi,{className:"h-4 w-4",style:{color:i.accent}})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{ao(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: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(hr,{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(xc,{className:"h-4 w-4",style:{color:i.accent}})," Connect with Me"]}),e.jsxs("button",{onClick:j,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(cd,{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:()=>ao(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:C[$.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(joe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function T0t({card:t}){var N;const[s,r]=S.useState(!1),[n,a]=S.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{ao(t.id,"button_click",C),A()},d=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:fe.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:fe.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.email?window.location.href=`mailto:${t.profile.email}`:fe.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),ao(t.id,"button_click","book"))},v=()=>{var C,A;ao(t.id,"contact_saved"),Noe({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(A=t.profile)==null?void 0:A.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(ao(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),fe.success("Link copied!")},b=()=>{a("referral"),r(!0),ao(t.id,"button_click","refer")},j=()=>{a("connect"),r(!0),ao(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-[#f5f1eb]",children:[e.jsx("div",{className:"bg-[#1b3a4b] h-2"}),e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(gn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Ea,{src:t.avatar_url||void 0,alt:o}),e.jsx(xn,{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:Zn,label:"Call",handler:d},{icon:oo,label:"Text",handler:u},{icon:_r,label:"Email",handler:p}].map(({icon:C,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(C,{className:"h-5 w-5 text-[#1b3a4b]"}),e.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children:A})]},A))}),e.jsxs("button",{onClick:f,className:"w-full h-12 text-base font-semibold rounded-lg mb-6 bg-[#1b3a4b] hover:bg-[#264d61] text-white transition-colors flex items-center justify-center gap-2 shadow-sm",children:[e.jsx(on,{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(woe,{card:t,variant:"classic"}),e.jsx(koe,{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(xi,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{ao(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(hr,{className:"h-4 w-4 text-[#5a7a6f]"})," Refer a Friend"]}),e.jsxs("button",{onClick:j,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(xc,{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(cd,{className:"h-4 w-4 text-[#5a7a6f]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((C,A)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ao(t.id,"button_click",`social_${C.platform}`),className:"h-10 w-10 rounded-full bg-white border border-[#d4cfc5] hover:bg-[#e8e3db] flex items-center justify-center text-lg transition-colors shadow-sm",children:w[C.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),e.jsx(joe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function H1e({card:t}){switch(t.theme){case"luxury":return e.jsx(C0t,{card:t});case"bold":return e.jsx(M0t,{card:t});case"classic":return e.jsx(T0t,{card:t});case"standard":default:return e.jsx(S0t,{card:t})}}function A0t(){const t=vu();S.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(E0t,{slug:s})}function E0t({slug:t}){return e.jsx(P0t,{slug:t})}function P0t({slug:t}){var o;const{data:s,isLoading:r,error:n}=h9e(t);if(S.useEffect(()=>{s!=null&&s.id&&ao(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(ah,{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(H1e,{card:s})]})}function g9e({presentationId:t,ctaLabel:s,agentName:r,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=S.useState(n||""),[d,u]=S.useState(a||""),[p,f]=S.useState(o||""),[v,_]=S.useState(""),[b,j]=S.useState(""),[w,N]=S.useState(!1),[C,A]=S.useState(!1),I=async L=>{if(L.preventDefault(),!l.trim()){fe.error("Please enter your name");return}N(!0);try{const{error:R}=await G.from("smart_presentation_leads").insert({presentation_id:t,name:l.trim(),email:d.trim()||null,phone:p.trim()||null,intent:v||null,message:b.trim()||null});if(R)throw R;try{await G.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{}G.functions.invoke("presentation-lead-notify",{body:{presentationId:t,name:l.trim(),email:d.trim()||void 0,phone:p.trim()||void 0,intent:v||void 0,message:b.trim()||void 0}}).catch($=>console.error("Presentation lead notify failed:",$)),A(!0)}catch{fe.error("Something went wrong. Please try again.")}finally{N(!1)}};return C?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(ua,{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(ve,{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(ve,{htmlFor:"pres-lead-phone",children:"Phone"}),e.jsx(Re,{id:"pres-lead-phone",type:"tel",value:p,onChange:L=>f(L.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ve,{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(ve,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),e.jsxs(tr,{value:v,onValueChange:_,children:[e.jsx(Js,{children:e.jsx(sr,{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(ve,{htmlFor:"pres-lead-message",children:"Message (optional)"}),e.jsx(Re,{id:"pres-lead-message",value:b,onChange:L=>j(L.target.value),placeholder:"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:w,children:w?"Sending...":s})]})}function I0t(){const t=vu();S.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(L0t,{shareToken:s})}function L0t({shareToken:t}){var b;const[s,r]=S.useState(null),[n,a]=S.useState(!0),[o,l]=S.useState(0),[i,d]=S.useState(!1);S.useEffect(()=>{u()},[t]);const u=async()=>{const{data:j,error:w}=await G.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(w||!j){d(!0),a(!1);return}const{data:N}=await G.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",j.owner_user_id).single();let C;if(N!=null&&N.brokerage_id){const{data:I}=await G.from("brokerages").select("name").eq("id",N.brokerage_id).single();C=(I==null?void 0:I.name)||void 0}let A=null;if(j.contact_id){const{data:I}=await G.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",j.contact_id).single();A=I}r({...j,owner_name:N==null?void 0:N.name,owner_email:N==null?void 0:N.email,owner_phone:N==null?void 0:N.phone,owner_avatar:N==null?void 0:N.avatar_url,owner_title:(N==null?void 0:N.title)||void 0,brokerage_name:C,contact_name: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 G.rpc("log_presentation_view",{p_presentation_id:j.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await G.rpc("log_presentation_view",{p_presentation_id:s.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}s.cta_url&&window.open(s.cta_url,"_blank")}},f=j=>{const w=j.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(w)return`https://www.youtube.com/embed/${w[1]}?rel=0`;if(j.includes("iframe.mediadelivery.net/play/")){const A=j.replace("/play/","/embed/"),I=A.includes("?")?"&":"?";return`${A}${I}responsive=true`}if(j.includes("iframe.mediadelivery.net")){const A=j.includes("?")?"&":"?";return`${j}${A}responsive=true`}const N=j.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(N)return`https://www.loom.com/embed/${N[1]}`;const C=j.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return C?`https://iframe.mediadelivery.net/embed/${C[1]}/${C[2]}?responsive=true`:j};if(n)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[e.jsx(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(j=>j.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:f(_.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((j,w)=>e.jsx("button",{onClick:()=>l(w),className:Pt("w-full text-left p-4 rounded-xl border transition-all",o===w?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(w+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:j.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:j.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:j.description})]})]})},w))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),(b=s.cta_url)!=null&&b.trim()?e.jsxs(K,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(sn,{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(g9e,{presentationId:s.id,ctaLabel:s.cta_label,agentName:s.owner_name||void 0,prefillName:s.contact_name,prefillEmail:s.contact_email,prefillPhone:s.contact_phone})})]})]}),e.jsx("footer",{className:"border-t border-gray-100 bg-white mt-12 py-6 text-center text-xs text-gray-400",children:"Powered by LevelUp"})]})}const Mf=()=>{const t=ti();return Ct({queryKey:["user-team",t],queryFn:async()=>{const{data:s,error:r}=await G.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 G.from("teams").select("*").eq("id",s.team_id).single();if(a)throw a;return{membershipId:s.id,teamId:s.team_id,role:s.role,team:n}},enabled:!!t,staleTime:5*60*1e3})};function D0t(){const{user:t}=Gs(),s=ti(),{data:r}=Mf();return Ct({queryKey:["open-houses",s,r==null?void 0:r.teamId,r==null?void 0:r.role],queryFn:async()=>{const{data:n,error:a}=await G.from("open_houses").select("*").eq("agent_id",s).order("event_date",{ascending:!1});if(a)throw a;let o=n||[];if((r==null?void 0:r.role)==="team_leader"&&r.teamId){const{data:l,error:i}=await G.rpc("get_team_open_houses",{_user_id:s});if(!i&&l){const d=[...new Set(l.map(f=>f.agent_id))],u={};if(d.length>0){const{data:f}=await G.from("profiles").select("id, name").in("id",d);f==null||f.forEach(v=>{v.name&&(u[v.id]=v.name)})}const p=l.map(f=>({...f,agent_name:u[f.agent_id]||void 0}));o=[...o,...p]}}return o.sort((l,i)=>i.event_date.localeCompare(l.event_date)),o},enabled:!!t&&!!s})}function x9e(t){const{user:s}=Gs(),r=ns();return S.useEffect(()=>{if(!t)return;const n=G.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()=>{G.removeChannel(n)}},[t,r]),Ct({queryKey:["open-house-visitors",t],queryFn:async()=>{const{data:n,error:a}=await G.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 O0t(){const t=ns(),s=ti();return Ot({mutationFn:async r=>{const{data:n,error:a}=await G.from("open_houses").insert({...r,agent_id:s}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),an({title:"Open house created!"})},onError:r=>{an({title:"Error",description:r.message,variant:"destructive"})}})}function y9e(){const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{error:n}=await G.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 R0t(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("open_houses").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),an({title:"Open house deleted"})}})}function F0t(t){return Ct({queryKey:["public-open-house",t],queryFn:async()=>{const{data:s,error:r}=await G.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 G.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 z0t(t){const{user:s}=Gs();return Ct({queryKey:["survey-questions",t],queryFn:async()=>{const{data:r,error:n}=await G.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;return r},enabled:!!s&&!!t})}function B0t(t){return Ct({queryKey:["public-survey-questions",t],queryFn:async()=>{const{data:s,error:r}=await G.from("open_house_survey_questions").select("*").eq("open_house_id",t).eq("is_active",!0).order("sort_order");if(r)throw r;return s},enabled:!!t})}function $0t(){return Ot({mutationFn:async t=>{const{error:s}=await G.from("open_house_survey_responses").insert(t);if(s)throw s}})}function q0t(t){const{user:s}=Gs();return Ct({queryKey:["survey-responses",t],queryFn:async()=>{const{data:r,error:n}=await G.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;const a=(r||[]).map(i=>i.id);if(a.length===0)return{questions:[],responses:[]};const{data:o,error:l}=await G.from("open_house_survey_responses").select("*").in("question_id",a).order("created_at",{ascending:!1});if(l)throw l;return{questions:r,responses:o||[]}},enabled:!!s&&!!t})}function U0t(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.from("open_house_survey_questions").insert(s).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function V0t(){const t=ns();return Ot({mutationFn:async({id:s,open_house_id:r,...n})=>{const{error:a}=await G.from("open_house_survey_questions").update(n).eq("id",s);if(a)throw a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function H0t(){const t=ns();return Ot({mutationFn:async({id:s,open_house_id:r})=>{const{error:n}=await G.from("open_house_survey_questions").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function W0t(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.rpc("seed_default_survey_questions",{_open_house_id:s});if(r)throw r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r]})}})}function G0t(){return Ot({mutationFn:async t=>{const{data:s,error:r}=await G.from("open_house_visitors").insert(t).select("id").single();if(r)throw r;return s}})}var Soe="Switch",[K0t]=Ac(Soe),[Z0t,Y0t]=K0t(Soe),v9e=S.forwardRef((t,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d="on",onCheckedChange:u,form:p,...f}=t,[v,_]=S.useState(null),b=Pa(s,A=>_(A)),j=S.useRef(!1),w=v?p||!!v.closest("form"):!0,[N,C]=xu({prop:a,defaultProp:o??!1,onChange:u,caller:Soe});return e.jsxs(Z0t,{scope:r,checked:N,disabled:i,children:[e.jsx(Qr.button,{type:"button",role:"switch","aria-checked":N,"aria-required":l,"data-state":j9e(N),"data-disabled":i?"":void 0,disabled:i,value:d,...f,ref:b,onClick:Cr(t.onClick,A=>{C(I=>!I),w&&(j.current=A.isPropagationStopped(),j.current||A.stopPropagation())})}),w&&e.jsx(w9e,{control:v,bubbles:!j.current,name:n,value:d,checked:N,required:l,disabled:i,form:p,style:{transform:"translateX(-100%)"}})]})});v9e.displayName=Soe;var _9e="SwitchThumb",b9e=S.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=Y0t(_9e,r);return e.jsx(Qr.span,{"data-state":j9e(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});b9e.displayName=_9e;var X0t="SwitchBubbleInput",w9e=S.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=S.useRef(null),i=Pa(l,o),d=NL(r),u=hL(s);return S.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&_){const b=new Event("click",{bubbles:n});_.call(p,r),p.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}})});w9e.displayName=X0t;function j9e(t){return t?"checked":"unchecked"}var k9e=v9e,Q0t=b9e;const Br=S.forwardRef(({className:t,...s},r)=>e.jsx(k9e,{className:Pt("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",t),...s,ref:r,children:e.jsx(Q0t,{className:Pt("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Br.displayName=k9e.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 Yo(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function ml(t,s){const r=Kn(t);return isNaN(s)?Yo(t,NaN):(s&&r.setDate(r.getDate()+s),r)}function Wh(t,s){const r=Kn(t);if(isNaN(s))return Yo(t,NaN);if(!s)return r;const n=r.getDate(),a=Yo(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 N9e(t,s){const r=+Kn(t);return Yo(t,r+s)}const W1e=6048e5,J0t=864e5,Coe=6e4,SL=36e5,evt=1e3,L8=43200,A5e=1440;function E5e(t,s){return N9e(t,s*SL)}let tvt={};function H_(){return tvt}function ih(t,s){var i,d,u,p;const r=H_(),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??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.weekStartsOn)??0,a=Kn(t),o=a.getDay(),l=(o=a.getTime()?r+1:s.getTime()>=l.getTime()?r:r-1}function Gh(t){const s=Kn(t);return s.setHours(0,0,0,0),s}function C_(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 up(t,s){const r=Gh(t),n=Gh(s),a=+r-C_(r),o=+n-C_(n);return Math.round((a-o)/J0t)}function svt(t){const s=S9e(t),r=Yo(t,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),Y0(r)}function R4(t,s){return N9e(t,s*Coe)}function Ck(t,s){const r=s*7;return ml(t,r)}function rvt(t,s){return Wh(t,s*12)}function nvt(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 tre(t,s){const r=Kn(t),n=Kn(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function G1e(t){return Yo(t,Date.now())}function cl(t,s){const r=Gh(t),n=Gh(s);return+r==+n}function K1e(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Age(t){if(!K1e(t)&&typeof t!="number")return!1;const s=Kn(t);return!isNaN(Number(s))}function h3(t,s){const r=Kn(t),n=Kn(s),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function ivt(t,s,r){const n=ih(t,r),a=ih(s,r),o=+n-C_(n),l=+a-C_(a);return Math.round((o-l)/W1e)}function Gg(t,s){const r=Kn(t),n=Kn(s),a=P5e(r,n),o=Math.abs(up(r,n));r.setDate(r.getDate()-a*o);const l=+(P5e(r,n)===-a),i=a*(o-l);return i===0?0:i}function P5e(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 C9e(t){return s=>{const n=(t?Math[t]:Math.trunc)(s);return n===0?0:n}}function M9e(t,s){return+Kn(t)-+Kn(s)}function ovt(t,s,r){const n=M9e(t,s)/SL;return C9e(r==null?void 0:r.roundingMethod)(n)}function lvt(t){const s=Kn(t);return s.setHours(23,59,59,999),s}function Kp(t){const s=Kn(t),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function cvt(t){const s=Kn(t);return+lvt(s)==+Kp(s)}function dvt(t,s){const r=Kn(t),n=Kn(s),a=tre(r,n),o=Math.abs(h3(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=tre(r,n)===-a;cvt(Kn(t))&&o===1&&tre(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function uvt(t,s,r){const n=M9e(t,s)/1e3;return C9e(r==null?void 0:r.roundingMethod)(n)}function hvt(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 mc(t){const s=Kn(t);return s.setDate(1),s.setHours(0,0,0,0),s}function T9e(t){const s=Kn(t),r=Yo(t,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function Moe(t,s){var i,d,u,p;const r=H_(),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??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.weekStartsOn)??0,a=Kn(t),o=a.getDay(),l=(o{let n;const a=mvt[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 Lhe(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const fvt={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},gvt={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},xvt={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},yvt={date:Lhe({formats:fvt,defaultWidth:"full"}),time:Lhe({formats:gvt,defaultWidth:"full"}),dateTime:Lhe({formats:xvt,defaultWidth:"full"})},vvt={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},_vt=(t,s,r,n)=>vvt[t];function ZA(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 bvt={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},wvt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},jvt={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"]},kvt={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"]},Nvt={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"}},Svt={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"}},Cvt=(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"},Mvt={ordinalNumber:Cvt,era:ZA({values:bvt,defaultWidth:"wide"}),quarter:ZA({values:wvt,defaultWidth:"wide",argumentCallback:t=>t-1}),month:ZA({values:jvt,defaultWidth:"wide"}),day:ZA({values:kvt,defaultWidth:"wide"}),dayPeriod:ZA({values:Nvt,defaultWidth:"wide",formattingValues:Svt,defaultFormattingWidth:"wide"})};function YA(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)?Avt(i,f=>f.test(l)):Tvt(i,f=>f.test(l));let u;u=t.valueCallback?t.valueCallback(d):d,u=r.valueCallback?r.valueCallback(u):u;const p=s.slice(l.length);return{value:u,rest:p}}}function Tvt(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function Avt(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 Pvt=/^(\d+)(th|st|nd|rd)?/i,Ivt=/\d+/i,Lvt={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},Dvt={any:[/^b/i,/^(a|c)/i]},Ovt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Rvt={any:[/1/i,/2/i,/3/i,/4/i]},Fvt={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},zvt={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]},Bvt={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},$vt={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]},qvt={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},Uvt={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}},Vvt={ordinalNumber:Evt({matchPattern:Pvt,parsePattern:Ivt,valueCallback:t=>parseInt(t,10)}),era:YA({matchPatterns:Lvt,defaultMatchWidth:"wide",parsePatterns:Dvt,defaultParseWidth:"any"}),quarter:YA({matchPatterns:Ovt,defaultMatchWidth:"wide",parsePatterns:Rvt,defaultParseWidth:"any",valueCallback:t=>t+1}),month:YA({matchPatterns:Fvt,defaultMatchWidth:"wide",parsePatterns:zvt,defaultParseWidth:"any"}),day:YA({matchPatterns:Bvt,defaultMatchWidth:"wide",parsePatterns:$vt,defaultParseWidth:"any"}),dayPeriod:YA({matchPatterns:qvt,defaultMatchWidth:"any",parsePatterns:Uvt,defaultParseWidth:"any"})},Toe={code:"en-US",formatDistance:pvt,formatLong:yvt,formatRelative:_vt,localize:Mvt,match:Vvt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Hvt(t){const s=Kn(t);return up(s,T9e(s))+1}function Z1e(t){const s=Kn(t),r=+Y0(s)-+svt(s);return Math.round(r/W1e)+1}function Y1e(t,s){var p,f,v,_;const r=Kn(t),n=r.getFullYear(),a=H_(),o=(s==null?void 0:s.firstWeekContainsDate)??((f=(p=s==null?void 0:s.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??a.firstWeekContainsDate??((_=(v=a.locale)==null?void 0:v.options)==null?void 0:_.firstWeekContainsDate)??1,l=Yo(t,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=ih(l,s),d=Yo(t,0);d.setFullYear(n,0,o),d.setHours(0,0,0,0);const u=ih(d,s);return r.getTime()>=i.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function Wvt(t,s){var i,d,u,p;const r=H_(),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??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.firstWeekContainsDate)??1,a=Y1e(t,s),o=Yo(t,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),ih(o,s)}function X1e(t,s){const r=Kn(t),n=+ih(r,s)-+Wvt(r,s);return Math.round(n/W1e)+1}function Zo(t,s){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(s,"0");return r+n}const Yv={y(t,s){const r=t.getFullYear(),n=r>0?r:1-r;return Zo(s==="yy"?n%100:n,s.length)},M(t,s){const r=t.getMonth();return s==="M"?String(r+1):Zo(r+1,2)},d(t,s){return Zo(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 Zo(t.getHours()%12||12,s.length)},H(t,s){return Zo(t.getHours(),s.length)},m(t,s){return Zo(t.getMinutes(),s.length)},s(t,s){return Zo(t.getSeconds(),s.length)},S(t,s){const r=s.length,n=t.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return Zo(a,s.length)}},s4={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},I5e={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 Yv.y(t,s)},Y:function(t,s,r,n){const a=Y1e(t,n),o=a>0?a:1-a;if(s==="YY"){const l=o%100;return Zo(l,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):Zo(o,s.length)},R:function(t,s){const r=S9e(t);return Zo(r,s.length)},u:function(t,s){const r=t.getFullYear();return Zo(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 Zo(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 Zo(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 Yv.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 Zo(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=X1e(t,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):Zo(a,s.length)},I:function(t,s,r){const n=Z1e(t);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):Zo(n,s.length)},d:function(t,s,r){return s==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):Yv.d(t,s)},D:function(t,s,r){const n=Hvt(t);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):Zo(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 Zo(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 Zo(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 Zo(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=s4.noon:n===0?a=s4.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=s4.evening:n>=12?a=s4.afternoon:n>=4?a=s4.morning:a=s4.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 Yv.h(t,s)},H:function(t,s,r){return s==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):Yv.H(t,s)},K:function(t,s,r){const n=t.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):Zo(n,s.length)},k:function(t,s,r){let n=t.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):Zo(n,s.length)},m:function(t,s,r){return s==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):Yv.m(t,s)},s:function(t,s,r){return s==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):Yv.s(t,s)},S:function(t,s){return Yv.S(t,s)},X:function(t,s,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return D5e(n);case"XXXX":case"XX":return mk(n);case"XXXXX":case"XXX":default:return mk(n,":")}},x:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"x":return D5e(n);case"xxxx":case"xx":return mk(n);case"xxxxx":case"xxx":default:return mk(n,":")}},O:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+L5e(n,":");case"OOOO":default:return"GMT"+mk(n,":")}},z:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+L5e(n,":");case"zzzz":default:return"GMT"+mk(n,":")}},t:function(t,s,r){const n=Math.trunc(t.getTime()/1e3);return Zo(n,s.length)},T:function(t,s,r){const n=t.getTime();return Zo(n,s.length)}};function L5e(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+Zo(o,2)}function D5e(t,s){return t%60===0?(t>0?"-":"+")+Zo(Math.abs(t)/60,2):mk(t,s)}function mk(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=Zo(Math.trunc(n/60),2),o=Zo(n%60,2);return r+a+s+o}const O5e=(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"})}},E9e=(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"})}},Gvt=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return O5e(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}}",O5e(n,s)).replace("{{time}}",E9e(a,s))},Ege={p:E9e,P:Gvt},Kvt=/^D+$/,Zvt=/^Y+$/,Yvt=["D","DD","YY","YYYY"];function P9e(t){return Kvt.test(t)}function I9e(t){return Zvt.test(t)}function Pge(t,s,r){const n=Xvt(t,s,r);if(console.warn(n),Yvt.includes(t))throw new RangeError(n)}function Xvt(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 Qvt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Jvt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,e1t=/^'([^]*?)'?$/,t1t=/''/g,s1t=/[a-zA-Z]/;function ws(t,s,r){var p,f,v,_,b,j,w,N;const n=H_(),a=(r==null?void 0:r.locale)??n.locale??Toe,o=(r==null?void 0:r.firstWeekContainsDate)??((f=(p=r==null?void 0:r.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??n.firstWeekContainsDate??((_=(v=n.locale)==null?void 0:v.options)==null?void 0:_.firstWeekContainsDate)??1,l=(r==null?void 0:r.weekStartsOn)??((j=(b=r==null?void 0:r.locale)==null?void 0:b.options)==null?void 0:j.weekStartsOn)??n.weekStartsOn??((N=(w=n.locale)==null?void 0:w.options)==null?void 0:N.weekStartsOn)??0,i=Kn(t);if(!Age(i))throw new RangeError("Invalid time value");let d=s.match(Jvt).map(C=>{const A=C[0];if(A==="p"||A==="P"){const I=Ege[A];return I(C,a.formatLong)}return C}).join("").match(Qvt).map(C=>{if(C==="''")return{isToken:!1,value:"'"};const A=C[0];if(A==="'")return{isToken:!1,value:r1t(C)};if(I5e[A])return{isToken:!0,value:C};if(A.match(s1t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+A+"`");return{isToken:!1,value:C}});a.localize.preprocessor&&(d=a.localize.preprocessor(i,d));const u={firstWeekContainsDate:o,weekStartsOn:l,locale:a};return d.map(C=>{if(!C.isToken)return C.value;const A=C.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&I9e(A)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&P9e(A))&&Pge(A,s,String(t));const I=I5e[A[0]];return I(i,A,a.localize,u)}).join("")}function r1t(t){const s=t.match(e1t);return s?s[1].replace(t1t,"'"):t}function n1t(t,s,r){const n=H_(),a=(r==null?void 0:r.locale)??n.locale??Toe,o=2520,l=tre(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 p=uvt(u,d),f=(C_(u)-C_(d))/1e3,v=Math.round((p-f)/60);let _;if(v<2)return r!=null&&r.includeSeconds?p<5?a.formatDistance("lessThanXSeconds",5,i):p<10?a.formatDistance("lessThanXSeconds",10,i):p<20?a.formatDistance("lessThanXSeconds",20,i):p<40?a.formatDistance("halfAMinute",0,i):p<60?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",1,i):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 IN(t,s){const r=Kn(t),n=Kn(s);return+r<+n}function u1t(t){return+Kn(t)>Date.now()}function h1t(t,s){const r=s instanceof Date?Yo(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 m1t=10;class L9e{constructor(){_n(this,"subPriority",0)}validate(s,r){return!0}}class p1t extends L9e{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 f1t extends L9e{constructor(){super(...arguments);_n(this,"priority",m1t);_n(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:Yo(r,h1t(r,Date))}}class Bo{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new p1t(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class g1t extends Bo{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 id={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},Ox={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 od(t,s){return t&&{value:s(t.value),rest:t.rest}}function Nc(t,s){const r=s.match(t);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function Rx(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*SL+o*Coe+l*evt),rest:s.slice(r[0].length)}}function D9e(t){return Nc(id.anyDigitsSigned,t)}function Yc(t,s){switch(t){case 1:return Nc(id.singleDigit,s);case 2:return Nc(id.twoDigits,s);case 3:return Nc(id.threeDigits,s);case 4:return Nc(id.fourDigits,s);default:return Nc(new RegExp("^\\d{1,"+t+"}"),s)}}function une(t,s){switch(t){case 1:return Nc(id.singleDigitSigned,s);case 2:return Nc(id.twoDigitsSigned,s);case 3:return Nc(id.threeDigitsSigned,s);case 4:return Nc(id.fourDigitsSigned,s);default:return Nc(new RegExp("^-?\\d{1,"+t+"}"),s)}}function Q1e(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 O9e(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 R9e(t){return t%400===0||t%4===0&&t%100!==0}class x1t extends Bo{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 od(Yc(4,r),o);case"yo":return od(a.ordinalNumber(r,{unit:"year"}),o);default:return od(Yc(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=O9e(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 y1t extends Bo{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 od(Yc(4,r),o);case"Yo":return od(a.ordinalNumber(r,{unit:"year"}),o);default:return od(Yc(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,o){const l=Y1e(r,o);if(a.isTwoDigitYear){const d=O9e(a.year,l);return r.setFullYear(d,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),ih(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),ih(r,o)}}class v1t extends Bo{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 une(n==="R"?4:n.length,r)}set(r,n,a){const o=Yo(r,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),Y0(o)}}class _1t extends Bo{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 une(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class b1t extends Bo{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 Yc(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 w1t extends Bo{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 Yc(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 j1t extends Bo{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 od(Nc(id.month,r),o);case"MM":return od(Yc(2,r),o);case"Mo":return od(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 k1t extends Bo{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 od(Nc(id.month,r),o);case"LL":return od(Yc(2,r),o);case"Lo":return od(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 N1t(t,s,r){const n=Kn(t),a=X1e(n,r)-s;return n.setDate(n.getDate()-a*7),n}class S1t extends Bo{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 Nc(id.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return Yc(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,o){return ih(N1t(r,a,o),o)}}function C1t(t,s){const r=Kn(t),n=Z1e(r)-s;return r.setDate(r.getDate()-n*7),r}class M1t extends Bo{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 Nc(id.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return Yc(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return Y0(C1t(r,a))}}const T1t=[31,28,31,30,31,30,31,31,30,31,30,31],A1t=[31,29,31,30,31,30,31,31,30,31,30,31];class E1t extends Bo{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 Nc(id.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return Yc(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=R9e(a),l=r.getMonth();return o?n>=1&&n<=A1t[l]:n>=1&&n<=T1t[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class P1t extends Bo{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 Nc(id.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return Yc(n.length,r)}}validate(r,n){const a=r.getFullYear();return R9e(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 J1e(t,s,r){var f,v,_,b;const n=H_(),a=(r==null?void 0:r.weekStartsOn)??((v=(f=r==null?void 0:r.locale)==null?void 0:f.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,p=s<0||s>6?s-(l+u)%7:(d+u)%7-(l+u)%7;return ml(o,p)}class I1t extends Bo{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=J1e(r,a,o),r.setHours(0,0,0,0),r}}class L1t extends Bo{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 od(Yc(n.length,r),l);case"eo":return od(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=J1e(r,a,o),r.setHours(0,0,0,0),r}}class D1t extends Bo{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 od(Yc(n.length,r),l);case"co":return od(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=J1e(r,a,o),r.setHours(0,0,0,0),r}}function O1t(t,s){const r=Kn(t),n=o1t(r),a=s-n;return ml(r,a)}class R1t extends Bo{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 Yc(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return od(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 od(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return od(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return od(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=O1t(r,a),r.setHours(0,0,0,0),r}}class F1t extends Bo{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(Q1e(a),0,0,0),r}}class z1t extends Bo{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(Q1e(a),0,0,0),r}}class B1t extends Bo{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(Q1e(a),0,0,0),r}}class $1t extends Bo{constructor(){super(...arguments);_n(this,"priority",70);_n(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return Nc(id.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return Yc(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 q1t extends Bo{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 Nc(id.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return Yc(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class U1t extends Bo{constructor(){super(...arguments);_n(this,"priority",70);_n(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return Nc(id.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return Yc(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 V1t extends Bo{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 Nc(id.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return Yc(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 H1t extends Bo{constructor(){super(...arguments);_n(this,"priority",60);_n(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return Nc(id.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return Yc(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class W1t extends Bo{constructor(){super(...arguments);_n(this,"priority",50);_n(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return Nc(id.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return Yc(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class G1t extends Bo{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 od(Yc(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class K1t extends Bo{constructor(){super(...arguments);_n(this,"priority",10);_n(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return Rx(Ox.basicOptionalMinutes,r);case"XX":return Rx(Ox.basic,r);case"XXXX":return Rx(Ox.basicOptionalSeconds,r);case"XXXXX":return Rx(Ox.extendedOptionalSeconds,r);case"XXX":default:return Rx(Ox.extended,r)}}set(r,n,a){return n.timestampIsSet?r:Yo(r,r.getTime()-C_(r)-a)}}class Z1t extends Bo{constructor(){super(...arguments);_n(this,"priority",10);_n(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return Rx(Ox.basicOptionalMinutes,r);case"xx":return Rx(Ox.basic,r);case"xxxx":return Rx(Ox.basicOptionalSeconds,r);case"xxxxx":return Rx(Ox.extendedOptionalSeconds,r);case"xxx":default:return Rx(Ox.extended,r)}}set(r,n,a){return n.timestampIsSet?r:Yo(r,r.getTime()-C_(r)-a)}}class Y1t extends Bo{constructor(){super(...arguments);_n(this,"priority",40);_n(this,"incompatibleTokens","*")}parse(r){return D9e(r)}set(r,n,a){return[Yo(r,a*1e3),{timestampIsSet:!0}]}}class X1t extends Bo{constructor(){super(...arguments);_n(this,"priority",20);_n(this,"incompatibleTokens","*")}parse(r){return D9e(r)}set(r,n,a){return[Yo(r,a),{timestampIsSet:!0}]}}const Q1t={G:new g1t,y:new x1t,Y:new y1t,R:new v1t,u:new _1t,Q:new b1t,q:new w1t,M:new j1t,L:new k1t,w:new S1t,I:new M1t,d:new E1t,D:new P1t,E:new I1t,e:new L1t,c:new D1t,i:new R1t,a:new F1t,b:new z1t,B:new B1t,h:new $1t,H:new q1t,K:new U1t,k:new V1t,m:new H1t,s:new W1t,S:new G1t,X:new K1t,x:new Z1t,t:new Y1t,T:new X1t},J1t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,e_t=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,t_t=/^'([^]*?)'?$/,s_t=/''/g,r_t=/\S/,n_t=/[a-zA-Z]/;function e_e(t,s,r,n){var j,w,N,C;const a=i1t(),o=a.locale??Toe,l=a.firstWeekContainsDate??((w=(j=a.locale)==null?void 0:j.options)==null?void 0:w.firstWeekContainsDate)??1,i=a.weekStartsOn??((C=(N=a.locale)==null?void 0:N.options)==null?void 0:C.weekStartsOn)??0;if(s==="")return t===""?Kn(r):Yo(r,NaN);const d={firstWeekContainsDate:l,weekStartsOn:i,locale:o},u=[new f1t],p=s.match(e_t).map(A=>{const I=A[0];if(I in Ege){const L=Ege[I];return L(A,o.formatLong)}return A}).join("").match(J1t),f=[];for(let A of p){I9e(A)&&Pge(A,s,t),P9e(A)&&Pge(A,s,t);const I=A[0],L=Q1t[I];if(L){const{incompatibleTokens:R}=L;if(Array.isArray(R)){const q=f.find(U=>R.includes(U.token)||U.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==="*"&&f.length>0)throw new RangeError(`The format string mustn't contain \`${A}\` and any other token at the same time`);f.push({token:I,fullToken:A});const $=L.run(t,A,o.match,d);if(!$)return Yo(r,NaN);u.push($.setter),t=$.rest}else{if(I.match(n_t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+I+"`");if(A==="''"?A="'":I==="'"&&(A=a_t(A)),t.indexOf(A)===0)t=t.slice(A.length);else return Yo(r,NaN)}}if(t.length>0&&r_t.test(t))return Yo(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 Yo(r,NaN);const b={};for(const A of v){if(!A.validate(_,d))return Yo(r,NaN);const I=A.set(_,b,d);Array.isArray(I)?(_=I[0],Object.assign(b,I[1])):_=I}return Yo(r,_)}function a_t(t){return t.match(t_t)[1].replace(s_t,"'")}function Xx(t){return+Kn(t)o-l);return r>=n&&r<=a}function sre(t,s){return ml(t,-s)}function Ah(t,s){const n=h_t(t);let a;if(n.date){const d=m_t(n.date,2);a=p_t(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=f_t(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=g_t(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 D8={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},c_t=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,d_t=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,u_t=/^([+-])(\d{2})(?::?(\d{2}))?$/;function h_t(t){const s={},r=t.split(D8.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],D8.timeZoneDelimiter.test(s.date)&&(s.date=t.split(D8.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=D8.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function m_t(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 p_t(t,s){if(s===null)return new Date(NaN);const r=t.match(c_t);if(!r)return new Date(NaN);const n=!!r[4],a=XA(r[1]),o=XA(r[2])-1,l=XA(r[3]),i=XA(r[4]),d=XA(r[5])-1;if(n)return b_t(s,i,d)?x_t(s,i,d):new Date(NaN);{const u=new Date(0);return!v_t(s,o,l)||!__t(s,a)?new Date(NaN):(u.setUTCFullYear(s,o,Math.max(a,l)),u)}}function XA(t){return t?parseInt(t):1}function f_t(t){const s=t.match(d_t);if(!s)return NaN;const r=Dhe(s[1]),n=Dhe(s[2]),a=Dhe(s[3]);return w_t(r,n,a)?r*SL+n*Coe+a*1e3:NaN}function Dhe(t){return t&&parseFloat(t.replace(",","."))||0}function g_t(t){if(t==="Z")return 0;const s=t.match(u_t);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return j_t(n,a)?r*(n*SL+a*Coe):NaN}function x_t(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 y_t=[31,null,31,30,31,30,31,31,30,31,30,31];function F9e(t){return t%400===0||t%4===0&&t%100!==0}function v_t(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(y_t[s]||(F9e(t)?29:28))}function __t(t,s){return s>=1&&s<=(F9e(t)?366:365)}function b_t(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function w_t(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function j_t(t,s){return s>=0&&s<=59}function Ohe(t,s){const r=Kn(t),n=r.getFullYear(),a=r.getDate(),o=Yo(t,0);o.setFullYear(n,s,15),o.setHours(0,0,0,0);const l=a1t(o);return r.setMonth(s,Math.min(a,l)),r}function VP(t,s){const r=Kn(t);return r.setHours(s),r}function HP(t,s){const r=Kn(t);return r.setMinutes(s),r}function F5e(t,s){const r=Kn(t);return isNaN(+r)?Yo(t,NaN):(r.setFullYear(s),r)}function Mk(t,s){return Wh(t,-s)}var Io;(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})(Io||(Io={}));var z5e;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})(z5e||(z5e={}));const ra=Io.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),o1=t=>{switch(typeof t){case"undefined":return ra.undefined;case"string":return ra.string;case"number":return Number.isNaN(t)?ra.nan:ra.number;case"boolean":return ra.boolean;case"function":return ra.function;case"bigint":return ra.bigint;case"symbol":return ra.symbol;case"object":return Array.isArray(t)?ra.array:t===null?ra.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?ra.promise:typeof Map<"u"&&t instanceof Map?ra.map:typeof Set<"u"&&t instanceof Set?ra.set:typeof Date<"u"&&t instanceof Date?ra.date:ra.object;default:return ra.unknown}},en=Io.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 ry 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()}}ry.create=t=>new ry(t);const Ige=(t,s)=>{let r;switch(t.code){case en.invalid_type:t.received===ra.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case en.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Io.jsonStringifyReplacer)}`;break;case en.unrecognized_keys:r=`Unrecognized key(s) in object: ${Io.joinValues(t.keys,", ")}`;break;case en.invalid_union:r="Invalid input";break;case en.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Io.joinValues(t.options)}`;break;case en.invalid_enum_value:r=`Invalid enum value. Expected ${Io.joinValues(t.options)}, received '${t.received}'`;break;case en.invalid_arguments:r="Invalid function arguments";break;case en.invalid_return_type:r="Invalid function return type";break;case en.invalid_date:r="Invalid date";break;case en.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}"`:Io.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case en.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 en.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 en.custom:r="Invalid input";break;case en.invalid_intersection_types:r="Intersection results could not be merged";break;case en.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case en.not_finite:r="Number must be finite";break;default:r=s.defaultError,Io.assertNever(t)}return{message:r}};let k_t=Ige;function N_t(){return k_t}const S_t=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 qn(t,s){const r=N_t(),n=S_t({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ige?void 0:Ige].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 Ci;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 Ci;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 Ci=Object.freeze({status:"aborted"}),ME=t=>({status:"dirty",value:t}),Tf=t=>({status:"valid",value:t}),B5e=t=>t.status==="aborted",$5e=t=>t.status==="dirty",m3=t=>t.status==="valid",hne=t=>typeof Promise<"u"&&t instanceof Promise;var fa;(function(t){t.errToObj=s=>typeof s=="string"?{message:s}:s||{},t.toString=s=>typeof s=="string"?s:s==null?void 0:s.message})(fa||(fa={}));class M_{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 q5e=(t,s)=>{if(m3(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 ry(t.common.issues);return this._error=r,this._error}}};function Zi(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 To{get description(){return this._def.description}_getType(s){return o1(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:o1(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:o1(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(hne(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:o1(s)},a=this._parseSync({data:s,path:n.path,parent:n});return q5e(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:o1(s)};if(!this["~standard"].async)try{const o=this._parseSync({data:s,path:[],parent:r});return m3(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=>m3(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:o1(s)},a=this._parse({data:s,path:n.path,parent:n}),o=await(hne(a)?a:Promise.resolve(a));return q5e(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:en.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 g3({schema:this,typeName:Mi.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 h_.create(this,this._def)}nullable(){return x3.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Qx.create(this)}promise(){return gne.create(this,this._def)}or(s){return pne.create([this,s],this._def)}and(s){return fne.create(this,s,this._def)}transform(s){return new g3({...Zi(this._def),schema:this,typeName:Mi.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new Rge({...Zi(this._def),innerType:this,defaultValue:r,typeName:Mi.ZodDefault})}brand(){return new Z_t({typeName:Mi.ZodBranded,type:this,...Zi(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new Fge({...Zi(this._def),innerType:this,catchValue:r,typeName:Mi.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return t_e.create(this,s)}readonly(){return zge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const C_t=/^c[^\s-]{8,}$/i,M_t=/^[0-9a-z]+$/,T_t=/^[0-9A-HJKMNP-TV-Z]{26}$/i,A_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,E_t=/^[a-z0-9_-]{21}$/i,P_t=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,I_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)?)??$/,L_t=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,D_t="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Rhe;const 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])$/,R_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])$/,F_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]))$/,z_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])$/,B_t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$_t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,z9e="((\\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])))",q_t=new RegExp(`^${z9e}$`);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 U_t(t){return new RegExp(`^${B9e(t)}$`)}function V_t(t){let s=`${z9e}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 H_t(t,s){return!!((s==="v4"||!s)&&O_t.test(t)||(s==="v6"||!s)&&F_t.test(t))}function W_t(t,s){if(!P_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 G_t(t,s){return!!((s==="v4"||!s)&&R_t.test(t)||(s==="v6"||!s)&&z_t.test(t))}class R1 extends To{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==ra.string){const o=this._getOrReturnCtx(s);return qn(o,{code:en.invalid_type,expected:ra.string,received:o.parsedType}),Ci}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),qn(a,{code:en.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:en.invalid_string,...fa.errToObj(n)})}_addCheck(s){return new R1({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...fa.errToObj(s)})}url(s){return this._addCheck({kind:"url",...fa.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...fa.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...fa.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...fa.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...fa.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...fa.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...fa.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...fa.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",...fa.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",...fa.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...fa.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",...fa.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,...fa.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,...fa.errToObj(s==null?void 0:s.message)})}duration(s){return this._addCheck({kind:"duration",...fa.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,...fa.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r==null?void 0:r.position,...fa.errToObj(r==null?void 0:r.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,...fa.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,...fa.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,...fa.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,...fa.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,...fa.errToObj(r)})}nonempty(s){return this.min(1,fa.errToObj(s))}trim(){return new R1({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new R1({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new R1({...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 R1({checks:[],typeName:Mi.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Zi(t)});function K_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 p3 extends To{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)!==ra.number){const o=this._getOrReturnCtx(s);return qn(o,{code:en.invalid_type,expected:ra.number,received:o.parsedType}),Ci}let n;const a=new bp;for(const o of this._def.checks)o.kind==="int"?Io.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),qn(n,{code:en.invalid_type,expected:"integer",received:"float",message:o.message}),a.dirty()):o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),qn(n,{code:en.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?K_t(s.data,o.value)!==0&&(n=this._getOrReturnCtx(s,n),qn(n,{code:en.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),qn(n,{code:en.not_finite,message:o.message}),a.dirty()):Io.assertNever(o);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,fa.toString(r))}gt(s,r){return this.setLimit("min",s,!1,fa.toString(r))}lte(s,r){return this.setLimit("max",s,!0,fa.toString(r))}lt(s,r){return this.setLimit("max",s,!1,fa.toString(r))}setLimit(s,r,n,a){return new p3({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:fa.toString(a)}]})}_addCheck(s){return new p3({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:fa.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:fa.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:fa.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:fa.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:fa.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:fa.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:fa.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:fa.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:fa.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"&&Io.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 p3({checks:[],typeName:Mi.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Zi(t)});class YI extends To{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)!==ra.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),qn(n,{code:en.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="multipleOf"?s.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(s,n),qn(n,{code:en.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):Io.assertNever(o);return{status:a.value,value:s.data}}_getInvalidInput(s){const r=this._getOrReturnCtx(s);return qn(r,{code:en.invalid_type,expected:ra.bigint,received:r.parsedType}),Ci}gte(s,r){return this.setLimit("min",s,!0,fa.toString(r))}gt(s,r){return this.setLimit("min",s,!1,fa.toString(r))}lte(s,r){return this.setLimit("max",s,!0,fa.toString(r))}lt(s,r){return this.setLimit("max",s,!1,fa.toString(r))}setLimit(s,r,n,a){return new YI({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:fa.toString(a)}]})}_addCheck(s){return new YI({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:fa.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:fa.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:fa.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:fa.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:fa.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 YI({checks:[],typeName:Mi.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Zi(t)});class Lge extends To{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==ra.boolean){const n=this._getOrReturnCtx(s);return qn(n,{code:en.invalid_type,expected:ra.boolean,received:n.parsedType}),Ci}return Tf(s.data)}}Lge.create=t=>new Lge({typeName:Mi.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Zi(t)});class mne extends To{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==ra.date){const o=this._getOrReturnCtx(s);return qn(o,{code:en.invalid_type,expected:ra.date,received:o.parsedType}),Ci}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return qn(o,{code:en.invalid_date}),Ci}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),qn(a,{code:en.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Io.assertNever(o);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new mne({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:fa.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:fa.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 mne({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Mi.ZodDate,...Zi(t)});class U5e extends To{_parse(s){if(this._getType(s)!==ra.symbol){const n=this._getOrReturnCtx(s);return qn(n,{code:en.invalid_type,expected:ra.symbol,received:n.parsedType}),Ci}return Tf(s.data)}}U5e.create=t=>new U5e({typeName:Mi.ZodSymbol,...Zi(t)});class V5e extends To{_parse(s){if(this._getType(s)!==ra.undefined){const n=this._getOrReturnCtx(s);return qn(n,{code:en.invalid_type,expected:ra.undefined,received:n.parsedType}),Ci}return Tf(s.data)}}V5e.create=t=>new V5e({typeName:Mi.ZodUndefined,...Zi(t)});class H5e extends To{_parse(s){if(this._getType(s)!==ra.null){const n=this._getOrReturnCtx(s);return qn(n,{code:en.invalid_type,expected:ra.null,received:n.parsedType}),Ci}return Tf(s.data)}}H5e.create=t=>new H5e({typeName:Mi.ZodNull,...Zi(t)});class W5e extends To{constructor(){super(...arguments),this._any=!0}_parse(s){return Tf(s.data)}}W5e.create=t=>new W5e({typeName:Mi.ZodAny,...Zi(t)});class G5e extends To{constructor(){super(...arguments),this._unknown=!0}_parse(s){return Tf(s.data)}}G5e.create=t=>new G5e({typeName:Mi.ZodUnknown,...Zi(t)});class T_ extends To{_parse(s){const r=this._getOrReturnCtx(s);return qn(r,{code:en.invalid_type,expected:ra.never,received:r.parsedType}),Ci}}T_.create=t=>new T_({typeName:Mi.ZodNever,...Zi(t)});class K5e extends To{_parse(s){if(this._getType(s)!==ra.undefined){const n=this._getOrReturnCtx(s);return qn(n,{code:en.invalid_type,expected:ra.void,received:n.parsedType}),Ci}return Tf(s.data)}}K5e.create=t=>new K5e({typeName:Mi.ZodVoid,...Zi(t)});class Qx extends To{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==ra.array)return qn(r,{code:en.invalid_type,expected:ra.array,received:r.parsedType}),Ci;if(a.exactLength!==null){const l=r.data.length>a.exactLength.value,i=r.data.lengtha.maxLength.value&&(qn(r,{code:en.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 M_(r,l,r.path,i)))).then(l=>bp.mergeArray(n,l));const o=[...r.data].map((l,i)=>a.type._parseSync(new M_(r,l,r.path,i)));return bp.mergeArray(n,o)}get element(){return this._def.type}min(s,r){return new Qx({...this._def,minLength:{value:s,message:fa.toString(r)}})}max(s,r){return new Qx({...this._def,maxLength:{value:s,message:fa.toString(r)}})}length(s,r){return new Qx({...this._def,exactLength:{value:s,message:fa.toString(r)}})}nonempty(s){return this.min(1,s)}}Qx.create=(t,s)=>new Qx({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Mi.ZodArray,...Zi(s)});function x4(t){if(t instanceof wd){const s={};for(const r in t.shape){const n=t.shape[r];s[r]=h_.create(x4(n))}return new wd({...t._def,shape:()=>s})}else return t instanceof Qx?new Qx({...t._def,type:x4(t.element)}):t instanceof h_?h_.create(x4(t.unwrap())):t instanceof x3?x3.create(x4(t.unwrap())):t instanceof LN?LN.create(t.items.map(s=>x4(s))):t}class wd extends To{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=Io.objectKeys(s);return this._cached={shape:s,keys:r},this._cached}_parse(s){if(this._getType(s)!==ra.object){const u=this._getOrReturnCtx(s);return qn(u,{code:en.invalid_type,expected:ra.object,received:u.parsedType}),Ci}const{status:n,ctx:a}=this._processInputParams(s),{shape:o,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof T_&&this._def.unknownKeys==="strip"))for(const u in a.data)l.includes(u)||i.push(u);const d=[];for(const u of l){const p=o[u],f=a.data[u];d.push({key:{status:"valid",value:u},value:p._parse(new M_(a,f,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof T_){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of i)d.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(u==="strict")i.length>0&&(qn(a,{code:en.unrecognized_keys,keys:i}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const p of i){const f=a.data[p];d.push({key:{status:"valid",value:p},value:u._parse(new M_(a,f,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of d){const f=await p.key,v=await p.value;u.push({key:f,value:v,alwaysSet:p.alwaysSet})}return u}).then(u=>bp.mergeObjectSync(n,u)):bp.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(s){return fa.errToObj,new wd({...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:fa.errToObj(s).message??a}:{message:a}}}:{}})}strip(){return new wd({...this._def,unknownKeys:"strip"})}passthrough(){return new wd({...this._def,unknownKeys:"passthrough"})}extend(s){return new wd({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new wd({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:Mi.ZodObject})}setKey(s,r){return this.augment({[s]:r})}catchall(s){return new wd({...this._def,catchall:s})}pick(s){const r={};for(const n of Io.objectKeys(s))s[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new wd({...this._def,shape:()=>r})}omit(s){const r={};for(const n of Io.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new wd({...this._def,shape:()=>r})}deepPartial(){return x4(this)}partial(s){const r={};for(const n of Io.objectKeys(this.shape)){const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}return new wd({...this._def,shape:()=>r})}required(s){const r={};for(const n of Io.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof h_;)o=o._def.innerType;r[n]=o}return new wd({...this._def,shape:()=>r})}keyof(){return $9e(Io.objectKeys(this.shape))}}wd.create=(t,s)=>new wd({shape:()=>t,unknownKeys:"strip",catchall:T_.create(),typeName:Mi.ZodObject,...Zi(s)});wd.strictCreate=(t,s)=>new wd({shape:()=>t,unknownKeys:"strict",catchall:T_.create(),typeName:Mi.ZodObject,...Zi(s)});wd.lazycreate=(t,s)=>new wd({shape:t,unknownKeys:"strip",catchall:T_.create(),typeName:Mi.ZodObject,...Zi(s)});class pne extends To{_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 ry(i.ctx.common.issues));return qn(r,{code:en.invalid_union,unionErrors:l}),Ci}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},p=d._parseSync({data:r.data,path:r.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!o&&(o={result:p,ctx:u}),u.common.issues.length&&l.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;const i=l.map(d=>new ry(d));return qn(r,{code:en.invalid_union,unionErrors:i}),Ci}}get options(){return this._def.options}}pne.create=(t,s)=>new pne({options:t,typeName:Mi.ZodUnion,...Zi(s)});function Dge(t,s){const r=o1(t),n=o1(s);if(t===s)return{valid:!0,data:t};if(r===ra.object&&n===ra.object){const a=Io.objectKeys(s),o=Io.objectKeys(t).filter(i=>a.indexOf(i)!==-1),l={...t,...s};for(const i of o){const d=Dge(t[i],s[i]);if(!d.valid)return{valid:!1};l[i]=d.data}return{valid:!0,data:l}}else if(r===ra.array&&n===ra.array){if(t.length!==s.length)return{valid:!1};const a=[];for(let o=0;o{if(B5e(o)||B5e(l))return Ci;const i=Dge(o.value,l.value);return i.valid?(($5e(o)||$5e(l))&&r.dirty(),{status:r.value,value:i.data}):(qn(n,{code:en.invalid_intersection_types}),Ci)};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}))}}fne.create=(t,s,r)=>new fne({left:t,right:s,typeName:Mi.ZodIntersection,...Zi(r)});class LN extends To{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ra.array)return qn(n,{code:en.invalid_type,expected:ra.array,received:n.parsedType}),Ci;if(n.data.lengththis._def.items.length&&(qn(n,{code:en.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 M_(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 LN({...this._def,rest:s})}}LN.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new LN({items:t,typeName:Mi.ZodTuple,rest:null,...Zi(s)})};class Z5e extends To{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!==ra.map)return qn(n,{code:en.invalid_type,expected:ra.map,received:n.parsedType}),Ci;const a=this._def.keyType,o=this._def.valueType,l=[...n.data.entries()].map(([i,d],u)=>({key:a._parse(new M_(n,i,n.path,[u,"key"])),value:o._parse(new M_(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,p=await d.value;if(u.status==="aborted"||p.status==="aborted")return Ci;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}})}else{const i=new Map;for(const d of l){const u=d.key,p=d.value;if(u.status==="aborted"||p.status==="aborted")return Ci;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}}}}Z5e.create=(t,s,r)=>new Z5e({valueType:s,keyType:t,typeName:Mi.ZodMap,...Zi(r)});class XI extends To{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ra.set)return qn(n,{code:en.invalid_type,expected:ra.set,received:n.parsedType}),Ci;const a=this._def;a.minSize!==null&&n.data.sizea.maxSize.value&&(qn(n,{code:en.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 p of d){if(p.status==="aborted")return Ci;p.status==="dirty"&&r.dirty(),u.add(p.value)}return{status:r.value,value:u}}const i=[...n.data.values()].map((d,u)=>o._parse(new M_(n,d,n.path,u)));return n.common.async?Promise.all(i).then(d=>l(d)):l(i)}min(s,r){return new XI({...this._def,minSize:{value:s,message:fa.toString(r)}})}max(s,r){return new XI({...this._def,maxSize:{value:s,message:fa.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}XI.create=(t,s)=>new XI({valueType:t,minSize:null,maxSize:null,typeName:Mi.ZodSet,...Zi(s)});class Y5e extends To{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})}}Y5e.create=(t,s)=>new Y5e({getter:t,typeName:Mi.ZodLazy,...Zi(s)});class Oge extends To{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return qn(r,{received:r.data,code:en.invalid_literal,expected:this._def.value}),Ci}return{status:"valid",value:s.data}}get value(){return this._def.value}}Oge.create=(t,s)=>new Oge({value:t,typeName:Mi.ZodLiteral,...Zi(s)});function $9e(t,s){return new f3({values:t,typeName:Mi.ZodEnum,...Zi(s)})}class f3 extends To{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return qn(r,{expected:Io.joinValues(n),received:r.parsedType,code:en.invalid_type}),Ci}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(s.data)){const r=this._getOrReturnCtx(s),n=this._def.values;return qn(r,{received:r.data,code:en.invalid_enum_value,options:n}),Ci}return Tf(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 f3.create(s,{...this._def,...r})}exclude(s,r=this._def){return f3.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}f3.create=$9e;class X5e extends To{_parse(s){const r=Io.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==ra.string&&n.parsedType!==ra.number){const a=Io.objectValues(r);return qn(n,{expected:Io.joinValues(a),received:n.parsedType,code:en.invalid_type}),Ci}if(this._cache||(this._cache=new Set(Io.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=Io.objectValues(r);return qn(n,{received:n.data,code:en.invalid_enum_value,options:a}),Ci}return Tf(s.data)}get enum(){return this._def.values}}X5e.create=(t,s)=>new X5e({values:t,typeName:Mi.ZodNativeEnum,...Zi(s)});class gne extends To{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==ra.promise&&r.common.async===!1)return qn(r,{code:en.invalid_type,expected:ra.promise,received:r.parsedType}),Ci;const n=r.parsedType===ra.promise?r.data:Promise.resolve(r.data);return Tf(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}gne.create=(t,s)=>new gne({type:t,typeName:Mi.ZodPromise,...Zi(s)});class g3 extends To{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Mi.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(s){const{status:r,ctx:n}=this._processInputParams(s),a=this._def.effect||null,o={addIssue:l=>{qn(n,l),l.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),a.type==="preprocess"){const l=a.transform(n.data,o);if(n.common.async)return Promise.resolve(l).then(async i=>{if(r.value==="aborted")return Ci;const d=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return d.status==="aborted"?Ci:d.status==="dirty"||r.value==="dirty"?ME(d.value):d});{if(r.value==="aborted")return Ci;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?Ci:i.status==="dirty"||r.value==="dirty"?ME(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"?Ci:(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"?Ci:(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(!m3(l))return Ci;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=>m3(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):Ci);Io.assertNever(a)}}g3.create=(t,s,r)=>new g3({schema:t,typeName:Mi.ZodEffects,effect:s,...Zi(r)});g3.createWithPreprocess=(t,s,r)=>new g3({schema:s,effect:{type:"preprocess",transform:t},typeName:Mi.ZodEffects,...Zi(r)});class h_ extends To{_parse(s){return this._getType(s)===ra.undefined?Tf(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}h_.create=(t,s)=>new h_({innerType:t,typeName:Mi.ZodOptional,...Zi(s)});class x3 extends To{_parse(s){return this._getType(s)===ra.null?Tf(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}x3.create=(t,s)=>new x3({innerType:t,typeName:Mi.ZodNullable,...Zi(s)});class Rge extends To{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===ra.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Rge.create=(t,s)=>new Rge({innerType:t,typeName:Mi.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...Zi(s)});class Fge extends To{_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 hne(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ry(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new ry(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Fge.create=(t,s)=>new Fge({innerType:t,typeName:Mi.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...Zi(s)});class Q5e extends To{_parse(s){if(this._getType(s)!==ra.nan){const n=this._getOrReturnCtx(s);return qn(n,{code:en.invalid_type,expected:ra.nan,received:n.parsedType}),Ci}return{status:"valid",value:s.data}}}Q5e.create=t=>new Q5e({typeName:Mi.ZodNaN,...Zi(t)});class Z_t extends To{_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 t_e extends To{_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"?Ci:o.status==="dirty"?(r.dirty(),ME(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"?Ci: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 t_e({in:s,out:r,typeName:Mi.ZodPipeline})}}class zge extends To{_parse(s){const r=this._def.innerType._parse(s),n=a=>(m3(a)&&(a.value=Object.freeze(a.value)),a);return hne(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}zge.create=(t,s)=>new zge({innerType:t,typeName:Mi.ZodReadonly,...Zi(s)});var Mi;(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"})(Mi||(Mi={}));const Jl=R1.create,WP=p3.create,Y_t=Lge.create;T_.create;Qx.create;const sS=wd.create;pne.create;fne.create;LN.create;const xne=Oge.create,q9e=f3.create;gne.create;h_.create;x3.create;const Mr=S.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{className:Pt("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...s}));Mr.displayName="Textarea";const X_t=["Excellent","Good","Neutral","Bad","Very Bad"],Q_t=[5,4,3,2,1];function J_t({questions:t,visitorId:s,onComplete:r,onSkip:n}){const a=$0t(),[o,l]=S.useState({}),i=t.filter(v=>v.question_type==="rating"),d=t.filter(v=>v.question_type!=="rating"),u=(v,_)=>{l(b=>({...b,[v]:{rating_value:_}}))},p=(v,_)=>{l(b=>({...b,[v]:{text_value:_}}))},f=async()=>{const v=Object.entries(o).filter(([,_])=>_.rating_value!=null||_.text_value&&_.text_value.trim()).map(([_,b])=>{var j;return{visitor_id:s,question_id:_,rating_value:b.rating_value??null,text_value:((j=b.text_value)==null?void 0:j.trim())||null}});if(v.length>0)try{await a.mutateAsync(v)}catch{}r()};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"Quick Feedback"}),e.jsx("button",{onClick:n,className:"text-sm text-slate-400 hover:text-slate-600 underline",children:"Skip"})]}),e.jsx("p",{className:"text-sm text-slate-500 -mt-2",children:"Your feedback helps the agent — totally optional!"}),i.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"flex-1"}),X_t.map(v=>e.jsx("div",{className:"w-12 text-center",children:e.jsx("span",{className:"text-[10px] text-slate-400 leading-tight block",children:v})},v))]}),i.map(v=>e.jsxs("div",{className:"flex items-center gap-1 py-1.5 border-b border-slate-100 last:border-0",children:[e.jsx("span",{className:"flex-1 text-sm text-slate-700 pr-2",children:v.question_text}),Q_t.map(_=>{var b;return e.jsx("div",{className:"w-12 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>u(v.id,_),className:`w-6 h-6 rounded-full border-2 transition-all ${((b=o[v.id])==null?void 0:b.rating_value)===_?"bg-slate-900 border-slate-900":"border-slate-300 hover:border-slate-500"}`})},_)})]},v.id))]}),d.map(v=>{var _;return e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 block mb-1",children:v.question_text}),e.jsx(Mr,{value:((_=o[v.id])==null?void 0:_.text_value)||"",onChange:b=>p(v.id,b.target.value),placeholder:"Your thoughts...",className:"h-16 text-sm resize-none rounded-xl border-slate-200"})]},v.id)}),e.jsx(K,{onClick:f,disabled:a.isPending,className:"w-full h-12 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:a.isPending?e.jsx(As,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}const ebt=sS({first_name:Jl().trim().min(1,"First name is required").max(50),last_name:Jl().trim().max(50).optional(),email:Jl().trim().email("Please enter a valid email").max(255).optional().or(xne("")),phone:Jl().trim().max(20).optional().or(xne(""))}),tbt=[{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 U9e({slug:t}={}){var ie;const s=Mo(),r=t||s.slug,{data:n,isLoading:a,error:o}=F0t(r),l=G0t(),[i,d]=S.useState("welcome"),[u,p]=S.useState(null),[f,v]=S.useState({first_name:"",last_name:"",email:"",phone:""}),[_,b]=S.useState(""),[j,w]=S.useState(!1),[N,C]=S.useState(!1),[A,I]=S.useState(""),[L,R]=S.useState(""),{data:$,isLoading:q}=B0t(n==null?void 0:n.id),U=!!(n!=null&&n.enable_survey);S.useEffect(()=>{i==="pending_survey"&&(q||d(U&&(($==null?void 0:$.length)??0)>0?"survey":"done"))},[i,q,U,$]);const V=ae=>{if(!ae)return"";const[le,pe]=ae.split(":"),be=parseInt(le),ye=be>=12?"PM":"AM";return`${be>12?be-12:be||12}:${pe} ${ye}`},X=()=>{R("");const ae=ebt.safeParse(f);if(!ae.success){R(ae.error.issues[0].message);return}if(!f.email&&!f.phone){R("Please provide either an email or phone number");return}d("intent")},se=async ae=>{b(ae);try{const le=await l.mutateAsync({open_house_id:n.id,first_name:f.first_name.trim(),last_name:f.last_name.trim()||void 0,email:f.email.trim()||void 0,phone:f.phone.trim()||void 0,visitor_intent:ae,wants_market_updates:j,has_agent:N,working_with_agent_name:N&&A.trim()?A.trim():void 0});p(le.id),U?!q&&$&&$.length>0?d("survey"):d("pending_survey"):d("done")}catch{R("Something went wrong. Please try again.")}};if(a)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center",children:e.jsx("div",{className:"w-10 h-10 border-4 border-white/20 border-t-white rounded-full animate-spin"})});if(o||!n)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(Un,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Open House Not Found"}),e.jsx("p",{className:"text-white/60",children:"This sign-in page doesn't exist or is no longer active."})]})});const te=n.profiles,Y=((ie=te==null?void 0:te.name)==null?void 0:ie.split(" ").map(ae=>ae[0]).join("").slice(0,2))||"?",de=n.event_type==="community";return e.jsxs(e.Fragment,{children:[e.jsxs(ah,{children:[e.jsxs("title",{children:[de?"Community Event":"Open House"," | ",n.property_address]}),e.jsx("meta",{name:"description",content:`Sign in to the ${de?"community event":"open house"} at ${n.property_address}`}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsxs(gn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[e.jsx(Ea,{src:(te==null?void 0:te.avatar_url)||"",alt:(te==null?void 0:te.name)||""}),e.jsx(xn,{className:"bg-white/10 text-white text-lg",children:Y})]}),e.jsx("p",{className:"text-white/60 text-sm",children:te==null?void 0:te.name}),(te==null?void 0:te.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:te.title})]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl overflow-hidden",children:[n.photo_url&&e.jsxs("div",{className:"relative h-44 sm:h-52 overflow-hidden",children:[e.jsx("img",{src:n.photo_url,alt:n.property_address,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-900/80 via-slate-900/20 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 px-6 pb-4",children:[e.jsx("h1",{className:"text-white font-bold text-lg leading-tight drop-shadow-md",children:n.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-1.5 text-white/70 text-xs",children:[n.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ai,{className:"h-3 w-3"}),n.city,n.state?`, ${n.state}`:""," ",n.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ws(new Date(n.event_date+"T00:00:00"),"MMM d, yyyy")]}),n.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),V(n.start_time),n.end_time?` – ${V(n.end_time)}`:""]})]})]})]}),!n.photo_url&&e.jsx("div",{className:"bg-gradient-to-r from-slate-800 to-slate-700 px-6 py-5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/10 flex items-center justify-center shrink-0 mt-0.5",children:de?e.jsx(Aa,{className:"h-5 w-5 text-white"}):e.jsx(Un,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-white font-bold text-lg leading-tight",children:n.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-2 text-white/60 text-xs",children:[n.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ai,{className:"h-3 w-3"}),n.city,n.state?`, ${n.state}`:""," ",n.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ws(new Date(n.event_date+"T00:00:00"),"MMM d, yyyy")]}),n.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),V(n.start_time),n.end_time?` – ${V(n.end_time)}`:""]})]})]})]})}),e.jsxs("div",{className:"p-6",children:[i==="welcome"&&e.jsxs("div",{className:"text-center space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-slate-900 mb-2",children:"Welcome!"}),e.jsx("p",{className:"text-slate-500 text-sm",children:n.agent_greeting||"Please sign in below."})]}),e.jsxs(K,{onClick:()=>d("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",e.jsx(Fi,{className:"h-5 w-5 ml-2"})]}),e.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),i==="info"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{onClick:()=>d("welcome"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Ua,{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(ve,{className:"text-slate-600 text-xs",children:"First Name *"}),e.jsx(Re,{value:f.first_name,onChange:ae=>v(le=>({...le,first_name:ae.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-slate-600 text-xs",children:"Last Name"}),e.jsx(Re,{value:f.last_name,onChange:ae=>v(le=>({...le,last_name:ae.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-slate-600 text-xs",children:"Email"}),e.jsx(Re,{type:"email",value:f.email,onChange:ae=>v(le=>({...le,email:ae.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-slate-600 text-xs",children:"Phone"}),e.jsx(Re,{type:"tel",value:f.phone,onChange:ae=>v(le=>({...le,phone:ae.target.value})),placeholder:"(555) 123-4567",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer pt-1",children:[e.jsx("input",{type:"checkbox",checked:j,onChange:ae=>w(ae.target.checked),className:"rounded border-slate-300 text-slate-900 focus:ring-slate-500"}),e.jsx("span",{className:"text-sm text-slate-600",children:"Send me market updates for this area"})]}),e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-slate-600",children:"Already working with an agent?"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-slate-400",children:N?"Yes":"No"}),e.jsx(Br,{checked:N,onCheckedChange:C})]})]}),N&&e.jsx(Re,{value:A,onChange:ae=>I(ae.target.value),placeholder:"Agent's name",className:"mt-1 h-10 rounded-xl border-slate-200 text-sm"})]}),L&&e.jsx("p",{className:"text-destructive text-sm",children:L}),e.jsxs(K,{onClick:X,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(Fi,{className:"h-5 w-5 ml-2"})]})]}),i==="intent"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{onClick:()=>d("info"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Ua,{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:tbt.map(ae=>e.jsxs("button",{onClick:()=>se(ae.value),disabled:l.isPending,className:"flex flex-col items-center gap-2 p-5 rounded-xl border-2 border-slate-200 hover:border-slate-900 hover:bg-slate-50 transition-all text-center group",children:[e.jsx("span",{className:"text-2xl",children:ae.emoji}),e.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:ae.label})]},ae.value))}),L&&e.jsx("p",{className:"text-destructive text-sm text-center",children:L})]}),i==="pending_survey"&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-3",children:[e.jsx("div",{className:"w-8 h-8 border-[3px] border-slate-200 border-t-slate-900 rounded-full animate-spin"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading survey..."})]}),i==="survey"&&u&&$&&e.jsx(J_t,{questions:$,visitorId:u,onComplete:()=>d("done"),onSkip:()=>d("done")}),i==="done"&&e.jsxs("div",{className:"text-center space-y-4 py-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-green-100 flex items-center justify-center mx-auto",children:e.jsx(da,{className:"h-8 w-8 text-green-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-slate-900",children:"You're all set!"}),e.jsxs("p",{className:"text-slate-500 text-sm mt-1",children:["Thanks for signing in, ",f.first_name,". ",de?"Enjoy the event!":"Enjoy the open house!"]})]}),(te==null?void 0:te.name)&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:te.name})]})]})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function sbt(){const s=vu().pathname.slice(1);return S.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(U9e,{slug:s})}function rbt({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(Un,{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(Ai,{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(Zn,{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(_r,{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(gc,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function nbt({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(Fi,{className:"w-4 h-4 text-white/80"}),e.jsx("h3",{className:"text-sm font-semibold text-white",children:"Current Stage"})]})}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-lg font-bold text-slate-800",children:t.label}),e.jsx("p",{className:"text-sm text-slate-500 mt-1 leading-relaxed",children:t.description})]}),s&&e.jsxs("div",{className:"bg-slate-50 rounded-xl p-4 border border-slate-100",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:"Update from your agent"}),e.jsx("p",{className:"text-sm text-slate-700 leading-relaxed",children:s})]}),r&&e.jsxs("div",{className:"bg-blue-50/60 rounded-xl p-4 border border-blue-100",children:[e.jsx("p",{className:"text-xs font-semibold text-blue-600 uppercase tracking-wider mb-1.5",children:"What's Next"}),e.jsx("p",{className:"text-sm text-blue-800 leading-relaxed",children:r})]}),n&&e.jsx("div",{className:"rounded-xl overflow-hidden bg-slate-900 aspect-video shadow-md",children:e.jsx("iframe",{src:a(n)||n,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Next step video"})})]})]})}function fl(t){const s=t.split(/[-/T]/);if(s.length>=3){const r=Number(s[0]);return r>99?new Date(r,Number(s[1])-1,Number(s[2])):new Date(Number(s[2]),Number(s[0])-1,Number(s[1]))}return new Date(`${t}T12:00:00`)}function obt(t,s){const r=ws(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 lbt(t,s){const r=ws(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 cbt({targetCloseDate:t,contractDate:s,inspectionDate:r,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:s,icon:o5,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:r,icon:fn,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:Un,color:"text-purple-600 bg-purple-50"},{label:a?"Closed":"Target Close",date:a||t,icon:on,color:"text-emerald-600 bg-emerald-50"}].filter(i=>i.date);if(o.length===0)return null;const l=(i,d,u)=>{const p=fl(d);if(u==="google")window.open(obt(i,p),"_blank");else{const f=lbt(i,p),v=document.createElement("a");v.href=f,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:p})=>{const f=fl(d),v=Xx(f)&&!$d(f),_=$d(f),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 ${p}`,children:e.jsx(u,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs text-slate-500",children:i}),e.jsxs("p",{className:`text-sm font-medium ${_?"text-emerald-600":v?"text-slate-400":"text-slate-800"}`,children:[ws(f,"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(Q1,{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 dbt({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 G.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(In,{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(xi,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function ubt({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(Hc,{className:"w-3.5 h-3.5 text-emerald-600"}):e.jsx(cf,{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:ws(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 hbt({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var b,j;const[l,i]=S.useState({first_name:((b=t.client_name)==null?void 0:b.split(" ")[0])||"",last_name:((j=t.client_name)==null?void 0:j.split(" ").slice(1).join(" "))||"",email:t.client_email||"",phone:t.client_phone||"",preferred_contact_method:"email",client_role:"buyer",notes:"",spouse_first_name:"",spouse_last_name:"",spouse_email:"",spouse_phone:""}),[d,u]=S.useState({}),[p,f]=S.useState(!1),v=Ot({mutationFn:async()=>{const{error:w}=await G.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:p&&l.spouse_first_name||null,spouse_last_name:p&&l.spouse_last_name||null,spouse_email:p&&l.spouse_email||null,spouse_phone:p&&l.spouse_phone||null});if(w)throw w},onSuccess:o,onError:w=>{console.error("[PortalOnboarding] Submit failed:",w),fe.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(Ai,{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:w=>{w.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(ve,{className:"text-xs text-slate-600",children:"First Name *"}),e.jsx(Re,{required:!0,value:l.first_name,onChange:w=>i(N=>({...N,first_name:w.target.value})),className:"mt-1 rounded-xl",placeholder:"John"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(Re,{value:l.last_name,onChange:w=>i(N=>({...N,last_name:w.target.value})),className:"mt-1 rounded-xl",placeholder:"Doe"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(Re,{type:"email",value:l.email,onChange:w=>i(N=>({...N,email:w.target.value})),className:"mt-1 rounded-xl",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(Re,{type:"tel",value:l.phone,onChange:w=>i(N=>({...N,phone:w.target.value})),className:"mt-1 rounded-xl",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Preferred Contact Method"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:[{value:"email",label:"Email"},{value:"call",label:"Phone"},{value:"text",label:"Text"}].map(w=>e.jsx("button",{type:"button",onClick:()=>i(N=>({...N,preferred_contact_method:w.value})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.preferred_contact_method===w.value?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:w.label},w.value))})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Your Role"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:["buyer","seller","both"].map(w=>e.jsx("button",{type:"button",onClick:()=>i(N=>({...N,client_role:w})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.client_role===w?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:w.charAt(0).toUpperCase()+w.slice(1)},w))})]}),n.map(w=>e.jsxs("div",{children:[e.jsxs(ve,{className:"text-xs text-slate-600",children:[w.question_text," ",w.is_required&&"*"]}),w.field_type==="text"&&e.jsx(Re,{required:w.is_required,value:d[w.id]||"",onChange:N=>u(C=>({...C,[w.id]:N.target.value})),className:"mt-1 rounded-xl"}),w.field_type==="textarea"&&e.jsx("textarea",{required:w.is_required,value:d[w.id]||"",onChange:N=>u(C=>({...C,[w.id]:N.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),w.field_type==="dropdown"&&e.jsxs("select",{required:w.is_required,value:d[w.id]||"",onChange:N=>u(C=>({...C,[w.id]:N.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm h-10",children:[e.jsx("option",{value:"",children:"Select..."}),(w.options||[]).map(N=>e.jsx("option",{value:N,children:N},N))]}),w.field_type==="toggle"&&e.jsx("div",{className:"mt-1.5 flex gap-2",children:["Yes","No"].map(N=>e.jsx("button",{type:"button",onClick:()=>u(C=>({...C,[w.id]:N})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${d[w.id]===N?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:N},N))})]},w.id)),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Notes for your agent"}),e.jsx("textarea",{value:l.notes,onChange:w=>i(N=>({...N,notes:w.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Anything you'd like your agent to know..."})]}),t.allow_spouse&&e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>f(!p),className:"text-sm text-blue-600 hover:text-blue-700 font-medium",children:p?"− Remove spouse/partner":"+ Add spouse/partner"}),p&&e.jsxs("div",{className:"mt-3 p-4 bg-slate-50 rounded-xl space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"First Name"}),e.jsx(Re,{value:l.spouse_first_name,onChange:w=>i(N=>({...N,spouse_first_name:w.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(Re,{value:l.spouse_last_name,onChange:w=>i(N=>({...N,spouse_last_name:w.target.value})),className:"mt-1 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(Re,{type:"email",value:l.spouse_email,onChange:w=>i(N=>({...N,spouse_email:w.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(Re,{type:"tel",value:l.spouse_phone,onChange:w=>i(N=>({...N,spouse_phone:w.target.value})),className:"mt-1 rounded-xl"})]})]})]}),e.jsx(K,{type:"submit",disabled: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 mbt(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function pbt(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 fbt={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. 🎉"}},V9e=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function s_e(t){return V9e.map(s=>{if(s==="Active")return{key:"Active",label:mbt(t),description:pbt(t)};const r=fbt[s];return{key:s,label:r.label,description:r.description}})}function J5e(t){if(!t)return 0;const s=V9e.indexOf(t);return s>=0?s:0}function gbt(t,s){return Ct({queryKey:["client-portal-public",t],queryFn:async()=>{if(!t)return null;const{data:r,error:n}=await G.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 xbt(t){return Ct({queryKey:["client-portal-by-id",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.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 H9e({slug:t}){var te,Y,de,ie,ae,le;const[s,r]=S.useState(!1),[n,a]=S.useState("primary"),[o]=S.useState(()=>{const pe=`portal_fp_${t}`;let be=localStorage.getItem(pe);return be||(be=localStorage.getItem("portal_fp"),be?localStorage.setItem(pe,be):(be=crypto.randomUUID(),localStorage.setItem(pe,be),localStorage.setItem("portal_fp",be))),be});S.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:l,isLoading:i,error:d}=gbt(t,!0),u=l==null?void 0:l.linked_portal_id,{data:p}=xbt(u),f=(te=l==null?void 0:l.deal_pipeline)==null?void 0:te.owner_user_id,{data:v}=Ct({queryKey:["portal-stages",f],queryFn:async()=>{const{data:pe,error:be}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",f).order("sort_order",{ascending:!0});if(be)throw be;return pe},enabled:!!f}),{data:_}=Ct({queryKey:["portal-agent",f],queryFn:async()=>{const{data:pe,error:be}=await G.from("profiles").select("id, name, avatar_url, phone, email").eq("id",f).single();if(be)throw be;return pe},enabled:!!f}),b=n==="linked"&&p?p:l,j=b==null?void 0:b.id,{data:w}=Ct({queryKey:["portal-updates-public",j],queryFn:async()=>{const{data:pe,error:be}=await G.from("portal_updates").select("*").eq("portal_id",j).order("created_at",{ascending:!1});if(be)throw be;return pe},enabled:!!j}),N=(Y=b==null?void 0:b.deal_pipeline)==null?void 0:Y.id,{data:C}=Ct({queryKey:["portal-documents",N],queryFn:async()=>{const{data:pe,error:be}=await G.from("deal_files").select("*").eq("deal_id",N).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(be)throw be;return pe},enabled:!!N}),A=l==null?void 0:l.id,{data:I,isLoading:L}=Ct({queryKey:["portal-onboarding-check",A,o],queryFn:async()=>{const{data:pe,error:be}=await G.from("portal_onboarding_submissions").select("id").eq("portal_id",A).eq("device_fingerprint",o).maybeSingle();if(be)throw be;return pe},enabled:!!A&&!!(l!=null&&l.require_onboarding)}),{data:R}=Ct({queryKey:["portal-custom-questions-public",f],queryFn:async()=>{const{data:pe,error:be}=await G.from("portal_custom_questions").select("*").eq("owner_user_id",f).eq("is_active",!0).order("sort_order",{ascending:!0});if(be)throw be;return pe},enabled:!!f&&!!(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 pe=l==null?void 0:l.deal_pipeline;return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:e.jsx(hbt,{portal:l,dealData:pe,agentProfile:_,customQuestions:R||[],deviceFingerprint:o,onComplete:()=>r(!0)})})}const q=(de=l==null?void 0:l.deal_pipeline)==null?void 0:de.deal_type,U=(ie=p==null?void 0:p.deal_pipeline)==null?void 0:ie.deal_type,V=!!p,X=pe=>pe==="listing"?"Your Sale":pe==="buy-side"?"Your Purchase":"Transaction",se=pe=>pe==="listing"?e.jsx(Un,{className:"w-3.5 h-3.5"}):e.jsx(Im,{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(rbt,{dealData:b==null?void 0:b.deal_pipeline,agentProfile:_,welcomeMessage:b==null?void 0:b.welcome_message,isWon:(le=(ae=b==null?void 0:b.deal_pipeline)==null?void 0:ae.deal_pipeline_stages)==null?void 0:le.is_won_stage}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 space-y-5 mt-6",children:[V&&e.jsxs("div",{className:"flex gap-1 bg-slate-100 rounded-xl p-1",children:[e.jsxs("button",{onClick:()=>a("primary"),className:`flex-1 flex items-center justify-center gap-1.5 rounded-lg py-2.5 text-sm font-medium transition-all ${n==="primary"?"bg-white text-slate-800 shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:[se(q),X(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(U),X(U)]})]}),e.jsx(ybt,{portal:b,updates:w,documents:C}),e.jsxs("div",{className:"text-center pt-6 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-slate-400",children:[e.jsx(rh,{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 ybt({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=s_e(i);d&&d.length>0&&(u=d.map((_,b)=>{var j,w;return{key:`custom-${b}`,label:_.label||((j=u[b])==null?void 0:j.label)||`Stage ${b+1}`,description:_.description||((w=u[b])==null?void 0:w.description)||"",video_url:_.video_url||void 0}}));const p=d&&d.length>0?Math.min(J5e(o==null?void 0:o.name),u.length-1):J5e(o==null?void 0:o.name),f=u[p],v=f==null?void 0:f.video_url;return e.jsxs(e.Fragment,{children:[e.jsx(abt,{targetCloseDate:a==null?void 0:a.target_close_date,actualCloseDate:a==null?void 0:a.actual_close_date,clientName:t.client_name}),e.jsx(nbt,{journeyStages:u,currentIndex:p}),f&&e.jsx(ibt,{currentStage:f,nextStepText:t.next_step_text,nextStepVideoUrl:v||t.next_step_video_url}),e.jsx(cbt,{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(dbt,{documents:r}),s&&s.length>0&&e.jsx(ubt,{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 vbt(){const s=vu().pathname.slice(1);return S.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(H9e,{slug:s})}const Bge="levelup_affiliate_ref",_bt=30,bbt=()=>{const[t]=Ec();S.useEffect(()=>{const s=t.get("ref");if(s){const r={code:s.toUpperCase(),timestamp:Date.now()};localStorage.setItem(Bge,JSON.stringify(r)),console.log("[Affiliate] Stored referral code:",s)}},[t])},wbt=()=>{try{const t=localStorage.getItem(Bge);if(!t)return null;const s=JSON.parse(t),r=_bt*24*60*60*1e3;return Date.now()-s.timestamp>r?(localStorage.removeItem(Bge),console.log("[Affiliate] Referral code expired"),null):s.code}catch{return null}},yne="/assets/levelup-logo-header-_ZX7DvlA.png",jbt="/assets/scale-your-team-ku4MPatU.png";function kbt({open:t,onOpenChange:s}){return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Ss,{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(Aa,{className:"h-5 w-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Ns,{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 au={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"]}},Nbt=[{icon:ym,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Bl,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:on,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:gc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:In,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:io,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],Sbt=[{icon:hr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:hn,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Zn,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Ru,title:"Birthday & Anniversary Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Ai,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:Xo,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Si,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Dm,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],Cbt=[{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."}],Mbt=()=>{const{user:t,loading:s}=Gs(),r=Dr(),[n]=Ec();S.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",q=window.location.pathname==="/";if($&&q){r("/public/listings",{replace:!0});return}},[r]);const[a,o]=S.useState(null),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,f]=S.useState(""),[v,_]=S.useState(""),[b,j]=S.useState(""),[w,N]=S.useState(!1),[C,A]=S.useState(!1),I=($,q=!1)=>{i({tier:$,skipTrial:q}),u(!0)};bbt(),S.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",q=location.pathname.startsWith("/public/");!s&&t&&!$&&!q&&r("/dashboard")},[t,s,r,location.pathname]),S.useEffect(()=>{n.get("canceled")==="true"&&fe.error("Checkout was canceled. Feel free to try again when you're ready!")},[n]);const L=async($,q=!1)=>{if(!p){fe.error("Please enter your email address");return}if(!v.trim()){fe.error("Please enter your full name");return}N(!0),o($+(q?"_direct":""));const U=wbt();try{const{data:V,error:X}=await G.functions.invoke("create-checkout",{body:{tier:$,email:p,name:v.trim(),couponCode:b.trim()||void 0,skipTrial:q,referralCode:U}});if(X)throw X;if(V!=null&&V.url)window.open(V.url,"_blank","noopener,noreferrer"),fe.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(V){console.error("Checkout error:",V),fe.error(V.message||"Failed to start checkout. Please try again.")}finally{N(!1),o(null),u(!1),i(null)}},R=()=>{l&&L(l.tier,l.skipTrial)};return s?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#4a6b6d]",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-white border-t-transparent"})}):e.jsxs("div",{className:"min-h-screen bg-background overflow-hidden",children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:e.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("img",{src:yne,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var $;return($=document.getElementById("features"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},children:"Pricing"}),e.jsx(K,{onClick:()=>r("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),e.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-8",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx("img",{alt:"LevelUp Consulting Group",className:"h-[136px] md:h-[164px] drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),e.jsxs("p",{className:"text-lg text-white/80 max-w-3xl mx-auto leading-relaxed font-sans font-bold md:text-4xl",children:["The tools you need to get it done.",e.jsx("br",{}),e.jsx("em",{children:"The platform you need to keep it going."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center items-center pt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("free-trial"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"px-8 py-7 text-lg font-semibold bg-white text-[#1e3a4c] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",children:["Start Your Free Trial",e.jsx(Fi,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),e.jsx(K,{size:"lg",variant:"outline",onClick:()=>{var $;return($=document.getElementById("features"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"px-8 py-7 text-lg font-semibold border-2 border-white text-white bg-transparent hover:bg-white hover:text-[#1e3a4c] rounded-full",children:"See What's Included"})]})]})})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl md:text-5xl leading-tight font-sans font-semibold text-secondary",children:"We help brokerages and agents grow with training, tools, and built-in execution."}),e.jsxs("div",{className:"space-y-2 text-lg text-muted-foreground",children:[e.jsx("p",{children:"Agents get weekly coaching + plug-and-play marketing."}),e.jsx("p",{children:"Brokerages get higher adoption, consistency, and real engagement."})]}),e.jsx("p",{className:"text-2xl md:text-4xl text-[#4a6b6d] pt-4 font-sans font-bold",children:"LEVELUP EQUIPS BOTH TO THRIVE."}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Learn how we support agents and empower brokerages to grow—together."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center pt-4",children:[e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>{var $;return($=document.getElementById("brokerage"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/5",children:[e.jsx(Aa,{className:"mr-2 h-5 w-5"}),"Brokerage Partnership"]}),e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:[e.jsx(Xi,{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:Nbt.map(($,q)=>e.jsxs(Ee,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Lt,{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(zt,{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(hn,{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:Sbt.map(($,q)=>e.jsxs(Ee,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Lt,{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(zt,{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(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-white text-[#4a6b6d] hover:bg-white/90 shadow-xl transition-all hover:scale-105",children:["Get Agent OS with Your Membership",e.jsx(Fi,{className:"ml-2 w-5 h-5"})]})})]})]}),e.jsx("section",{id:"brokerage",className:"py-20 bg-[#4a6b6d]/5",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsx("div",{className:"max-w-6xl mx-auto",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-[#4a6b6d]/10 text-[#4a6b6d] text-sm font-medium",children:[e.jsx(Aa,{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(ua,{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(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["See Brokerage Plans",e.jsx(Ha,{className:"ml-2 w-5 h-5"})]}),e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>A(!0),className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/10",children:[e.jsx(on,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),e.jsx("div",{className:"relative hidden md:block",children:e.jsx("img",{src:jbt,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:Cbt.map(($,q)=>e.jsx(Ee,{className:"bg-muted/30 border-0",children:e.jsxs(Oe,{className:"pt-8",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(U=>e.jsx(Gn,{className:"w-5 h-5 fill-yellow-400 text-yellow-400"},U))}),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(K,{size:"lg",className:"px-12 py-7 text-lg font-semibold bg-white text-[#4a6b6d] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",onClick:()=>I("individual_agent"),children:["Start Free Trial",e.jsx(Fi,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]})})]})})]}),e.jsx("section",{id:"pricing",className:"py-20 bg-muted/30",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("h2",{className:"text-3xl mb-6 font-sans md:text-5xl font-bold",children:["Simple, Transparent ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"Pricing"})]}),e.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:"Choose the plan that fits your needs. All plans include everything you need to succeed."})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:[e.jsxs(Ee,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Lt,{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(Xi,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsx(zt,{className:"text-xl font-sans",children:au.individual_agent.name})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:au.individual_agent.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:au.individual_agent.period})]}),e.jsx(yr,{className:"text-base mt-2",children:au.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"}),au.individual_agent.trial]})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:au.individual_agent.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ua,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsxs(UP,{className:"flex flex-col gap-3 pt-4",children:[e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("individual_agent"),children:"Start Free Trial"}),e.jsx(K,{variant:"outline",className:"w-full rounded-full border-2 border-[#4a6b6d] text-[#4a6b6d] bg-white hover:bg-[#4a6b6d]/5 uppercase text-sm font-medium tracking-wide",onClick:()=>I("individual_agent",!0),children:"Skip Trial, Subscribe Now"})]})]}),e.jsxs(Ee,{className:"relative flex flex-col border-2 border-[#4a6b6d] shadow-2xl scale-105 bg-background",children:[e.jsx("div",{className:"absolute -top-4 left-1/2 -translate-x-1/2 px-6 py-2 bg-[#4a6b6d] text-white text-sm font-semibold rounded-full shadow-lg",children:"Most Popular"}),e.jsxs(Lt,{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(Aa,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-xl font-sans",children:au.brokerage_under_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:au.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:au.brokerage_under_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:au.brokerage_under_25.period})]}),e.jsx(yr,{className:"text-base mt-2",children:au.brokerage_under_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:au.brokerage_under_25.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ua,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsx(UP,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg shadow-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("brokerage_under_25"),children:"Get Started"})})]}),e.jsxs(Ee,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Lt,{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(Aa,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-xl font-sans",children:au.brokerage_over_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:au.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:au.brokerage_over_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:au.brokerage_over_25.period})]}),e.jsx(yr,{className:"text-base mt-2",children:au.brokerage_over_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:au.brokerage_over_25.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ua,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsx(UP,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("brokerage_over_25"),children:"Get Started"})})]})]})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl text-white font-sans md:text-5xl",children:"Ready to Level Up?"}),e.jsx("p",{className:"text-lg text-white/80 max-w-2xl mx-auto",children:"Join thousands of agents who are closing more deals, saving time, and growing their business with LevelUp."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs(K,{size:"lg",onClick:()=>{var $;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(Fi,{className:"ml-2 w-5 h-5"})]}),e.jsx(K,{size:"lg",onClick:()=>r("/auth"),className:"px-10 py-7 text-lg font-semibold border-2 border-white text-white bg-transparent hover:bg-white hover:text-[#4a6b6d]",children:"Sign In"})]})]})})]}),e.jsx("footer",{className:"py-12 bg-[#3d5a5c] text-white/80",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsx("img",{src:yne,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(kbt,{open:C,onOpenChange:A}),e.jsx(vs,{open:d,onOpenChange:u,children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{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(ve,{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:p,onChange:$=>f($.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(ve,{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:$=>j($.target.value),className:"mt-1"})]})]}),e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:R,disabled:w,children:w?"Loading...":"Continue to Checkout"})]})})]})},Tbt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(ah,{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"})]})]})]})]})})]}),Abt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(ah,{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"})]})]})]})]})})]}),Ebt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(ah,{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"})]})]})]})]})})]}),Pbt=sS({email:Jl().email("Invalid email address"),password:Jl().min(6,"Password must be at least 6 characters")}),Ibt=()=>{const{signIn:t,user:s}=Gs(),r=Dr(),[n,a]=S.useState(!1),[o,l]=S.useState({}),[i,d]=S.useState(""),[u,p]=S.useState(!1),[f,v]=S.useState(!1);S.useEffect(()=>{s&&r("/dashboard")},[s,r]);const _=async j=>{j.preventDefault(),l({}),a(!0);const w=new FormData(j.currentTarget),N=w.get("email"),C=w.get("password");try{Pbt.parse({email:N,password:C}),await t(N,C)}catch(A){if(A instanceof ry){const I={};A.errors.forEach(L=>{L.path[0]&&(I[L.path[0]]=L.message)}),l(I)}}finally{a(!1)}},b=async()=>{if(!i){fe.error("Please enter your email address");return}p(!0);try{const{error:j}=await G.functions.invoke("send-password-reset",{body:{email:i,redirectTo:"https://dashboard.relevelup.com/profile?reset=true"}});if(j)throw j;fe.success("Password reset email sent! Check your inbox."),v(!1),d("")}catch(j){fe.error(j.message||"Failed to send reset email")}finally{p(!1)}};return e.jsxs("div",{className:"min-h-screen relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-[#4a6b6d] via-[#3d5a5c] to-[#2a4347]",children:e.jsxs("div",{className:"absolute inset-0 opacity-30",children:[e.jsx("div",{className:"absolute top-0 left-0 w-96 h-96 bg-white/10 rounded-full blur-3xl animate-pulse"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-96 h-96 bg-white/5 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/2 w-64 h-64 bg-white/5 rounded-full blur-3xl animate-pulse",style:{animationDelay:"2s"}})]})}),e.jsxs("div",{className:"relative z-10 flex flex-col min-h-screen",children:[e.jsx("header",{className:"p-6",children:e.jsxs(vo,{to:"/",className:"inline-flex items-center gap-2 text-sm text-white/80 hover:text-white transition-colors",children:[e.jsx(Ua,{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:bBe,alt:"LevelUp",className:"h-12 w-auto"})})}),e.jsxs(Ee,{className:"border-0 shadow-2xl bg-white/95 backdrop-blur-sm",children:[e.jsxs(Lt,{className:"space-y-1 text-center pb-4",children:[e.jsx(zt,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(yr,{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(ve,{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(ve,{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(K,{type:"submit",className:"w-full bg-[#4a6b6d] hover:bg-[#3d5a5c] text-white font-semibold py-6 text-lg transition-all duration-200 shadow-lg hover:shadow-xl",disabled:n,children:n?"Signing in...":"Sign In"}),e.jsxs(vs,{open:f,onOpenChange:v,children:[e.jsx(Ei,{asChild:!0,children:e.jsx(K,{variant:"link",className:"w-full text-sm text-[#4a6b6d] hover:text-[#3d5a5c]",children:"Forgot password?"})}),e.jsxs(ys,{className:"bg-white",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{htmlFor:"reset-email",className:"text-gray-700",children:"Email"}),e.jsx(Re,{id:"reset-email",type:"email",placeholder:"your@email.com",value:i,onChange:j=>d(j.target.value),className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"})]}),e.jsx(K,{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(vo,{to:"/",className:"text-white hover:underline font-medium",children:"View Plans"})]})]})})]})]})},Lbt=()=>{const[t]=Ec(),s=t.get("tier"),r=s==null?void 0:s.includes("brokerage");return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ee,{className:"max-w-lg w-full",children:[e.jsxs(Lt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-green-500/10 flex items-center justify-center mb-4",children:e.jsx(gi,{className:"w-10 h-10 text-green-500"})}),e.jsx(zt,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(yr,{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(_r,{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."})})]})]})})},W9e=t=>{const[s,r]=S.useState(null),[n,a]=S.useState(!0);return S.useEffect(()=>{if(!t){a(!1);return}(async()=>{try{const{data:i}=await G.storage.from("avatars").list(`${t}`);if(i&&i.length>0){const{data:d}=G.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 G.storage.from("avatars").list(`${t}`);if(l&&l.length>0){const{data:i}=G.storage.from("avatars").getPublicUrl(`${t}/${l[0].name}`);r(`${i.publicUrl}?t=${Date.now()}`)}}catch(l){console.error("Error refreshing avatar:",l)}}}},G9e=async t=>{const s=new Map;return await Promise.all(t.map(async r=>{try{const{data:n}=await G.storage.from("avatars").list(`${r}`);if(n&&n.length>0){const{data:a}=G.storage.from("avatars").getPublicUrl(`${r}/${n[0].name}`);s.set(r,a.publicUrl)}}catch{}})),s},Dbt=t=>{const[s,r]=S.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return S.useEffect(()=>{if(!t){r(a=>({...a,loading:!1}));return}(async()=>{try{const{data:a,error:o}=await G.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(),p=Math.ceil((u-d)/(1e3*60*60*24)),f=p<=0;r({isTrial:!0,isExpired:f,expiresAt:a.subscription_end_date,daysLeft:f?0:p,loading:!1})}else if(i){const d=new Date().getTime(),u=new Date(a.trial_expires_at).getTime(),p=Math.ceil((u-d)/(1e3*60*60*24)),f=p<=0;r({isTrial:!0,isExpired:f,expiresAt:a.trial_expires_at,daysLeft:f?0:p,loading:!1})}else r({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!1})}catch(a){console.error("Error in useTrialStatus:",a),r(o=>({...o,loading:!1}))}})()},[t]),s},K9e=()=>{const{data:t,isLoading:s}=Ct({queryKey:["feature-flags"],queryFn:async()=>{const{data:n,error:a}=await G.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")}},e3e="community_last_seen_post_at";function Obt(){const{user:t}=Gs(),s=vu(),[r,n]=S.useState(0),[a,o]=S.useState(null);S.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${e3e}_${t.id}`);o(i)},[t]),S.useEffect(()=>{if(!t)return;(async()=>{let d=G.from("community_posts").select("id",{count:"exact",head:!0});a&&(d=d.gt("created_at",a));const{data:u}=await G.from("profiles").select("brokerage_id").eq("id",t.id).single(),{count:p,error:f}=await d;!f&&p!==null&&n(p)})()},[t,a]),S.useEffect(()=>{if(!t)return;const i=G.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 p=s.pathname==="/community";p||n(j=>j+1);const{data:f}=await G.from("profiles").select("name").eq("id",u.user_id).single(),v=(f==null?void 0:f.name)||"Someone",_=u.content.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),b=_.length>50?_.substring(0,50)+"...":_;p||fe("New Community Post",{description:`${v}: ${b}`,action:{label:"View",onClick:()=>{window.location.href="/community"}}})}).subscribe();return()=>{G.removeChannel(i)}},[t,s.pathname]);const l=S.useCallback(()=>{if(!t)return;const i=new Date().toISOString();localStorage.setItem(`${e3e}_${t.id}`,i),o(i),n(0)},[t]);return S.useEffect(()=>{s.pathname==="/community"&&r>0&&l()},[s.pathname,r,l]),{unreadCount:r,markAsRead:l}}function Rbt(){const{isAdmin:t}=Gs(),{data:s=0}=Ct({queryKey:["wishlist-open-count"],queryFn:async()=>{const{count:r,error:n}=await G.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 gM=xoe,r_e=q1e,Fbt=yoe,Z9e=S.forwardRef(({className:t,...s},r)=>e.jsx(mM,{className:Pt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));Z9e.displayName=mM.displayName;const zbt=XN("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"}}),rS=S.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(Fbt,{children:[e.jsx(Z9e,{}),e.jsxs(pM,{ref:a,className:Pt(zbt({side:t}),s),...n,children:[r,e.jsxs(kL,{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(Ur,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));rS.displayName=pM.displayName;const xM=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col space-y-2 text-center sm:text-left",t),...s});xM.displayName="SheetHeader";const yM=S.forwardRef(({className:t,...s},r)=>e.jsx(wL,{ref:r,className:Pt("text-lg font-semibold text-foreground",t),...s}));yM.displayName=wL.displayName;const Y9e=S.forwardRef(({className:t,...s},r)=>e.jsx(jL,{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));Y9e.displayName=jL.displayName;function Bbt(t,s){return S.useReducer((r,n)=>s[r][n]??r,t)}var n_e="ScrollArea",[X9e]=Ac(n_e),[$bt,Af]=X9e(n_e),Q9e=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,d]=S.useState(null),[u,p]=S.useState(null),[f,v]=S.useState(null),[_,b]=S.useState(null),[j,w]=S.useState(null),[N,C]=S.useState(0),[A,I]=S.useState(0),[L,R]=S.useState(!1),[$,q]=S.useState(!1),U=Pa(s,X=>d(X)),V=$_(a);return e.jsx($bt,{scope:r,type:n,dir:V,scrollHideDelay:o,scrollArea:i,viewport:u,onViewportChange:p,content:f,onContentChange:v,scrollbarX:_,onScrollbarXChange:b,scrollbarXEnabled:L,onScrollbarXEnabledChange:R,scrollbarY:j,onScrollbarYChange:w,scrollbarYEnabled:$,onScrollbarYEnabledChange:q,onCornerWidthChange:C,onCornerHeightChange:I,children:e.jsx(Qr.div,{dir:V,...l,ref:U,style:{position:"relative","--radix-scroll-area-corner-width":N+"px","--radix-scroll-area-corner-height":A+"px",...t.style}})})});Q9e.displayName=n_e;var J9e="ScrollAreaViewport",e$e=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=Af(J9e,r),i=S.useRef(null),d=Pa(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})})]})});e$e.displayName=J9e;var py="ScrollAreaScrollbar",a_e=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Af(py,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=t.orientation==="horizontal";return S.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?e.jsx(qbt,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(Ubt,{...n,ref:s,forceMount:r}):a.type==="auto"?e.jsx(t$e,{...n,ref:s,forceMount:r}):a.type==="always"?e.jsx(i_e,{...n,ref:s}):null});a_e.displayName=py;var qbt=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Af(py,t.__scopeScrollArea),[o,l]=S.useState(!1);return S.useEffect(()=>{const i=a.scrollArea;let d=0;if(i){const u=()=>{window.clearTimeout(d),l(!0)},p=()=>{d=window.setTimeout(()=>l(!1),a.scrollHideDelay)};return i.addEventListener("pointerenter",u),i.addEventListener("pointerleave",p),()=>{window.clearTimeout(d),i.removeEventListener("pointerenter",u),i.removeEventListener("pointerleave",p)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(hd,{present:r||o,children:e.jsx(t$e,{"data-state":o?"visible":"hidden",...n,ref:s})})}),Ubt=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Af(py,t.__scopeScrollArea),o=t.orientation==="horizontal",l=Poe(()=>d("SCROLL_END"),100),[i,d]=Bbt("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 S.useEffect(()=>{if(i==="idle"){const u=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,a.scrollHideDelay,d]),S.useEffect(()=>{const u=a.viewport,p=o?"scrollLeft":"scrollTop";if(u){let f=u[p];const v=()=>{const _=u[p];f!==_&&(d("SCROLL"),l()),f=_};return u.addEventListener("scroll",v),()=>u.removeEventListener("scroll",v)}},[a.viewport,o,d,l]),e.jsx(hd,{present:r||i!=="hidden",children:e.jsx(i_e,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:Cr(t.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Cr(t.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),t$e=S.forwardRef((t,s)=>{const r=Af(py,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=S.useState(!1),i=t.orientation==="horizontal",d=Poe(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=Af(py,t.__scopeScrollArea),o=S.useRef(null),l=S.useRef(0),[i,d]=S.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=i$e(i.viewport,i.content),p={...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 f(v,_){return Zbt(v,l.current,i,_)}return r==="horizontal"?e.jsx(Vbt,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const v=a.viewport.scrollLeft,_=t3e(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=f(v,a.dir))}}):r==="vertical"?e.jsx(Hbt,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const v=a.viewport.scrollTop,_=t3e(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=f(v))}}):null}),Vbt=S.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Af(py,t.__scopeScrollArea),[l,i]=S.useState(),d=S.useRef(null),u=Pa(s,d,o.onScrollbarXChange);return S.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(r$e,{"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":Eoe(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,f)=>{if(o.viewport){const v=o.viewport.scrollLeft+p.deltaX;t.onWheelScroll(v),l$e(v,f)&&p.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:_ne(l.paddingLeft),paddingEnd:_ne(l.paddingRight)}})}})}),Hbt=S.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Af(py,t.__scopeScrollArea),[l,i]=S.useState(),d=S.useRef(null),u=Pa(s,d,o.onScrollbarYChange);return S.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(r$e,{"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":Eoe(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,f)=>{if(o.viewport){const v=o.viewport.scrollTop+p.deltaY;t.onWheelScroll(v),l$e(v,f)&&p.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:_ne(l.paddingTop),paddingEnd:_ne(l.paddingBottom)}})}})}),[Wbt,s$e]=X9e(py),r$e=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:p,onResize:f,...v}=t,_=Af(py,r),[b,j]=S.useState(null),w=Pa(s,U=>j(U)),N=S.useRef(null),C=S.useRef(""),A=_.viewport,I=n.content-n.viewport,L=Vc(p),R=Vc(d),$=Poe(f,10);function q(U){if(N.current){const V=U.clientX-N.current.left,X=U.clientY-N.current.top;u({x:V,y:X})}}return S.useEffect(()=>{const U=V=>{const X=V.target;(b==null?void 0:b.contains(X))&&L(V,I)};return document.addEventListener("wheel",U,{passive:!1}),()=>document.removeEventListener("wheel",U,{passive:!1})},[A,b,I,L]),S.useEffect(R,[n,R]),y3(b,$),y3(_.content,$),e.jsx(Wbt,{scope:r,scrollbar:b,hasThumb:a,onThumbChange:Vc(o),onThumbPointerUp:Vc(l),onThumbPositionChange:R,onThumbPointerDown:Vc(i),children:e.jsx(Qr.div,{...v,ref:w,style:{position:"absolute",...v.style},onPointerDown:Cr(t.onPointerDown,U=>{U.button===0&&(U.target.setPointerCapture(U.pointerId),N.current=b.getBoundingClientRect(),C.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",_.viewport&&(_.viewport.style.scrollBehavior="auto"),q(U))}),onPointerMove:Cr(t.onPointerMove,q),onPointerUp:Cr(t.onPointerUp,U=>{const V=U.target;V.hasPointerCapture(U.pointerId)&&V.releasePointerCapture(U.pointerId),document.body.style.webkitUserSelect=C.current,_.viewport&&(_.viewport.style.scrollBehavior=""),N.current=null})})})}),vne="ScrollAreaThumb",n$e=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=s$e(vne,t.__scopeScrollArea);return e.jsx(hd,{present:r||a.hasThumb,children:e.jsx(Gbt,{ref:s,...n})})}),Gbt=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=Af(vne,r),l=s$e(vne,r),{onThumbPositionChange:i}=l,d=Pa(s,f=>l.onThumbChange(f)),u=S.useRef(void 0),p=Poe(()=>{u.current&&(u.current(),u.current=void 0)},100);return S.useEffect(()=>{const f=o.viewport;if(f){const v=()=>{if(p(),!u.current){const _=Ybt(f,i);u.current=_,i()}};return i(),f.addEventListener("scroll",v),()=>f.removeEventListener("scroll",v)}},[o.viewport,p,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:Cr(t.onPointerDownCapture,f=>{const _=f.target.getBoundingClientRect(),b=f.clientX-_.left,j=f.clientY-_.top;l.onThumbPointerDown({x:b,y:j})}),onPointerUp:Cr(t.onPointerUp,l.onThumbPointerUp)})});n$e.displayName=vne;var o_e="ScrollAreaCorner",a$e=S.forwardRef((t,s)=>{const r=Af(o_e,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(Kbt,{...t,ref:s}):null});a$e.displayName=o_e;var Kbt=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=Af(o_e,r),[o,l]=S.useState(0),[i,d]=S.useState(0),u=!!(o&&i);return y3(a.scrollbarX,()=>{var f;const p=((f=a.scrollbarX)==null?void 0:f.offsetHeight)||0;a.onCornerHeightChange(p),d(p)}),y3(a.scrollbarY,()=>{var f;const p=((f=a.scrollbarY)==null?void 0:f.offsetWidth)||0;a.onCornerWidthChange(p),l(p)}),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 _ne(t){return t?parseInt(t,10):0}function i$e(t,s){const r=t/s;return isNaN(r)?0:r}function Eoe(t){const s=i$e(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*s;return Math.max(n,18)}function Zbt(t,s,r,n="ltr"){const a=Eoe(r),o=a/2,l=s||o,i=a-l,d=r.scrollbar.paddingStart+l,u=r.scrollbar.size-r.scrollbar.paddingEnd-i,p=r.content-r.viewport,f=n==="ltr"?[0,p]:[p*-1,0];return o$e([d,u],f)(t)}function t3e(t,s,r="ltr"){const n=Eoe(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=ZI(t,d);return o$e([0,l],[0,i])(u)}function o$e(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 l$e(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 Poe(t,s){const r=Vc(t),n=S.useRef(0);return S.useEffect(()=>()=>window.clearTimeout(n.current),[]),S.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function y3(t,s){const r=Vc(s);Zc(()=>{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 c$e=Q9e,Xbt=e$e,Qbt=a$e;const Bi=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(c$e,{ref:n,className:Pt("relative overflow-hidden",t),...r,children:[e.jsx(Xbt,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(Ioe,{}),e.jsx(Qbt,{})]}));Bi.displayName=c$e.displayName;const Ioe=S.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(a_e,{ref:n,orientation:s,className:Pt("flex touch-none select-none transition-colors",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:e.jsx(n$e,{className:"relative flex-1 rounded-full bg-border"})}));Ioe.displayName=a_e.displayName;var Loe="Collapsible",[Jbt]=Ac(Loe),[ewt,l_e]=Jbt(Loe),d$e=S.forwardRef((t,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=t,[d,u]=xu({prop:n,defaultProp:a??!1,onChange:l,caller:Loe});return e.jsx(ewt,{scope:r,disabled:o,contentId:Gd(),open:d,onOpenToggle:S.useCallback(()=>u(p=>!p),[u]),children:e.jsx(Qr.div,{"data-state":d_e(d),"data-disabled":o?"":void 0,...i,ref:s})})});d$e.displayName=Loe;var u$e="CollapsibleTrigger",h$e=S.forwardRef((t,s)=>{const{__scopeCollapsible:r,...n}=t,a=l_e(u$e,r);return e.jsx(Qr.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":d_e(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Cr(t.onClick,a.onOpenToggle)})});h$e.displayName=u$e;var c_e="CollapsibleContent",m$e=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=l_e(c_e,t.__scopeCollapsible);return e.jsx(hd,{present:r||a.open,children:({present:o})=>e.jsx(twt,{...n,ref:s,present:o})})});m$e.displayName=c_e;var twt=S.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=l_e(c_e,r),[i,d]=S.useState(n),u=S.useRef(null),p=Pa(s,u),f=S.useRef(0),v=f.current,_=S.useRef(0),b=_.current,j=l.open||i,w=S.useRef(j),N=S.useRef(void 0);return S.useEffect(()=>{const C=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(C)},[]),Zc(()=>{const C=u.current;if(C){N.current=N.current||{transitionDuration:C.style.transitionDuration,animationName:C.style.animationName},C.style.transitionDuration="0s",C.style.animationName="none";const A=C.getBoundingClientRect();f.current=A.height,_.current=A.width,w.current||(C.style.transitionDuration=N.current.transitionDuration,C.style.animationName=N.current.animationName),d(n)}},[l.open,n]),e.jsx(Qr.div,{"data-state":d_e(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!j,...o,ref:p,style:{"--radix-collapsible-content-height":v?`${v}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...t.style},children:j&&a})});function d_e(t){return t?"open":"closed"}var swt=d$e;const mf=swt,pf=h$e,ff=m$e,rwt="/assets/levelup-logo-Eif24dqY.png",nwt="/assets/levelup-logo-icon-C-7iromj.png",awt="/assets/levelup-logo-mobile-B9skSjUG.png";var CL=t=>t.type==="checkbox",Tk=t=>t instanceof Date,Mh=t=>t==null;const p$e=t=>typeof t=="object";var ud=t=>!Mh(t)&&!Array.isArray(t)&&p$e(t)&&!Tk(t),f$e=t=>ud(t)&&t.target?CL(t.target)?t.target.checked:t.target.value:t,iwt=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,g$e=(t,s)=>t.has(iwt(s)),owt=t=>{const s=t.constructor&&t.constructor.prototype;return ud(s)&&s.hasOwnProperty("isPrototypeOf")},u_e=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Od(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(!(u_e&&(t instanceof Blob||n))&&(r||ud(t)))if(s=r?[]:{},!r&&!owt(t))s=t;else for(const a in t)t.hasOwnProperty(a)&&(s[a]=Od(t[a]));else return t;return s}var Doe=t=>/^\w*$/.test(t),sd=t=>t===void 0,h_e=t=>Array.isArray(t)?t.filter(Boolean):[],m_e=t=>h_e(t.replace(/["|']|\]/g,"").split(/\.|\[/)),bn=(t,s,r)=>{if(!s||!ud(t))return r;const n=(Doe(s)?[s]:m_e(s)).reduce((a,o)=>Mh(a)?a:a[o],t);return sd(n)||n===t?sd(t[s])?r:t[s]:n},rp=t=>typeof t=="boolean",Ko=(t,s,r)=>{let n=-1;const a=Doe(s)?[s]:m_e(s),o=a.length,l=o-1;for(;++nmt.useContext(p_e),lwt=t=>{const{children:s,...r}=t;return mt.createElement(p_e.Provider,{value:r},s)};var x$e=(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]!==Sg.all&&(s._proxyFormState[l]=!n||Sg.all),r&&(r[l]=!0),t[l]}});return a};const f_e=typeof window<"u"?mt.useLayoutEffect:mt.useEffect;function cwt(t){const s=Ooe(),{control:r=s.control,disabled:n,name:a,exact:o}=t||{},[l,i]=mt.useState(r._formState),d=mt.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return f_e(()=>r._subscribe({name:a,formState:d.current,exact:o,callback:u=>{!n&&i({...r._formState,...u})}}),[a,n,o]),mt.useEffect(()=>{d.current.isValid&&r._setValid(!0)},[r]),mt.useMemo(()=>x$e(l,r,d.current,!1),[l,r])}var zx=t=>typeof t=="string",y$e=(t,s,r,n,a)=>zx(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),$ge=t=>Mh(t)||!p$e(t);function p0(t,s,r=new WeakSet){if($ge(t)||$ge(s))return t===s;if(Tk(t)&&Tk(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(Tk(l)&&Tk(i)||ud(l)&&ud(i)||Array.isArray(l)&&Array.isArray(i)?!p0(l,i,r):l!==i)return!1}}return!0}function dwt(t){const s=Ooe(),{control:r=s.control,name:n,defaultValue:a,disabled:o,exact:l,compute:i}=t||{},d=mt.useRef(a),u=mt.useRef(i),p=mt.useRef(void 0);u.current=i;const f=mt.useMemo(()=>r._getWatch(n,d.current),[r,n]),[v,_]=mt.useState(u.current?u.current(f):f);return f_e(()=>r._subscribe({name:n,formState:{values:!0},exact:l,callback:b=>{if(!o){const j=y$e(n,r._names,b.values||r._formValues,!1,d.current);if(u.current){const w=u.current(j);p0(w,p.current)||(_(w),p.current=w)}else _(j)}}}),[r,o,n,l]),mt.useEffect(()=>r._removeUnmounted()),v}function uwt(t){const s=Ooe(),{name:r,disabled:n,control:a=s.control,shouldUnregister:o,defaultValue:l}=t,i=g$e(a._names.array,r),d=mt.useMemo(()=>bn(a._formValues,r,bn(a._defaultValues,r,l)),[a,r,l]),u=dwt({control:a,name:r,defaultValue:d,exact:!0}),p=cwt({control:a,name:r,exact:!0}),f=mt.useRef(t),v=mt.useRef(a.register(r,{...t.rules,value:u,...rp(t.disabled)?{disabled:t.disabled}:{}}));f.current=t;const _=mt.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!bn(p.errors,r)},isDirty:{enumerable:!0,get:()=>!!bn(p.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!bn(p.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!bn(p.validatingFields,r)},error:{enumerable:!0,get:()=>bn(p.errors,r)}}),[p,r]),b=mt.useCallback(C=>v.current.onChange({target:{value:f$e(C),name:r},type:bne.CHANGE}),[r]),j=mt.useCallback(()=>v.current.onBlur({target:{value:bn(a._formValues,r),name:r},type:bne.BLUR}),[r,a._formValues]),w=mt.useCallback(C=>{const A=bn(a._fields,r);A&&C&&(A._f.ref={focus:()=>C.focus&&C.focus(),select:()=>C.select&&C.select(),setCustomValidity:I=>C.setCustomValidity(I),reportValidity:()=>C.reportValidity()})},[a._fields,r]),N=mt.useMemo(()=>({name:r,value:u,...rp(n)||p.disabled?{disabled:p.disabled||n}:{},onChange:b,onBlur:j,ref:w}),[r,n,p.disabled,b,j,w,u]);return mt.useEffect(()=>{const C=a._options.shouldUnregister||o;a.register(r,{...f.current.rules,...rp(f.current.disabled)?{disabled:f.current.disabled}:{}});const A=(I,L)=>{const R=bn(a._fields,I);R&&R._f&&(R._f.mount=L)};if(A(r,!0),C){const I=Od(bn(a._options.defaultValues,r));Ko(a._defaultValues,r,I),sd(bn(a._formValues,r))&&Ko(a._formValues,r,I)}return!i&&a.register(r),()=>{(i?C&&!a._state.action:C)?a.unregister(r):A(r,!1)}},[r,a,i,o]),mt.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),mt.useMemo(()=>({field:N,formState:p,fieldState:_}),[N,p,_])}const hwt=t=>t.render(uwt(t));var v$e=(t,s,r,n,a)=>s?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:a||!0}}:{},GP=t=>Array.isArray(t)?t:[t],s3e=()=>{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=[]}}},fm=t=>ud(t)&&!Object.keys(t).length,g_e=t=>t.type==="file",Cg=t=>typeof t=="function",wne=t=>{if(!u_e)return!1;const s=t?t.ownerDocument:0;return t instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},_$e=t=>t.type==="select-multiple",x_e=t=>t.type==="radio",mwt=t=>x_e(t)||CL(t),Fhe=t=>wne(t)&&t.isConnected;function pwt(t,s){const r=s.slice(0,-1).length;let n=0;for(;n{for(const s in t)if(Cg(t[s]))return!0;return!1};function jne(t,s={}){const r=Array.isArray(t);if(ud(t)||r)for(const n in t)Array.isArray(t[n])||ud(t[n])&&!b$e(t[n])?(s[n]=Array.isArray(t[n])?[]:{},jne(t[n],s[n])):Mh(t[n])||(s[n]=!0);return s}function w$e(t,s,r){const n=Array.isArray(t);if(ud(t)||n)for(const a in t)Array.isArray(t[a])||ud(t[a])&&!b$e(t[a])?sd(s)||$ge(r[a])?r[a]=Array.isArray(t[a])?jne(t[a],[]):{...jne(t[a])}:w$e(t[a],Mh(s)?{}:s[a],r[a]):r[a]=!p0(t[a],s[a]);return r}var QA=(t,s)=>w$e(t,s,jne(s));const r3e={value:!1,isValid:!1},n3e={value:!0,isValid:!0};var j$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&&!sd(t[0].attributes.value)?sd(t[0].value)||t[0].value===""?n3e:{value:t[0].value,isValid:!0}:n3e:r3e}return r3e},k$e=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>sd(t)?t:s?t===""?NaN:t&&+t:r&&zx(t)?new Date(t):n?n(t):t;const a3e={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,a3e):a3e;function i3e(t){const s=t.ref;return g_e(s)?s.files:x_e(s)?N$e(t.refs).value:_$e(s)?[...s.selectedOptions].map(({value:r})=>r):CL(s)?j$e(t.refs).value:k$e(sd(s.value)?t.ref.value:s.value,t)}var gwt=(t,s,r,n)=>{const a={};for(const o of t){const l=bn(s,o);l&&Ko(a,o,l._f)}return{criteriaMode:r,names:[...t],fields:a,shouldUseNativeValidation:n}},kne=t=>t instanceof RegExp,JA=t=>sd(t)?t:kne(t)?t.source:ud(t)?kne(t.value)?t.value.source:t.value:t,o3e=t=>({isOnSubmit:!t||t===Sg.onSubmit,isOnBlur:t===Sg.onBlur,isOnChange:t===Sg.onChange,isOnAll:t===Sg.all,isOnTouch:t===Sg.onTouched});const l3e="AsyncFunction";var xwt=t=>!!t&&!!t.validate&&!!(Cg(t.validate)&&t.validate.constructor.name===l3e||ud(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===l3e)),ywt=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),c3e=(t,s,r)=>!r&&(s.watchAll||s.watch.has(t)||[...s.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const KP=(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(KP(i,s))break}else if(ud(i)&&KP(i,s))break}}};function d3e(t,s,r){const n=bn(t,r);if(n||Doe(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 vwt=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return fm(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||Sg.all))},_wt=(t,s,r)=>!t||!s||t===s||GP(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),bwt=(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,wwt=(t,s)=>!h_e(bn(t,s)).length&&vd(t,s),jwt=(t,s,r)=>{const n=GP(bn(t,r));return Ko(n,"root",s[r]),Ko(t,r,n),t},rre=t=>zx(t);function u3e(t,s,r="validate"){if(rre(t)||Array.isArray(t)&&t.every(rre)||rp(t)&&!t)return{type:r,message:rre(t)?t:"",ref:s}}var r4=t=>ud(t)&&!kne(t)?t:{value:t,message:""},h3e=async(t,s,r,n,a,o)=>{const{ref:l,refs:i,required:d,maxLength:u,minLength:p,min:f,max:v,pattern:_,validate:b,name:j,valueAsNumber:w,mount:N}=t._f,C=bn(r,j);if(!N||s.has(j))return{};const A=i?i[0]:l,I=se=>{a&&A.reportValidity&&(A.setCustomValidity(rp(se)?"":se||""),A.reportValidity())},L={},R=x_e(l),$=CL(l),q=R||$,U=(w||g_e(l))&&sd(l.value)&&sd(C)||wne(l)&&l.value===""||C===""||Array.isArray(C)&&!C.length,V=v$e.bind(null,j,n,L),X=(se,te,Y,de=Hy.maxLength,ie=Hy.minLength)=>{const ae=se?te:Y;L[j]={type:se?de:ie,message:ae,ref:l,...V(se?de:ie,ae)}};if(o?!Array.isArray(C)||!C.length:d&&(!q&&(U||Mh(C))||rp(C)&&!C||$&&!j$e(i).isValid||R&&!N$e(i).isValid)){const{value:se,message:te}=rre(d)?{value:!!d,message:d}:r4(d);if(se&&(L[j]={type:Hy.required,message:te,ref:A,...V(Hy.required,te)},!n))return I(te),L}if(!U&&(!Mh(f)||!Mh(v))){let se,te;const Y=r4(v),de=r4(f);if(!Mh(C)&&!isNaN(C)){const ie=l.valueAsNumber||C&&+C;Mh(Y.value)||(se=ie>Y.value),Mh(de.value)||(te=ienew Date(new Date().toDateString()+" "+be),le=l.type=="time",pe=l.type=="week";zx(Y.value)&&C&&(se=le?ae(C)>ae(Y.value):pe?C>Y.value:ie>new Date(Y.value)),zx(de.value)&&C&&(te=le?ae(C)+se.value,de=!Mh(te.value)&&C.length<+te.value;if((Y||de)&&(X(Y,se.message,te.message),!n))return I(L[j].message),L}if(_&&!U&&zx(C)){const{value:se,message:te}=r4(_);if(kne(se)&&!C.match(se)&&(L[j]={type:Hy.pattern,message:te,ref:l,...V(Hy.pattern,te)},!n))return I(te),L}if(b){if(Cg(b)){const se=await b(C,r),te=u3e(se,A);if(te&&(L[j]={...te,...V(Hy.validate,te.message)},!n))return I(te.message),L}else if(ud(b)){let se={};for(const te in b){if(!fm(se)&&!n)break;const Y=u3e(await b[te](C,r),A,te);Y&&(se={...Y,...V(te,Y.message)},I(Y.message),n&&(L[j]=se))}if(!fm(se)&&(L[j]={ref:A,...se},!n))return L}}return I(!0),L};const kwt={mode:Sg.onSubmit,reValidateMode:Sg.onChange,shouldFocusError:!0};function Nwt(t={}){let s={...kwt,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:Cg(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},a=ud(s.defaultValues)||ud(s.values)?Od(s.defaultValues||s.values)||{}:{},o=s.shouldUnregister?{}:Od(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 p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let f={...p};const v={array:s3e(),state:s3e()},_=s.criteriaMode===Sg.all,b=qe=>Xe=>{clearTimeout(u),u=setTimeout(qe,Xe)},j=async qe=>{if(!s.disabled&&(p.isValid||f.isValid||qe)){const Xe=s.resolver?fm((await $()).errors):await U(n,!0);Xe!==r.isValid&&v.state.next({isValid:Xe})}},w=(qe,Xe)=>{!s.disabled&&(p.isValidating||p.validatingFields||f.isValidating||f.validatingFields)&&((qe||Array.from(i.mount)).forEach($e=>{$e&&(Xe?Ko(r.validatingFields,$e,Xe):vd(r.validatingFields,$e))}),v.state.next({validatingFields:r.validatingFields,isValidating:!fm(r.validatingFields)}))},N=(qe,Xe=[],$e,Ke,ct=!0,Ue=!0)=>{if(Ke&&$e&&!s.disabled){if(l.action=!0,Ue&&Array.isArray(bn(n,qe))){const Ve=$e(bn(n,qe),Ke.argA,Ke.argB);ct&&Ko(n,qe,Ve)}if(Ue&&Array.isArray(bn(r.errors,qe))){const Ve=$e(bn(r.errors,qe),Ke.argA,Ke.argB);ct&&Ko(r.errors,qe,Ve),wwt(r.errors,qe)}if((p.touchedFields||f.touchedFields)&&Ue&&Array.isArray(bn(r.touchedFields,qe))){const Ve=$e(bn(r.touchedFields,qe),Ke.argA,Ke.argB);ct&&Ko(r.touchedFields,qe,Ve)}(p.dirtyFields||f.dirtyFields)&&(r.dirtyFields=QA(a,o)),v.state.next({name:qe,isDirty:X(qe,Xe),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Ko(o,qe,Xe)},C=(qe,Xe)=>{Ko(r.errors,qe,Xe),v.state.next({errors:r.errors})},A=qe=>{r.errors=qe,v.state.next({errors:r.errors,isValid:!1})},I=(qe,Xe,$e,Ke)=>{const ct=bn(n,qe);if(ct){const Ue=bn(o,qe,sd($e)?bn(a,qe):$e);sd(Ue)||Ke&&Ke.defaultChecked||Xe?Ko(o,qe,Xe?Ue:i3e(ct._f)):Y(qe,Ue),l.mount&&j()}},L=(qe,Xe,$e,Ke,ct)=>{let Ue=!1,Ve=!1;const Je={name:qe};if(!s.disabled){if(!$e||Ke){(p.isDirty||f.isDirty)&&(Ve=r.isDirty,r.isDirty=Je.isDirty=X(),Ue=Ve!==Je.isDirty);const Rt=p0(bn(a,qe),Xe);Ve=!!bn(r.dirtyFields,qe),Rt?vd(r.dirtyFields,qe):Ko(r.dirtyFields,qe,!0),Je.dirtyFields=r.dirtyFields,Ue=Ue||(p.dirtyFields||f.dirtyFields)&&Ve!==!Rt}if($e){const Rt=bn(r.touchedFields,qe);Rt||(Ko(r.touchedFields,qe,$e),Je.touchedFields=r.touchedFields,Ue=Ue||(p.touchedFields||f.touchedFields)&&Rt!==$e)}Ue&&ct&&v.state.next(Je)}return Ue?Je:{}},R=(qe,Xe,$e,Ke)=>{const ct=bn(r.errors,qe),Ue=(p.isValid||f.isValid)&&rp(Xe)&&r.isValid!==Xe;if(s.delayError&&$e?(d=b(()=>C(qe,$e)),d(s.delayError)):(clearTimeout(u),d=null,$e?Ko(r.errors,qe,$e):vd(r.errors,qe)),($e?!p0(ct,$e):ct)||!fm(Ke)||Ue){const Ve={...Ke,...Ue&&rp(Xe)?{isValid:Xe}:{},errors:r.errors,name:qe};r={...r,...Ve},v.state.next(Ve)}},$=async qe=>{w(qe,!0);const Xe=await s.resolver(o,s.context,gwt(qe||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return w(qe),Xe},q=async qe=>{const{errors:Xe}=await $(qe);if(qe)for(const $e of qe){const Ke=bn(Xe,$e);Ke?Ko(r.errors,$e,Ke):vd(r.errors,$e)}else r.errors=Xe;return Xe},U=async(qe,Xe,$e={valid:!0})=>{for(const Ke in qe){const ct=qe[Ke];if(ct){const{_f:Ue,...Ve}=ct;if(Ue){const Je=i.array.has(Ue.name),Rt=ct._f&&xwt(ct._f);Rt&&p.validatingFields&&w([Ke],!0);const $t=await h3e(ct,i.disabled,o,_,s.shouldUseNativeValidation&&!Xe,Je);if(Rt&&p.validatingFields&&w([Ke]),$t[Ue.name]&&($e.valid=!1,Xe))break;!Xe&&(bn($t,Ue.name)?Je?jwt(r.errors,$t,Ue.name):Ko(r.errors,Ue.name,$t[Ue.name]):vd(r.errors,Ue.name))}!fm(Ve)&&await U(Ve,Xe,$e)}}return $e.valid},V=()=>{for(const qe of i.unMount){const Xe=bn(n,qe);Xe&&(Xe._f.refs?Xe._f.refs.every($e=>!Fhe($e)):!Fhe(Xe._f.ref))&&Te(qe)}i.unMount=new Set},X=(qe,Xe)=>!s.disabled&&(qe&&Xe&&Ko(o,qe,Xe),!p0(be(),a)),se=(qe,Xe,$e)=>y$e(qe,i,{...l.mount?o:sd(Xe)?a:zx(qe)?{[qe]:Xe}:Xe},$e,Xe),te=qe=>h_e(bn(l.mount?o:a,qe,s.shouldUnregister?bn(a,qe,[]):[])),Y=(qe,Xe,$e={})=>{const Ke=bn(n,qe);let ct=Xe;if(Ke){const Ue=Ke._f;Ue&&(!Ue.disabled&&Ko(o,qe,k$e(Xe,Ue)),ct=wne(Ue.ref)&&Mh(Xe)?"":Xe,_$e(Ue.ref)?[...Ue.ref.options].forEach(Ve=>Ve.selected=ct.includes(Ve.value)):Ue.refs?CL(Ue.ref)?Ue.refs.forEach(Ve=>{(!Ve.defaultChecked||!Ve.disabled)&&(Array.isArray(ct)?Ve.checked=!!ct.find(Je=>Je===Ve.value):Ve.checked=ct===Ve.value||!!ct)}):Ue.refs.forEach(Ve=>Ve.checked=Ve.value===ct):g_e(Ue.ref)?Ue.ref.value="":(Ue.ref.value=ct,Ue.ref.type||v.state.next({name:qe,values:Od(o)})))}($e.shouldDirty||$e.shouldTouch)&&L(qe,ct,$e.shouldTouch,$e.shouldDirty,!0),$e.shouldValidate&&pe(qe)},de=(qe,Xe,$e)=>{for(const Ke in Xe){if(!Xe.hasOwnProperty(Ke))return;const ct=Xe[Ke],Ue=qe+"."+Ke,Ve=bn(n,Ue);(i.array.has(qe)||ud(ct)||Ve&&!Ve._f)&&!Tk(ct)?de(Ue,ct,$e):Y(Ue,ct,$e)}},ie=(qe,Xe,$e={})=>{const Ke=bn(n,qe),ct=i.array.has(qe),Ue=Od(Xe);Ko(o,qe,Ue),ct?(v.array.next({name:qe,values:Od(o)}),(p.isDirty||p.dirtyFields||f.isDirty||f.dirtyFields)&&$e.shouldDirty&&v.state.next({name:qe,dirtyFields:QA(a,o),isDirty:X(qe,Ue)})):Ke&&!Ke._f&&!Mh(Ue)?de(qe,Ue,$e):Y(qe,Ue,$e),c3e(qe,i)&&v.state.next({...r,name:qe}),v.state.next({name:l.mount?qe:void 0,values:Od(o)})},ae=async qe=>{l.mount=!0;const Xe=qe.target;let $e=Xe.name,Ke=!0;const ct=bn(n,$e),Ue=Rt=>{Ke=Number.isNaN(Rt)||Tk(Rt)&&isNaN(Rt.getTime())||p0(Rt,bn(o,$e,Rt))},Ve=o3e(s.mode),Je=o3e(s.reValidateMode);if(ct){let Rt,$t;const ls=Xe.type?i3e(ct._f):f$e(qe),Qt=qe.type===bne.BLUR||qe.type===bne.FOCUS_OUT,rs=!ywt(ct._f)&&!s.resolver&&!bn(r.errors,$e)&&!ct._f.deps||bwt(Qt,bn(r.touchedFields,$e),r.isSubmitted,Je,Ve),as=c3e($e,i,Qt);Ko(o,$e,ls),Qt?(ct._f.onBlur&&ct._f.onBlur(qe),d&&d(0)):ct._f.onChange&&ct._f.onChange(qe);const ir=L($e,ls,Qt),vt=!fm(ir)||as;if(!Qt&&v.state.next({name:$e,type:qe.type,values:Od(o)}),rs)return(p.isValid||f.isValid)&&(s.mode==="onBlur"?Qt&&j():Qt||j()),vt&&v.state.next({name:$e,...as?{}:ir});if(!Qt&&as&&v.state.next({...r}),s.resolver){const{errors:Cs}=await $([$e]);if(Ue(ls),Ke){const or=d3e(r.errors,n,$e),Ar=d3e(Cs,n,or.name||$e);Rt=Ar.error,$e=Ar.name,$t=fm(Cs)}}else w([$e],!0),Rt=(await h3e(ct,i.disabled,o,_,s.shouldUseNativeValidation))[$e],w([$e]),Ue(ls),Ke&&(Rt?$t=!1:(p.isValid||f.isValid)&&($t=await U(n,!0)));Ke&&(ct._f.deps&&pe(ct._f.deps),R($e,$t,Rt,ir))}},le=(qe,Xe)=>{if(bn(r.errors,Xe)&&qe.focus)return qe.focus(),1},pe=async(qe,Xe={})=>{let $e,Ke;const ct=GP(qe);if(s.resolver){const Ue=await q(sd(qe)?qe:ct);$e=fm(Ue),Ke=qe?!ct.some(Ve=>bn(Ue,Ve)):$e}else qe?(Ke=(await Promise.all(ct.map(async Ue=>{const Ve=bn(n,Ue);return await U(Ve&&Ve._f?{[Ue]:Ve}:Ve)}))).every(Boolean),!(!Ke&&!r.isValid)&&j()):Ke=$e=await U(n);return v.state.next({...!zx(qe)||(p.isValid||f.isValid)&&$e!==r.isValid?{}:{name:qe},...s.resolver||!qe?{isValid:$e}:{},errors:r.errors}),Xe.shouldFocus&&!Ke&&KP(n,le,qe?ct:i.mount),Ke},be=qe=>{const Xe={...l.mount?o:a};return sd(qe)?Xe:zx(qe)?bn(Xe,qe):qe.map($e=>bn(Xe,$e))},ye=(qe,Xe)=>({invalid:!!bn((Xe||r).errors,qe),isDirty:!!bn((Xe||r).dirtyFields,qe),error:bn((Xe||r).errors,qe),isValidating:!!bn(r.validatingFields,qe),isTouched:!!bn((Xe||r).touchedFields,qe)}),we=qe=>{qe&&GP(qe).forEach(Xe=>vd(r.errors,Xe)),v.state.next({errors:qe?r.errors:{}})},ke=(qe,Xe,$e)=>{const Ke=(bn(n,qe,{_f:{}})._f||{}).ref,ct=bn(r.errors,qe)||{},{ref:Ue,message:Ve,type:Je,...Rt}=ct;Ko(r.errors,qe,{...Rt,...Xe,ref:Ke}),v.state.next({name:qe,errors:r.errors,isValid:!1}),$e&&$e.shouldFocus&&Ke&&Ke.focus&&Ke.focus()},Ze=(qe,Xe)=>Cg(qe)?v.state.subscribe({next:$e=>"values"in $e&&qe(se(void 0,Xe),$e)}):se(qe,Xe,!0),_e=qe=>v.state.subscribe({next:Xe=>{_wt(qe.name,Xe.name,qe.exact)&&vwt(Xe,qe.formState||p,rt,qe.reRenderRoot)&&qe.callback({values:{...o},...r,...Xe,defaultValues:a})}}).unsubscribe,Ce=qe=>(l.mount=!0,f={...f,...qe.formState},_e({...qe,formState:f})),Te=(qe,Xe={})=>{for(const $e of qe?GP(qe):i.mount)i.mount.delete($e),i.array.delete($e),Xe.keepValue||(vd(n,$e),vd(o,$e)),!Xe.keepError&&vd(r.errors,$e),!Xe.keepDirty&&vd(r.dirtyFields,$e),!Xe.keepTouched&&vd(r.touchedFields,$e),!Xe.keepIsValidating&&vd(r.validatingFields,$e),!s.shouldUnregister&&!Xe.keepDefaultValue&&vd(a,$e);v.state.next({values:Od(o)}),v.state.next({...r,...Xe.keepDirty?{isDirty:X()}:{}}),!Xe.keepIsValid&&j()},Fe=({disabled:qe,name:Xe})=>{(rp(qe)&&l.mount||qe||i.disabled.has(Xe))&&(qe?i.disabled.add(Xe):i.disabled.delete(Xe))},Ae=(qe,Xe={})=>{let $e=bn(n,qe);const Ke=rp(Xe.disabled)||rp(s.disabled);return Ko(n,qe,{...$e||{},_f:{...$e&&$e._f?$e._f:{ref:{name:qe}},name:qe,mount:!0,...Xe}}),i.mount.add(qe),$e?Fe({disabled:rp(Xe.disabled)?Xe.disabled:s.disabled,name:qe}):I(qe,!0,Xe.value),{...Ke?{disabled:Xe.disabled||s.disabled}:{},...s.progressive?{required:!!Xe.required,min:JA(Xe.min),max:JA(Xe.max),minLength:JA(Xe.minLength),maxLength:JA(Xe.maxLength),pattern:JA(Xe.pattern)}:{},name:qe,onChange:ae,onBlur:ae,ref:ct=>{if(ct){Ae(qe,Xe),$e=bn(n,qe);const Ue=sd(ct.value)&&ct.querySelectorAll&&ct.querySelectorAll("input,select,textarea")[0]||ct,Ve=mwt(Ue),Je=$e._f.refs||[];if(Ve?Je.find(Rt=>Rt===Ue):Ue===$e._f.ref)return;Ko(n,qe,{_f:{...$e._f,...Ve?{refs:[...Je.filter(Fhe),Ue,...Array.isArray(bn(a,qe))?[{}]:[]],ref:{type:Ue.type,name:qe}}:{ref:Ue}}}),I(qe,!1,void 0,Ue)}else $e=bn(n,qe,{}),$e._f&&($e._f.mount=!1),(s.shouldUnregister||Xe.shouldUnregister)&&!(g$e(i.array,qe)&&l.action)&&i.unMount.add(qe)}}},We=()=>s.shouldFocusError&&KP(n,le,i.mount),ht=qe=>{rp(qe)&&(v.state.next({disabled:qe}),KP(n,(Xe,$e)=>{const Ke=bn(n,$e);Ke&&(Xe.disabled=Ke._f.disabled||qe,Array.isArray(Ke._f.refs)&&Ke._f.refs.forEach(ct=>{ct.disabled=Ke._f.disabled||qe}))},0,!1))},De=(qe,Xe)=>async $e=>{let Ke;$e&&($e.preventDefault&&$e.preventDefault(),$e.persist&&$e.persist());let ct=Od(o);if(v.state.next({isSubmitting:!0}),s.resolver){const{errors:Ue,values:Ve}=await $();r.errors=Ue,ct=Od(Ve)}else await U(n);if(i.disabled.size)for(const Ue of i.disabled)vd(ct,Ue);if(vd(r.errors,"root"),fm(r.errors)){v.state.next({errors:{}});try{await qe(ct,$e)}catch(Ue){Ke=Ue}}else Xe&&await Xe({...r.errors},$e),We(),setTimeout(We);if(v.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:fm(r.errors)&&!Ke,submitCount:r.submitCount+1,errors:r.errors}),Ke)throw Ke},Dt=(qe,Xe={})=>{bn(n,qe)&&(sd(Xe.defaultValue)?ie(qe,Od(bn(a,qe))):(ie(qe,Xe.defaultValue),Ko(a,qe,Od(Xe.defaultValue))),Xe.keepTouched||vd(r.touchedFields,qe),Xe.keepDirty||(vd(r.dirtyFields,qe),r.isDirty=Xe.defaultValue?X(qe,Od(bn(a,qe))):X()),Xe.keepError||(vd(r.errors,qe),p.isValid&&j()),v.state.next({...r}))},he=(qe,Xe={})=>{const $e=qe?Od(qe):a,Ke=Od($e),ct=fm(qe),Ue=ct?a:Ke;if(Xe.keepDefaultValues||(a=$e),!Xe.keepValues){if(Xe.keepDirtyValues){const Ve=new Set([...i.mount,...Object.keys(QA(a,o))]);for(const Je of Array.from(Ve))bn(r.dirtyFields,Je)?Ko(Ue,Je,bn(o,Je)):ie(Je,bn(Ue,Je))}else{if(u_e&&sd(qe))for(const Ve of i.mount){const Je=bn(n,Ve);if(Je&&Je._f){const Rt=Array.isArray(Je._f.refs)?Je._f.refs[0]:Je._f.ref;if(wne(Rt)){const $t=Rt.closest("form");if($t){$t.reset();break}}}}if(Xe.keepFieldsRef)for(const Ve of i.mount)ie(Ve,bn(Ue,Ve));else n={}}o=s.shouldUnregister?Xe.keepDefaultValues?Od(a):{}:Od(Ue),v.array.next({values:{...Ue}}),v.state.next({values:{...Ue}})}i={mount:Xe.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!p.isValid||!!Xe.keepIsValid||!!Xe.keepDirtyValues,l.watch=!!s.shouldUnregister,v.state.next({submitCount:Xe.keepSubmitCount?r.submitCount:0,isDirty:ct?!1:Xe.keepDirty?r.isDirty:!!(Xe.keepDefaultValues&&!p0(qe,a)),isSubmitted:Xe.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:ct?{}:Xe.keepDirtyValues?Xe.keepDefaultValues&&o?QA(a,o):r.dirtyFields:Xe.keepDefaultValues&&qe?QA(a,qe):Xe.keepDirty?r.dirtyFields:{},touchedFields:Xe.keepTouched?r.touchedFields:{},errors:Xe.keepErrors?r.errors:{},isSubmitSuccessful:Xe.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Qe=(qe,Xe)=>he(Cg(qe)?qe(o):qe,Xe),ot=(qe,Xe={})=>{const $e=bn(n,qe),Ke=$e&&$e._f;if(Ke){const ct=Ke.refs?Ke.refs[0]:Ke.ref;ct.focus&&(ct.focus(),Xe.shouldSelect&&Cg(ct.select)&&ct.select())}},rt=qe=>{r={...r,...qe}},it={control:{register:Ae,unregister:Te,getFieldState:ye,handleSubmit:De,setError:ke,_subscribe:_e,_runSchema:$,_focusError:We,_getWatch:se,_getDirty:X,_setValid:j,_setFieldArray:N,_setDisabledField:Fe,_setErrors:A,_getFieldArray:te,_reset:he,_resetDefaultValues:()=>Cg(s.defaultValues)&&s.defaultValues().then(qe=>{Qe(qe,s.resetOptions),v.state.next({isLoading:!1})}),_removeUnmounted:V,_disableForm:ht,_subjects:v,_proxyFormState:p,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state(qe){l=qe},get _defaultValues(){return a},get _names(){return i},set _names(qe){i=qe},get _formState(){return r},get _options(){return s},set _options(qe){s={...s,...qe}}},subscribe:Ce,trigger:pe,register:Ae,handleSubmit:De,watch:Ze,setValue:ie,getValues:be,reset:Qe,resetField:Dt,clearErrors:we,unregister:Te,setError:ke,setFocus:ot,getFieldState:ye};return{...it,formControl:it}}function Roe(t={}){const s=mt.useRef(void 0),r=mt.useRef(void 0),[n,a]=mt.useState({isDirty:!1,isValidating:!1,isLoading:Cg(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:Cg(t.defaultValues)?void 0:t.defaultValues});if(!s.current)if(t.formControl)s.current={...t.formControl,formState:n},t.defaultValues&&!Cg(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...i}=Nwt(t);s.current={...i,formState:n}}const o=s.current.control;return o._options=t,f_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]),mt.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),mt.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),mt.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),mt.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),mt.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==n.isDirty&&o._subjects.state.next({isDirty:l})}},[o,n.isDirty]),mt.useEffect(()=>{t.values&&!p0(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]),mt.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=x$e(n,o),s.current}const m3e=(t,s,r)=>{if(t&&"reportValidity"in t){const n=bn(r,s);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},S$e=(t,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?m3e(n.ref,r,t):n.refs&&n.refs.forEach(a=>m3e(a,r,t))}},Swt=(t,s)=>{s.shouldUseNativeValidation&&S$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(Cwt(s.names||Object.keys(t),n)){const l=Object.assign({},bn(r,n));Ko(l,"root",o),Ko(r,n,l)}else Ko(r,n,o)}return r},Cwt=(t,s)=>t.some(r=>r.startsWith(s+"."));var Mwt=function(t,s){for(var r={};t.length;){var n=t[0],a=n.code,o=n.message,l=n.path.join(".");if(!r[l])if("unionErrors"in n){var i=n.unionErrors[0].errors[0];r[l]={message:i.message,type:i.code}}else r[l]={message:o,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(p){return p.errors.forEach(function(f){return t.push(f)})}),s){var d=r[l].types,u=d&&d[n.code];r[l]=v$e(l,s,r,a,u?[].concat(u,n.message):n.message)}t.shift()}return r},Foe=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&&S$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:Swt(Mwt(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const zoe=lwt,C$e=S.createContext({}),bc=({...t})=>e.jsx(C$e.Provider,{value:{name:t.name},children:e.jsx(hwt,{...t})}),Boe=()=>{const t=S.useContext(C$e),s=S.useContext(M$e),{getFieldState:r,formState:n}=Ooe(),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}},M$e=S.createContext({}),dc=S.forwardRef(({className:t,...s},r)=>{const n=S.useId();return e.jsx(M$e.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:Pt("space-y-2",t),...s})})});dc.displayName="FormItem";const uc=S.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=Boe();return e.jsx(ve,{ref:r,className:Pt(n&&"text-destructive",t),htmlFor:a,...s})});uc.displayName="FormLabel";const hc=S.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=Boe();return e.jsx(Wve,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});hc.displayName="FormControl";const nre=S.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=Boe();return e.jsx("p",{ref:r,id:n,className:Pt("text-sm text-muted-foreground",t),...s})});nre.displayName="FormDescription";const Eh=S.forwardRef(({className:t,children:s,...r},n)=>{const{error:a,formMessageId:o}=Boe(),l=a?String(a==null?void 0:a.message):s;return l?e.jsx("p",{ref:n,id:o,className:Pt("text-sm font-medium text-destructive",t),...r,children:l}):null});Eh.displayName="FormMessage";const Twt=sS({category:q9e(["general","technology","crm","marketing"]),subject:Jl().min(5,"Subject must be at least 5 characters").max(200),description:Jl().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),Awt={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function qge({trigger:t}){const[s,r]=S.useState(!1),[n,a]=S.useState(!1),{user:o}=Gs(),l=Roe({resolver:Foe(Twt),defaultValues:{category:"general",subject:"",description:""}}),i=async d=>{if(!o){fe.error("You must be logged in to submit a ticket");return}a(!0);try{const{error:u}=await G.from("support_tickets").insert({user_id:o.id,category:d.category,subject:d.subject,description:d.description});if(u)throw u;try{await G.functions.invoke("support-ticket-notify",{body:{category:Awt[d.category],subject:d.subject}})}catch(p){console.log("Notification send attempted:",p)}fe.success("Support ticket submitted successfully!"),l.reset(),r(!1)}catch(u){console.error("Error submitting ticket:",u),fe.error("Failed to submit ticket. Please try again.")}finally{a(!1)}};return e.jsxs(vs,{open:s,onOpenChange:r,children:[e.jsx(Ei,{asChild:!0,children:t||e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(pP,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:"Support"})]})}),e.jsxs(ys,{className:"sm:max-w-[500px]",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(Zn,{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(zoe,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(bc,{control:l.control,name:"category",render:({field:d})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Category"}),e.jsxs(tr,{onValueChange:d.onChange,defaultValue:d.value,children:[e.jsx(hc,{children:e.jsx(Js,{children:e.jsx(sr,{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(Eh,{})]})}),e.jsx(bc,{control:l.control,name:"subject",render:({field:d})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Subject"}),e.jsx(hc,{children:e.jsx(Re,{placeholder:"Brief description of your issue",...d})}),e.jsx(Eh,{})]})}),e.jsx(bc,{control:l.control,name:"description",render:({field:d})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Description"}),e.jsx(hc,{children:e.jsx(Mr,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...d})}),e.jsx(Eh,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:n,children:n?"Submitting...":"Submit Ticket"})]})]})})]})]})}const Ewt=()=>{const{user:t}=Gs(),s=Dr(),[r,n]=S.useState([]),[a,o]=S.useState(0),[l,i]=S.useState(!1),[d,u]=S.useState(null);S.useEffect(()=>{if(!t)return;const b=`notification_last_read_${t.id}`;let j=d;if(!j){const C=localStorage.getItem(b);C&&(j=C,u(C))}(async()=>{const{data:C,error:A}=await G.from("push_notifications").select("*").order("created_at",{ascending:!1}).limit(20);if(!A&&C){n(C);const I=j?new Date(j):null,L=C.filter(R=>I?new Date(R.created_at)>I:!0);o(L.length)}})();const N=G.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},C=>{const A=C.new;n(L=>[A,...L].slice(0,20));const I=j?new Date(j):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()=>{G.removeChannel(N)}},[t,d]);const p=b=>{const j=b.toLowerCase();return j.includes("community")||j.includes("post")?oo:j.includes("academy")||j.includes("video")?kn:j.includes("template")?Bl:j.includes("event")?on:j.includes("newsletter")?I0:j.includes("brokerage")?th:j.includes("swag")||j.includes("social")?io:j.includes("toolbox")||j.includes("tool")?$g:j.includes("brief")?hn:oo},f=b=>{i(!1),b.url&&b.url!=="/"&&s(b.url)},v=()=>{if(!t)return;const b=new Date().toISOString(),j=`notification_last_read_${t.id}`;localStorage.setItem(j,b),u(b),o(0)},_=b=>{i(b),b&&a>0&&v()};return e.jsxs(Kd,{open:l,onOpenChange:_,children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(cf,{className:"h-5 w-5"}),a>0&&e.jsx(at,{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(Td,{align:"end",className:"w-80",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b",children:[e.jsx("span",{className:"font-semibold",children:"Notifications"}),r.length>0&&e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:v,children:"Mark all read"})]}),e.jsx(Bi,{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 j=p(b.title);return e.jsxs(Ta,{className:"group flex items-start gap-3 p-3 cursor-pointer data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",onClick:()=>f(b),children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx(j,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-sm",children: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:Cd(new Date(b.created_at),{addSuffix:!0})})]})]},b.id)})})]})]})};var p3e=1,Pwt=.9,Iwt=.8,Lwt=.17,zhe=.1,Bhe=.999,Dwt=.9999,Owt=.99,Rwt=/[\\\/_+.#"@\[\(\{&]/,Fwt=/[\\\/_+.#"@\[\(\{&]/g,zwt=/[\s-]/,T$e=/[\s-]/g;function Uge(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?p3e:Owt;var i=`${a},${o}`;if(l[i]!==void 0)return l[i];for(var d=n.charAt(o),u=r.indexOf(d,a),p=0,f,v,_,b;u>=0;)f=Uge(t,s,r,n,u+1,o+1,l),f>p&&(u===a?f*=p3e:Rwt.test(t.charAt(u-1))?(f*=Iwt,_=t.slice(a,u-1).match(Fwt),_&&a>0&&(f*=Math.pow(Bhe,_.length))):zwt.test(t.charAt(u-1))?(f*=Pwt,b=t.slice(a,u-1).match(T$e),b&&a>0&&(f*=Math.pow(Bhe,b.length))):(f*=Lwt,a>0&&(f*=Math.pow(Bhe,u-a))),t.charAt(u)!==s.charAt(o)&&(f*=Dwt)),(ff&&(f=v*zhe)),f>p&&(p=f),u=r.indexOf(d,u+1);return l[i]=p,p}function f3e(t){return t.toLowerCase().replace(T$e," ")}function Bwt(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,Uge(t,s,f3e(t),f3e(s),0,0,{})}var eE='[cmdk-group=""]',$he='[cmdk-group-items=""]',$wt='[cmdk-group-heading=""]',A$e='[cmdk-item=""]',g3e=`${A$e}:not([aria-disabled="true"])`,Vge="cmdk-item-select",y4="data-value",qwt=(t,s,r)=>Bwt(t,s,r),E$e=S.createContext(void 0),ML=()=>S.useContext(E$e),P$e=S.createContext(void 0),y_e=()=>S.useContext(P$e),I$e=S.createContext(void 0),L$e=S.forwardRef((t,s)=>{let r=v4(()=>{var we,ke;return{search:"",value:(ke=(we=t.value)!=null?we:t.defaultValue)!=null?ke:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=v4(()=>new Set),a=v4(()=>new Map),o=v4(()=>new Map),l=v4(()=>new Set),i=D$e(t),{label:d,children:u,value:p,onValueChange:f,filter:v,shouldFilter:_,loop:b,disablePointerSelection:j=!1,vimBindings:w=!0,...N}=t,C=Gd(),A=Gd(),I=Gd(),L=S.useRef(null),R=Jwt();DN(()=>{if(p!==void 0){let we=p.trim();r.current.value=we,$.emit()}},[p]),DN(()=>{R(6,te)},[]);let $=S.useMemo(()=>({subscribe:we=>(l.current.add(we),()=>l.current.delete(we)),snapshot:()=>r.current,setState:(we,ke,Ze)=>{var _e,Ce,Te,Fe;if(!Object.is(r.current[we],ke)){if(r.current[we]=ke,we==="search")se(),V(),R(1,X);else if(we==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Ae=document.getElementById(I);Ae?Ae.focus():(_e=document.getElementById(C))==null||_e.focus()}if(R(7,()=>{var Ae;r.current.selectedItemId=(Ae=Y())==null?void 0:Ae.id,$.emit()}),Ze||R(5,te),((Ce=i.current)==null?void 0:Ce.value)!==void 0){let Ae=ke??"";(Fe=(Te=i.current).onValueChange)==null||Fe.call(Te,Ae);return}}$.emit()}},emit:()=>{l.current.forEach(we=>we())}}),[]),q=S.useMemo(()=>({value:(we,ke,Ze)=>{var _e;ke!==((_e=o.current.get(we))==null?void 0:_e.value)&&(o.current.set(we,{value:ke,keywords:Ze}),r.current.filtered.items.set(we,U(ke,Ze)),R(2,()=>{V(),$.emit()}))},item:(we,ke)=>(n.current.add(we),ke&&(a.current.has(ke)?a.current.get(ke).add(we):a.current.set(ke,new Set([we]))),R(3,()=>{se(),V(),r.current.value||X(),$.emit()}),()=>{o.current.delete(we),n.current.delete(we),r.current.filtered.items.delete(we);let Ze=Y();R(4,()=>{se(),(Ze==null?void 0:Ze.getAttribute("id"))===we&&X(),$.emit()})}),group:we=>(a.current.has(we)||a.current.set(we,new Set),()=>{o.current.delete(we),a.current.delete(we)}),filter:()=>i.current.shouldFilter,label:d||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:C,inputId:I,labelId:A,listInnerRef:L}),[]);function U(we,ke){var Ze,_e;let Ce=(_e=(Ze=i.current)==null?void 0:Ze.filter)!=null?_e:qwt;return we?Ce(we,r.current.search,ke):0}function V(){if(!r.current.search||i.current.shouldFilter===!1)return;let we=r.current.filtered.items,ke=[];r.current.filtered.groups.forEach(_e=>{let Ce=a.current.get(_e),Te=0;Ce.forEach(Fe=>{let Ae=we.get(Fe);Te=Math.max(Ae,Te)}),ke.push([_e,Te])});let Ze=L.current;de().sort((_e,Ce)=>{var Te,Fe;let Ae=_e.getAttribute("id"),We=Ce.getAttribute("id");return((Te=we.get(We))!=null?Te:0)-((Fe=we.get(Ae))!=null?Fe:0)}).forEach(_e=>{let Ce=_e.closest($he);Ce?Ce.appendChild(_e.parentElement===Ce?_e:_e.closest(`${$he} > *`)):Ze.appendChild(_e.parentElement===Ze?_e:_e.closest(`${$he} > *`))}),ke.sort((_e,Ce)=>Ce[1]-_e[1]).forEach(_e=>{var Ce;let Te=(Ce=L.current)==null?void 0:Ce.querySelector(`${eE}[${y4}="${encodeURIComponent(_e[0])}"]`);Te==null||Te.parentElement.appendChild(Te)})}function X(){let we=de().find(Ze=>Ze.getAttribute("aria-disabled")!=="true"),ke=we==null?void 0:we.getAttribute(y4);$.setState("value",ke||void 0)}function se(){var we,ke,Ze,_e;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let Ce=0;for(let Te of n.current){let Fe=(ke=(we=o.current.get(Te))==null?void 0:we.value)!=null?ke:"",Ae=(_e=(Ze=o.current.get(Te))==null?void 0:Ze.keywords)!=null?_e:[],We=U(Fe,Ae);r.current.filtered.items.set(Te,We),We>0&&Ce++}for(let[Te,Fe]of a.current)for(let Ae of Fe)if(r.current.filtered.items.get(Ae)>0){r.current.filtered.groups.add(Te);break}r.current.filtered.count=Ce}function te(){var we,ke,Ze;let _e=Y();_e&&(((we=_e.parentElement)==null?void 0:we.firstChild)===_e&&((Ze=(ke=_e.closest(eE))==null?void 0:ke.querySelector($wt))==null||Ze.scrollIntoView({block:"nearest"})),_e.scrollIntoView({block:"nearest"}))}function Y(){var we;return(we=L.current)==null?void 0:we.querySelector(`${A$e}[aria-selected="true"]`)}function de(){var we;return Array.from(((we=L.current)==null?void 0:we.querySelectorAll(g3e))||[])}function ie(we){let ke=de()[we];ke&&$.setState("value",ke.getAttribute(y4))}function ae(we){var ke;let Ze=Y(),_e=de(),Ce=_e.findIndex(Fe=>Fe===Ze),Te=_e[Ce+we];(ke=i.current)!=null&&ke.loop&&(Te=Ce+we<0?_e[_e.length-1]:Ce+we===_e.length?_e[0]:_e[Ce+we]),Te&&$.setState("value",Te.getAttribute(y4))}function le(we){let ke=Y(),Ze=ke==null?void 0:ke.closest(eE),_e;for(;Ze&&!_e;)Ze=we>0?Xwt(Ze,eE):Qwt(Ze,eE),_e=Ze==null?void 0:Ze.querySelector(g3e);_e?$.setState("value",_e.getAttribute(y4)):ae(we)}let pe=()=>ie(de().length-1),be=we=>{we.preventDefault(),we.metaKey?pe():we.altKey?le(1):ae(1)},ye=we=>{we.preventDefault(),we.metaKey?ie(0):we.altKey?le(-1):ae(-1)};return S.createElement(Qr.div,{ref:s,tabIndex:-1,...N,"cmdk-root":"",onKeyDown:we=>{var ke;(ke=N.onKeyDown)==null||ke.call(N,we);let Ze=we.nativeEvent.isComposing||we.keyCode===229;if(!(we.defaultPrevented||Ze))switch(we.key){case"n":case"j":{w&&we.ctrlKey&&be(we);break}case"ArrowDown":{be(we);break}case"p":case"k":{w&&we.ctrlKey&&ye(we);break}case"ArrowUp":{ye(we);break}case"Home":{we.preventDefault(),ie(0);break}case"End":{we.preventDefault(),pe();break}case"Enter":{we.preventDefault();let _e=Y();if(_e){let Ce=new Event(Vge);_e.dispatchEvent(Ce)}}}}},S.createElement("label",{"cmdk-label":"",htmlFor:q.inputId,id:q.labelId,style:t2t},d),$oe(t,we=>S.createElement(P$e.Provider,{value:$},S.createElement(E$e.Provider,{value:q},we))))}),Uwt=S.forwardRef((t,s)=>{var r,n;let a=Gd(),o=S.useRef(null),l=S.useContext(I$e),i=ML(),d=D$e(t),u=(n=(r=d.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;DN(()=>{if(!u)return i.item(a,l==null?void 0:l.id)},[u]);let p=O$e(a,o,[t.value,t.children,o],t.keywords),f=y_e(),v=A_(R=>R.value&&R.value===p.current),_=A_(R=>u||i.filter()===!1?!0:R.search?R.filtered.items.get(a)>0:!0);S.useEffect(()=>{let R=o.current;if(!(!R||t.disabled))return R.addEventListener(Vge,b),()=>R.removeEventListener(Vge,b)},[_,t.onSelect,t.disabled]);function b(){var R,$;j(),($=(R=d.current).onSelect)==null||$.call(R,p.current)}function j(){f.setState("value",p.current,!0)}if(!_)return null;let{disabled:w,value:N,onSelect:C,forceMount:A,keywords:I,...L}=t;return S.createElement(Qr.div,{ref:G0(o,s),...L,id:a,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!v,"data-disabled":!!w,"data-selected":!!v,onPointerMove:w||i.getDisablePointerSelection()?void 0:j,onClick:w?void 0:b},t.children)}),Vwt=S.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=Gd(),i=S.useRef(null),d=S.useRef(null),u=Gd(),p=ML(),f=A_(_=>a||p.filter()===!1?!0:_.search?_.filtered.groups.has(l):!0);DN(()=>p.group(l),[]),O$e(l,i,[t.value,t.heading,d]);let v=S.useMemo(()=>({id:l,forceMount:a}),[a]);return S.createElement(Qr.div,{ref:G0(i,s),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},r&&S.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),$oe(t,_=>S.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},S.createElement(I$e.Provider,{value:v},_))))}),Hwt=S.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=S.useRef(null),o=A_(l=>!l.search);return!r&&!o?null:S.createElement(Qr.div,{ref:G0(a,s),...n,"cmdk-separator":"",role:"separator"})}),Wwt=S.forwardRef((t,s)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=y_e(),l=A_(u=>u.search),i=A_(u=>u.selectedItemId),d=ML();return S.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),S.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)}})}),Gwt=S.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=S.useRef(null),l=S.useRef(null),i=A_(u=>u.selectedItemId),d=ML();return S.useEffect(()=>{if(l.current&&o.current){let u=l.current,p=o.current,f,v=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let _=u.offsetHeight;p.style.setProperty("--cmdk-list-height",_.toFixed(1)+"px")})});return v.observe(u),()=>{cancelAnimationFrame(f),v.unobserve(u)}}},[]),S.createElement(Qr.div,{ref:G0(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:d.listId},$oe(t,u=>S.createElement("div",{ref:G0(l,d.listInnerRef),"cmdk-list-sizer":""},u)))}),Kwt=S.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return S.createElement(xoe,{open:r,onOpenChange:n},S.createElement(yoe,{container:l},S.createElement(mM,{"cmdk-overlay":"",className:a}),S.createElement(pM,{"aria-label":t.label,"cmdk-dialog":"",className:o},S.createElement(L$e,{ref:s,...i}))))}),Zwt=S.forwardRef((t,s)=>A_(r=>r.filtered.count===0)?S.createElement(Qr.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),Ywt=S.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return S.createElement(Qr.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},$oe(t,l=>S.createElement("div",{"aria-hidden":!0},l)))}),Fm=Object.assign(L$e,{List:Gwt,Item:Uwt,Input:Wwt,Group:Vwt,Separator:Hwt,Dialog:Kwt,Empty:Zwt,Loading:Ywt});function Xwt(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function Qwt(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function D$e(t){let s=S.useRef(t);return DN(()=>{s.current=t}),s}var DN=typeof window>"u"?S.useEffect:S.useLayoutEffect;function v4(t){let s=S.useRef();return s.current===void 0&&(s.current=t()),s}function A_(t){let s=y_e(),r=()=>t(s.snapshot());return S.useSyncExternalStore(s.subscribe,r,r)}function O$e(t,s,r,n=[]){let a=S.useRef(),o=ML();return DN(()=>{var l;let i=(()=>{var u;for(let p of r){if(typeof p=="string")return p.trim();if(typeof p=="object"&&"current"in p)return p.current?(u=p.current.textContent)==null?void 0:u.trim():a.current}})(),d=n.map(u=>u.trim());o.value(t,i,d),(l=s.current)==null||l.setAttribute(y4,i),a.current=i}),a}var Jwt=()=>{let[t,s]=S.useState(),r=v4(()=>new Map);return DN(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),s({})}};function e2t(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function $oe({asChild:t,children:s},r){return t&&S.isValidElement(s)?S.cloneElement(e2t(s),{ref:s.ref},r(s.props.children)):r(s)}var t2t={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const wf=S.forwardRef(({className:t,...s},r)=>e.jsx(Fm,{ref:r,className:Pt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));wf.displayName=Fm.displayName;const s2t=({children:t,...s})=>e.jsx(vs,{...s,children:e.jsx(ys,{className:"overflow-hidden p-0 shadow-lg",children:e.jsx(wf,{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})})}),jf=S.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(fn,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Fm.Input,{ref:r,className:Pt("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));jf.displayName=Fm.Input.displayName;const kf=S.forwardRef(({className:t,...s},r)=>e.jsx(Fm.List,{ref:r,className:Pt("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));kf.displayName=Fm.List.displayName;const Nf=S.forwardRef((t,s)=>e.jsx(Fm.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Nf.displayName=Fm.Empty.displayName;const Sf=S.forwardRef(({className:t,...s},r)=>e.jsx(Fm.Group,{ref:r,className:Pt("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));Sf.displayName=Fm.Group.displayName;const r2t=S.forwardRef(({className:t,...s},r)=>e.jsx(Fm.Separator,{ref:r,className:Pt("-mx-1 h-px bg-border",t),...s}));r2t.displayName=Fm.Separator.displayName;const Nm=S.forwardRef(({className:t,...s},r)=>e.jsx(Fm.Item,{ref:r,className:Pt("group relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-primary/80 data-[selected=true]:text-primary-foreground data-[disabled=true]:opacity-50",t),...s}));Nm.displayName=Fm.Item.displayName;const n2t={event:{label:"Events",icon:ld,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:Bl,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:sh,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:$g,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:hn,color:"bg-fuchsia-500/10 text-fuchsia-600"}},x3e=()=>{const[t,s]=S.useState(!1),[r,n]=S.useState(""),[a,o]=S.useState([]),[l,i]=S.useState(!1),d=Dr();S.useEffect(()=>{const v=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),s(b=>!b))};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[]);const u=S.useCallback(async v=>{if(!v.trim()){o([]);return}i(!0);const _=`%${v}%`;try{const[b,j,w,N,C]=await Promise.all([G.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),G.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${_},description.ilike.${_}`).limit(5),G.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),G.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${_},description.ilike.${_}`).limit(5),G.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}`})}),j.data&&j.data.forEach(I=>{A.push({id:I.id,title:I.name,description:I.description,type:"template",date:I.publish_date,path:`/templates/${I.id}`})}),w.data&&w.data.forEach(I=>{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}`})}),C.data&&C.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)}},[]);S.useEffect(()=>{const v=setTimeout(()=>{u(r)},300);return()=>clearTimeout(v)},[r,u]);const p=v=>{s(!1),n(""),d(v)},f=a.reduce((v,_)=>(v[_.type]||(v[_.type]=[]),v[_.type].push(_),v),{});return e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-9 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>s(!0),children:[e.jsx(fn,{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(s2t,{open:t,onOpenChange:s,children:[e.jsx(jf,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:r,onValueChange:n}),e.jsxs(kf,{children:[l&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&r&&a.length===0&&e.jsxs(Nf,{children:['No results found for "',r,'"']}),!l&&!r&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Start typing to search across all content..."}),Object.entries(f).map(([v,_])=>{const b=n2t[v],j=b.icon;return e.jsx(Sf,{heading:b.label,children:_.map(w=>e.jsxs(Nm,{value:`${w.type}-${w.id}-${w.title}`,onSelect:()=>p(w.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[e.jsx("div",{className:`p-2 rounded-md ${b.color}`,children:e.jsx(j,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:w.title}),w.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:w.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(at,{variant:"secondary",className:"text-xs",children:b.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Cd(new Date(w.date),{addSuffix:!0})})]})]},`${w.type}-${w.id}`))},v)})]})]})]})},a2t=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=S.useState(null),o=Dr();if(S.useEffect(()=>{const u=()=>{const f=new Date().getTime(),_=new Date(t).getTime()-f;if(_<=0){a({days:0,hours:0,minutes:0});return}const b=Math.floor(_/(1e3*60*60*24)),j=Math.floor(_%(1e3*60*60*24)/(1e3*60*60)),w=Math.floor(_%(1e3*60*60)/(1e3*60));a({days:b,hours:j,minutes:w})};u();const p=setInterval(u,6e4);return()=>clearInterval(p)},[t]),!n)return null;const l=n.days===0&&n.hours===0&&n.minutes===0,i=n.days<=1,d=n.days<=3&&!i;return l?e.jsxs("div",{className:Pt("flex items-center justify-between gap-3 px-4 py-2 rounded-lg bg-destructive/10 border border-destructive/20",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Th,{className:"h-4 w-4 text-destructive"}),e.jsx("span",{className:"text-sm font-medium text-destructive",children:"Your free trial has expired"})]}),r&&e.jsxs(K,{size:"sm",onClick:()=>o("/subscription"),className:"bg-primary hover:bg-primary/90 text-xs h-7 px-3",children:[e.jsx(hn,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):e.jsxs("div",{className:Pt("flex items-center justify-between gap-3 px-4 py-2 rounded-lg border transition-colors",i?"bg-destructive/10 border-destructive/20":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:Pt("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:Pt("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:Pt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.days,"d"]}),e.jsxs("span",{className:Pt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),e.jsxs("span",{className:Pt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),e.jsx("span",{className:Pt("text-xs",i?"text-destructive/70":d?"text-amber-600/70":"text-primary/70"),children:"remaining"})]})]})]}),r&&e.jsxs(K,{size:"sm",onClick:()=>o("/subscription"),variant:i?"destructive":d?"default":"outline",className:Pt("text-xs h-7 px-3",d&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[e.jsx(hn,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},i2t=()=>{const t=Dr();return e.jsx("div",{className:"fixed inset-0 bg-background/95 backdrop-blur-sm z-50 flex items-center justify-center p-4 overflow-y-auto",children:e.jsxs(Ee,{className:"w-full max-w-2xl shadow-2xl border-destructive/20 my-8",children:[e.jsxs(Lt,{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(Th,{className:"h-8 w-8 text-destructive"})}),e.jsx(zt,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(yr,{className:"text-base",children:"Your 7-day free trial has expired. Upgrade now to continue accessing all the powerful tools and resources LevelUp has to offer!"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(Ee,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Oe,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(hr,{className:"h-6 w-6 text-primary"})}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Individual Agent"}),e.jsxs("p",{className:"text-2xl font-bold text-primary mb-2",children:["$39",e.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Perfect for solo agents ready to level up"}),e.jsxs(K,{className:"w-full",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Choose Individual"]})]})}),e.jsx(Ee,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Oe,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(Aa,{className:"h-6 w-6 text-amber-600"})}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Brokerage"}),e.jsxs("p",{className:"text-2xl font-bold text-amber-600 mb-2",children:["$299",e.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"For teams and brokerages"}),e.jsxs(K,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(Aa,{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(Zn,{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(_r,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},o2t=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",onClick:s,className:Pt("relative transition-colors",t&&"text-primary hover:text-primary",r),children:[e.jsx(zg,{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(Wc,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var qoe="Checkbox",[l2t]=Ac(qoe),[c2t,v_e]=l2t(qoe);function d2t(t){const{__scopeCheckbox:s,checked:r,children:n,defaultChecked:a,disabled:o,form:l,name:i,onCheckedChange:d,required:u,value:p="on",internal_do_not_use_render:f}=t,[v,_]=xu({prop:r,defaultProp:a??!1,onChange:d,caller:qoe}),[b,j]=S.useState(null),[w,N]=S.useState(null),C=S.useRef(!1),A=b?!!l||!!b.closest("form"):!0,I={checked:v,disabled:o,setChecked:_,control:b,setControl:j,name:i,form:l,value:p,hasConsumerStoppedPropagationRef:C,required:u,defaultChecked:m_(a)?!1:a,isFormControl:A,bubbleInput:w,setBubbleInput:N};return e.jsx(c2t,{scope:s,...I,children:u2t(f)?f(I):n})}var R$e="CheckboxTrigger",F$e=S.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...n},a)=>{const{control:o,value:l,disabled:i,checked:d,required:u,setControl:p,setChecked:f,hasConsumerStoppedPropagationRef:v,isFormControl:_,bubbleInput:b}=v_e(R$e,t),j=Pa(a,p),w=S.useRef(d);return S.useEffect(()=>{const N=o==null?void 0:o.form;if(N){const C=()=>f(w.current);return N.addEventListener("reset",C),()=>N.removeEventListener("reset",C)}},[o,f]),e.jsx(Qr.button,{type:"button",role:"checkbox","aria-checked":m_(d)?"mixed":d,"aria-required":u,"data-state":U$e(d),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:j,onKeyDown:Cr(s,N=>{N.key==="Enter"&&N.preventDefault()}),onClick:Cr(r,N=>{f(C=>m_(C)?!0:!C),b&&_&&(v.current=N.isPropagationStopped(),v.current||N.stopPropagation())})})});F$e.displayName=R$e;var __e=S.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d,onCheckedChange:u,form:p,...f}=t;return e.jsx(d2t,{__scopeCheckbox:r,checked:a,defaultChecked:o,disabled:i,required:l,onCheckedChange:u,name:n,form:p,value:d,internal_do_not_use_render:({isFormControl:v})=>e.jsxs(e.Fragment,{children:[e.jsx(F$e,{...f,ref:s,__scopeCheckbox:r}),v&&e.jsx(q$e,{__scopeCheckbox:r})]})})});__e.displayName=qoe;var z$e="CheckboxIndicator",B$e=S.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=v_e(z$e,r);return e.jsx(hd,{present:n||m_(o.checked)||o.checked===!0,children:e.jsx(Qr.span,{"data-state":U$e(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});B$e.displayName=z$e;var $$e="CheckboxBubbleInput",q$e=S.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:i,disabled:d,name:u,value:p,form:f,bubbleInput:v,setBubbleInput:_}=v_e($$e,t),b=Pa(r,_),j=NL(o),w=hL(n);S.useEffect(()=>{const C=v;if(!C)return;const A=window.HTMLInputElement.prototype,L=Object.getOwnPropertyDescriptor(A,"checked").set,R=!a.current;if(j!==o&&L){const $=new Event("click",{bubbles:R});C.indeterminate=m_(o),L.call(C,m_(o)?!1:o),C.dispatchEvent($)}},[v,j,o,a]);const N=S.useRef(m_(o)?!1:o);return e.jsx(Qr.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??N.current,required:i,disabled:d,name:u,value:p,form:f,...s,tabIndex:-1,ref:b,style:{...s.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});q$e.displayName=$$e;function u2t(t){return typeof t=="function"}function m_(t){return t==="indeterminate"}function U$e(t){return m_(t)?"indeterminate":t?"checked":"unchecked"}const zo=S.forwardRef(({className:t,...s},r)=>e.jsx(__e,{ref:r,className:Pt("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(B$e,{className:Pt("flex items-center justify-center text-current"),children:e.jsx(ua,{className:"h-4 w-4"})})}));zo.displayName=__e.displayName;var b_e="Radio",[h2t,V$e]=Ac(b_e),[m2t,p2t]=h2t(b_e),H$e=S.forwardRef((t,s)=>{const{__scopeRadio:r,name:n,checked:a=!1,required:o,disabled:l,value:i="on",onCheck:d,form:u,...p}=t,[f,v]=S.useState(null),_=Pa(s,w=>v(w)),b=S.useRef(!1),j=f?u||!!f.closest("form"):!0;return e.jsxs(m2t,{scope:r,checked:a,disabled:l,children:[e.jsx(Qr.button,{type:"button",role:"radio","aria-checked":a,"data-state":Z$e(a),"data-disabled":l?"":void 0,disabled:l,value:i,...p,ref:_,onClick:Cr(t.onClick,w=>{a||d==null||d(),j&&(b.current=w.isPropagationStopped(),b.current||w.stopPropagation())})}),j&&e.jsx(K$e,{control:f,bubbles:!b.current,name:n,value:i,checked:a,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});H$e.displayName=b_e;var W$e="RadioIndicator",G$e=S.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=p2t(W$e,r);return e.jsx(hd,{present:n||o.checked,children:e.jsx(Qr.span,{"data-state":Z$e(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})})});G$e.displayName=W$e;var f2t="RadioBubbleInput",K$e=S.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=S.useRef(null),i=Pa(l,o),d=NL(r),u=hL(s);return S.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&_){const b=new Event("click",{bubbles:n});_.call(p,r),p.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}})});K$e.displayName=f2t;function Z$e(t){return t?"checked":"unchecked"}var g2t=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Uoe="RadioGroup",[x2t]=Ac(Uoe,[q_,V$e]),Y$e=q_(),X$e=V$e(),[y2t,v2t]=x2t(Uoe),Q$e=S.forwardRef((t,s)=>{const{__scopeRadioGroup:r,name:n,defaultValue:a,value:o,required:l=!1,disabled:i=!1,orientation:d,dir:u,loop:p=!0,onValueChange:f,...v}=t,_=Y$e(r),b=$_(u),[j,w]=xu({prop:o,defaultProp:a??null,onChange:f,caller:Uoe});return e.jsx(y2t,{scope:r,name:n,required:l,disabled:i,value:j,onValueChange:w,children:e.jsx(coe,{asChild:!0,..._,orientation:d,dir:b,loop:p,children:e.jsx(Qr.div,{role:"radiogroup","aria-required":l,"aria-orientation":d,"data-disabled":i?"":void 0,dir:b,...v,ref:s})})})});Q$e.displayName=Uoe;var J$e="RadioGroupItem",eqe=S.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=v2t(J$e,r),l=o.disabled||n,i=Y$e(r),d=X$e(r),u=S.useRef(null),p=Pa(s,u),f=o.value===a.value,v=S.useRef(!1);return S.useEffect(()=>{const _=j=>{g2t.includes(j.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(doe,{asChild:!0,...i,focusable:!l,active:f,children:e.jsx(H$e,{disabled:l,required:o.required,checked:f,...d,...a,name:o.name,ref:p,onCheck:()=>o.onValueChange(a.value),onKeyDown:Cr(_=>{_.key==="Enter"&&_.preventDefault()}),onFocus:Cr(a.onFocus,()=>{var _;v.current&&((_=u.current)==null||_.click())})})})});eqe.displayName=J$e;var _2t="RadioGroupIndicator",tqe=S.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=X$e(r);return e.jsx(G$e,{...a,...n,ref:s})});tqe.displayName=_2t;var sqe=Q$e,rqe=eqe,b2t=tqe;const w_e=S.forwardRef(({className:t,...s},r)=>e.jsx(sqe,{className:Pt("grid gap-2",t),...s,ref:r}));w_e.displayName=sqe.displayName;const Nne=S.forwardRef(({className:t,...s},r)=>e.jsx(rqe,{ref:r,className:Pt("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(b2t,{className:"flex items-center justify-center",children:e.jsx(Gc,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Nne.displayName=rqe.displayName;const w2t=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=Gs(),[o,l]=S.useState({}),[i,d]=S.useState({}),[u,p]=S.useState([]);S.useEffect(()=>{s&&a&&t.polls.length>0&&f()},[s,a,t.polls]);const f=async()=>{if(!a)return;const w=t.polls.map(C=>C.id),{data:N}=await G.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",w);if(N){const C={};N.forEach(A=>{C[A.poll_id]||(C[A.poll_id]=[]),C[A.poll_id].push(A.option_id)}),d(C)}},v=(w,N)=>{l(C=>({...C,[w]:N}))},_=(w,N,C)=>{l(A=>{const I=A[w]||[];return C?{...A,[w]:[...I,N]}:{...A,[w]:I.filter(L=>L!==N)}})},b=async w=>{if(!a)return;const N=o[w];if(!N||Array.isArray(N)&&N.length===0){fe.error("Please select an option");return}p(C=>[...C,w]);try{await G.from("levelup_brief_poll_responses").delete().eq("poll_id",w).eq("user_id",a.id);const C=Array.isArray(N)?N:[N],A=C.map(L=>({poll_id:w,option_id:L,user_id:a.id})),{error:I}=await G.from("levelup_brief_poll_responses").insert(A);if(I)throw I;d(L=>({...L,[w]:C})),fe.success("Response submitted!")}catch(C){console.error("Error submitting poll response:",C),fe.error("Failed to submit response")}finally{p(C=>C.filter(A=>A!==w))}},j=w=>(w.includes("mediadelivery.net")||w.includes("bunny"),w);return e.jsx(vs,{open:s,onOpenChange:w=>!w&&r(),children:e.jsxs(ys,{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(Ur,{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(zg,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx(at,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),e.jsx(Ns,{className:"text-xl font-bold text-white",children:t.brief.title})]})]})]}),e.jsx(Bi,{className:"max-h-[calc(90vh-240px)]",children:e.jsxs("div",{className:"p-6 space-y-6",children:[t.brief.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.brief.description}}),t.brief.video_url&&e.jsx("div",{className:"relative w-full aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:j(t.brief.video_url),className:"absolute inset-0 w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})}),t.brief.graphic_url&&!t.brief.video_url&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted",children:t.brief.graphic_link_url?e.jsx("a",{href:t.brief.graphic_link_url,target:"_blank",rel:"noopener noreferrer",className:"block",children:e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain cursor-pointer hover:opacity-90 transition-opacity"})}):e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain"})}),t.links.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:"Quick Links"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.links.map(w=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>window.open(w.url,"_blank"),className:"gap-2",children:[e.jsx(sn,{className:"h-4 w-4"}),w.title]},w.id))})]}),t.polls.map(w=>{var A,I;const N=((A=i[w.id])==null?void 0:A.length)>0,C=u.includes(w.id);return e.jsxs("div",{className:"space-y-3 p-4 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:w.question}),N&&e.jsxs(at,{variant:"secondary",className:"gap-1",children:[e.jsx(da,{className:"h-3 w-3"}),"Responded"]})]}),w.poll_type==="single"?e.jsx(w_e,{value:o[w.id]||((I=i[w.id])==null?void 0:I[0])||"",onValueChange:L=>v(w.id,L),className:"space-y-2",children:w.options.map(L=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Nne,{value:L.id,id:L.id}),e.jsx(ve,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id))}):e.jsx("div",{className:"space-y-2",children:w.options.map(L=>{const $=(o[w.id]||i[w.id]||[]).includes(L.id);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(zo,{id:L.id,checked:$,onCheckedChange:q=>_(w.id,L.id,q)}),e.jsx(ve,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id)})}),e.jsx(K,{size:"sm",onClick:()=>b(w.id),disabled:C,children:C?"Submitting...":N?"Update Response":"Submit"})]},w.id)})]})}),e.jsxs("div",{className:"p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] border-t bg-muted/30 flex flex-col items-center gap-2 sticky bottom-0 z-10",children:[e.jsx(K,{onClick:r,className:"w-full max-w-xs",children:"Got it!"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Don't show again"})]})]})})},j2t=()=>{const{user:t}=Gs(),[s,r]=S.useState(null),[n,a]=S.useState(!1),[o,l]=S.useState(!0),[i,d]=S.useState(!1),u=S.useCallback(async()=>{if(!t){l(!1);return}try{const{data:b,error:j}=await G.from("levelup_briefs").select("*").eq("is_published",!0).lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(1).single();if(j||!b){l(!1);return}const{data:w}=await G.from("levelup_brief_views").select("*").eq("brief_id",b.id).eq("user_id",t.id).maybeSingle(),[N,C]=await Promise.all([G.from("levelup_brief_links").select("*").eq("brief_id",b.id).order("sort_order"),G.from("levelup_brief_polls").select("*").eq("brief_id",b.id).order("sort_order")]),A=[];if(C.data)for(const q of C.data){const{data:U}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",q.id).order("sort_order");A.push({...q,options:U||[]})}const I={brief:b,links:N.data||[],polls:A};r(I);const L=!!w,R=(w==null?void 0:w.dismissed_at)!=null,$=localStorage.getItem(`brief-dismissed-${b.id}`)==="true";if(R||$)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(w.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]);S.useEffect(()=>{u()},[u]);const p=async()=>{if(!(!t||!s))try{const{data:b}=await G.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();b?await G.from("levelup_brief_views").update({viewed_at:new Date().toISOString()}).eq("id",b.id):await G.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),p()},dismissBrief:async()=>{if(!(!t||!s)){a(!1),d(!1);try{const{data:b,error:j}=await G.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();if(j&&console.error("Error checking existing brief view:",j),b){const{error:w}=await G.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",b.id).eq("user_id",t.id);w&&console.error("Error updating brief dismiss:",w)}else{const{error:w}=await G.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});w&&console.error("Error inserting brief dismiss:",w)}localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}catch(b){console.error("Error dismissing brief:",b),s&&localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}}},refetch:u}};function k2t(){const[t,s]=S.useState(!1),[r,n]=S.useState(!1),[a,o]=S.useState(null);S.useEffect(()=>{if(localStorage.getItem("install-banner-dismissed")||window.matchMedia("(display-mode: standalone)").matches||!/iPhone|iPad|iPod|Android/i.test(navigator.userAgent))return;const f=/iPhone|iPad|iPod/i.test(navigator.userAgent);n(f),s(!0);const 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(xi,{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(TP,{className:"h-3 w-3 inline"}),' then "Add to Home Screen"']}):e.jsx("p",{className:"text-xs opacity-80",children:"Quick access anytime"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!r&&a&&e.jsx(K,{size:"sm",variant:"secondary",onClick:i,className:"text-xs",children:"Install"}),e.jsx("button",{onClick:l,className:"p-1.5 hover:bg-primary-foreground/10 rounded-full transition-colors","aria-label":"Dismiss",children:e.jsx(Ur,{className:"h-4 w-4"})})]})]})}):null}const N2t=({children:t,onRefresh:s})=>{const[r,n]=S.useState(!1),[a,o]=S.useState(0),[l,i]=S.useState(!1),d=S.useRef(null),u=S.useRef(0),p=ns(),f=80,v=120,_=S.useCallback(C=>{const A=d.current;A&&A.scrollTop<=0&&(u.current=C.touches[0].clientY,n(!0))},[]),b=S.useCallback(C=>{if(!r||l)return;const A=d.current;if(!A||A.scrollTop>0){n(!1),o(0);return}const L=C.touches[0].clientY-u.current;if(L>0){const $=Math.min(L*.5,v);o($),$>10&&C.preventDefault()}},[r,l]),j=S.useCallback(async()=>{if(r)if(n(!1),a>=f&&!l){i(!0),o(f);try{s?await s():await p.invalidateQueries()}catch(C){console.error("Refresh failed:",C)}finally{i(!1),o(0)}}else o(0)},[r,a,l,s,p]),w=Math.min(a/f,1),N=w*180;return e.jsxs("div",{ref:d,className:"h-full overflow-auto",onTouchStart:_,onTouchMove:b,onTouchEnd:j,children:[e.jsx("div",{className:"flex justify-center items-center overflow-hidden transition-all duration-200 ease-out",style:{height:a>0?a:0,opacity:w},children:e.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${l?"animate-spin":""}`,style:{transform:l?void 0:`rotate(${N}deg)`,transition:l?void 0:"transform 0.1s ease-out"},children:e.jsx(Po,{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})]})},nqe=()=>{const{user:t}=Gs(),[s,r]=S.useState(!1),[n,a]=S.useState(!1),[o,l]=S.useState(0),[i,d]=S.useState(!0);S.useEffect(()=>{(async()=>{if(!t){d(!1);return}try{const{data:_}=await G.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(_){a(!0),r(!1),d(!1);return}const{data:b}=await G.from("profiles").select("login_count").eq("id",t.id).single(),j=(b==null?void 0:b.login_count)||0;l(j);const w=sessionStorage.getItem("review-prompt-dismissed");r(j>=4&&!w)}catch(_){console.error("Error checking review eligibility:",_)}finally{d(!1)}})()},[t]);const u=S.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),p=S.useCallback(async(v,_)=>{if(!t)return{success:!1,error:"Not authenticated"};try{const{error:b}=await G.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]),f=S.useCallback(async()=>{if(t)try{await G.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:p,markPostedToGoogle:f}},S2t="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",C2t=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=nqe(),[o,l]=S.useState(!1),[i,d]=S.useState("review"),[u,p]=S.useState(0),[f,v]=S.useState(0),[_,b]=S.useState(""),[j,w]=S.useState(!1),[N,C]=S.useState(!1);if(s||!t&&!N)return null;const A=async()=>{if(u===0){an({title:"Please select a rating",variant:"destructive"});return}w(!0);const R=await n(u,_);w(!1),R.success?(C(!0),an({title:"Thank you for your feedback!",description:"Your review helps us improve."}),d("google")):an({title:"Error submitting review",description:R.error,variant:"destructive"})},I=async R=>{R&&(await navigator.clipboard.writeText(_||`${u} star rating for LevelUp!`),an({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(S2t,"_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(vs,{open:o,onOpenChange:L,children:e.jsx(ys,{className:"sm:max-w-md",children:i==="review"?e.jsxs(e.Fragment,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(R=>e.jsx("button",{type:"button",onClick:()=>p(R),onMouseEnter:()=>v(R),onMouseLeave:()=>v(0),className:"p-1 transition-transform hover:scale-110",children:e.jsx(Gn,{className:Pt("h-8 w-8 transition-colors",(f||u)>=R?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},R))}),e.jsx(Mr,{placeholder:"Tell us about your experience (optional)",value:_,onChange:R=>b(R.target.value),rows:4,className:"resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:L,className:"flex-1",children:"Maybe Later"}),e.jsx(K,{onClick:A,disabled:j||u===0,className:"flex-1",children:j?"Submitting...":"Submit Review"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(K,{variant:"outline",onClick:()=>I(!1),className:"flex-1",children:"No Thanks"}),e.jsx(K,{onClick:()=>I(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function M2t(t){const s="=".repeat((4-t.length%4)%4),r=(t+s).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),a=new Uint8Array(n.length);for(let o=0;o{if(!f){l(!1);return}(async()=>{try{const j="vapid_public_key";let w=localStorage.getItem(j);if(!w){const{data:A,error:I}=await G.functions.invoke("get-vapid-public-key",{body:{}});if(I)throw I;if(w=(A==null?void 0:A.vapidPublicKey)??null,!w)throw new Error("Missing VAPID public key");localStorage.setItem(j,w)}p(w);const N=await navigator.serviceWorker.register("/push-sw.js");d(N),r(Notification.permission);const C=await N.pushManager.getSubscription();a(!!C)}catch(j){console.error("Error initializing push notifications:",j)}finally{l(!1)}})()},[f]);const v=S.useCallback(async()=>{if(!f||!i||!t)return console.error("Push notifications not supported or user not logged in"),!1;if(!u)return fe.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 G.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"?fe.error("Notifications blocked. Please enable them in your browser settings (click the lock icon in the address bar)."):fe.error("Notification permission was dismissed. Please try again."),!1}const j=M2t(u);let w;try{w=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:j})}catch(A){console.error("PushManager.subscribe() failed:",A);const I=(A==null?void 0:A.message)||String(A);return I.includes("permission")?fe.error("Push permission denied. Check your browser notification settings."):I.includes("key")||I.includes("VAPID")?fe.error("Push configuration error. Please contact support."):I.includes("AbortError")?fe.error("Push subscription was cancelled. Please try again."):fe.error(`Failed to subscribe: ${I}`),!1}const N=w.toJSON(),{error:C}=await G.from("push_subscriptions").upsert({user_id:t.id,endpoint:N.endpoint,p256dh_key:N.keys.p256dh,auth_key:N.keys.auth},{onConflict:"user_id,endpoint"});if(C)throw console.error("Error saving subscription:",C),fe.error("Failed to save notification preferences. Please try again."),C;return a(!0),fe.success("Push notifications enabled!"),!0}catch(b){if(console.error("Error subscribing to push notifications:",b),!(b instanceof Error&&b.message.includes("toast"))){const j=b instanceof Error?b.message:"Unknown error";fe.error("Failed to enable push notifications: "+j)}return!1}finally{l(!1)}},[f,i,t,u]),_=S.useCallback(async()=>{if(!i||!t)return!1;try{l(!0);const b=await i.pushManager.getSubscription();return b&&await b.unsubscribe(),await G.from("push_subscriptions").delete().eq("user_id",t.id),a(!1),fe.success("Push notifications disabled"),!0}catch(b){console.error("Error unsubscribing:",b);const j=b instanceof Error?b.message:"Unknown error";return fe.error("Failed to disable push notifications: "+j),!1}finally{l(!1)}},[i,t]);return{isSupported:f,permission:s,isSubscribed:n,isLoading:o,vapidPublicKey:u,subscribe:v,unsubscribe:_}}const qhe="push_notification_prompt_dismissed",T2t=()=>{const{user:t}=Gs(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=aqe(),[o,l]=S.useState(!1),[i,d]=S.useState(!1);S.useEffect(()=>{if(!t||!s||r||n||localStorage.getItem(`${qhe}_${t.id}`))return;const v=setTimeout(()=>{l(!0)},2e3);return()=>clearTimeout(v)},[t,s,r,n]);const u=async()=>{d(!0);const f=await a();d(!1),f&&(t&&localStorage.setItem(`${qhe}_${t.id}`,"true"),l(!1))},p=()=>{t&&localStorage.setItem(`${qhe}_${t.id}`,"true"),l(!1)};return!s||r?null:e.jsx(vs,{open:o,onOpenChange:f=>!f&&p(),children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Ss,{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(cf,{className:"h-6 w-6 text-primary"})}),e.jsx(Ns,{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(K,{onClick:u,disabled:i,className:"w-full",children:i?"Enabling...":"Enable Notifications"}),e.jsx(K,{variant:"ghost",onClick:p,className:"w-full",children:"Not Now"})]}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:"You can always change this in your Profile settings."})]})})},y3e=t=>{let s;const r=new Set,n=(u,p)=>{const f=typeof u=="function"?u(s):u;if(!Object.is(f,s)){const v=s;s=p??(typeof f!="object"||f===null)?f:Object.assign({},s,f),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},A2t=t=>t?y3e(t):y3e,E2t=t=>t;function P2t(t,s=E2t){const r=mt.useSyncExternalStore(t.subscribe,mt.useCallback(()=>s(t.getState()),[t,s]),mt.useCallback(()=>s(t.getInitialState()),[t,s]));return mt.useDebugValue(r),r}const v3e=t=>{const s=A2t(t),r=n=>P2t(s,n);return Object.assign(r,s),r},I2t=t=>t?v3e(t):v3e;function L2t(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 Hge=t=>s=>{try{const r=t(s);return r instanceof Promise?r:{then(n){return Hge(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return Hge(n)(r)}}}},D2t=(t,s)=>(r,n,a)=>{let o={storage:L2t(()=>localStorage),partialize:j=>j,version:0,merge:(j,w)=>({...w,...j}),...s},l=!1;const i=new Set,d=new Set;let u=o.storage;if(!u)return t((...j)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...j)},n,a);const p=()=>{const j=o.partialize({...n()});return u.setItem(o.name,{state:j,version:o.version})},f=a.setState;a.setState=(j,w)=>(f(j,w),p());const v=t((...j)=>(r(...j),p()),n,a);a.getInitialState=()=>v;let _;const b=()=>{var j,w;if(!u)return;l=!1,i.forEach(C=>{var A;return C((A=n())!=null?A:v)});const N=((w=o.onRehydrateStorage)==null?void 0:w.call(o,(j=n())!=null?j:v))||void 0;return Hge(u.getItem.bind(u))(o.name).then(C=>{if(C)if(typeof C.version=="number"&&C.version!==o.version){if(o.migrate){const A=o.migrate(C.state,C.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,C.state];return[!1,void 0]}).then(C=>{var A;const[I,L]=C;if(_=o.merge(L,(A=n())!=null?A:v),r(_,!0),I)return p()}).then(()=>{N==null||N(_,void 0),_=n(),l=!0,d.forEach(C=>C(_))}).catch(C=>{N==null||N(void 0,C)})};return a.persist={setOptions:j=>{o={...o,...j},j.storage&&(u=j.storage)},clearStorage:()=>{u==null||u.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>b(),hasHydrated:()=>l,onHydrate:j=>(i.add(j),()=>{i.delete(j)}),onFinishHydration:j=>(d.add(j),()=>{d.delete(j)})},o.skipHydration||b(),_||v},O2t=D2t,Voe=I2t()(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})})),iqe=S.createContext({onlineUsers:[],totalOnline:0}),R2t=async t=>{try{const{data:s}=await G.storage.from("avatars").list(`${t}`);if(s&&s.length>0){const{data:r}=G.storage.from("avatars").getPublicUrl(`${t}/${s[0].name}`);return r.publicUrl}}catch{}},F2t=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=Gs(),[a,o]=S.useState([]),[l,i]=S.useState(null);S.useEffect(()=>{if(!s)return;const u=G.channel("app-presence",{config:{presence:{key:s.id}}});return u.on("presence",{event:"sync"},()=>{const p=u.presenceState(),f=[];Object.entries(p).forEach(([v,_])=>{if(_&&_.length>0){const b=_[0];f.push({id:v,name:b.name||"Unknown",avatarUrl:b.avatarUrl,brokerageId:b.brokerageId,onlineSince:b.onlineSince})}}),o(f)}).on("presence",{event:"join"},()=>{}).on("presence",{event:"leave"},()=>{}).subscribe(async p=>{var f;if(p==="SUBSCRIBED"){const{data:v}=await G.from("profiles").select("name, brokerage_id").eq("id",s.id).single(),_=await R2t(s.id);await u.track({name:(v==null?void 0:v.name)||((f=s.email)==null?void 0:f.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(iqe.Provider,{value:{onlineUsers:d,totalOnline:a.length},children:t})},oqe=()=>S.useContext(iqe),_3e="dashboard-sidebar-collapsed",Ms=({children:t,title:s})=>{var We;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=Gs(),{isAssistant:i,actingAsAgent:d,hasPermission:u}=T1e(),{isImpersonating:p}=M1e(),v=(i&&!!d?40:0)+(p?40:0),{avatarUrl:_}=W9e(r==null?void 0:r.id),{isTrial:b,isExpired:j,expiresAt:w}=Dbt(r==null?void 0:r.id),{isMarketplaceEnabled:N}=K9e(),{currentBrief:C,shouldShowPopup:A,hasUnseenBrief:I,openBrief:L,closeBrief:R,dismissBrief:$}=j2t(),{unreadCount:q}=Obt(),{openCount:U}=Rbt(),{data:V}=Mf(),X=!!V,te=Voe(ht=>ht.cartItems).reduce((ht,De)=>ht+De.quantity,0),Y=Dr(),de=vu(),[ie,ae]=S.useState(null);S.useEffect(()=>{r!=null&&r.id&&G.from("profiles").select("name").eq("id",r.id).single().then(({data:ht})=>{ht!=null&&ht.name&&ae(ht.name)})},[r==null?void 0:r.id]);const le=ie||((We=r==null?void 0:r.user_metadata)==null?void 0:We.name)||(r==null?void 0:r.email)||"User",[pe,be]=S.useState(()=>typeof window<"u"?localStorage.getItem(_3e)==="true":!1);S.useEffect(()=>{localStorage.setItem(_3e,String(pe))},[pe]);const[ye,we]=S.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,contacts:!0,help:!1}),ke=ht=>{we(De=>({...De,[ht]:!De[ht]}))},Ze=ht=>ht.split(" ").map(De=>De[0]).join("").toUpperCase().slice(0,2),_e=ht=>de.pathname===ht,Ce=ht=>ht.some(De=>de.pathname===De),Te=({path:ht,icon:De,label:Dt,badgeCount:he})=>{const Qe=e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",_e(ht)&&"bg-sidebar-accent text-sidebar-accent-foreground",pe?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>Y(ht),children:[e.jsxs("div",{className:"relative",children:[e.jsx(De,{className:"h-4 w-4 shrink-0"}),pe&&he!=null&&he>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!pe&&Dt,!pe&&he!=null&&he>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:he>9?"9+":he})]});return pe?e.jsxs(nd,{delayDuration:0,children:[e.jsx(ad,{asChild:!0,children:Qe}),e.jsxs(Wc,{side:"right",className:"flex items-center gap-2",children:[Dt,he!=null&&he>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:he>9?"9+":he})]})]}):Qe},Fe=({id:ht,label:De,icon:Dt,children:he,activePaths:Qe,showBetaBadge:ot,defaultPath:rt,badgeCount:Ne})=>{if(pe){const it=rt||Qe[0];return e.jsxs(nd,{delayDuration:0,children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:Pt("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Ce(Qe)&&"text-primary"),onClick:()=>Y(it),children:e.jsxs("div",{className:"relative",children:[e.jsx(Dt,{className:"h-4 w-4"}),Ne!=null&&Ne>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(Wc,{side:"right",className:"flex items-center gap-2",children:[De,ot&&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"}),Ne!=null&&Ne>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:Ne>9?"9+":Ne})]})]})}return e.jsxs(mf,{open:ye[ht],onOpenChange:()=>ke(ht),children:[e.jsx(pf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ce(Qe)&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[e.jsx(Dt,{className:"h-4 w-4"}),De,ot&&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:[Ne!=null&&Ne>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:Ne>9?"9+":Ne}),e.jsx(Vo,{className:Pt("h-4 w-4 transition-transform duration-200",ye[ht]&&"rotate-180")})]})]})}),e.jsx(ff,{className:"pl-4 space-y-1 mt-1",children:he})]})},Ae=({isMobile:ht=!1})=>{const De=ht?!1:pe;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:Pt("p-3 border-b border-sidebar-border",De?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[De?e.jsx("img",{src:nwt,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:rwt,alt:"LevelUp",className:"h-8 w-auto"}),!ht&&e.jsxs(nd,{delayDuration:0,children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>be(!De),children:e.jsx(zl,{className:Pt("h-4 w-4 transition-transform duration-300",De&&"rotate-180")})})}),e.jsx(Wc,{side:"right",children:De?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(Bi,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:e.jsxs("nav",{className:Pt("p-3 space-y-1",De&&"flex flex-col items-center"),children:[e.jsx(Te,{path:"/dashboard",icon:nN,label:"Dashboard"}),e.jsx(Te,{path:"/apps",icon:Vp,label:"Apps & Tools"}),pe?e.jsxs(nd,{delayDuration:0,children:[e.jsx(ad,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-10 h-10 p-0 justify-center relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/levelup-u"),children:[e.jsx(sh,{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(Wc,{side:"right",className:"flex items-center gap-2",children:["LevelUp U",e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-primary-foreground bg-primary rounded px-1 py-0.5",children:"New"})]})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/levelup-u"),children:[e.jsx(sh,{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(Te,{path:"/events",icon:ld,label:"Events"}),e.jsxs(Fe,{id:"agentos",label:"Agent OS",icon:i5,activePaths:["/mission-control","/mission-control/contacts","/mission-control/plans","/mission-control/popbys","/mission-control/video-library","/mission-control/scorecard","/mission-control/listings","/mission-control/pipeline","/mission-control/tasks","/mission-control/smart-drips","/mission-control/relationship-scorecard","/mission-control/sphere-gaps","/mission-control/connect-page"],showBetaBadge:!0,defaultPath:"/mission-control",children:[u("contacts")&&e.jsx(Te,{path:"/mission-control",icon:Si,label:"Mission Control"}),u("contacts")&&!De&&e.jsxs(mf,{open:ye.contacts,onOpenChange:()=>ke("contacts"),children:[e.jsx(pf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ce(["/mission-control/contacts","/mission-control/relationship-scorecard","/mission-control/sphere-gaps","/mission-control/connect-page"])&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Contacts"]}),e.jsx(Vo,{className:Pt("h-3.5 w-3.5 transition-transform duration-200",ye.contacts&&"rotate-180")})]})}),e.jsxs(ff,{className:"pl-4 pr-1 space-y-0.5 mt-0.5",children:[e.jsx(Te,{path:"/mission-control/contacts",icon:hr,label:"All Contacts"}),e.jsx(Te,{path:"/mission-control/relationship-scorecard",icon:Am,label:"Relationship Report"}),e.jsx(Te,{path:"/mission-control/sphere-gaps",icon:CP,label:"Sphere Gaps"}),e.jsx(Te,{path:"/mission-control/connect-page",icon:Ho,label:"Connect Page"})]})]}),u("contacts")&&De&&e.jsx(Te,{path:"/mission-control/contacts",icon:hr,label:"Contacts"}),u("contacts")&&e.jsx(Te,{path:"/mission-control/plans",icon:ld,label:"TouchPlans"}),u("pipeline")&&e.jsx(Te,{path:"/mission-control/pipeline",icon:Wx,label:"Deal Pipeline"}),u("pipeline")&&e.jsx(Te,{path:"/mission-control/tasks",icon:d0,label:"Tasks"}),u("popbys")&&e.jsx(Te,{path:"/mission-control/popbys",icon:io,label:"Popbys"}),u("videos")&&e.jsx(Te,{path:"/mission-control/video-library",icon:kn,label:"Video Library"}),u("scorecard")&&e.jsx(Te,{path:"/mission-control/scorecard",icon:Xo,label:"Scorecard"}),u("listings")&&e.jsx(Te,{path:"/mission-control/listings",icon:Aa,label:"Listing Exchange"}),!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/mission-control/smart-drips")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/mission-control/smart-drips"),children:[e.jsx(Dm,{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"})]}),De&&e.jsx(Te,{path:"/mission-control/smart-drips",icon:Dm,label:"Smart Drips"})]}),e.jsxs(Fe,{id:"marketing",label:"Marketing",icon:zg,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx(Te,{path:"/templates",icon:Bl,label:"Templates"}),e.jsx(Te,{path:"/social-swag-2",icon:O0,label:"Social Swag"}),e.jsx(Te,{path:"/newsletters",icon:I0,label:"Newsletters"})]}),e.jsxs(Fe,{id:"learning",label:"Learning",icon:Ou,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx(Te,{path:"/academy",icon:sh,label:"Academy"}),e.jsx(Te,{path:"/toolbox",icon:$g,label:"Toolbox"})]}),e.jsxs(Fe,{id:"community",label:"Community",icon:oo,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:q,children:[e.jsx(Te,{path:"/community",icon:hr,label:"Community",badgeCount:q}),e.jsx(Te,{path:"/wishlist",icon:s_,label:"Wishlist",badgeCount:U}),!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open("https://www.facebook.com/share/g/1CC6thti2V/","_blank"),children:[e.jsx(sn,{className:"h-4 w-4"}),"Facebook Group"]})]}),e.jsxs(Fe,{id:"goods",label:"The Goods",icon:km,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[N&&!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",de.pathname.startsWith("/marketplace")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/marketplace"),children:[e.jsx(km,{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&&De&&e.jsx(Te,{path:"/marketplace",icon:km,label:"Marketplace"}),e.jsx(Te,{path:"/reward-store",icon:Ki,label:"Reward Store"})]}),e.jsxs(Fe,{id:"help",label:"Help & Services",icon:i0,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx(Te,{path:"/support",icon:p5,label:"Support"}),e.jsx(Te,{path:"/additional-services",icon:hn,label:"Additional Services"})]}),a&&e.jsxs(e.Fragment,{children:[!De&&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"})}),De?e.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:e.jsx(Te,{path:"/admin",icon:zu,label:"Admin Dashboard"})}):e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",de.pathname==="/admin"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/admin"),children:[e.jsx(zu,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&e.jsxs(e.Fragment,{children:[!De&&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"})}),De?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(Te,{path:"/my-brokerage",icon:Aa,label:"My Brokerage"}),e.jsx(Te,{path:"/brokerage-content",icon:Ou,label:"Brokerage Content"})]}),X&&!o&&e.jsx(Te,{path:"/my-team",icon:hr,label:"My Team"}),o&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{path:"/brokerage/dashboard",icon:$l,label:"Manage Brokerages"}),e.jsx(Te,{path:"/brokerage/teams",icon:hr,label:"Teams"}),e.jsx(Te,{path:"/brokerage-resources",icon:th,label:"Brokerage Resources"})]})]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/my-brokerage"),children:[e.jsx(Aa,{className:"h-4 w-4"}),"My Brokerage"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/brokerage-content")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/brokerage-content"),children:[e.jsx(Ou,{className:"h-4 w-4"}),"Brokerage Content"]})]}),X&&!o&&e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/my-team"),children:[e.jsx(hr,{className:"h-4 w-4"}),"My Team"]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/brokerage/dashboard"),children:[e.jsx($l,{className:"h-4 w-4"}),"Manage Brokerages"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/brokerage/teams"),children:[e.jsx(hr,{className:"h-4 w-4"}),"Teams",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"New"})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/brokerage-resources"),children:[e.jsx(th,{className:"h-4 w-4"}),"Brokerage Resources"]})]})]})]})]})}),e.jsxs("div",{className:"p-3 border-t border-sidebar-border md:hidden",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/profile"),children:[e.jsx(Xi,{className:"h-4 w-4"}),"Profile"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:n,children:[e.jsx(g5,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(F2t,{children:e.jsx(QN,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[b&&j&&e.jsx(i2t,{}),typeof document<"u"&&wm.createPortal(e.jsx("aside",{className:Pt("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-[2147483647] isolate !pointer-events-auto transition-[width] duration-300",pe?"w-16":"w-56"),style:{top:`${v}px`,height:`calc(100vh - ${v}px)`},children:e.jsx(Ae,{})}),document.body),e.jsxs("div",{className:Pt("flex-1 flex flex-col overflow-hidden transition-all duration-300",pe?"md:ml-16":"md:ml-56"),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(gM,{children:[e.jsx(r_e,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(mP,{className:"h-5 w-5"})})}),e.jsx(rS,{side:"left",className:"w-56 p-0 bg-card",children:e.jsx(Ae,{isMobile:!0})})]}),e.jsx("div",{className:"flex-1 md:hidden",children:e.jsx("img",{src:awt,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(x3e,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[b&&!j&&w&&e.jsx(a2t,{expiresAt:w,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(x3e,{})}),C&&e.jsx(o2t,{hasUnseenBrief:I,onClick:L}),N&&e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",onClick:()=>Y("/marketplace/cart"),children:[e.jsx(km,{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(Ewt,{}),e.jsx(qge,{}),e.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",le.split(" ")[0],"!"]}),e.jsxs(Kd,{children:[e.jsx(Zd,{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(gn,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[e.jsx(Ea,{src:_||void 0}),e.jsx(xn,{className:"bg-primary text-primary-foreground font-medium text-sm",children:Ze(le)})]})})}),e.jsxs(Td,{align:"end",className:"w-48",children:[e.jsxs(Ta,{onClick:()=>Y("/profile"),className:"cursor-pointer",children:[e.jsx(Xi,{className:"h-4 w-4 mr-2"}),"Profile"]}),e.jsxs(Ta,{onClick:()=>Y("/mission-control/integrations"),className:"cursor-pointer",children:[e.jsx(_P,{className:"h-4 w-4 mr-2"}),"Integrations"]}),e.jsx(S_,{}),e.jsxs(Ta,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(g5,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),e.jsx(N2t,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),C&&e.jsx(w2t,{brief:C,open:A,onClose:R,onDismiss:$}),e.jsx(k2t,{}),e.jsx(C2t,{}),e.jsx(T2t,{})]})]})})})},z2t=()=>{const{user:t}=Gs(),[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState(""),i=async f=>{var v;if(!(t!=null&&t.email)){fe.error("Please sign in to upgrade");return}r(!0),a(f);try{const{data:_,error:b}=await G.functions.invoke("create-checkout",{body:{tier:f,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"),fe.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(_){console.error("Checkout error:",_),fe.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"],p=["Everything in Brokerage plan","Unlimited agent seats","Dedicated account manager","Advanced analytics & reporting","White-label options","API access","Custom integrations","Enterprise-level support"];return e.jsx(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(ve,{htmlFor:"coupon",className:"text-sm font-medium",children:"Have a discount code?"}),e.jsx(Re,{id:"coupon",placeholder:"Enter discount code",value:o,onChange:f=>l(f.target.value),className:"mt-1"})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6 mb-8",children:[e.jsxs(Ee,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 bg-primary text-primary-foreground text-xs px-3 py-1 rounded-bl-lg font-medium",children:"Popular"}),e.jsxs(Lt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(hr,{className:"h-7 w-7 text-primary"})}),e.jsx(zt,{className:"text-xl",children:"Individual Agent"}),e.jsx(yr,{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((f,v)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ua,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},v))}),e.jsxs(K,{className:"w-full",size:"lg",onClick:()=>i("individual_agent"),disabled:s,children:[s&&n==="individual_agent"?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Ee,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors",children:[e.jsxs(Lt,{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(Aa,{className:"h-7 w-7 text-amber-600"})}),e.jsx(zt,{className:"text-xl",children:"Brokerage"}),e.jsx(yr,{children:"For teams and brokerages up to 25 agents"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-amber-600",children:"$299"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:u.map((f,v)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ua,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},v))}),e.jsxs(K,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",size:"lg",onClick:()=>i("brokerage_under_25"),disabled:s,children:[s&&n==="brokerage_under_25"?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Aa,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Ee,{className:"border-2 border-purple-500/20 hover:border-purple-500/50 transition-colors",children:[e.jsxs(Lt,{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(Aa,{className:"h-7 w-7 text-purple-600"})}),e.jsx(zt,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(yr,{children:"For larger brokerages with 25+ agents"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-purple-600",children:"$499"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:p.map((f,v)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ua,{className:"h-4 w-4 text-purple-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},v))}),e.jsxs(K,{variant:"outline",className:"w-full border-purple-500 text-purple-600 hover:bg-purple-50",size:"lg",onClick:()=>i("brokerage_over_25"),disabled:s,children:[s&&n==="brokerage_over_25"?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Aa,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]})]}),e.jsx(Ee,{className:"bg-muted/50",children:e.jsxs(Oe,{className:"py-6",children:[e.jsx("p",{className:"text-center font-medium mb-4",children:"Questions? We're here to help!"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(Zn,{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(_r,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})})]})})},B2t=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=Gs(),a=Dr(),[o,l]=S.useState(""),[i,d]=S.useState(!1),[u,p]=S.useState(!1);S.useEffect(()=>{!s&&!t&&a("/auth")},[t,s,a]),S.useEffect(()=>{!s&&t&&n&&a("/profile?setup=true")},[t,s,n,a]);const f=async()=>{if(!o.trim()){fe.error("Please enter a brokerage name");return}const{data:v}=await G.auth.getSession(),_=v.session;if(!t||!_){fe.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:j}=await G.functions.invoke("create-brokerage",{body:{name:o.trim()}});if(console.log("[SetupBrokerage] create-brokerage response",{data:b,error:j}),j)throw j;if(!(b!=null&&b.ok))throw new Error((b==null?void 0:b.error)||"Failed to create brokerage");d(!1),p(!0),fe.success("Brokerage created! Setting up your account..."),setTimeout(()=>{a("/profile?setup=true")},2e3)}catch(b){console.error("Error creating brokerage:",b),fe.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(Ee,{className:"max-w-lg w-full",children:[e.jsxs(Lt,{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(As,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx(zt,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(yr,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(gi,{className:"w-5 h-5 text-green-500"}),e.jsx("span",{children:"Brokerage created"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(As,{className:"w-5 h-5 animate-spin text-primary"}),e.jsx("span",{children:"Assigning you as manager..."})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground mt-4",children:"You'll be redirected to complete your profile setup in a moment."})]})]})}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ee,{className:"max-w-lg w-full",children:[e.jsxs(Lt,{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(Aa,{className:"w-10 h-10 text-primary"})}),e.jsx(zt,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(yr,{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(ve,{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"&&f()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This is how your brokerage will appear to your agents"})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-muted/50 space-y-3",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(hr,{className:"w-4 h-4 text-primary"}),"What you can do as a Brokerage Manager:"]}),e.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(gi,{className:"w-4 h-4 text-green-500"}),"Invite agents to join your brokerage"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(gi,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(gi,{className:"w-4 h-4 text-green-500"}),"Track your team's activity and engagement"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(gi,{className:"w-4 h-4 text-green-500"}),"Share resources with your agents"]})]})]}),e.jsxs(K,{onClick:f,className:"w-full",disabled:i||!o.trim(),children:[i?"Creating...":"Create Brokerage",e.jsx(Fi,{className:"w-4 h-4 ml-2"})]})]})]})})},b3e=()=>{const t=Dr(),[s,r]=S.useState("verifying"),[n,a]=S.useState("");S.useEffect(()=>{(async()=>{try{const{data:{session:i},error:d}=await G.auth.getSession();if(d)throw d;if(i!=null&&i.user){const{data:u}=await G.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 G.functions.invoke("trial-claim-hook",{body:{userId:i.user.id}})}catch(p){console.log("Trial claim hook (non-critical):",p)}setTimeout(()=>{t("/profile?setup=true")},1500)}else setTimeout(()=>{r("already_claimed")},2e3)}catch(i){console.error("Claim error:",i),r("already_claimed")}})()},[t]);const o=()=>{window.location.href="https://dashboard.relevelup.com/auth"};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"space-y-1 text-center",children:[e.jsxs("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary/10",children:[s==="verifying"&&e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),s==="success"&&e.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),s==="already_claimed"&&e.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),s==="error"&&e.jsx("svg",{className:"h-8 w-8 text-destructive",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]}),e.jsxs(zt,{className:"text-2xl",children:[s==="verifying"&&"Claiming Your Account...",s==="success"&&"Account Claimed!",s==="already_claimed"&&"Account Already Claimed",s==="error"&&"Claim Failed"]}),e.jsxs(yr,{children:[s==="verifying"&&"Please wait while we verify your account...",s==="success"&&"Redirecting you to complete your profile...",s==="already_claimed"&&"This account has already been set up. Please log in to access your dashboard.",s==="error"&&n]})]}),(s==="already_claimed"||s==="error")&&e.jsx(Oe,{children:e.jsx(K,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},$2t=()=>{const t=Dr(),[s]=Ec(),[r,n]=S.useState(s.get("code")||""),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState(""),[p,f]=S.useState(!1),[v,_]=S.useState(!1),[b,j]=S.useState(!1),[w,N]=S.useState(!1),[C,A]=S.useState(null),[I,L]=S.useState(null),[R,$]=S.useState(null),[q,U]=S.useState(null);S.useEffect(()=>{const te=s.get("code");te&&(n(te),V(te))},[s]);const V=async te=>{j(!0);const{data:Y,error:de}=await G.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(de||!Y){fe.error("Invalid invite code"),j(!1);return}if(!Y.is_active){fe.error("This invite code is no longer active"),j(!1);return}if(Y.max_uses&&Y.uses_count>=Y.max_uses){fe.error("This invite code has reached its maximum uses"),j(!1);return}if(Y.expires_at&&new Date(Y.expires_at){te.preventDefault(),V(r)},se=async te=>{var Y;if(te.preventDefault(),!d.trim()){fe.error("Please enter your name");return}if(l.length<6){fe.error("Password must be at least 6 characters");return}_(!0);try{const de=`${window.location.origin}/`,{data:ie,error:ae}=await G.auth.signUp({email:a.trim(),password:l,options:{emailRedirectTo:de,data:{name:d.trim()}}});if(ae){ae.message.includes("already registered")?fe.error("This email is already registered. Please sign in instead."):fe.error(ae.message);return}ie.user&&(await G.rpc("add_default_signup_tag",{user_id:ie.user.id}),I?await G.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,brokerageId:I}}):q?await G.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,trialDays:q}}):await G.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,grandfathered:!0}}),C&&await G.from("invite_codes").update({uses_count:((Y=(await G.from("invite_codes").select("uses_count").eq("id",C).single()).data)==null?void 0:Y.uses_count)+1}).eq("id",C),fe.success("Account created! You can now access the dashboard."),t("/dashboard"))}catch(de){console.error("Signup error:",de),fe.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(Ee,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[e.jsx(zt,{className:"text-2xl font-bold text-primary",children:R?`Join ${R}`:"Join LevelUp"}),e.jsx(yr,{children:w?R?`Create your account to join ${R}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx(Oe,{children:w?e.jsxs("form",{onSubmit:se,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(ve,{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(ve,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{id:"password",type:p?"text":"password",placeholder:"••••••••",value:l,onChange:te=>i(te.target.value),required:!0,minLength:6}),e.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>f(!p),children:p?e.jsx(Em,{className:"h-4 w-4"}):e.jsx(ya,{className:"h-4 w-4"})})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:v,children:v?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):e.jsxs("form",{onSubmit:X,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(K,{type:"submit",className:"w-full",disabled:b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},q2t="/assets/testimonial-avatar-1-BsCQFauB.jpg",U2t="/assets/testimonial-avatar-2-B6VPVc2t.jpg",V2t="/assets/testimonial-avatar-3-GuEFwYUE.jpg",H2t="/assets/testimonial-avatar-4-98iKMtkB.jpg",W2t="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",G2t=[q2t,U2t,V2t,H2t,W2t],K2t=sS({name:Jl().trim().min(2,"Name must be at least 2 characters").max(100),email:Jl().trim().email("Please enter a valid email address").max(255),phone:Jl().trim().min(10,"Please enter a valid phone number").max(20).optional().or(xne("")),brokerage:Jl().trim().max(200).optional().or(xne(""))}),Z2t=[{icon:ym,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Bl,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:on,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:gc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:In,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:io,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],Y2t=[{icon:hr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:hn,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Zn,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Ru,title:"Birthday Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Ai,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:Xo,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Si,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Dm,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],X2t=[{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."}],Q2t=()=>{const t=Dr(),[s,r]=S.useState(!1),[n,a]=S.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=S.useState({}),i=async d=>{var p,f;d.preventDefault(),l({});const u=K2t.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 G.functions.invoke("create-trial-signup",{body:{name:n.name.trim(),email:n.email.trim().toLowerCase(),phone:((p=n.phone)==null?void 0:p.trim())||void 0,brokerage:((f=n.brokerage)==null?void 0:f.trim())||void 0}});if(_){console.error("Trial signup error:",_),fe.error(_.message||"Something went wrong. Please try again.");return}if(v!=null&&v.error){fe.error(v.error);return}fe.success("🎉 Welcome aboard! Check your email to claim your account."),t("/trial/success")}catch(v){console.error("Trial signup error:",v),fe.error("Something went wrong. Please try again.")}finally{r(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(ah,{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:yne,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var d;return(d=document.getElementById("features"))==null?void 0:d.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(K,{onClick:()=>t("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),e.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"grid lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{className:"space-y-8 text-center lg:text-left",children:[e.jsx("div",{className:"flex justify-center lg:justify-start",children:e.jsx("img",{alt:"LevelUp Consulting Group",className:"h-24 md:h-32 drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium",children:[e.jsx(hn,{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(da,{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(da,{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:G2t.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(Ee,{className:"bg-white shadow-2xl border-0",children:e.jsxs(Oe,{className:"p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-[#4a6b6d] mb-4",children:e.jsx(Gx,{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(ve,{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(ve,{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(ve,{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(ve,{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(K,{type:"submit",className:"w-full h-12 text-lg font-semibold bg-[#4a6b6d] hover:bg-[#3d5a5c]",disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx(Fi,{className:"ml-2 h-5 w-5"})]})}),e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["By signing up, you agree to our"," ",e.jsx("a",{href:"/terms-of-service",className:"text-[#4a6b6d] hover:underline",children:"Terms"})," ","and"," ",e.jsx("a",{href:"/privacy-policy",className:"text-[#4a6b6d] hover:underline",children:"Privacy Policy"})]})]})]})})})]})})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl md:text-5xl leading-tight font-sans font-semibold text-secondary",children:"We help brokerages and agents grow with training, tools, and built-in execution."}),e.jsxs("div",{className:"space-y-2 text-lg text-muted-foreground",children:[e.jsx("p",{children:"Agents get weekly coaching + plug-and-play marketing."}),e.jsx("p",{children:"Brokerages get higher adoption, consistency, and real engagement."})]}),e.jsx("p",{className:"text-2xl md:text-4xl text-[#4a6b6d] pt-4 font-sans font-bold",children:"LEVELUP EQUIPS BOTH TO THRIVE."})]})})}),e.jsx("section",{id:"features",className:"py-20 bg-muted/30",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl mb-6 font-sans font-bold",children:"What's inside our members only portal?"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Everything you need to grow your business, all in one place."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:Z2t.map((d,u)=>e.jsxs(Ee,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Lt,{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(zt,{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(hn,{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:Y2t.map((d,u)=>e.jsxs(Ee,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Lt,{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(zt,{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:X2t.map((d,u)=>e.jsx(Ee,{className:"border hover:shadow-lg transition-shadow",children:e.jsxs(Oe,{className:"p-6",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(p=>e.jsx(Gn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},p))}),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(rh,{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(Dm,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Fast Setup"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Start in 2 minutes"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(hr,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Expert Support"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Real estate pros"})]})]})]})})}),e.jsx("section",{id:"free-trial",className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs(Ee,{className:"bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] border-0 shadow-2xl overflow-hidden relative",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs(Oe,{className:"p-12 text-center relative",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-4 font-sans",children:"Ready to Level Up Your Business?"}),e.jsx("p",{className:"text-xl text-white/80 mb-8 max-w-2xl mx-auto",children:"Join thousands of successful agents. Start your free 7-day trial today."}),e.jsxs(K,{onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),size:"lg",className:"h-14 px-8 text-lg font-semibold bg-white text-[#1e3a4c] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 rounded-full",children:["Start Your Free Trial Now",e.jsx(Fi,{className:"ml-2 h-5 w-5"})]})]})]})})}),e.jsx("footer",{className:"bg-[#1e3a4c] py-12",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-6",children:[e.jsx("img",{src:U1e,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."})]})})})]})]})},J2t=()=>{const t=Dr();return e.jsxs(e.Fragment,{children:[e.jsx(ah,{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:yne,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsx(K,{onClick:()=>t("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})}),e.jsxs("section",{className:"relative pt-24 pb-12 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden flex-1 flex items-center",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(Ee,{className:"max-w-lg w-full bg-white shadow-2xl border-0",children:e.jsxs(Oe,{className:"p-8 md:p-12 text-center",children:[e.jsxs("div",{className:"relative inline-block mb-8",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] flex items-center justify-center",children:e.jsx(da,{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(Sd,{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(_r,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Check Your Inbox"})]}),e.jsx("p",{className:"text-muted-foreground",children:"We just sent you a magic link to claim your account and set up your password. Click the link in your email to get started!"})]}),e.jsxs("div",{className:"text-left space-y-3 mb-8",children:[e.jsx("p",{className:"text-sm text-muted-foreground font-medium uppercase tracking-wide",children:"What happens next:"}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-white",children:"1"})}),e.jsx("p",{className:"text-foreground",children:"Check your email for the welcome message"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-white",children:"2"})}),e.jsx("p",{className:"text-foreground",children:'Click "Claim Your Account" to set your password'})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-white",children:"3"})}),e.jsx("p",{className:"text-foreground",children:"Start exploring all the features!"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["Didn't receive the email? Check your spam folder or"," ",e.jsx("button",{onClick:()=>t("/trial"),className:"text-[#4a6b6d] hover:underline font-medium",children:"try again"})]}),e.jsxs(K,{onClick:()=>t("/auth"),className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["Go to Sign In",e.jsx(Fi,{className:"ml-2 h-4 w-4"})]})]})})})})]}),e.jsx("footer",{className:"bg-[#1e3a4c] py-8",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4",children:[e.jsx("img",{src:U1e,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},ejt=sS({viewerName:Jl().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:Jl().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:Jl().max(20,"Phone must be less than 20 characters").optional(),message:Jl().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function tjt({shareToken:t,agentName:s,hasContact:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(null),u=Roe({resolver:Foe(ejt),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),p=async f=>{a(!0),d(null);try{const{data:v,error:_}=await G.functions.invoke("video-reply-notify",{body:{shareToken:t,viewerName:f.viewerName,viewerEmail:f.viewerEmail,viewerPhone:f.viewerPhone||void 0,message:f.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(Ee,{className:"border-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",children:e.jsxs(Oe,{className:"py-8 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/20 mb-4",children:e.jsx(da,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:"Message Sent!"}),e.jsxs("p",{className:"text-muted-foreground",children:[s?`${s} will`:"They'll"," get back to you soon."]})]})}):e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(gc,{className:"h-5 w-5 text-primary"}),e.jsx(zt,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(yr,{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(zoe,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(p),className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(bc,{control:u.control,name:"viewerName",render:({field:f})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Your Name *"}),e.jsx(hc,{children:e.jsx(Re,{placeholder:"John Smith",...f})}),e.jsx(Eh,{})]})}),e.jsx(bc,{control:u.control,name:"viewerEmail",render:({field:f})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Email *"}),e.jsx(hc,{children:e.jsx(Re,{type:"email",placeholder:"john@example.com",...f})}),e.jsx(Eh,{})]})})]}),!r&&e.jsx(bc,{control:u.control,name:"viewerPhone",render:({field:f})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Phone (optional)"}),e.jsx(hc,{children:e.jsx(Re,{type:"tel",placeholder:"(555) 123-4567",...f})}),e.jsx(Eh,{})]})}),e.jsx(bc,{control:u.control,name:"message",render:({field:f})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Message *"}),e.jsx(hc,{children:e.jsx(Mr,{placeholder:r?"Thanks for the video! I had a question about...":"I'm interested in learning more about...",className:"min-h-[100px] resize-none",...f})}),e.jsx(Eh,{})]})}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i}),e.jsx(K,{type:"submit",className:"w-full gap-2",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ka,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const sjt=()=>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(M0,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 rotate-12"})]}),rjt=()=>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(hn,{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(hn,{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(M0,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),njt=()=>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(Ag,{className:"w-20 h-20 text-pink-400 rotate-12"})}),e.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:e.jsx(Ag,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),e.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:e.jsx(Ag,{className:"w-14 h-14 text-purple-400 rotate-45"})}),e.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:e.jsx(Ag,{className:"w-16 h-16 text-pink-300 -rotate-6"})}),e.jsx(Si,{className:"absolute top-[15%] left-[30%] w-5 h-5 text-rose-300/40 fill-rose-300/20 animate-pulse"}),e.jsx(Si,{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(Si,{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"})]}),ajt=()=>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(rc,{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(rc,{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"}})]}),ijt=()=>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(Ag,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),e.jsx(Ag,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),e.jsx(l5,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),ojt=()=>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(sN,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),e.jsx(sN,{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(hn,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),e.jsx(hn,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),ljt=()=>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(o_,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),e.jsx(o_,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),e.jsx(o_,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),e.jsx(D1,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),e.jsx(D1,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(D1,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(D1,{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"})]}),cjt=()=>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(Si,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-red-400/22 fill-red-400/12"}),e.jsx(Si,{className:"absolute top-[20%] right-[25%] w-5 h-5 text-orange-400/22 fill-orange-400/12"})]}),djt=()=>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(hn,{className:"absolute top-[3%] left-[50%] w-10 h-10 text-yellow-400/40"}),e.jsx(Sd,{className:"absolute bottom-[18%] left-[10%] w-12 h-12 text-purple-400/18 rotate-12"}),e.jsx(Sd,{className:"absolute bottom-[20%] right-[12%] w-10 h-10 text-amber-400/15 -rotate-12"})]}),ujt=()=>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(hn,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),e.jsx(hn,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),hjt=()=>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(y0,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),e.jsx(y0,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),e.jsx(y0,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),e.jsx(y0,{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"})]})]})]}),mjt=()=>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(rc,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(rc,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(M0,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),pjt=()=>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(Ru,{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(Sd,{className:"absolute top-[8%] left-[45%] w-10 h-10 text-purple-400/22 rotate-12"}),e.jsx(io,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),fjt=()=>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(Si,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-rose-400/28 fill-rose-400/18"}),e.jsx(Si,{className:"absolute top-[8%] right-[12%] w-14 h-14 text-pink-400/25 fill-pink-400/15"}),e.jsx(Si,{className:"absolute bottom-[15%] left-[12%] w-12 h-12 text-red-400/22 fill-red-400/12"}),e.jsx(Si,{className:"absolute bottom-[18%] right-[10%] w-13 h-13 text-rose-300/25 fill-rose-300/15"}),e.jsx(Si,{className:"absolute top-[15%] left-[30%] w-6 h-6 text-pink-300/35 fill-pink-300/20 animate-pulse"}),e.jsx(Si,{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(Si,{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(Si,{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"})]}),gjt=()=>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(i_,{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(i_,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),e.jsx(hn,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),e.jsx(i_,{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"})]}),xjt=()=>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(Un,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),e.jsx(Un,{className:"absolute bottom-[15%] right-[8%] w-16 h-16 text-emerald-500/18"}),e.jsx(Im,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),e.jsx(Im,{className:"absolute bottom-[22%] left-[22%] w-8 h-8 text-yellow-400/22"}),e.jsx(Si,{className:"absolute top-[18%] left-[40%] w-6 h-6 text-rose-400/22 fill-rose-400/12"}),e.jsx(Si,{className:"absolute top-[22%] right-[35%] w-5 h-5 text-teal-400/20 fill-teal-400/10"}),e.jsx(hn,{className:"absolute top-[5%] left-[55%] w-8 h-8 text-teal-400/30"}),e.jsx(Sd,{className:"absolute bottom-[20%] left-[48%] w-10 h-10 text-cyan-400/18 rotate-12"})]}),yjt=()=>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(Sd,{className:"absolute top-[5%] left-[12%] w-14 h-14 text-emerald-400/25 rotate-12"}),e.jsx(Sd,{className:"absolute top-[8%] right-[10%] w-12 h-12 text-teal-400/22 -rotate-12"}),e.jsx(Im,{className:"absolute bottom-[18%] left-[18%] w-12 h-12 text-amber-400/25"}),e.jsx(Un,{className:"absolute bottom-[15%] right-[12%] w-14 h-14 text-teal-500/18"}),e.jsx(hn,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),e.jsx(hn,{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"})]}),vjt=()=>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(Im,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),e.jsx(Im,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),e.jsx(Im,{className:"absolute top-[12%] right-[15%] w-9 h-9 text-amber-300/25"}),e.jsx(Un,{className:"absolute top-[8%] left-[42%] w-12 h-12 text-teal-500/18"}),e.jsx(Sd,{className:"absolute bottom-[22%] right-[18%] w-12 h-12 text-orange-400/18 rotate-12"}),e.jsx(hn,{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"})]}),_jt=()=>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(Un,{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(Im,{className:"absolute top-[10%] right-[12%] w-10 h-10 text-amber-400/28"}),e.jsx(Si,{className:"absolute top-[8%] left-[18%] w-8 h-8 text-rose-400/25 fill-rose-400/15"}),e.jsx(hn,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),e.jsx(S0,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),w3e=()=>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"})]}),bjt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Si,{className:"absolute top-6 left-[12%] w-4 h-4 text-rose-300/50 fill-rose-300/30 animate-pulse"}),e.jsx(Si,{className:"absolute top-10 right-[18%] w-3 h-3 text-pink-300/50 fill-pink-300/30 animate-pulse delay-150"}),e.jsx(Si,{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(Si,{className:"absolute top-14 right-[35%] w-3.5 h-3.5 text-pink-300/40 fill-pink-300/20 animate-pulse delay-200"})]}),wjt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(S0,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),e.jsx(hn,{className:"absolute top-10 right-[15%] w-3 h-3 text-amber-400/50 animate-pulse delay-100"}),e.jsx(Un,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),jjt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(eN,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),e.jsx(x5,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),e.jsx(eN,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),tE=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(hn,{className:"absolute top-5 left-[10%] w-4 h-4 text-emerald-400/50 animate-pulse"}),e.jsx(Sd,{className:"absolute top-10 right-[12%] w-5 h-5 text-amber-400/50 animate-pulse delay-150"}),e.jsx(hn,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),j3e=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Un,{className:"absolute top-6 left-[12%] w-4 h-4 text-teal-400/40 animate-pulse"}),e.jsx(hn,{className:"absolute top-10 right-[15%] w-3 h-3 text-emerald-400/50 animate-pulse delay-100"}),e.jsx(Un,{className:"absolute top-4 right-[40%] w-3 h-3 text-cyan-400/30 animate-pulse delay-200"})]}),Wge=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:e.jsx(hn,{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(Si,{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(bjt,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:e.jsx(JE,{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(tE,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:e.jsx(eN,{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(jjt,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:e.jsx(Xo,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Market Update for ${t}`:"Market Update",subText:"The latest insights from your local market",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue"},{id:"referral_thank_you",name:"Referral Thank You",description:"Thank someone for a referral",icon:e.jsx(hr,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Thank You for the Referral, ${t}!`:"Thank You for the Referral!",subText:"Your trust in me means everything",gradientClasses:"from-emerald-50/70 via-green-50/50 to-teal-50/40 dark:from-emerald-950/30 dark:via-green-950/20 dark:to-teal-950/20",accentColor:"emerald",decorativeElement:e.jsx(tE,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:e.jsx(rc,{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(w3e,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:e.jsx(Ai,{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(j3e,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:e.jsx(x5,{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(tE,{})},{id:"birthday",name:"Birthday",description:"Celebrate their special day",icon:e.jsx(Ru,{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(pjt,{})},{id:"valentines_day",name:"Valentine's Day",description:"Show appreciation on this special day",icon:e.jsx(Si,{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(fjt,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:e.jsx(i_,{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(gjt,{})},{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(djt,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:e.jsx(l5,{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(ijt,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:e.jsx(Ag,{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(njt,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(rc,{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(ajt,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:e.jsx(M0,{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(sjt,{})},{id:"independence_day",name:"4th of July",description:"Celebrate Independence Day",icon:e.jsx($h,{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(rjt,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(rc,{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(mjt,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:e.jsx(sN,{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(ojt,{})},{id:"thanksgiving",name:"Thanksgiving",description:"Express gratitude this season",icon:e.jsx(Si,{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(cjt,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:e.jsx(o_,{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(ljt,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:e.jsx(hn,{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(ujt,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:e.jsx(y0,{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(hjt,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:e.jsx(Un,{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(xjt,{})},{id:"under_contract",name:"Under Contract",description:"Celebrate this exciting milestone",icon:e.jsx(Sd,{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(yjt,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:e.jsx(on,{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(j3e,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:e.jsx(Kc,{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(tE,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:e.jsx(dN,{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(S0,{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(wjt,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:e.jsx(Im,{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(vjt,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:e.jsx(Un,{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(_jt,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:e.jsx(pu,{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(tE,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:e.jsx(rc,{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(w3e,{})}],kjt=[{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 Njt(t){return Wge.filter(s=>s.category===t)}function E5(t){return Wge.find(s=>s.id===t)||Wge[0]}function k3e(){const{shareToken:t,recipientToken:s}=Mo(),[r,n]=S.useState(null),[a,o]=S.useState(null),[l,i]=S.useState(null),[d,u]=S.useState(!0),[p,f]=S.useState(null),[v,_]=S.useState(!0),b=S.useRef(null),j=S.useRef(0),w=S.useRef(0),N=(()=>{const se=new URLSearchParams(window.location.search);return s||se.get("rt")||null})(),C=S.useCallback((se,te=!1)=>{if(!N||se<=0)return;const Y=Math.max(1,Math.round(se));if(Y<=w.current)return;const ie=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${encodeURIComponent(N)}&e=watch&ws=${Y}`;te&&navigator.sendBeacon?navigator.sendBeacon(ie):fetch(ie,{method:"GET",keepalive:te}).catch(()=>{}),w.current=Math.max(w.current,Y)},[N]);S.useEffect(()=>{var le;if(!v||!(r!=null&&r.playback_url)||!N)return;let se=!1;const te=()=>{j.current>0&&C(j.current,!0)},Y=()=>{document.visibilityState==="hidden"&&te()},de=()=>{te()},ie=()=>{var be;if(se||!b.current||!((be=window.playerjs)!=null&&be.Player))return;const pe=new window.playerjs.Player(b.current);pe.on("timeupdate",ye=>{const we=Math.floor(Number((ye==null?void 0:ye.seconds)??0));!Number.isFinite(we)||we<=0||(j.current=Math.max(j.current,we))}),pe.on("pause",()=>{j.current>0&&C(j.current)}),pe.on("ended",()=>{j.current>0&&C(j.current,!0)})},ae=document.querySelector('script[data-bunny-playerjs="true"]');if((le=window.playerjs)!=null&&le.Player)ie();else if(ae)ae.addEventListener("load",ie,{once:!0});else{const pe=document.createElement("script");pe.src="https://assets.mediadelivery.net/playerjs/playerjs-latest.min.js",pe.async=!0,pe.defer=!0,pe.dataset.bunnyPlayerjs="true",pe.onload=ie,document.body.appendChild(pe)}return document.addEventListener("visibilitychange",Y),window.addEventListener("beforeunload",de),()=>{se=!0,document.removeEventListener("visibilitychange",Y),window.removeEventListener("beforeunload",de),te()}},[v,r==null?void 0:r.playback_url,N,C]),S.useEffect(()=>{j.current=0,w.current=0},[N,t]),S.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(ie=>{document.querySelectorAll(ie).forEach(ae=>{ae.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()}},[]),S.useEffect(()=>{(async()=>{if(!t){f("Invalid share link"),u(!1);return}const{data:te,error:Y}=await G.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){f("Video not found or has been removed"),u(!1);return}n(te);try{await G.rpc("log_video_view",{p_video_id:te.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch(de){console.warn("Failed to log video view:",de)}if(te.owner_user_id){const{data:de}=await G.from("profiles").select("id, name, email, phone").eq("id",te.owner_user_id).single();if(de){o(de);try{const{data:ie}=await G.storage.from("avatars").list(`${te.owner_user_id}`);if(ie&&ie.length>0){const{data:ae}=G.storage.from("avatars").getPublicUrl(`${te.owner_user_id}/${ie[0].name}`);i(ae.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()},R=E5((r==null?void 0:r.page_template)||"default"),$=(r==null?void 0:r.recipient_name)||null,q=R.headerText($),V=`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(As,{className:"h-8 w-8 animate-spin text-primary"})});if(p||!r)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx(Ee,{className:"max-w-md w-full",children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(kn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Video Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:p||"This video is no longer available."})]})})});const X=R.id!=="default";return e.jsxs(e.Fragment,{children:[e.jsxs(ah,{children:[e.jsx("title",{children:q}),e.jsx("meta",{name:"description",content:R.subText}),e.jsx("meta",{property:"og:title",content:q}),e.jsx("meta",{property:"og:description",content:R.subText}),e.jsx("meta",{property:"og:type",content:"video.other"}),e.jsx("meta",{property:"og:url",content:V}),r.preview_url&&e.jsx("meta",{property:"og:image",content:r.preview_url}),!r.preview_url&&r.thumbnail_url&&e.jsx("meta",{property:"og:image",content:r.thumbnail_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{property:"og:video",content:r.playback_url}),e.jsx("meta",{property:"og:video:type",content:"text/html"}),e.jsx("meta",{property:"og:video:width",content:"1280"}),e.jsx("meta",{property:"og:video:height",content:"720"})]}),e.jsx("meta",{name:"twitter:card",content:"player"}),e.jsx("meta",{name:"twitter:title",content:q}),e.jsx("meta",{name:"twitter:description",content:R.subText}),r.preview_url&&e.jsx("meta",{name:"twitter:image",content:r.preview_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{name:"twitter:player",content:r.playback_url}),e.jsx("meta",{name:"twitter:player:width",content:"1280"}),e.jsx("meta",{name:"twitter:player:height",content:"720"})]})]}),e.jsxs("div",{className:Pt("min-h-screen flex items-center justify-center p-4 bg-gradient-to-b relative",R.gradientClasses),children:[X&&R.decorativeElement,e.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[X&&e.jsxs("div",{className:"text-center py-4 animate-fade-in",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:Pt("w-14 h-14 rounded-full flex items-center justify-center shadow-sm",R.accentColor==="primary"&&"bg-primary/10 text-primary",R.accentColor==="amber"&&"bg-amber-100 text-amber-600 dark:bg-amber-900/50 dark:text-amber-400",R.accentColor==="teal"&&"bg-teal-100 text-teal-600 dark:bg-teal-900/50 dark:text-teal-400",R.accentColor==="rose"&&"bg-rose-100 text-rose-600 dark:bg-rose-900/50 dark:text-rose-400",R.accentColor==="emerald"&&"bg-emerald-100 text-emerald-600 dark:bg-emerald-900/50 dark:text-emerald-400",R.accentColor==="yellow"&&"bg-yellow-100 text-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400",R.accentColor==="pink"&&"bg-pink-100 text-pink-600 dark:bg-pink-900/50 dark:text-pink-400",R.accentColor==="blue"&&"bg-blue-100 text-blue-600 dark:bg-blue-900/50 dark:text-blue-400",R.accentColor==="red"&&"bg-red-100 text-red-600 dark:bg-red-900/50 dark:text-red-400",R.accentColor==="orange"&&"bg-orange-100 text-orange-600 dark:bg-orange-900/50 dark:text-orange-400",R.accentColor==="green"&&"bg-green-100 text-green-600 dark:bg-green-900/50 dark:text-green-400",R.accentColor==="violet"&&"bg-violet-100 text-violet-600 dark:bg-violet-900/50 dark:text-violet-400",R.accentColor==="sky"&&"bg-sky-100 text-sky-600 dark:bg-sky-900/50 dark:text-sky-400"),children:e.jsx("div",{className:"scale-150",children:R.icon})})}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold mb-2",children:q}),e.jsx("p",{className:"text-muted-foreground",children:R.subText})]}),a&&e.jsxs("div",{className:"flex items-center gap-4 p-4 bg-card/90 backdrop-blur-sm rounded-lg border shadow-sm",children:[e.jsxs(gn,{className:"h-14 w-14 border-2 border-primary/20",children:[e.jsx(Ea,{src:l||void 0,alt:a.name||"Agent"}),e.jsx(xn,{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:X?"A special video from":"A personal video from"}),e.jsx("h2",{className:"text-lg font-semibold truncate",children:a.name||"Your Agent"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Real Estate Professional"})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[a.phone&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`tel:${a.phone}`,"aria-label":"Call agent",children:e.jsx(Zn,{className:"h-4 w-4"})})}),a.email&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`mailto:${a.email}`,"aria-label":"Email agent",children:e.jsx(_r,{className:"h-4 w-4"})})})]})]}),e.jsx(Ee,{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(kn,{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(ul,{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)})]})}),!X&&e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.title||"Video Message"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:v?"Enjoy the video!":"Click to play the video"})]}),!v&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(K,{size:"lg",onClick:()=>_(!0),className:"gap-2",children:[e.jsx(ul,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(tjt,{shareToken:t,agentName:(a==null?void 0:a.name)||null,hasContact:!!r.contact_id})]})]})]})}function Sjt(){return S.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(sht,{})}function Cjt(){const{token:t}=Mo();return S.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(As,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading video preview…"})]})})}const Mjt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Tjt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},n4={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Ajt(){var Y,de,ie,ae;const{slugOrId:t}=Mo(),[s]=Ec(),{data:r,isLoading:n}=o9e(t||""),a=l9e(),o=Gyt(),l=s.get("ref"),[i,d]=S.useState(""),[u,p]=S.useState(""),[f,v]=S.useState(""),[_,b]=S.useState(""),[j,w]=S.useState(!1),[N,C]=S.useState(!1),[A,I]=S.useState(null),[L,R]=S.useState(!1);S.useEffect(()=>{l&&o.mutate(l)},[l]);const $=le=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(le),q=async le=>{if(le.preventDefault(),!(!i.trim()||!f.trim()||!r)){w(!0);try{await a.mutateAsync({listingId:r.id,agentId:r.agent_id,firstName:i.trim(),lastName:u.trim(),email:f.trim(),phone:_.trim(),shareToken:l}),C(!0),fe.success("Thanks! The agent will be in touch soon.")}catch(pe){console.error("Lead submission error:",pe),fe.error(`Failed to submit: ${pe.message||"Please try again"}`)}finally{w(!1)}}},U=(r==null?void 0:r.photos)||[],V=U.find(le=>le.is_primary)||U[0],X=()=>{A!==null&&I(A===0?U.length-1:A-1)},se=()=>{A!==null&&I(A===U.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(vo,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:dne,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Un,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing may no longer be available."}),e.jsx(K,{asChild:!0,children:e.jsx(vo,{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(ah,{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":""} ${n4[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 ${n4[r.property_type]} in ${r.city}, ${r.state}. View photos, details, and contact the listing agent.`}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:`https://listings.relevelup.com/${r.slug||r.id}`}),V&&e.jsx("meta",{property:"og:image",content:V.photo_url}),V&&e.jsx("meta",{property:"og:image:alt",content:`${r.property_address||r.city} - ${n4[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}`}),V&&e.jsx("meta",{name:"twitter:image",content:V.photo_url}),e.jsx("meta",{name:"robots",content:"index, follow"}),e.jsx("meta",{name:"geo.region",content:`US-${r.state}`}),e.jsx("meta",{name:"geo.placename",content:r.city}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"RealEstateListing",name:r.property_address||`${r.city}, ${r.state} Home`,description:r.description||`${n4[r.property_type]} for sale in ${r.city}, ${r.state}`,url:`https://listings.relevelup.com/${r.slug||r.id}`,datePosted:r.created_at,image:U.map(le=>le.photo_url),address:{"@type":"PostalAddress",streetAddress:r.property_address||void 0,addressLocality:r.city,addressRegion:r.state,addressCountry:"US"},geo:r.neighborhood?{"@type":"GeoCoordinates",name:r.neighborhood}:void 0,offers:{"@type":"Offer",price:r.price,priceCurrency:"USD",availability:r.status==="sold"?"https://schema.org/SoldOut":r.status==="under_contract"?"https://schema.org/LimitedAvailability":"https://schema.org/InStock"},numberOfRooms:r.bedrooms||void 0,numberOfBathroomsTotal:r.bathrooms||void 0,floorSize:r.square_footage?{"@type":"QuantitativeValue",value:r.square_footage,unitCode:"FTK"}:void 0,yearBuilt:r.year_built||void 0,broker:r.agent?{"@type":"RealEstateAgent",name:r.agent.name,email:r.agent.email,worksFor:(de=r.agent.brokerage)!=null&&de.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(vo,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:dne,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs(vo,{to:"/public/listings",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(Ua,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),U.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>I(0),children:e.jsx("img",{src:V==null?void 0:V.photo_url,alt:`${r.property_address||r.city+", "+r.state} - ${n4[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:U.slice(1,5).map((le,pe)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>I(pe+1),children:[e.jsx("img",{src:le.photo_url,alt:`${r.property_address||r.city} - Photo ${pe+2} of ${U.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),pe===3&&U.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",U.length-5," more"]})]},le.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx(at,{className:`${Mjt[r.status]} text-white border-0`,children:Tjt[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(Ai,{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(N0,{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(Vx,{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(Zx,{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(on,{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(at,{variant:"secondary",children:[e.jsx(Aa,{className:"h-3 w-3 mr-1"}),n4[r.property_type]]}),r.lot_size&&e.jsxs(at,{variant:"secondary",children:["Lot: ",r.lot_size]}),r.has_hoa&&e.jsx(at,{variant:"secondary",children:"HOA"})]}),r.description&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"About This Property"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})]}),r.agent_notes&&r.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.agent_notes})]}),r.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:r.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[r.video&&r.video.playback_url&&e.jsx(Ee,{className:"overflow-hidden bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:e.jsxs(Oe,{className:"p-0",children:[e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>R(!0),children:[r.video.thumbnail_url?e.jsx("img",{src:r.video.thumbnail_url,alt:"Video thumbnail",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gradient-to-br from-primary/20 to-primary/30",children:e.jsx(kn,{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(ul,{className:"h-8 w-8 text-primary fill-primary ml-1"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs(K,{onClick:()=>R(!0),className:"w-full gap-2",size:"lg",children:[e.jsx(ul,{className:"h-4 w-4"}),"Watch Video Tour"]}),r.video.title&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2 text-center truncate",children:r.video.title})]})]})}),r.agent&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Xi,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-semibold text-lg",children:r.agent.name}),((ie=r.agent.brokerage)==null?void 0:ie.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.agent.brokerage.name})]})]}),e.jsxs(Ee,{className:"border-primary",children:[e.jsx(Lt,{children:e.jsx(zt,{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(_r,{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(ve,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Re,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:le=>d(le.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Re,{id:"lastName",type:"text",placeholder:"Doe",value:u,onChange:le=>p(le.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email *"}),e.jsx(Re,{id:"email",type:"email",placeholder:"you@example.com",value:f,onChange:le=>v(le.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone"}),e.jsx(Re,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:_,onChange:le=>b(le.target.value)})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:j,children:j?"Submitting...":"Get More Info"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})})]})]})]})]}),e.jsx(vs,{open:A!==null,onOpenChange:()=>I(null),children:e.jsxs(ys,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(Ss,{className:"sr-only",children:e.jsx(Ns,{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(Ur,{className:"h-5 w-5"})}),A!==null&&U[A]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:U[A].photo_url,alt:`Photo ${A+1}`,className:"w-full max-h-[80vh] object-contain"}),U.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:X,className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(zl,{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(Ha,{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," / ",U.length]})]})]})]})}),e.jsx(vs,{open:L,onOpenChange:R,children:e.jsxs(ys,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[e.jsx(Ss,{className:"sr-only",children:e.jsx(Ns,{children:"Video Tour"})}),e.jsx("button",{onClick:()=>R(!1),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Ur,{className:"h-5 w-5"})}),((ae=r==null?void 0:r.video)==null?void 0:ae.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 Ejt(){var o;const{slug:t}=Mo(),{data:s,isLoading:r,error:n}=h9e(t);if(S.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),S.useEffect(()=>{s!=null&&s.id&&ao(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(ah,{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(H1e,{card:s})]})}const j_e=S.createContext({});function k_e(t){const s=S.useRef(null);return s.current===null&&(s.current=t()),s.current}const Pjt=typeof window<"u",lqe=Pjt?S.useLayoutEffect:S.useEffect,Hoe=S.createContext(null);function N_e(t,s){t.indexOf(s)===-1&&t.push(s)}function Sne(t,s){const r=t.indexOf(s);r>-1&&t.splice(r,1)}const ny=(t,s,r)=>r>s?s:r{};const E_={},cqe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function dqe(t){return typeof t=="object"&&t!==null}const uqe=t=>/^0[^.\s]+$/u.test(t);function hqe(t){let s;return()=>(s===void 0&&(s=t()),s)}const gf=t=>t,Ijt=(t,s)=>r=>s(t(r)),TL=(...t)=>t.reduce(Ijt),QI=(t,s,r)=>{const n=s-t;return n===0?1:(r-t)/n};class C_e{constructor(){this.subscriptions=[]}add(s){return N_e(this.subscriptions,s),()=>Sne(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,af=t=>t/1e3;function mqe(t,s){return s?t*(1e3/s):0}const pqe=(t,s,r)=>(((1-3*r+3*s)*t+(3*r-6*s))*t+3*s)*t,Ljt=1e-7,Djt=12;function Ojt(t,s,r,n,a){let o,l,i=0;do l=s+(r-s)/2,o=pqe(l,n,a)-t,o>0?r=l:s=l;while(Math.abs(o)>Ljt&&++iOjt(o,0,1,t,r);return o=>o===0||o===1?o:pqe(a(o),s,n)}const fqe=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,gqe=t=>s=>1-t(1-s),xqe=AL(.33,1.53,.69,.99),M_e=gqe(xqe),yqe=fqe(M_e),vqe=t=>t>=1?1:(t*=2)<1?.5*M_e(t):.5*(2-Math.pow(2,-10*(t-1))),T_e=t=>1-Math.sin(Math.acos(t)),_qe=gqe(T_e),bqe=fqe(T_e),Rjt=AL(.42,0,1,1),Fjt=AL(0,0,.58,1),wqe=AL(.42,0,.58,1),zjt=t=>Array.isArray(t)&&typeof t[0]!="number",jqe=t=>Array.isArray(t)&&typeof t[0]=="number",Bjt={linear:gf,easeIn:Rjt,easeInOut:wqe,easeOut:Fjt,circIn:T_e,circInOut:bqe,circOut:_qe,backIn:M_e,backInOut:yqe,backOut:xqe,anticipate:vqe},$jt=t=>typeof t=="string",N3e=t=>{if(jqe(t)){S_e(t.length===4);const[s,r,n,a]=t;return AL(s,r,n,a)}else if($jt(t))return Bjt[t];return t},O8=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function qjt(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(p){l.has(p)&&(u.schedule(p),t()),p(i)}const u={schedule:(p,f=!1,v=!1)=>{const b=v&&a?r:n;return f&&l.add(p),b.add(p),p},cancel:p=>{n.delete(p),l.delete(p)},process:p=>{if(i=p,a){o=!0;return}a=!0;const f=r;r=n,n=f,r.forEach(d),r.clear(),a=!1,o&&(o=!1,u.process(p))}};return u}const Ujt=40;function kqe(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=O8.reduce((A,I)=>(A[I]=qjt(o),A),{}),{setup:i,read:d,resolveKeyframes:u,preUpdate:p,update:f,preRender:v,render:_,postRender:b}=l,j=()=>{const A=E_.useManualTiming,I=A?a.timestamp:performance.now();r=!1,A||(a.delta=n?1e3/60:Math.max(Math.min(I-a.timestamp,Ujt),1)),a.timestamp=I,a.isProcessing=!0,i.process(a),d.process(a),u.process(a),p.process(a),f.process(a),v.process(a),_.process(a),b.process(a),a.isProcessing=!1,r&&s&&(n=!1,t(j))},w=()=>{r=!0,n=!0,a.isProcessing||t(j)};return{schedule:O8.reduce((A,I)=>{const L=l[I];return A[I]=(R,$=!1,q=!1)=>(r||w(),L.schedule(R,$,q)),A},{}),cancel:A=>{for(let I=0;I(are===void 0&&Ph.set(Eu.isProcessing||E_.useManualTiming?Eu.timestamp:performance.now()),are),set:t=>{are=t,queueMicrotask(Vjt)}},Nqe=t=>s=>typeof s=="string"&&s.startsWith(t),Sqe=Nqe("--"),Hjt=Nqe("var(--"),A_e=t=>Hjt(t)?Wjt.test(t.split("/*")[0].trim()):!1,Wjt=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function S3e(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const vM={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},JI={...vM,transform:t=>ny(0,1,t)},R8={...vM,default:1},ZP=t=>Math.round(t*1e5)/1e5,E_e=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Gjt(t){return t==null}const Kjt=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,P_e=(t,s)=>r=>!!(typeof r=="string"&&Kjt.test(r)&&r.startsWith(t)||s&&!Gjt(r)&&Object.prototype.hasOwnProperty.call(r,s)),Cqe=(t,s,r)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(E_e);return{[t]:parseFloat(a),[s]:parseFloat(o),[r]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},Zjt=t=>ny(0,255,t),Vhe={...vM,transform:t=>Math.round(Zjt(t))},Ak={test:P_e("rgb","red"),parse:Cqe("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+Vhe.transform(t)+", "+Vhe.transform(s)+", "+Vhe.transform(r)+", "+ZP(JI.transform(n))+")"};function Yjt(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 Gge={test:P_e("#"),parse:Yjt,transform:Ak.transform},EL=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),t1=EL("deg"),Jx=EL("%"),Qn=EL("px"),Xjt=EL("vh"),Qjt=EL("vw"),C3e={...Jx,parse:t=>Jx.parse(t)/100,transform:t=>Jx.transform(t*100)},F4={test:P_e("hsl","hue"),parse:Cqe("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+Jx.transform(ZP(s))+", "+Jx.transform(ZP(r))+", "+ZP(JI.transform(n))+")"},jd={test:t=>Ak.test(t)||Gge.test(t)||F4.test(t),parse:t=>Ak.test(t)?Ak.parse(t):F4.test(t)?F4.parse(t):Gge.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Ak.transform(t):F4.transform(t),getAnimatableNone:t=>{const s=jd.parse(t);return s.alpha=0,jd.transform(s)}},Jjt=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function ekt(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(E_e))==null?void 0:s.length)||0)+(((r=t.match(Jjt))==null?void 0:r.length)||0)>0}const Mqe="number",Tqe="color",tkt="var",skt="var(",M3e="${}",rkt=/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(rkt,d=>(jd.test(d)?(n.color.push(o),a.push(Tqe),r.push(jd.parse(d))):d.startsWith(skt)?(n.var.push(o),a.push(tkt),r.push(d)):(n.number.push(o),a.push(Mqe),r.push(parseFloat(d))),++o,M3e)).split(M3e);return{values:r,split:i,indexes:n,types:a}}function nkt(t){return v3(t).values}function Aqe({split:t,types:s}){const r=t.length;return n=>{let a="";for(let o=0;otypeof t=="number"?0:jd.test(t)?jd.getAnimatableNone(t):t,okt=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:ikt(t);function lkt(t){const s=v3(t);return Aqe(s)(s.values.map((n,a)=>okt(n,s.split[a])))}const qg={test:ekt,parse:nkt,createTransformer:akt,getAnimatableNone:lkt};function Hhe(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 ckt({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=Hhe(d,i,t+1/3),o=Hhe(d,i,t),l=Hhe(d,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function Cne(t,s){return r=>r>0?s:t}const tc=(t,s,r)=>t+(s-t)*r,Whe=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},dkt=[Gge,Ak,F4],ukt=t=>dkt.find(s=>s.test(t));function T3e(t){const s=ukt(t);if(!s)return!1;let r=s.parse(t);return s===F4&&(r=ckt(r)),r}const A3e=(t,s)=>{const r=T3e(t),n=T3e(s);if(!r||!n)return Cne(t,s);const a={...r};return o=>(a.red=Whe(r.red,n.red,o),a.green=Whe(r.green,n.green,o),a.blue=Whe(r.blue,n.blue,o),a.alpha=tc(r.alpha,n.alpha,o),Ak.transform(a))},Kge=new Set(["none","hidden"]);function hkt(t,s){return Kge.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function mkt(t,s){return r=>tc(t,s,r)}function I_e(t){return typeof t=="number"?mkt:typeof t=="string"?A_e(t)?Cne:jd.test(t)?A3e:gkt:Array.isArray(t)?Eqe:typeof t=="object"?jd.test(t)?A3e:pkt:Cne}function Eqe(t,s){const r=[...t],n=r.length,a=t.map((o,l)=>I_e(o)(o,s[l]));return o=>{for(let l=0;l{for(const o in n)r[o]=n[o](a);return r}}function fkt(t,s){const r=[],n={color:0,var:0,number:0};for(let a=0;a{const r=qg.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?Kge.has(t)&&!a.values.length||Kge.has(s)&&!n.values.length?hkt(t,s):TL(Eqe(fkt(n,a),a.values),r):Cne(t,s)};function Pqe(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?tc(t,s,r):I_e(t)(t,s)}const xkt=t=>{const s=({timestamp:r})=>t(r);return{start:(r=!0)=>gl.update(s,r),stop:()=>P_(s),now:()=>Eu.isProcessing?Eu.timestamp:Ph.now()}},Iqe=(t,s,r=10)=>{let n="";const a=Math.max(Math.round(s/r),2);for(let o=0;o=Mne?1/0:s}function ykt(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(L_e(n),Mne);return{type:"keyframes",ease:o=>n.next(a*o).value/s,duration:af(a)}}const Rc={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 Zge(t,s){return t*Math.sqrt(1-s*s)}const vkt=12;function _kt(t,s,r){let n=r;for(let a=1;a{const p=u*l,f=p*t,v=p-r,_=Zge(u,l),b=Math.exp(-f);return Ghe-v/_*b},o=u=>{const f=u*l*t,v=f*r+r,_=Math.pow(l,2)*Math.pow(u,2)*t,b=Math.exp(-f),j=Zge(Math.pow(u,2),l);return(-a(u)+Ghe>0?-1:1)*((v-_)*b)/j}):(a=u=>{const p=Math.exp(-u*t),f=(u-r)*t+1;return-Ghe+p*f},o=u=>{const p=Math.exp(-u*t),f=(r-u)*(t*t);return p*f});const i=5/t,d=_kt(a,o,i);if(t=gp(t),isNaN(d))return{stiffness:Rc.stiffness,damping:Rc.damping,duration:t};{const u=Math.pow(d,2)*n;return{stiffness:u,damping:l*2*Math.sqrt(n*u),duration:t}}}const wkt=["duration","bounce"],jkt=["stiffness","damping","mass"];function E3e(t,s){return s.some(r=>t[r]!==void 0)}function kkt(t){let s={velocity:Rc.velocity,stiffness:Rc.stiffness,damping:Rc.damping,mass:Rc.mass,isResolvedFromDuration:!1,...t};if(!E3e(t,jkt)&&E3e(t,wkt))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:Rc.mass,stiffness:a,damping:o}}else{const r=bkt({...t,velocity:0});s={...s,...r,mass:Rc.mass},s.isResolvedFromDuration=!0}return s}function Tne(t=Rc.visualDuration,s=Rc.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:p,duration:f,velocity:v,isResolvedFromDuration:_}=kkt({...r,velocity:-af(r.velocity||0)}),b=v||0,j=u/(2*Math.sqrt(d*p)),w=l-o,N=af(Math.sqrt(d/p)),C=Math.abs(w)<5;n||(n=C?Rc.restSpeed.granular:Rc.restSpeed.default),a||(a=C?Rc.restDelta.granular:Rc.restDelta.default);let A,I,L,R,$,q;if(j<1)L=Zge(N,j),R=(b+j*N*w)/L,A=V=>{const X=Math.exp(-j*N*V);return l-X*(R*Math.sin(L*V)+w*Math.cos(L*V))},$=j*N*R+w*L,q=j*N*w-R*L,I=V=>Math.exp(-j*N*V)*($*Math.sin(L*V)+q*Math.cos(L*V));else if(j===1){A=X=>l-Math.exp(-N*X)*(w+(b+N*w)*X);const V=b+N*w;I=X=>Math.exp(-N*X)*(N*V*X-b)}else{const V=N*Math.sqrt(j*j-1);A=Y=>{const de=Math.exp(-j*N*Y),ie=Math.min(V*Y,300);return l-de*((b+j*N*w)*Math.sinh(ie)+V*w*Math.cosh(ie))/V};const X=(b+j*N*w)/V,se=j*N*X-w*V,te=j*N*w-X*V;I=Y=>{const de=Math.exp(-j*N*Y),ie=Math.min(V*Y,300);return de*(se*Math.sinh(ie)+te*Math.cosh(ie))}}const U={calculatedDuration:_&&f||null,velocity:V=>gp(I(V)),next:V=>{if(!_&&j<1){const se=Math.exp(-j*N*V),te=Math.sin(L*V),Y=Math.cos(L*V),de=l-se*(R*te+w*Y),ie=gp(se*($*te+q*Y));return i.done=Math.abs(ie)<=n&&Math.abs(l-de)<=a,i.value=i.done?l:de,i}const X=A(V);if(_)i.done=V>=f;else{const se=gp(I(V));i.done=Math.abs(se)<=n&&Math.abs(l-X)<=a}return i.value=i.done?l:X,i},toString:()=>{const V=Math.min(L_e(U),Mne),X=Iqe(se=>U.next(V*se).value,V,30);return V+"ms "+X},toTransition:()=>{}};return U}Tne.applyToOptions=t=>{const s=ykt(t,100,Tne);return t.ease=s.ease,t.duration=gp(s.duration),t.type="keyframes",t};const Nkt=5;function Lqe(t,s,r){const n=Math.max(s-Nkt,0);return mqe(r-t(n),s-n)}function Yge({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:p}){const f=t[0],v={done:!1,value:f},_=q=>i!==void 0&&qd,b=q=>i===void 0?d:d===void 0||Math.abs(i-q)-j*Math.exp(-q/n),A=q=>N+C(q),I=q=>{const U=C(q),V=A(q);v.done=Math.abs(U)<=u,v.value=v.done?N:V};let L,R;const $=q=>{_(v.value)&&(L=q,R=Tne({keyframes:[v.value,b(v.value)],velocity:Lqe(A,q,v.value),damping:a,stiffness:o,restDelta:u,restSpeed:p}))};return $(0),{calculatedDuration:null,next:q=>{let U=!1;return!R&&L===void 0&&(U=!0,I(q),$(q)),L!==void 0&&q>=L?R.next(q-L):(!U&&I(q),v)}}}function Skt(t,s,r){const n=[],a=r||E_.mix||Pqe,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=Skt(s,n,a),d=i.length,u=p=>{if(l&&p1)for(;fu(ny(t[0],t[o-1],p)):u}function Mkt(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=QI(0,s,n);t.push(tc(r,1,a))}}function Tkt(t){const s=[0];return Mkt(s,t.length-1),s}function Akt(t,s){return t.map(r=>r*s)}function Ekt(t,s){return t.map(()=>s||wqe).splice(0,t.length-1)}function YP({duration:t=300,keyframes:s,times:r,ease:n="easeInOut"}){const a=zjt(n)?n.map(N3e):N3e(n),o={done:!1,value:s[0]},l=Akt(r&&r.length===s.length?r:Tkt(s),t),i=Ckt(l,s,{ease:Array.isArray(a)?a:Ekt(s,a)});return{calculatedDuration:t,next:d=>(o.value=i(d),o.done=d>=t,o)}}const Pkt=t=>t!==null;function Woe(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(Pkt),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const Ikt={decay:Yge,inertia:Yge,tween:YP,keyframes:YP,spring:Tne};function Dqe(t){typeof t.type=="string"&&(t.type=Ikt[t.type])}class D_e{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 Lkt=t=>t/100;class Ane extends D_e{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!==Ph.now()&&this.tick(Ph.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;Dqe(s);const{type:r=YP,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=s;let{keyframes:i}=s;const d=r||YP;d!==YP&&typeof i[0]!="number"&&(this.mixKeyframes=TL(Lkt,Pqe(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=L_e(u));const{calculatedDuration:p}=u;this.calculatedDuration=p,this.resolvedDuration=p+a,this.totalDuration=this.resolvedDuration*(n+1)-a,this.generator=u}updateTime(s){const r=Math.round(s-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=r}tick(s,r=!1){const{generator:n,totalDuration:a,mixKeyframes:o,mirroredGenerator:l,resolvedDuration:i,calculatedDuration:d}=this;if(this.startTime===null)return n.next(0);const{delay:u=0,keyframes:p,repeat:f,repeatType:v,repeatDelay:_,type:b,onUpdate:j,finalKeyframe:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-a/this.speed,this.startTime)),r?this.currentTime=s:this.updateTime(s);const N=this.currentTime-u*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?N<0:N>a;this.currentTime=Math.max(N,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let A=this.currentTime,I=n;if(f){const q=Math.min(this.currentTime,a)/i;let U=Math.floor(q),V=q%1;!V&&q>=1&&(V=1),V===1&&U--,U=Math.min(U,f+1),!!(U%2)&&(v==="reverse"?(V=1-V,_&&(V-=_/i)):v==="mirror"&&(I=l)),A=ny(0,1,V)*i}let L;C?(this.delayState.value=p[0],L=this.delayState):L=I.next(A),o&&!C&&(L.value=o(L.value));let{done:R}=L;!C&&d!==null&&(R=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const $=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&R);return $&&b!==Yge&&(L.value=Woe(p,this.options,w,this.speed)),j&&j(L.value),$&&this.finish(),L}then(s,r){return this.finished.then(s,r)}get duration(){return af(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+af(s)}get time(){return af(this.currentTime)}set time(s){s=gp(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 Lqe(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(Ph.now()),this.playbackSpeed=s,r&&this.driver&&(this.time=af(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:s=xkt,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(Ph.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 Dkt(t){for(let s=1;st*180/Math.PI,Xge=t=>{const s=Ek(Math.atan2(t[1],t[0]));return Qge(s)},Okt={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Xge,rotateZ:Xge,skewX:t=>Ek(Math.atan(t[1])),skewY:t=>Ek(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Qge=t=>(t=t%360,t<0&&(t+=360),t),P3e=Xge,I3e=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),L3e=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Rkt={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:I3e,scaleY:L3e,scale:t=>(I3e(t)+L3e(t))/2,rotateX:t=>Qge(Ek(Math.atan2(t[6],t[5]))),rotateY:t=>Qge(Ek(Math.atan2(-t[2],t[0]))),rotateZ:P3e,rotate:P3e,skewX:t=>Ek(Math.atan(t[4])),skewY:t=>Ek(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Jge(t){return t.includes("scale")?1:0}function exe(t,s){if(!t||t==="none")return Jge(s);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(r)n=Rkt,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=Okt,a=i}if(!a)return Jge(s);const o=n[s],l=a[1].split(",").map(zkt);return typeof o=="function"?o(l):l[o]}const Fkt=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return exe(r,s)};function zkt(t){return parseFloat(t.trim())}const _M=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],bM=new Set(_M),D3e=t=>t===vM||t===Qn,Bkt=new Set(["x","y","z"]),$kt=_M.filter(t=>!Bkt.has(t));function qkt(t){const s=[];return $kt.forEach(r=>{const n=t.getValue(r);n!==void 0&&(s.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),s}const F1={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})=>exe(s,"x"),y:(t,{transform:s})=>exe(s,"y")};F1.translateX=F1.x;F1.translateY=F1.y;const hN=new Set;let txe=!1,sxe=!1,rxe=!1;function Oqe(){if(sxe){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=qkt(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)})}sxe=!1,txe=!1,hN.forEach(t=>t.complete(rxe)),hN.clear()}function Rqe(){hN.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(sxe=!0)})}function Ukt(){rxe=!0,Rqe(),Oqe(),rxe=!1}class O_e{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),txe||(txe=!0,gl.read(Rqe),gl.resolveKeyframes(Oqe))):(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])}Dkt(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 Vkt=t=>t.startsWith("--");function Fqe(t,s,r){Vkt(s)?t.style.setProperty(s,r):t.style[s]=r}const Hkt={};function zqe(t,s){const r=hqe(t);return()=>Hkt[s]??r()}const Wkt=zqe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),Bqe=zqe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),TE=([t,s,r,n])=>`cubic-bezier(${t}, ${s}, ${r}, ${n})`,O3e={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:TE([0,.65,.55,1]),circOut:TE([.55,0,1,.45]),backIn:TE([.31,.01,.66,-.59]),backOut:TE([.33,1.53,.69,.99])};function $qe(t,s){if(t)return typeof t=="function"?Bqe()?Iqe(t,s):"ease-out":jqe(t)?TE(t):Array.isArray(t)?t.map(r=>$qe(r,s)||O3e.easeOut):O3e[t]}function Gkt(t,s,r,{delay:n=0,duration:a=300,repeat:o=0,repeatType:l="loop",ease:i="easeOut",times:d}={},u=void 0){const p={[s]:r};d&&(p.offset=d);const f=$qe(i,a);Array.isArray(f)&&(p.easing=f);const v={delay:n,duration:a,easing:Array.isArray(f)?"linear":f,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return u&&(v.pseudoElement=u),t.animate(p,v)}function qqe(t){return typeof t=="function"&&"applyToOptions"in t}function Kkt({type:t,...s}){return qqe(t)&&Bqe()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class Uqe extends D_e{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,S_e(typeof s.type!="string");const u=Kkt(s);this.animation=Gkt(r,n,a,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=Woe(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(p),Fqe(r,n,p),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 af(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+af(s)}get time(){return af(Number(this.animation.currentTime)||0)}set time(s){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=gp(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&&Wkt()?(this.animation.timeline=s,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),gf):a(this)}}const Vqe={anticipate:vqe,backInOut:yqe,circInOut:bqe};function Zkt(t){return t in Vqe}function Ykt(t){typeof t.ease=="string"&&Zkt(t.ease)&&(t.ease=Vqe[t.ease])}const Khe=10;class Xkt extends Uqe{constructor(s){Ykt(s),Dqe(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 Ane({...l,autoplay:!1}),d=Math.max(Khe,Ph.now()-this.startTime),u=ny(0,Khe,d-Khe),p=i.sample(d).value,{name:f}=this.options;o&&f&&Fqe(o,f,p),r.setWithVelocity(i.sample(Math.max(0,d-u)).value,p,u),i.stop()}}const R3e=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(qg.test(t)||t==="0")&&!t.startsWith("url("));function Qkt(t){const s=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function nNt(t){var f;const{motionValue:s,name:r,repeatDelay:n,repeatType:a,damping:o,type:l,keyframes:i}=t;if(!(((f=s==null?void 0:s.owner)==null?void 0:f.current)instanceof HTMLElement))return!1;const{onUpdate:u,transformTemplate:p}=s.owner.getProps();return rNt()&&r&&(Hqe.has(r)||sNt.has(r)&&tNt(i))&&(r!=="transform"||!p)&&!u&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const aNt=40;class iNt extends D_e{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:p,...f}){var b;super(),this.stop=()=>{var j,w;this._animation&&(this._animation.stop(),(j=this.stopTimeline)==null||j.call(this)),(w=this.keyframeResolver)==null||w.cancel()},this.createdAt=Ph.now();const v={autoplay:s,delay:r,type:n,repeat:a,repeatDelay:o,repeatType:l,name:d,motionValue:u,element:p,...f},_=(p==null?void 0:p.KeyframeResolver)||O_e;this.keyframeResolver=new _(i,(j,w,N)=>this.onKeyframesResolved(j,w,v,!N),d,u,p),(b=this.keyframeResolver)==null||b.scheduleResolve()}onKeyframesResolved(s,r,n,a){var N,C;this.keyframeResolver=void 0;const{name:o,type:l,velocity:i,delay:d,isHandoff:u,onUpdate:p}=n;this.resolvedAt=Ph.now();let f=!0;Jkt(s,o,l,i)||(f=!1,(E_.instantAnimations||!d)&&(p==null||p(Woe(s,n,r))),s[0]=s[s.length-1],nxe(n),n.repeat=0);const _={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>aNt?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},b=f&&!u&&nNt(_),j=(C=(N=_.motionValue)==null?void 0:N.owner)==null?void 0:C.current;let w;if(b)try{w=new Xkt({..._,element:j})}catch{w=new Ane(_)}else w=new Ane(_);w.finished.then(()=>{this.notifyFinished()}).catch(gf),this.pendingTimeline&&(this.stopTimeline=w.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=w}get finished(){return this._animation?this.animation.finished:this._finished}then(s,r){return this.finished.finally(s).then(()=>{})}get animation(){var s;return this._animation||((s=this.keyframeResolver)==null||s.resume(),Ukt()),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 Wqe(t,s,r,n=0,a=1){const o=Array.from(t).sort((u,p)=>u.sortNodePosition(p)).indexOf(s),l=t.size,i=(l-1)*n;return typeof r=="function"?r(o,l):a===1?o*n:i-o*n}const oNt=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function lNt(t){const s=oNt.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}function Gqe(t,s,r=1){const[n,a]=lNt(t);if(!n)return;const o=window.getComputedStyle(s).getPropertyValue(n);if(o){const l=o.trim();return cqe(l)?parseFloat(l):l}return A_e(a)?Gqe(a,s,r+1):a}const cNt={type:"spring",stiffness:500,damping:25,restSpeed:10},dNt=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),uNt={type:"keyframes",duration:.8},hNt={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},mNt=(t,{keyframes:s})=>s.length>2?uNt:bM.has(t)?t.startsWith("scale")?dNt(s[1]):cNt:hNt;function Kqe(t,s){if(t!=null&&t.inherit&&s){const{inherit:r,...n}=t;return{...s,...n}}return t}function R_e(t,s){const r=(t==null?void 0:t[s])??(t==null?void 0:t.default)??t;return r!==t?Kqe(r,t):r}const pNt=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function fNt(t){for(const s in t)if(!pNt.has(s))return!0;return!1}const F_e=(t,s,r,n={},a,o)=>l=>{const i=R_e(n,t)||{},d=i.delay||n.delay||0;let{elapsed:u=0}=n;u=u-gp(d);const p={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};fNt(i)||Object.assign(p,mNt(t,p)),p.duration&&(p.duration=gp(p.duration)),p.repeatDelay&&(p.repeatDelay=gp(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let f=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(nxe(p),p.delay===0&&(f=!0)),(E_.instantAnimations||E_.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(f=!0,nxe(p),p.delay=0),p.allowFlatten=!i.type&&!i.ease,f&&!o&&s.get()!==void 0){const v=Woe(p.keyframes,i);if(v!==void 0){gl.update(()=>{p.onUpdate(v),p.onComplete()});return}}return i.isSync?new Ane(p):new iNt(p)};function F3e(t){const s=[{},{}];return t==null||t.values.forEach((r,n)=>{s[0][n]=r.get(),s[1][n]=r.getVelocity()}),s}function z_e(t,s,r,n){if(typeof s=="function"){const[a,o]=F3e(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]=F3e(n);s=s(r!==void 0?r:t.custom,a,o)}return s}function mN(t,s,r){const n=t.getProps();return z_e(n,s,r!==void 0?r:n.custom,t)}const Zqe=new Set(["width","height","top","left","right","bottom",..._M]),z3e=30,gNt=t=>!isNaN(parseFloat(t));class xNt{constructor(s,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=Ph.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=Ph.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=gNt(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 C_e);const n=this.events[s].add(r);return s==="change"?()=>{n(),gl.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=Ph.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>z3e)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,z3e);return mqe(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 _3(t,s){return new xNt(t,s)}const axe=t=>Array.isArray(t);function yNt(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,_3(r))}function vNt(t){return axe(t)?t[t.length-1]||0:t}function _Nt(t,s){const r=mN(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=vNt(o[l]);yNt(t,l,i)}}const Lu=t=>!!(t&&t.getVelocity);function bNt(t){return!!(Lu(t)&&t.add)}function ixe(t,s){const r=t.getValue("willChange");if(bNt(r))return r.add(s);if(!r&&E_.WillChange){const n=new E_.WillChange("auto");t.addValue("willChange",n),n.add(s)}}function B_e(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const wNt="framerAppearId",Yqe="data-"+B_e(wNt);function Xqe(t){return t.props[Yqe]}function jNt({protectedKeys:t,needsAnimating:s},r){const n=t.hasOwnProperty(r)&&s[r]!==!0;return s[r]=!1,n}function Qqe(t,s,{delay:r=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=s;const d=t.getDefaultTransition();o=o?Kqe(o,d):d;const u=o==null?void 0:o.reduceMotion;n&&(o=n);const p=[],f=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||f&&jNt(f,v))continue;const j={delay:r,...R_e(o||{},v)},w=_.get();if(w!==void 0&&!_.isAnimating()&&!Array.isArray(b)&&b===w&&!j.velocity){gl.update(()=>_.set(b));continue}let N=!1;if(window.MotionHandoffAnimation){const I=Xqe(t);if(I){const L=window.MotionHandoffAnimation(I,v,gl);L!==null&&(j.startTime=L,N=!0)}}ixe(t,v);const C=u??t.shouldReduceMotion;_.start(F_e(v,_,b,C&&Zqe.has(v)?{type:!1}:j,t,N));const A=_.animation;A&&p.push(A)}if(l){const v=()=>gl.update(()=>{l&&_Nt(t,l)});p.length?Promise.all(p).then(v):v()}return p}function oxe(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(Qqe(t,n,r)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:p=0,staggerChildren:f,staggerDirection:v}=a;return kNt(t,s,u,p,f,v,r)}:()=>Promise.resolve(),{when:i}=a;if(i){const[u,p]=i==="beforeChildren"?[o,l]:[l,o];return u().then(()=>p())}else return Promise.all([o(),l(r.delay)])}function kNt(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(oxe(d,s,{...l,delay:r+(typeof n=="function"?0:n)+Wqe(t.variantChildren,d,n,a,o)}).then(()=>d.notify("AnimationComplete",s)));return Promise.all(i)}function NNt(t,s,r={}){t.notify("AnimationStart",s);let n;if(Array.isArray(s)){const a=s.map(o=>oxe(t,o,r));n=Promise.all(a)}else if(typeof s=="string")n=oxe(t,s,r);else{const a=typeof s=="function"?mN(t,s,r.custom):s;n=Promise.all(Qqe(t,a,r))}return n.then(()=>{t.notify("AnimationComplete",s)})}const SNt={test:t=>t==="auto",parse:t=>t},Jqe=t=>s=>s.test(t),eUe=[vM,Qn,Jx,t1,Qjt,Xjt,SNt],B3e=t=>eUe.find(Jqe(t));function CNt(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||uqe(t):!0}const MNt=new Set(["brightness","contrast","saturate","opacity"]);function TNt(t){const[s,r]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[n]=r.match(E_e)||[];if(!n)return t;const a=r.replace(n,"");let o=MNt.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const ANt=/\b([a-z-]*)\(.*?\)/gu,lxe={...qg,getAnimatableNone:t=>{const s=t.match(ANt);return s?s.map(TNt).join(" "):t}},cxe={...qg,getAnimatableNone:t=>{const s=qg.parse(t);return qg.createTransformer(t)(s.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},$3e={...vM,transform:Math.round},ENt={rotate:t1,rotateX:t1,rotateY:t1,rotateZ:t1,scale:R8,scaleX:R8,scaleY:R8,scaleZ:R8,skew:t1,skewX:t1,skewY:t1,distance:Qn,translateX:Qn,translateY:Qn,translateZ:Qn,x:Qn,y:Qn,z:Qn,perspective:Qn,transformPerspective:Qn,opacity:JI,originX:C3e,originY:C3e,originZ:Qn},$_e={borderWidth:Qn,borderTopWidth:Qn,borderRightWidth:Qn,borderBottomWidth:Qn,borderLeftWidth:Qn,borderRadius:Qn,borderTopLeftRadius:Qn,borderTopRightRadius:Qn,borderBottomRightRadius:Qn,borderBottomLeftRadius:Qn,width:Qn,maxWidth:Qn,height:Qn,maxHeight:Qn,top:Qn,right:Qn,bottom:Qn,left:Qn,inset:Qn,insetBlock:Qn,insetBlockStart:Qn,insetBlockEnd:Qn,insetInline:Qn,insetInlineStart:Qn,insetInlineEnd:Qn,padding:Qn,paddingTop:Qn,paddingRight:Qn,paddingBottom:Qn,paddingLeft:Qn,paddingBlock:Qn,paddingBlockStart:Qn,paddingBlockEnd:Qn,paddingInline:Qn,paddingInlineStart:Qn,paddingInlineEnd:Qn,margin:Qn,marginTop:Qn,marginRight:Qn,marginBottom:Qn,marginLeft:Qn,marginBlock:Qn,marginBlockStart:Qn,marginBlockEnd:Qn,marginInline:Qn,marginInlineStart:Qn,marginInlineEnd:Qn,fontSize:Qn,backgroundPositionX:Qn,backgroundPositionY:Qn,...ENt,zIndex:$3e,fillOpacity:JI,strokeOpacity:JI,numOctaves:$3e},PNt={...$_e,color:jd,backgroundColor:jd,outlineColor:jd,fill:jd,stroke:jd,borderColor:jd,borderTopColor:jd,borderRightColor:jd,borderBottomColor:jd,borderLeftColor:jd,filter:lxe,WebkitFilter:lxe,mask:cxe,WebkitMask:cxe},tUe=t=>PNt[t],INt=new Set([lxe,cxe]);function sUe(t,s){let r=tUe(t);return INt.has(r)||(r=qg),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const LNt=new Set(["auto","none","0"]);function DNt(t,s,r){let n=0,a;for(;n{s.getValue(d).set(u)}),this.resolveNoneKeyframes()}}function rUe(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 nUe=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function ire(t){return dqe(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:q_e}=kqe(queueMicrotask,!1),fg={x:!1,y:!1};function aUe(){return fg.x||fg.y}function RNt(t){return t==="x"||t==="y"?fg[t]?null:(fg[t]=!0,()=>{fg[t]=!1}):fg.x||fg.y?null:(fg.x=fg.y=!0,()=>{fg.x=fg.y=!1})}function iUe(t,s){const r=rUe(t),n=new AbortController,a={passive:!0,...s,signal:n.signal};return[r,a,()=>n.abort()]}function FNt(t){return!(t.pointerType==="touch"||aUe())}function zNt(t,s,r={}){const[n,a,o]=iUe(t,r);return n.forEach(l=>{let i=!1,d=!1,u;const p=()=>{l.removeEventListener("pointerleave",b)},f=w=>{u&&(u(w),u=void 0),p()},v=w=>{i=!1,window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v),d&&(d=!1,f(w))},_=()=>{i=!0,window.addEventListener("pointerup",v,a),window.addEventListener("pointercancel",v,a)},b=w=>{if(w.pointerType!=="touch"){if(i){d=!0;return}f(w)}},j=w=>{if(!FNt(w))return;d=!1;const N=s(l,w);typeof N=="function"&&(u=N,l.addEventListener("pointerleave",b,a))};l.addEventListener("pointerenter",j,a),l.addEventListener("pointerdown",_,a)}),o}const oUe=(t,s)=>s?t===s?!0:oUe(t,s.parentElement):!1,U_e=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,BNt=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function $Nt(t){return BNt.has(t.tagName)||t.isContentEditable===!0}const qNt=new Set(["INPUT","SELECT","TEXTAREA"]);function UNt(t){return qNt.has(t.tagName)||t.isContentEditable===!0}const ore=new WeakSet;function q3e(t){return s=>{s.key==="Enter"&&t(s)}}function Zhe(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const VNt=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=q3e(()=>{if(ore.has(r))return;Zhe(r,"down");const a=q3e(()=>{Zhe(r,"up")}),o=()=>Zhe(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 U3e(t){return U_e(t)&&!aUe()}const V3e=new WeakSet;function HNt(t,s,r={}){const[n,a,o]=iUe(t,r),l=i=>{const d=i.currentTarget;if(!U3e(i)||V3e.has(i))return;ore.add(d),r.stopPropagation&&V3e.add(i);const u=s(d,i),p=(_,b)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",v),ore.has(d)&&ore.delete(d),U3e(_)&&typeof u=="function"&&u(_,{success:b})},f=_=>{p(_,d===window||d===document||r.useGlobalTarget||oUe(d,_.target))},v=_=>{p(_,!1)};window.addEventListener("pointerup",f,a),window.addEventListener("pointercancel",v,a)};return n.forEach(i=>{(r.useGlobalTarget?window:i).addEventListener("pointerdown",l,a),ire(i)&&(i.addEventListener("focus",u=>VNt(u,a)),!$Nt(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function V_e(t){return dqe(t)&&"ownerSVGElement"in t}const lre=new WeakMap;let s1;const lUe=(t,s,r)=>(n,a)=>a&&a[0]?a[0][t+"Size"]:V_e(n)&&"getBBox"in n?n.getBBox()[s]:n[r],WNt=lUe("inline","width","offsetWidth"),GNt=lUe("block","height","offsetHeight");function KNt({target:t,borderBoxSize:s}){var r;(r=lre.get(t))==null||r.forEach(n=>{n(t,{get width(){return WNt(t,s)},get height(){return GNt(t,s)}})})}function ZNt(t){t.forEach(KNt)}function YNt(){typeof ResizeObserver>"u"||(s1=new ResizeObserver(ZNt))}function XNt(t,s){s1||YNt();const r=rUe(t);return r.forEach(n=>{let a=lre.get(n);a||(a=new Set,lre.set(n,a)),a.add(s),s1==null||s1.observe(n)}),()=>{r.forEach(n=>{const a=lre.get(n);a==null||a.delete(s),a!=null&&a.size||s1==null||s1.unobserve(n)})}}const cre=new Set;let z4;function QNt(){z4=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};cre.forEach(s=>s(t))},window.addEventListener("resize",z4)}function JNt(t){return cre.add(t),z4||QNt(),()=>{cre.delete(t),!cre.size&&typeof z4=="function"&&(window.removeEventListener("resize",z4),z4=void 0)}}function H3e(t,s){return typeof t=="function"?JNt(t):XNt(t,s)}function eSt(t){return V_e(t)&&t.tagName==="svg"}const tSt=[...eUe,jd,qg],sSt=t=>tSt.find(Jqe(t)),W3e=()=>({translate:0,scale:1,origin:0,originPoint:0}),B4=()=>({x:W3e(),y:W3e()}),G3e=()=>({min:0,max:0}),Rd=()=>({x:G3e(),y:G3e()}),rSt=new WeakMap;function Goe(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function e6(t){return typeof t=="string"||Array.isArray(t)}const H_e=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],W_e=["initial",...H_e];function Koe(t){return Goe(t.animate)||W_e.some(s=>e6(t[s]))}function cUe(t){return!!(Koe(t)||t.variants)}function nSt(t,s,r){for(const n in s){const a=s[n],o=r[n];if(Lu(a))t.addValue(n,a);else if(Lu(o))t.addValue(n,_3(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,_3(l!==void 0?l:a,{owner:t}))}}for(const n in r)s[n]===void 0&&t.removeValue(n);return s}const dxe={current:null},dUe={current:!1},aSt=typeof window<"u";function iSt(){if(dUe.current=!0,!!aSt)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>dxe.current=t.matches;t.addEventListener("change",s),s()}else dxe.current=!1}const K3e=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Ene={};function uUe(t){Ene=t}function oSt(){return Ene}class lSt{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=O_e,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 _=Ph.now();this.renderScheduledAt<_&&(this.renderScheduledAt=_,gl.render(this.render,!1,!0))};const{latestValues:u,renderState:p}=i;this.latestValues=u,this.baseTarget={...u},this.initialValues=r.initial?{...u}:{},this.renderState=p,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=Koe(r),this.isVariantNode=cUe(r),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(s&&s.current);const{willChange:f,...v}=this.scrapeMotionValuesFromProps(r,{},this);for(const _ in v){const b=v[_];u[_]!==void 0&&Lu(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,rSt.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:(dUe.current||iSt(),this.shouldReduceMotion=dxe.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(),P_(this.notifyUpdate),P_(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&&Hqe.has(s)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:d,ease:u,duration:p}=r.accelerate,f=new Uqe({element:this.current,name:s,keyframes:i,times:d,ease:u,duration:gp(p)}),v=l(f);this.valueSubscriptions.set(s,()=>{v(),f.cancel()});return}const n=bM.has(s);n&&this.onBindTransform&&this.onBindTransform();const a=r.on("change",l=>{this.latestValues[s]=l,this.props.onUpdate&&gl.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 Ene){const r=Ene[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):Rd()}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=_3(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"&&(cqe(n)||uqe(n))?n=parseFloat(n):!sSt(n)&&qg.test(r)&&(n=sUe(s,r)),this.setBaseTarget(s,Lu(n)?n.get():n)),Lu(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=z_e(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&&!Lu(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 C_e),this.events[s].add(r)}notify(s,...r){this.events[s]&&this.events[s].notify(...r)}scheduleRenderMicrotask(){q_e.render(this.render)}}class hUe extends lSt{constructor(){super(...arguments),this.KeyframeResolver=ONt}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;Lu(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 mUe({top:t,left:s,right:r,bottom:n}){return{x:{min:s,max:r},y:{min:t,max:n}}}function cSt({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function dSt(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 Yhe(t){return t===void 0||t===1}function uxe({scale:t,scaleX:s,scaleY:r}){return!Yhe(t)||!Yhe(s)||!Yhe(r)}function pk(t){return uxe(t)||pUe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function pUe(t){return Z3e(t.x)||Z3e(t.y)}function Z3e(t){return t&&t!=="0%"}function Pne(t,s,r){const n=t-r,a=s*n;return r+a}function Y3e(t,s,r,n,a){return a!==void 0&&(t=Pne(t,a,n)),Pne(t,r,n)+s}function hxe(t,s=0,r=1,n,a){t.min=Y3e(t.min,s,r,n,a),t.max=Y3e(t.max,s,r,n,a)}function fUe(t,{x:s,y:r}){hxe(t.x,s.translate,s.scale,s.originPoint),hxe(t.y,r.translate,r.scale,r.originPoint)}const X3e=.999999999999,Q3e=1.0000000000001;function uSt(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;dX3e&&(s.x=1),s.yX3e&&(s.y=1)}function Lx(t,s){t.min+=s,t.max+=s}function J3e(t,s,r,n,a=.5){const o=tc(t.min,t.max,a);hxe(t,s,r,o,n)}function eMe(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function dre(t,s,r){const n=r??t;J3e(t.x,eMe(s.x,n.x),s.scaleX,s.scale,s.originX),J3e(t.y,eMe(s.y,n.y),s.scaleY,s.scale,s.originY)}function gUe(t,s){return mUe(dSt(t.getBoundingClientRect(),s))}function hSt(t,s,r){const n=gUe(t,r),{scroll:a}=s;return a&&(Lx(n.x,a.offset.x),Lx(n.y,a.offset.y)),n}const mSt={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},pSt=_M.length;function fSt(t,s,r){let n="",a=!0;for(let o=0;o{if(!s.target)return t;if(typeof t=="string")if(Qn.test(t))t=parseFloat(t);else return t;const r=tMe(t,s.target.x),n=tMe(t,s.target.y);return`${r}% ${n}%`}},gSt={correct:(t,{treeScale:s,projectionDelta:r})=>{const n=t,a=qg.parse(t);if(a.length>5)return n;const o=qg.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=tc(i,d,.5);return typeof a[2+l]=="number"&&(a[2+l]/=u),typeof a[3+l]=="number"&&(a[3+l]/=u),o(a)}},mxe={borderRadius:{...sE,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:sE,borderTopRightRadius:sE,borderBottomLeftRadius:sE,borderBottomRightRadius:sE,boxShadow:gSt};function yUe(t,{layout:s,layoutId:r}){return bM.has(t)||t.startsWith("origin")||(s||r!==void 0)&&(!!mxe[t]||t==="opacity")}function K_e(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)(Lu(n[i])||a&&Lu(a[i])||yUe(i,t)||((l=r==null?void 0:r.getValue(i))==null?void 0:l.liveStyle)!==void 0)&&(o[i]=n[i]);return o}function xSt(t){return window.getComputedStyle(t)}class ySt extends hUe{constructor(){super(...arguments),this.type="html",this.renderInstance=xUe}readValueFromInstance(s,r){var n;if(bM.has(r))return(n=this.projection)!=null&&n.isProjecting?Jge(r):Fkt(s,r);{const a=xSt(s),o=(Sqe(r)?a.getPropertyValue(r):a[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(s,{transformPagePoint:r}){return gUe(s,r)}build(s,r,n){G_e(s,r,n.transformTemplate)}scrapeMotionValuesFromProps(s,r,n){return K_e(s,r,n)}}const vSt={offset:"stroke-dashoffset",array:"stroke-dasharray"},_St={offset:"strokeDashoffset",array:"strokeDasharray"};function bSt(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?vSt:_St;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const wSt=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function vUe(t,{attrX:s,attrY:r,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},d,u,p){if(G_e(t,i,u),d){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:f,style:v}=t;f.transform&&(v.transform=f.transform,delete f.transform),(v.transform||f.transformOrigin)&&(v.transformOrigin=f.transformOrigin??"50% 50%",delete f.transformOrigin),v.transform&&(v.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete f.transformBox);for(const _ of wSt)f[_]!==void 0&&(v[_]=f[_],delete f[_]);s!==void 0&&(f.x=s),r!==void 0&&(f.y=r),n!==void 0&&(f.scale=n),a!==void 0&&bSt(f,a,o,l,!1)}const _Ue=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"]),bUe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function jSt(t,s,r,n){xUe(t,s,void 0,n);for(const a in s.attrs)t.setAttribute(_Ue.has(a)?a:B_e(a),s.attrs[a])}function wUe(t,s,r){const n=K_e(t,s,r);for(const a in t)if(Lu(t[a])||Lu(s[a])){const o=_M.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=t[a]}return n}class kSt extends hUe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Rd}getBaseTargetFromProps(s,r){return s[r]}readValueFromInstance(s,r){if(bM.has(r)){const n=tUe(r);return n&&n.default||0}return r=_Ue.has(r)?r:B_e(r),s.getAttribute(r)}scrapeMotionValuesFromProps(s,r,n){return wUe(s,r,n)}build(s,r,n){vUe(s,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(s,r,n,a){jSt(s,r,n,a)}mount(s){this.isSVGTag=bUe(s.tagName),super.mount(s)}}const NSt=W_e.length;function jUe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?jUe(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})=>NNt(t,r,n)))}function TSt(t){let s=MSt(t),r=sMe(),n=!0,a=!1;const o=u=>(p,f)=>{var _;const v=mN(t,f,u==="exit"?(_=t.presenceContext)==null?void 0:_.custom:void 0);if(v){const{transition:b,transitionEnd:j,...w}=v;p={...p,...w,...j}}return p};function l(u){s=u(t)}function i(u){const{props:p}=t,f=jUe(t.parent)||{},v=[],_=new Set;let b={},j=1/0;for(let N=0;Nj&&L,V=!1;const X=Array.isArray(I)?I:[I];let se=X.reduce(o(C),{});R===!1&&(se={});const{prevResolvedValues:te={}}=A,Y={...te,...se},de=le=>{U=!0,_.has(le)&&(V=!0,_.delete(le)),A.needsAnimating[le]=!0;const pe=t.getValue(le);pe&&(pe.liveStyle=!1)};for(const le in Y){const pe=se[le],be=te[le];if(b.hasOwnProperty(le))continue;let ye=!1;axe(pe)&&axe(be)?ye=!kUe(pe,be):ye=pe!==be,ye?pe!=null?de(le):_.add(le):pe!==void 0&&_.has(le)?de(le):A.protectedKeys[le]=!0}A.prevProp=I,A.prevResolvedValues=se,A.isActive&&(b={...b,...se}),(n||a)&&t.blockInitialAnimation&&(U=!1);const ie=$&&q;U&&(!ie||V)&&v.push(...X.map(le=>{const pe={type:C};if(typeof le=="string"&&(n||a)&&!ie&&t.manuallyAnimateOnMount&&t.parent){const{parent:be}=t,ye=mN(be,le);if(be.enteringChildren&&ye){const{delayChildren:we}=ye.transition||{};pe.delay=Wqe(be.enteringChildren,t,we)}}return{animation:le,options:pe}}))}if(_.size){const N={};if(typeof p.initial!="boolean"){const C=mN(t,Array.isArray(p.initial)?p.initial[0]:p.initial);C&&C.transition&&(N.transition=C.transition)}_.forEach(C=>{const A=t.getBaseTarget(C),I=t.getValue(C);I&&(I.liveStyle=!0),N[C]=A??null}),v.push({animation:N})}let w=!!v.length;return n&&(p.initial===!1||p.initial===p.animate)&&!t.manuallyAnimateOnMount&&(w=!1),n=!1,a=!1,w?s(v):Promise.resolve()}function d(u,p){var v;if(r[u].isActive===p)return Promise.resolve();(v=t.variantChildren)==null||v.forEach(_=>{var b;return(b=_.animationState)==null?void 0:b.setActive(u,p)}),r[u].isActive=p;const f=i(u);for(const _ in r)r[_].protectedKeys={};return f}return{animateChanges:i,setActive:d,setAnimateFunction:l,getState:()=>r,reset:()=>{r=sMe(),a=!0}}}function ASt(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!kUe(s,t):!1}function Zb(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function sMe(){return{animate:Zb(!0),whileInView:Zb(),whileHover:Zb(),whileTap:Zb(),whileDrag:Zb(),whileFocus:Zb(),exit:Zb()}}function pxe(t,s){t.min=s.min,t.max=s.max}function cg(t,s){pxe(t.x,s.x),pxe(t.y,s.y)}function rMe(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const NUe=1e-4,ESt=1-NUe,PSt=1+NUe,SUe=.01,ISt=0-SUe,LSt=0+SUe;function Ih(t){return t.max-t.min}function DSt(t,s,r){return Math.abs(t-s)<=r}function nMe(t,s,r,n=.5){t.origin=n,t.originPoint=tc(s.min,s.max,t.origin),t.scale=Ih(r)/Ih(s),t.translate=tc(r.min,r.max,t.origin)-t.originPoint,(t.scale>=ESt&&t.scale<=PSt||isNaN(t.scale))&&(t.scale=1),(t.translate>=ISt&&t.translate<=LSt||isNaN(t.translate))&&(t.translate=0)}function XP(t,s,r,n){nMe(t.x,s.x,r.x,n?n.originX:void 0),nMe(t.y,s.y,r.y,n?n.originY:void 0)}function aMe(t,s,r,n=0){const a=n?tc(r.min,r.max,n):r.min;t.min=a+s.min,t.max=t.min+Ih(s)}function OSt(t,s,r,n){aMe(t.x,s.x,r.x,n==null?void 0:n.x),aMe(t.y,s.y,r.y,n==null?void 0:n.y)}function iMe(t,s,r,n=0){const a=n?tc(r.min,r.max,n):r.min;t.min=s.min-a,t.max=t.min+Ih(s)}function Ine(t,s,r,n){iMe(t.x,s.x,r.x,n==null?void 0:n.x),iMe(t.y,s.y,r.y,n==null?void 0:n.y)}function oMe(t,s,r,n,a){return t-=s,t=Pne(t,1/r,n),a!==void 0&&(t=Pne(t,1/a,n)),t}function RSt(t,s=0,r=1,n=.5,a,o=t,l=t){if(Jx.test(s)&&(s=parseFloat(s),s=tc(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=tc(o.min,o.max,n);t===o&&(i-=s),t.min=oMe(t.min,s,r,i,a),t.max=oMe(t.max,s,r,i,a)}function lMe(t,s,[r,n,a],o,l){RSt(t,s[r],s[n],s[a],s.scale,o,l)}const FSt=["x","scaleX","originX"],zSt=["y","scaleY","originY"];function cMe(t,s,r,n){lMe(t.x,s,FSt,r?r.x:void 0,n?n.x:void 0),lMe(t.y,s,zSt,r?r.y:void 0,n?n.y:void 0)}function dMe(t){return t.translate===0&&t.scale===1}function CUe(t){return dMe(t.x)&&dMe(t.y)}function uMe(t,s){return t.min===s.min&&t.max===s.max}function BSt(t,s){return uMe(t.x,s.x)&&uMe(t.y,s.y)}function hMe(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function MUe(t,s){return hMe(t.x,s.x)&&hMe(t.y,s.y)}function mMe(t){return Ih(t.x)/Ih(t.y)}function pMe(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function Nx(t){return[t("x"),t("y")]}function $St(t,s,r){let n="";const a=t.x.translate/s.x,o=t.y.translate/s.y,l=(r==null?void 0:r.z)||0;if((a||o||l)&&(n=`translate3d(${a}px, ${o}px, ${l}px) `),(s.x!==1||s.y!==1)&&(n+=`scale(${1/s.x}, ${1/s.y}) `),r){const{transformPerspective:u,rotate:p,rotateX:f,rotateY:v,skewX:_,skewY:b}=r;u&&(n=`perspective(${u}px) ${n}`),p&&(n+=`rotate(${p}deg) `),f&&(n+=`rotateX(${f}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 TUe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],qSt=TUe.length,fMe=t=>typeof t=="string"?parseFloat(t):t,gMe=t=>typeof t=="number"||Qn.test(t);function USt(t,s,r,n,a,o){a?(t.opacity=tc(0,r.opacity??1,VSt(n)),t.opacityExit=tc(s.opacity??1,0,HSt(n))):o&&(t.opacity=tc(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(QI(t,s,n))}function WSt(t,s,r){const n=Lu(t)?t:_3(t);return n.start(F_e("",n,s,r)),n.animation}function t6(t,s,r,n={passive:!0}){return t.addEventListener(s,r,n),()=>t.removeEventListener(s,r)}const GSt=(t,s)=>t.depth-s.depth;class KSt{constructor(){this.children=[],this.isDirty=!1}add(s){N_e(this.children,s),this.isDirty=!0}remove(s){Sne(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(GSt),this.isDirty=!1,this.children.forEach(s)}}function ZSt(t,s){const r=Ph.now(),n=({timestamp:a})=>{const o=a-r;o>=s&&(P_(n),t(o-s))};return gl.setup(n,!0),()=>P_(n)}function ure(t){return Lu(t)?t.get():t}class YSt{constructor(){this.members=[]}add(s){N_e(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&&(Sne(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(Sne(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},Xhe=["","X","Y","Z"],XSt=1e3;let QSt=0;function Qhe(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function EUe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const r=Xqe(s);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",gl,!(a||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&EUe(n)}function PUe({attachResizeListener:t,defaultParent:s,measureScroll:r,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=s==null?void 0:s()){this.id=QSt++,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(tCt),this.nodes.forEach(oCt),this.nodes.forEach(lCt),this.nodes.forEach(sCt)},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;gl.read(()=>{f=window.innerWidth}),t(l,()=>{const _=window.innerWidth;_!==f&&(f=_,this.root.updateBlockedByResize=!0,p&&p(),p=ZSt(v,250),hre.hasAnimatedSinceResize&&(hre.hasAnimatedSinceResize=!1,this.nodes.forEach(_Me)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&u&&(i||d)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:f,hasRelativeLayoutChanged:v,layout:_})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const b=this.options.transition||u.getDefaultTransition()||mCt,{onLayoutAnimationStart:j,onLayoutAnimationComplete:w}=u.getProps(),N=!this.targetLayout||!MUe(this.targetLayout,_),C=!f&&v;if(this.options.layoutRoot||this.resumeFrom||C||f&&(N||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const A={...R_e(b,"layout"),onPlay:j,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(A.delay=0,A.type=!1),this.startAnimation(A),this.setAnimationOrigin(p,C)}else f||_Me(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(),P_(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(cCt),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&&EUe(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let p=0;p{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Ih(this.snapshot.measuredBox.x)&&!Ih(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;bMe(f.x,l.x,L),bMe(f.y,l.y,L),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Ine(v,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),uCt(this.relativeTarget,this.relativeTargetOrigin,v,L),A&&BSt(this.relativeTarget,A)&&(this.isProjectionDirty=!1),A||(A=Rd()),cg(A,this.relativeTarget)),j&&(this.animationValues=p,USt(p,u,this.latestValues,L,C,N)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=L},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){var i,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&&(P_(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=gl.update(()=>{hre.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=_3(0)),this.motionValue.jump(0,!1),this.currentAnimation=WSt(this.motionValue,[0,1e3],{...l,velocity:0,isSync:!0,onUpdate:p=>{this.mixTargetDelta(p),l.onUpdate&&l.onUpdate(p)},onStop:()=>{},onComplete:()=>{l.onComplete&&l.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const l=this.getStack();l&&l.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(XSt),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:i,target:d,layout:u,latestValues:p}=l;if(!(!i||!d||!u)){if(this!==l&&this.layout&&u&&IUe(this.options.animationType,this.layout.layoutBox,u.layoutBox)){d=this.target||Rd();const f=Ih(this.layout.layoutBox.x);d.x.min=l.target.x.min,d.x.max=d.x.min+f;const v=Ih(this.layout.layoutBox.y);d.y.min=l.target.y.min,d.y.max=d.y.min+v}cg(i,d),dre(i,p),XP(this.projectionDeltaWithTransform,this.layoutCorrected,i,p)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new YSt),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&&Qhe("z",l,u,this.animationValues);for(let p=0;p{var i;return(i=l.currentAnimation)==null?void 0:i.stop()}),this.root.nodes.forEach(yMe),this.root.sharedNodes.clear()}}}function JSt(t){t.updateLayout()}function eCt(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")Nx(f=>{const v=l?s.measuredBox[f]:s.layoutBox[f],_=Ih(v);v.min=n[f].min,v.max=v.min+_});else if(o==="x"||o==="y"){const f=o==="x"?"y":"x";pxe(l?s.measuredBox[f]:s.layoutBox[f],n[f])}else IUe(o,s.layoutBox,n)&&Nx(f=>{const v=l?s.measuredBox[f]:s.layoutBox[f],_=Ih(n[f]);v.max=v.min+_,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[f].max=t.relativeTarget[f].min+_)});const i=B4();XP(i,n,s.layoutBox);const d=B4();l?XP(d,t.applyTransform(a,!0),s.measuredBox):XP(d,n,s.layoutBox);const u=!CUe(i);let p=!1;if(!t.resumeFrom){const f=t.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:v,layout:_}=f;if(v&&_){const b=t.options.layoutAnchor||void 0,j=Rd();Ine(j,s.layoutBox,v.layoutBox,b);const w=Rd();Ine(w,n,_.layoutBox,b),MUe(j,w)||(p=!0),f.options.layoutRoot&&(t.relativeTarget=w,t.relativeTargetOrigin=j,t.relativeParent=f)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:s,delta:d,layoutDelta:i,hasLayoutChanged:u,hasRelativeLayoutChanged:p})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function tCt(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 sCt(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function rCt(t){t.clearSnapshot()}function yMe(t){t.clearMeasurements()}function nCt(t){t.isLayoutDirty=!0,t.updateLayout()}function vMe(t){t.isLayoutDirty=!1}function aCt(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function iCt(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function _Me(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function oCt(t){t.resolveTargetDelta()}function lCt(t){t.calcProjection()}function cCt(t){t.resetSkewAndRotation()}function dCt(t){t.removeLeadSnapshot()}function bMe(t,s,r){t.translate=tc(s.translate,0,r),t.scale=tc(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function wMe(t,s,r,n){t.min=tc(s.min,r.min,n),t.max=tc(s.max,r.max,n)}function uCt(t,s,r,n){wMe(t.x,s.x,r.x,n),wMe(t.y,s.y,r.y,n)}function hCt(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const mCt={duration:.45,ease:[.4,0,.1,1]},jMe=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),kMe=jMe("applewebkit/")&&!jMe("chrome/")?Math.round:gf;function NMe(t){t.min=kMe(t.min),t.max=kMe(t.max)}function pCt(t){NMe(t.x),NMe(t.y)}function IUe(t,s,r){return t==="position"||t==="preserve-aspect"&&!DSt(mMe(s),mMe(r),.2)}function fCt(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const gCt=PUe({attachResizeListener:(t,s)=>t6(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}),Jhe={current:void 0},LUe=PUe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Jhe.current){const t=new gCt({});t.mount(window),t.setOptions({layoutScroll:!0}),Jhe.current=t}return Jhe.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Z_e=S.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function SMe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function xCt(...t){return s=>{let r=!1;const n=t.map(a=>{const o=SMe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{width:_,height:b,top:j,left:w,right:N,bottom:C}=d.current;if(s||o===!1||!i.current||!_||!b)return;const A=r==="left"?`left: ${w}`:`right: ${N}`,I=n==="bottom"?`bottom: ${C}`:`top: ${j}`;i.current.dataset.motionPopId=l;const L=document.createElement("style");u&&(L.nonce=u);const R=a??document.head;return R.appendChild(L),L.sheet&&L.sheet.insertRule(` [data-motion-pop-id="${l}"] { position: absolute !important; width: ${_}px !important; height: ${b}px !important; ${A}px !important; ${I}px !important; } `),()=>{var $;($=i.current)==null||$.removeAttribute("data-motion-pop-id"),R.contains(L)&&R.removeChild(L)}},[s]),e.jsx(vCt,{isPresent:s,childRef:i,sizeRef:d,pop:o,children:o===!1?t:S.cloneElement(t,{ref:f})})}const bCt=({children:t,initial:s,isPresent:r,onExitComplete:n,custom:a,presenceAffectsLayout:o,mode:l,anchorX:i,anchorY:d,root:u})=>{const p=k_e(wCt),f=S.useId();let v=!0,_=S.useMemo(()=>(v=!1,{id:f,initial:s,isPresent:r,custom:a,onExitComplete:b=>{p.set(b,!0);for(const j of p.values())if(!j)return;n&&n()},register:b=>(p.set(b,!1),()=>p.delete(b))}),[r,p,n]);return o&&v&&(_={..._}),S.useMemo(()=>{p.forEach((b,j)=>p.set(j,!1))},[r]),S.useEffect(()=>{!r&&!p.size&&n&&n()},[r]),t=e.jsx(_Ct,{pop:l==="popLayout",isPresent:r,anchorX:i,anchorY:d,root:u,children:t}),e.jsx(Hoe.Provider,{value:_,children:t})};function wCt(){return new Map}function DUe(t=!0){const s=S.useContext(Hoe);if(s===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:a}=s,o=S.useId();S.useEffect(()=>{if(t)return a(o)},[t]);const l=S.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,l]:[!0]}const F8=t=>t.key||"";function CMe(t){const s=[];return S.Children.forEach(t,r=>{S.isValidElement(r)&&s.push(r)}),s}const jCt=({children:t,custom:s,initial:r=!0,onExitComplete:n,presenceAffectsLayout:a=!0,mode:o="sync",propagate:l=!1,anchorX:i="left",anchorY:d="top",root:u})=>{const[p,f]=DUe(l),v=S.useMemo(()=>CMe(t),[t]),_=l&&!p?[]:v.map(F8),b=S.useRef(!0),j=S.useRef(v),w=k_e(()=>new Map),N=S.useRef(new Set),[C,A]=S.useState(v),[I,L]=S.useState(v);lqe(()=>{b.current=!1,j.current=v;for(let q=0;q{const U=F8(q),V=l&&!p?!1:v===I||_.includes(U),X=()=>{if(N.current.has(U))return;if(w.has(U))N.current.add(U),w.set(U,!0);else return;let se=!0;w.forEach(te=>{te||(se=!1)}),se&&($==null||$(),L(j.current),l&&(f==null||f()),n&&n())};return e.jsx(bCt,{isPresent:V,initial:!b.current||r?void 0:!1,custom:s,presenceAffectsLayout:a,mode:o,root:u,onExitComplete:V?void 0:X,anchorX:i,anchorY:d,children:q},U)})})},OUe=S.createContext({strict:!1}),MMe={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 TMe=!1;function kCt(){if(TMe)return;const t={};for(const s in MMe)t[s]={isEnabled:r=>MMe[s].some(n=>!!r[n])};uUe(t),TMe=!0}function RUe(){return kCt(),oSt()}function NCt(t){const s=RUe();for(const r in t)s[r]={...s[r],...t[r]};uUe(s)}const SCt=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 Lne(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||SCt.has(t)}let FUe=t=>!Lne(t);function CCt(t){typeof t=="function"&&(FUe=s=>s.startsWith("on")?!Lne(s):t(s))}try{CCt(require("@emotion/is-prop-valid").default)}catch{}function MCt(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||Lu(t[a])||(FUe(a)||r===!0&&Lne(a)||!s&&!Lne(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const Zoe=S.createContext({});function TCt(t,s){if(Koe(t)){const{initial:r,animate:n}=t;return{initial:r===!1||e6(r)?r:void 0,animate:e6(n)?n:void 0}}return t.inherit!==!1?s:{}}function ACt(t){const{initial:s,animate:r}=TCt(t,S.useContext(Zoe));return S.useMemo(()=>({initial:s,animate:r}),[AMe(s),AMe(r)])}function AMe(t){return Array.isArray(t)?t.join(" "):t}const Y_e=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function zUe(t,s,r){for(const n in s)!Lu(s[n])&&!yUe(n,r)&&(t[n]=s[n])}function ECt({transformTemplate:t},s){return S.useMemo(()=>{const r=Y_e();return G_e(r,s,t),Object.assign({},r.vars,r.style)},[s])}function PCt(t,s){const r=t.style||{},n={};return zUe(n,r,t),Object.assign(n,ECt(t,s)),n}function ICt(t,s){const r={},n=PCt(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 BUe=()=>({...Y_e(),attrs:{}});function LCt(t,s,r,n){const a=S.useMemo(()=>{const o=BUe();return vUe(o,s,bUe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};zUe(o,t.style,t),a.style={...o,...a.style}}return a}const DCt=["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 X_e(t){return typeof t!="string"||t.includes("-")?!1:!!(DCt.indexOf(t)>-1||/[A-Z]/u.test(t))}function OCt(t,s,r,{latestValues:n},a,o=!1,l){const d=(l??X_e(t)?LCt:ICt)(s,n,a,t),u=MCt(s,typeof t=="string",o),p=t!==S.Fragment?{...u,...d,ref:r}:{},{children:f}=s,v=S.useMemo(()=>Lu(f)?f.get():f,[f]);return S.createElement(t,{...p,children:v})}function RCt({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:FCt(r,n,a,t),renderState:s()}}function FCt(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=Koe(t),u=cUe(t);s&&u&&!d&&t.inherit!==!1&&(l===void 0&&(l=s.initial),i===void 0&&(i=s.animate));let p=r?r.initial===!1:!1;p=p||l===!1;const f=p?i:l;if(f&&typeof f!="boolean"&&!Goe(f)){const v=Array.isArray(f)?f:[f];for(let _=0;_(s,r)=>{const n=S.useContext(Zoe),a=S.useContext(Hoe),o=()=>RCt(t,s,n,a);return r?o():k_e(o)},zCt=$Ue({scrapeMotionValuesFromProps:K_e,createRenderState:Y_e}),BCt=$Ue({scrapeMotionValuesFromProps:wUe,createRenderState:BUe}),$Ct=Symbol.for("motionComponentSymbol");function qCt(t,s,r){const n=S.useRef(r);S.useInsertionEffect(()=>{n.current=r});const a=S.useRef(null);return S.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 qUe=S.createContext({});function _4(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function UCt(t,s,r,n,a,o){var A,I;const{visualElement:l}=S.useContext(Zoe),i=S.useContext(OUe),d=S.useContext(Hoe),u=S.useContext(Z_e),p=u.reducedMotion,f=u.skipAnimations,v=S.useRef(null),_=S.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:p,skipAnimations:f,isSVG:o}),_.current&&v.current&&(v.current.manuallyAnimateOnMount=!0));const b=v.current,j=S.useContext(qUe);b&&!b.projection&&a&&(b.type==="html"||b.type==="svg")&&VCt(v.current,r,a,j);const w=S.useRef(!1);S.useInsertionEffect(()=>{b&&w.current&&b.update(r,d)});const N=r[Yqe],C=S.useRef(!!N&&typeof window<"u"&&!((A=window.MotionHandoffIsComplete)!=null&&A.call(window,N))&&((I=window.MotionHasOptimisedAnimation)==null?void 0:I.call(window,N)));return lqe(()=>{_.current=!0,b&&(w.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),b.scheduleRenderMicrotask(),C.current&&b.animationState&&b.animationState.animateChanges())}),S.useEffect(()=>{b&&(!C.current&&b.animationState&&b.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{var L;(L=window.MotionHandoffMarkAsComplete)==null||L.call(window,N)}),C.current=!1),b.enteringChildren=void 0)}),b}function VCt(t,s,r,n){const{layoutId:a,layout:o,drag:l,dragConstraints:i,layoutScroll:d,layoutRoot:u,layoutAnchor:p,layoutCrossfade:f}=s;t.projection=new r(t.latestValues,s["data-framer-portal-id"]?void 0:UUe(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&_4(i),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:f,layoutScroll:d,layoutRoot:u,layoutAnchor:p})}function UUe(t){if(t)return t.options.allowProjection!==!1?t.projection:UUe(t.parent)}function eme(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&NCt(n);const o=r?r==="svg":X_e(t),l=o?BCt:zCt;function i(u,p){let f;const v={...S.useContext(Z_e),...u,layoutId:HCt(u)},{isStatic:_}=v,b=ACt(u),j=l(u,_);if(!_&&typeof window<"u"){WCt();const w=GCt(v);f=w.MeasureLayout,b.visualElement=UCt(t,j,v,a,w.ProjectionNode,o)}return e.jsxs(Zoe.Provider,{value:b,children:[f&&b.visualElement?e.jsx(f,{visualElement:b.visualElement,...v}):null,OCt(t,u,qCt(j,b.visualElement,p),j,_,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const d=S.forwardRef(i);return d[$Ct]=t,d}function HCt({layoutId:t}){const s=S.useContext(j_e).id;return s&&t!==void 0?s+"-"+t:t}function WCt(t,s){S.useContext(OUe).strict}function GCt(t){const s=RUe(),{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 KCt(t,s){if(typeof Proxy>"u")return eme;const r=new Map,n=(o,l)=>eme(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,eme(l,void 0,t,s)),r.get(l))})}const ZCt=(t,s)=>s.isSVG??X_e(t)?new kSt(s):new ySt(s,{allowProjection:t!==S.Fragment});class YCt extends W_{constructor(s){super(s),s.animationState||(s.animationState=TSt(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();Goe(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 XCt=0;class QCt extends W_{constructor(){super(...arguments),this.id=XCt++,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:p,...f}=d;for(const v in f)(o=this.node.getValue(v))==null||o.jump(f[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 JCt={animation:{Feature:YCt},exit:{Feature:QCt}};function PL(t){return{point:{x:t.pageX,y:t.pageY}}}const e4t=t=>s=>U_e(s)&&t(s,PL(s));function QP(t,s,r,n){return t6(t,s,e4t(r),n)}const VUe=({current:t})=>t?t.ownerDocument.defaultView:null,EMe=(t,s)=>Math.abs(t-s);function t4t(t,s){const r=EMe(t.x,s.x),n=EMe(t.y,s.y);return Math.sqrt(r**2+n**2)}const PMe=new Set(["auto","scroll"]);class HUe{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=z8(this.lastRawMoveEventInfo,this.transformPagePoint));const _=tme(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,j=t4t(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!b&&!j)return;const{point:w}=_,{timestamp:N}=Eu;this.history.push({...w,timestamp:N});const{onStart:C,onMove:A}=this.handlers;b||(C&&C(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),A&&A(this.lastMoveEvent,_)},this.handlePointerMove=(_,b)=>{this.lastMoveEvent=_,this.lastRawMoveEventInfo=b,this.lastMoveEventInfo=z8(b,this.transformPagePoint),gl.update(this.updatePoint,!0)},this.handlePointerUp=(_,b)=>{this.end();const{onEnd:j,onSessionEnd:w,resumeAnimation:N}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&N&&N(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=tme(_.type==="pointercancel"?this.lastMoveEventInfo:z8(b,this.transformPagePoint),this.history);this.startEvent&&j&&j(_,C),w&&w(_,C)},!U_e(s))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const d=PL(s),u=z8(d,this.transformPagePoint),{point:p}=u,{timestamp:f}=Eu;this.history=[{...p,timestamp:f}];const{onSessionStart:v}=r;v&&v(s,tme(u,this.history)),this.removeListeners=TL(QP(this.contextWindow,"pointermove",this.handlePointerMove),QP(this.contextWindow,"pointerup",this.handlePointerUp),QP(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(s){let r=s.parentElement;for(;r;){const n=getComputedStyle(r);(PMe.has(n.overflowX)||PMe.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),gl.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),P_(this.updatePoint)}}function z8(t,s){return s?{point:s(t.point)}:t}function IMe(t,s){return{x:t.x-s.x,y:t.y-s.y}}function tme({point:t},s){return{point:t,delta:IMe(t,WUe(s)),offset:IMe(t,s4t(s)),velocity:r4t(s,.1)}}function s4t(t){return t[0]}function WUe(t){return t[t.length-1]}function r4t(t,s){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const a=WUe(t);for(;r>=0&&(n=t[r],!(a.timestamp-n.timestamp>gp(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>gp(s)*2&&(n=t[1]);const o=af(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 n4t(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?tc(r,t,n.max):Math.min(t,r)),t}function LMe(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 a4t(t,{top:s,left:r,bottom:n,right:a}){return{x:LMe(t.x,r,a),y:LMe(t.y,s,n)}}function DMe(t,s){let r=s.min-t.min,n=s.max-t.max;return s.max-s.minn?r=QI(s.min,s.max-n,t.min):n>a&&(r=QI(t.min,t.max-a,s.min)),ny(0,1,r)}function l4t(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 fxe=.35;function c4t(t=fxe){return t===!1?t=0:t===!0&&(t=fxe),{x:OMe(t,"left","right"),y:OMe(t,"top","bottom")}}function OMe(t,s,r){return{min:RMe(t,s),max:RMe(t,r)}}function RMe(t,s){return typeof t=="number"?t:t[s]||0}const d4t=new WeakMap;class u4t{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=Rd(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=s}start(s,{snapToCursor:r=!1,distanceThreshold:n}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const o=f=>{r&&this.snapToCursor(PL(f).point),this.stopAnimation()},l=(f,v)=>{const{drag:_,dragPropagation:b,onDragStart:j}=this.getProps();if(_&&!b&&(this.openDragLock&&this.openDragLock(),this.openDragLock=RNt(_),!this.openDragLock))return;this.latestPointerEvent=f,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),Nx(N=>{let C=this.getAxisMotionValue(N).get()||0;if(Jx.test(C)){const{projection:A}=this.visualElement;if(A&&A.layout){const I=A.layout.layoutBox[N];I&&(C=Ih(I)*(parseFloat(C)/100))}}this.originPoint[N]=C}),j&&gl.update(()=>j(f,v),!1,!0),ixe(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},i=(f,v)=>{this.latestPointerEvent=f,this.latestPanInfo=v;const{dragPropagation:_,dragDirectionLock:b,onDirectionLock:j,onDrag:w}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:N}=v;if(b&&this.currentDirection===null){this.currentDirection=m4t(N),this.currentDirection!==null&&j&&j(this.currentDirection);return}this.updateAxis("x",v.point,N),this.updateAxis("y",v.point,N),this.visualElement.render(),w&&gl.update(()=>w(f,v),!1,!0)},d=(f,v)=>{this.latestPointerEvent=f,this.latestPanInfo=v,this.stop(f,v),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:f}=this.getProps();(f||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new HUe(s,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:d,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:n,contextWindow:VUe(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&&gl.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||!B8(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=n4t(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&&_4(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&n?this.constraints=a4t(n.layoutBox,s):this.constraints=!1,this.elastic=c4t(r),a!==this.constraints&&!_4(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&Nx(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=l4t(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:r}=this.getProps();if(!s||!_4(s))return!1;const n=s.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=hSt(n,a.root,this.visualElement.getTransformPagePoint());let l=i4t(a.layout.layoutBox,o);if(r){const i=r(cSt(l));this.hasMutatedConstraints=!!i,i&&(l=mUe(i))}return l}startAnimation(s){const{drag:r,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),d=this.constraints||{},u=Nx(p=>{if(!B8(p,r,this.currentDirection))return;let f=d&&d[p]||{};(l===!0||l===p)&&(f={min:0,max:0});const v=a?200:1e6,_=a?40:1e7,b={type:"inertia",velocity:n?s[p]:0,bounceStiffness:v,bounceDamping:_,timeConstant:750,restDelta:1,restSpeed:10,...o,...f};return this.startAxisValueAnimation(p,b)});return Promise.all(u).then(i)}startAxisValueAnimation(s,r){const n=this.getAxisMotionValue(s);return ixe(this.visualElement,s),n.start(F_e(s,n,0,r,this.visualElement,!1))}stopAnimation(){Nx(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){Nx(r=>{const{drag:n}=this.getProps();if(!B8(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]-tc(l,i,.5)+d)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!_4(r)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Nx(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const d=i.get();a[l]=o4t({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(),Nx(l=>{if(!B8(l,s,null))return;const i=this.getAxisMotionValue(l),{min:d,max:u}=this.constraints[l];i.set(tc(d,u,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;d4t.set(this.visualElement,this);const s=this.visualElement.current,r=QP(s,"pointerdown",u=>{const{drag:p,dragListener:f=!0}=this.getProps(),v=u.target,_=v!==s&&UNt(v);p&&f&&!_&&this.start(u)});let n;const a=()=>{const{dragConstraints:u}=this.getProps();_4(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),n||(n=h4t(s,u.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),gl.read(a);const i=t6(window,"resize",()=>this.scalePositionWithinConstraints()),d=o.addEventListener("didUpdate",({delta:u,hasLayoutChanged:p})=>{this.isDragging&&p&&(Nx(f=>{const v=this.getAxisMotionValue(f);v&&(this.originPoint[f]+=u[f].translate,v.set(v.get()+u[f].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=fxe,dragMomentum:i=!0}=s;return{...s,drag:r,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function FMe(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function h4t(t,s,r){const n=H3e(t,FMe(r)),a=H3e(s,FMe(r));return()=>{n(),a()}}function B8(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function m4t(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class p4t extends W_{constructor(s){super(s),this.removeGroupControls=gf,this.removeListeners=gf,this.controls=new u4t(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||gf}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 sme=t=>(s,r)=>{t&&gl.update(()=>t(s,r),!1,!0)};class f4t extends W_{constructor(){super(...arguments),this.removePointerDownListener=gf}onPointerDown(s){this.session=new HUe(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:VUe(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:r,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:sme(s),onStart:sme(r),onMove:sme(n),onEnd:(o,l)=>{delete this.session,a&&gl.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=QP(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 rme=!1;class g4t extends S.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),rme&&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}),rme=!0,a||s.layoutDependency!==r||r===void 0||s.isPresent!==o?l.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?l.promote():l.relegate()||gl.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(),q_e.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:a}=s;rme=!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 GUe(t){const[s,r]=DUe(),n=S.useContext(j_e);return e.jsx(g4t,{...t,layoutGroup:n,switchLayoutGroup:S.useContext(qUe),isPresent:s,safeToRemove:r})}const x4t={pan:{Feature:f4t},drag:{Feature:p4t,ProjectionNode:LUe,MeasureLayout:GUe}};function zMe(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&&gl.postRender(()=>o(s,PL(s)))}class y4t extends W_{mount(){const{current:s}=this.node;s&&(this.unmount=zNt(s,(r,n)=>(zMe(this.node,n,"Start"),a=>zMe(this.node,a,"End"))))}unmount(){}}class v4t 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=TL(t6(this.node.current,"focus",()=>this.onFocus()),t6(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function BMe(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&&gl.postRender(()=>o(s,PL(s)))}class _4t extends W_{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=HNt(s,(a,o)=>(BMe(this.node,o,"Start"),(l,{success:i})=>BMe(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const gxe=new WeakMap,nme=new WeakMap,b4t=t=>{const s=gxe.get(t.target);s&&s(t)},w4t=t=>{t.forEach(b4t)};function j4t({root:t,...s}){const r=t||document;nme.has(r)||nme.set(r,{});const n=nme.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(w4t,{root:t,...s})),n[a]}function k4t(t,s,r){const n=j4t(s);return gxe.set(t,r),n.observe(t),()=>{gxe.delete(t),n.unobserve(t)}}const N4t={some:0,all:1};class S4t 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:N4t[a]},i=u=>{const{isIntersecting:p}=u;if(this.isInView===p||(this.isInView=p,o&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:f,onViewportLeave:v}=this.node.getProps(),_=p?f:v;_&&_(u)};this.stopObserver=k4t(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(C4t(s,r))&&this.startObserver()}unmount(){var s;(s=this.stopObserver)==null||s.call(this),this.hasEnteredView=!1,this.isInView=!1}}function C4t({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const M4t={inView:{Feature:S4t},tap:{Feature:_4t},focus:{Feature:v4t},hover:{Feature:y4t}},T4t={layout:{ProjectionNode:LUe,MeasureLayout:GUe}},A4t={...JCt,...M4t,...x4t,...T4t},wr=KCt(A4t,ZCt);function KUe({slugOverride:t}={}){var Ne;const{slug:s}=Mo(),r=t||s,[n]=Ec(),a=n.get("t"),[o,l]=S.useState(!0),[i,d]=S.useState(null),[u,p]=S.useState(null),f=S.useRef(null),v=S.useRef(null),[_,b]=S.useState(null),[j,w]=S.useState(null),[N,C]=S.useState(!1),[A,I]=S.useState(!1),[L,R]=S.useState(0),[$,q]=S.useState(!1),[U,V]=S.useState(""),[X,se]=S.useState(""),[te,Y]=S.useState(""),[de,ie]=S.useState(""),[ae,le]=S.useState(""),[pe,be]=S.useState(""),[ye,we]=S.useState(""),[ke,Ze]=S.useState(""),[_e,Ce]=S.useState(""),[Te,Fe]=S.useState(""),[Ae,We]=S.useState(""),[ht,De]=S.useState("");S.useEffect(()=>{Dt()},[r,a]);const Dt=async()=>{if(!r)return;l(!0);const{data:it,error:qe}=await G.from("contact_intake_pages").select("*").eq("slug",r).eq("is_active",!0).maybeSingle();if(qe||!it){q(!0),l(!1);return}p(it),v.current=it;const{data:Xe}=await G.from("profiles").select("name, avatar_url, title, phone, email, brokerage_id").eq("id",it.user_id).single();if(Xe){let $e;if(Xe.brokerage_id){const{data:Ue}=await G.from("brokerages").select("name").eq("id",Xe.brokerage_id).single();$e=(Ue==null?void 0:Ue.name)||void 0}let Ke=Xe.avatar_url||null;if(!Ke){const{data:Ue}=G.storage.from("avatars").getPublicUrl(`${it.user_id}/avatar.jpg`);Ue!=null&&Ue.publicUrl&&(Ke=`${Ue.publicUrl}?t=${Date.now()}`)}const ct={...Xe,avatar_url:Ke,brokerage_name:$e};d(ct),f.current=ct}if(a)try{console.log("[ConnectPage] Resolving token:",a,"for page:",it.id);const{data:$e,error:Ke}=await G.functions.invoke("process-intake-submissions",{body:{action:"resolve_token",token:a,page_id:it.id}});if(console.log("[ConnectPage] Resolve result:",{resolved:$e,resolveErr:Ke}),!Ke&&($e!=null&&$e.contact_id)){w($e.contact_id);const ct=$e.contact;ct&&(b(ct),V(ct.first_name||""),se(ct.last_name||""),Y(ct.email||""),ie(ct.phone||""),le(ct.address||""),be(ct.city||""),we(ct.state||""),Ze(ct.zip||""),Ce(ct.birthday||""),Fe(ct.home_anniversary||""))}}catch($e){console.error("Failed to resolve token:",$e)}l(!1)},he=async()=>{var it,qe;if(!U.trim()){fe.error("Please enter your first name");return}if(!r){fe.error("Invalid page. Please refresh.");return}I(!0);try{let Xe=(it=v.current)==null?void 0:it.id,$e=(qe=v.current)==null?void 0:qe.user_id;if(!Xe||!$e){const{data:ct}=await G.from("contact_intake_pages").select("id, user_id").eq("slug",r).eq("is_active",!0).maybeSingle();if(!ct){fe.error("This page is no longer active. Please contact the agent directly."),I(!1);return}Xe=ct.id,$e=ct.user_id}const{error:Ke}=await G.from("contact_intake_submissions").insert({intake_page_id:Xe,agent_user_id:$e,existing_contact_id:j,first_name:U.trim(),last_name:X.trim()||null,email:te.trim()||null,phone:de.trim()||null,address:ae.trim()||null,city:pe.trim()||null,state:ye.trim()||null,zip:ke.trim()||null,birthday:_e||null,home_anniversary:Te||null,real_estate_interest:Ae||null,message:ht.trim()||null});if(console.log("[ConnectPage] Insert result:",{error:Ke}),Ke)throw Ke;a&&await G.from("contact_intake_tokens").update({used_at:new Date().toISOString()}).eq("token",a),C(!0)}catch(Xe){console.error(Xe),fe.error("Something went wrong. Please try again.")}finally{I(!1)}};if(o)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsx(As,{className:"h-8 w-8 animate-spin text-slate-400"})});if($)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("h1",{className:"text-2xl font-semibold text-slate-700",children:"Page Not Found"}),e.jsx("p",{className:"text-slate-500",children:"This connect page doesn't exist or is no longer active."})]})});if(N)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50 p-4",children:[e.jsx(ah,{children:e.jsxs("title",{children:["Thank You | ",i==null?void 0:i.name]})}),e.jsxs(wr.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"max-w-md w-full text-center space-y-6 p-8",children:[e.jsx(wr.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",delay:.2},className:"mx-auto w-20 h-20 rounded-full bg-emerald-100 flex items-center justify-center",children:e.jsx(da,{className:"h-10 w-10 text-emerald-600"})}),e.jsx("h1",{className:"text-3xl font-bold text-slate-800",children:"Thank You!"}),e.jsxs("p",{className:"text-lg text-slate-600",children:[i==null?void 0:i.name," has received your info and will be in touch soon."]}),e.jsxs("div",{className:"flex items-center justify-center gap-1 text-sm text-slate-400 pt-4",children:[e.jsx(Si,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})]})]});const Qe=!!a&&!!_,ot=3,rt=[{title:Qe?"Confirm Your Info":"Let's Get Connected",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"First Name *"}),e.jsx("input",{type:"text",value:U,onChange:it=>V(it.target.value),placeholder:"Jane",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Last Name"}),e.jsx("input",{type:"text",value:X,onChange:it=>se(it.target.value),placeholder:"Smith",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Email"}),e.jsx("input",{type:"email",value:te,onChange:it=>Y(it.target.value),placeholder:"jane@email.com",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Phone"}),e.jsx("input",{type:"tel",value:de,onChange:it=>ie(it.target.value),placeholder:"(555) 123-4567",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]})},{title:"A Little More About You",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Street Address"}),e.jsx("input",{type:"text",value:ae,onChange:it=>le(it.target.value),placeholder:"123 Main St",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"City"}),e.jsx("input",{type:"text",value:pe,onChange:it=>be(it.target.value),placeholder:"Austin",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"col-span-1",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"State"}),e.jsx("input",{type:"text",value:ye,onChange:it=>we(it.target.value),placeholder:"TX",maxLength:2,className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Zip"}),e.jsx("input",{type:"text",value:ke,onChange:it=>Ze(it.target.value),placeholder:"78701",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Birthday"}),e.jsx("input",{type:"date",value:_e,onChange:it=>Ce(it.target.value),className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Home Anniversary"}),e.jsx("input",{type:"date",value:Te,onChange:it=>Fe(it.target.value),className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]})]})},{title:"One Last Thing",fields:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-600 mb-3",children:["Are you thinking about making a move anytime soon? ",e.jsx("span",{className:"text-slate-400 font-normal",children:"(totally optional)"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{value:"buying",label:"🏠 Buying",desc:"Looking for a home"},{value:"selling",label:"📋 Selling",desc:"Thinking of selling"},{value:"both",label:"🔄 Both",desc:"Buy & sell"},{value:"not_now",label:"😊 Not right now",desc:"Just staying connected"}].map(it=>e.jsxs("button",{type:"button",onClick:()=>We(Ae===it.value?"":it.value),className:`p-3.5 rounded-xl border-2 text-left transition-all ${Ae===it.value?"border-blue-500 bg-blue-50 shadow-sm":"border-slate-200 bg-white hover:border-slate-300"}`,children:[e.jsx("span",{className:"block text-sm font-medium text-slate-800",children:it.label}),e.jsx("span",{className:"block text-xs text-slate-500 mt-0.5",children:it.desc})]},it.value))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:["Anything else you'd like to share? ",e.jsx("span",{className:"text-slate-400 font-normal",children:"(optional)"})]}),e.jsx("textarea",{value:ht,onChange:it=>De(it.target.value),placeholder:"Feel free to drop a note...",rows:3,className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all resize-none"})]})]})}];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-blue-50",children:[e.jsxs(ah,{children:[e.jsxs("title",{children:["Connect with ",(i==null?void 0:i.name)||"Agent"]}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-8 sm:py-12",children:[e.jsxs(wr.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"text-center mb-8",children:[i!=null&&i.avatar_url?e.jsx("img",{src:i.avatar_url,alt:i.name,className:"w-24 h-24 rounded-full object-cover mx-auto mb-4 ring-4 ring-white shadow-lg"}):e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-blue-500 to-indigo-600 mx-auto mb-4 flex items-center justify-center ring-4 ring-white shadow-lg",children:e.jsx("span",{className:"text-3xl font-bold text-white",children:((Ne=i==null?void 0:i.name)==null?void 0:Ne.charAt(0))||"?"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800",children:i==null?void 0:i.name}),(i==null?void 0:i.title)&&e.jsx("p",{className:"text-slate-500 mt-0.5",children:i.title}),(i==null?void 0:i.brokerage_name)&&e.jsx("p",{className:"text-sm text-slate-400",children:i.brokerage_name}),((i==null?void 0:i.phone)||(i==null?void 0:i.email))&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[(i==null?void 0:i.phone)&&e.jsx("a",{href:`tel:${i.phone}`,className:"flex items-center justify-center w-10 h-10 rounded-full bg-blue-50 hover:bg-blue-100 text-blue-600 transition-colors","aria-label":"Call agent",children:e.jsx(Zn,{className:"h-4.5 w-4.5"})}),(i==null?void 0:i.email)&&e.jsx("a",{href:`mailto:${i.email}`,className:"flex items-center justify-center w-10 h-10 rounded-full bg-blue-50 hover:bg-blue-100 text-blue-600 transition-colors","aria-label":"Email agent",children:e.jsx(_r,{className:"h-4.5 w-4.5"})})]})]}),e.jsx(wr.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},className:"text-center text-slate-600 mb-8 px-4 leading-relaxed",children:(u==null?void 0:u.welcome_message)||"I'd love to stay connected! Fill in your info below."}),e.jsx("div",{className:"flex gap-2 mb-8 px-2",children:Array.from({length:ot}).map((it,qe)=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-all duration-500 ${qe<=L?"bg-blue-500":"bg-slate-200"}`},qe))}),e.jsxs(wr.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},className:"bg-white rounded-2xl shadow-lg shadow-slate-200/50 border border-slate-100 p-6 sm:p-8",children:[e.jsx(jCt,{mode:"wait",children:e.jsxs(wr.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.25},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[e.jsx(hn,{className:"h-5 w-5 text-blue-500"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-800",children:rt[L].title})]}),rt[L].fields]},L)}),e.jsxs("div",{className:"flex justify-between mt-8",children:[L>0?e.jsx("button",{type:"button",onClick:()=>R(it=>it-1),className:"px-5 py-2.5 text-sm font-medium text-slate-600 hover:text-slate-800 transition-colors",children:"Back"}):e.jsx("div",{}),L{if(L===0&&!U.trim()){fe.error("Please enter your first name");return}R(it=>it+1)},className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm",children:"Continue"}):e.jsx("button",{type:"button",onClick:()=>he(),disabled:A,className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm disabled:opacity-50 flex items-center gap-2",children:A?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):"Submit"})]}),L>0&&LR(it=>it+1),className:"text-xs text-slate-400 hover:text-slate-500 transition-colors",children:"Skip this step"})})]}),e.jsx("div",{className:"text-center mt-8",children:e.jsxs("div",{className:"flex items-center justify-center gap-1 text-xs text-slate-400",children:[e.jsx(Si,{className:"h-3 w-3"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})})]})]})}function rE({banners:t,autoPlayInterval:s=5e3,className:r}){const[n,a]=S.useState(0),[o,l]=S.useState(!1),i=S.useCallback(()=>{a(f=>(f+1)%t.length)},[t.length]),d=S.useCallback(()=>{a(f=>(f-1+t.length)%t.length)},[t.length]),u=S.useCallback(f=>{a(f)},[]);if(S.useEffect(()=>{if(t.length<=1||o)return;const f=setInterval(i,s);return()=>clearInterval(f)},[t.length,o,s,i]),!t||t.length===0)return null;const p=t[n];return e.jsxs("div",{className:Pt("relative w-full overflow-hidden rounded-xl",r),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[e.jsxs("div",{className:"relative aspect-[21/9] md:aspect-[3/1] w-full",children:[e.jsx("img",{src:p.image_url,alt:p.title,className:"w-full h-full object-cover rounded-t-xl"}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:Pt("absolute left-2 top-1/2 -translate-y-1/2 bg-black/30 hover:bg-black/50 text-white rounded-full","opacity-0 transition-opacity",o&&"opacity-100"),onClick:d,children:e.jsx(zl,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:Pt("absolute right-2 top-1/2 -translate-y-1/2 bg-black/30 hover:bg-black/50 text-white rounded-full","opacity-0 transition-opacity",o&&"opacity-100"),onClick:i,children:e.jsx(Ha,{className:"h-6 w-6"})})]}),t.length>1&&e.jsx("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex gap-2",children:t.map((f,v)=>e.jsx("button",{onClick:()=>u(v),className:Pt("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:p.title}),p.description&&e.jsx("p",{className:"text-xs text-background/70 truncate",children:p.description})]}),p.link_url&&e.jsx("a",{href:p.link_url,target:"_blank",rel:"noopener noreferrer",className:"shrink-0",children:e.jsx(K,{size:"sm",className:"bg-primary text-primary-foreground font-semibold transition-colors hover:bg-background hover:text-foreground",children:p.link_text||"Learn More"})})]})]})}function E4t(t){return"EST"}function s6(t){const r=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(t),n=E4t();return`${r} ${n}`}function P5(t){const s=new Date,r=new Date(t),n=R4(r,-15),a=R4(r,30);return s>a?"ended":wg(s,{start:r,end:a})?"live":wg(s,{start:n,end:r})?"starting_soon":"upcoming"}function Q_e(t){const s=P5(t);return s==="starting_soon"||s==="live"}const $Me=Q_e,P4t=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=S.useState(new Date);S.useEffect(()=>{const _=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(_)},[]);const o=t.filter(_=>Q_e(_.event_date));if(o.length===0)return null;const l=o[0],i=P5(l.event_date),d=s.find(_=>_.event_id===l.id),u=(d==null?void 0:d.zoom_join_url)||l.zoom_link,p=!!d,f=i==="live",v=f?{container:"from-red-500/10 via-red-500/5 to-primary/10 border-red-500/30",pulse:"from-red-500/5",indicator:"bg-red-500",text:"text-red-500",button:"bg-red-500 hover:bg-red-600",outlineButton:"border-red-500/50 text-red-500 hover:bg-red-500/10"}:{container:"from-amber-500/10 via-amber-500/5 to-primary/10 border-amber-500/30",pulse:"from-amber-500/5",indicator:"bg-amber-500",text:"text-amber-500",button:"bg-amber-500 hover:bg-amber-600",outlineButton:"border-amber-500/50 text-amber-500 hover:bg-amber-500/10"};return e.jsxs("div",{className:`relative mb-8 overflow-hidden rounded-xl bg-gradient-to-r ${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:f?e.jsxs(e.Fragment,{children:[e.jsx(lN,{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:f?`Started at ${s6(new Date(l.event_date))}`:`Starts at ${s6(new Date(l.event_date))}`})]}),e.jsx("div",{className:"flex items-center gap-2",children:p?e.jsxs(K,{onClick:()=>window.open(u,"_blank"),className:`${v.button} text-white gap-2`,children:[e.jsx(sn,{className:"h-4 w-4"}),f?"Join Now":"Join When Live"]}):e.jsxs(K,{variant:"outline",onClick:r,className:`${v.outlineButton} gap-2`,children:[e.jsx(hr,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var J_e="Progress",ebe=100,[I4t]=Ac(J_e),[L4t,D4t]=I4t(J_e),ZUe=S.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=O4t,...l}=t;(a||a===0)&&!qMe(a)&&console.error(R4t(`${a}`,"Progress"));const i=qMe(a)?a:ebe;n!==null&&!UMe(n,i)&&console.error(F4t(`${n}`,"Progress"));const d=UMe(n,i)?n:null,u=Dne(d)?o(d,i):void 0;return e.jsx(L4t,{scope:r,value:d,max:i,children:e.jsx(Qr.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":Dne(d)?d:void 0,"aria-valuetext":u,role:"progressbar","data-state":QUe(d,i),"data-value":d??void 0,"data-max":i,...l,ref:s})})});ZUe.displayName=J_e;var YUe="ProgressIndicator",XUe=S.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=D4t(YUe,r);return e.jsx(Qr.div,{"data-state":QUe(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});XUe.displayName=YUe;function O4t(t,s){return`${Math.round(t/s*100)}%`}function QUe(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function Dne(t){return typeof t=="number"}function qMe(t){return Dne(t)&&!isNaN(t)&&t>0}function UMe(t,s){return Dne(t)&&!isNaN(t)&&t<=s&&t>=0}function R4t(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${ebe}\`.`}function F4t(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 ${ebe} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var JUe=ZUe,z4t=XUe;const Ti=S.forwardRef(({className:t,value:s,...r},n)=>e.jsx(JUe,{ref:n,className:Pt("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(z4t,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));Ti.displayName=JUe.displayName;function B4t(){const{user:t,isBrokerageManager:s}=Gs(),[r,n]=S.useState([]),[a,o]=S.useState([]),[l,i]=S.useState(!1),[d,u]=S.useState(!0),p=s?"brokerage_manager":"agent";S.useEffect(()=>{if(!(t!=null&&t.id)){u(!1);return}f()},[t==null?void 0:t.id,p]);const f=async()=>{if(t!=null&&t.id)try{const{data:I,error:L}=await G.from("onboarding_checklist_items").select("*").eq("target_role",p).eq("is_active",!0).order("sort_order");if(L)throw L;const{data:R,error:$}=await G.from("onboarding_checklist_progress").select("item_id, completed_at").eq("user_id",t.id);if($)throw $;const{data:q,error:U}=await G.from("onboarding_checklist_dismissed").select("id").eq("user_id",t.id).maybeSingle();if(U)throw U;n(I||[]),o(R||[]),i(!!q),I&&I.length>0&&await v(I,R||[])}catch(I){console.error("Error fetching checklist data:",I)}finally{u(!1)}},v=async(I,L)=>{var Fe,Ae;if(!(t!=null&&t.id))return;const R=L.map(We=>We.item_id),$=I.filter(We=>!R.includes(We.id));if($.length===0)return;const[q,U,V,X,se,te,Y,de,ie,ae,le,pe,be,ye,we]=await Promise.all([G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle(),G.from("resource_shares").select("id",{count:"exact",head:!0}).eq("sender_id",t.id),G.from("community_posts").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("event_registrations").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","template"),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","academy_video"),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","toolbox"),G.from("activity_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("innercircle_contacts").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("agent_videos").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("contact_touch_logs").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("scorecard_transactions").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("listings").select("id",{count:"exact",head:!0}).eq("agent_id",t.id),G.from("innercircle_contacts").select("id").eq("owner_user_id",t.id),G.from("deal_pipeline").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id)]),ke={},Ze=(Fe=q.data)==null?void 0:Fe.brokerage_id;ke.share_resource=(U.count||0)>0,ke.post_community=(V.count||0)>0,ke.register_event=(X.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=(de.count||0)>0,ke.add_contact=(ie.count||0)>0,ke.create_video=(ae.count||0)>0,ke.complete_touch=(le.count||0)>0,ke.add_transaction=(pe.count||0)>0,ke.add_listing=(be.count||0)>0,ke.add_deal=(we.count||0)>0;const _e=((Ae=ye.data)==null?void 0:Ae.map(We=>We.id))||[],Ce=[];Ze?Ce.push(G.from("profiles").select("id").eq("brokerage_id",Ze).neq("id",t.id).then(We=>{var ht;ke.add_agent=(((ht=We.data)==null?void 0:ht.length)||0)>0})):ke.add_agent=!1,_e.length>0?(Ce.push(G.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",_e).then(We=>{ke.add_plan=(We.count||0)>0})),Ce.push(G.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",_e).then(We=>{ke.schedule_popby=(We.count||0)>0}))):(ke.add_plan=!1,ke.schedule_popby=!1),await Promise.all(Ce);const Te=$.filter(We=>ke[We.action_type]);if(Te.length>0){const We=Te.map(De=>({user_id:t.id,item_id:De.id})),{error:ht}=await G.from("onboarding_checklist_progress").upsert(We,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!ht){const De=Te.map(Dt=>({item_id:Dt.id,completed_at:new Date().toISOString()}));o(Dt=>[...Dt,...De])}}},_=async I=>{if(t!=null&&t.id)try{const{error:L}=await G.from("onboarding_checklist_progress").insert({user_id:t.id,item_id:I});if(L)throw L;o(R=>[...R,{item_id:I,completed_at:new Date().toISOString()}])}catch(L){console.error("Error marking item complete:",L)}},b=async()=>{if(t!=null&&t.id)try{const{error:I}=await G.from("onboarding_checklist_dismissed").insert({user_id:t.id});if(I)throw I;i(!0)}catch(I){console.error("Error dismissing checklist:",I)}},j=a.length,w=r.length,N=w>0&&j>=w,C=w>0?j/w*100:0;return{items:r,progress:a,isDismissed:l,loading:d,completedCount:j,totalCount:w,isComplete:N,progressPercentage:C,isItemComplete:I=>a.some(L=>L.item_id===I),markComplete:_,dismiss:b,refetch:f}}const $4t={add_agent:e.jsx(hr,{className:"h-4 w-4"}),share_resource:e.jsx(cd,{className:"h-4 w-4"}),post_community:e.jsx(oo,{className:"h-4 w-4"}),register_event:e.jsx(on,{className:"h-4 w-4"}),view_template:e.jsx(l0,{className:"h-4 w-4"}),watch_academy:e.jsx(sh,{className:"h-4 w-4"}),use_toolbox:e.jsx($g,{className:"h-4 w-4"}),launch_app:e.jsx(GE,{className:"h-4 w-4"}),add_deal:e.jsx(Wx,{className:"h-4 w-4"}),add_listing:e.jsx(Un,{className:"h-4 w-4"})},q4t={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function U4t(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:d,dismiss:u}=B4t(),p=Dr(),[f,v]=S.useState(!0);return r||s||a===0||o?null:e.jsxs(Ee,{className:"mb-6 border-primary/20 bg-gradient-to-r from-primary/5 to-transparent",children:[e.jsxs(Lt,{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(Gx,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Get Started with LevelUp"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Complete these steps to make the most of your membership"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>v(!f),className:"h-8 w-8 p-0",children:f?e.jsx(Rg,{className:"h-4 w-4"}):e.jsx(Vo,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",children:e.jsx(Ur,{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(Ti,{value:l,className:"h-2"})]})]}),f&&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:Pt("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 j=q4t[_.action_type];j?p(j):d(_.id)},children:[e.jsx("div",{className:"mt-0.5",children:b?e.jsx(da,{className:"h-5 w-5 text-primary"}):e.jsx(Gc,{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:$4t[_.action_type]||e.jsx(Gc,{className:"h-4 w-4"})}),e.jsx("span",{className:Pt("font-medium",b&&"line-through text-muted-foreground"),children:_.title})]}),_.description&&e.jsx("p",{className:Pt("text-sm text-muted-foreground mt-1",b&&"line-through"),children:_.description})]})]},_.id)})})})]})}const Ef=()=>Ct({queryKey:["relationship-types"],queryFn:async()=>{const{data:t,error:s}=await G.from("relationship_types").select("*").order("sort_order");if(s)throw s;return t}}),Jh=t=>{const s=ti(),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=G.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})},V4t=t=>Ct({queryKey:["innercircle-contact",t],queryFn:async()=>{const{data:s,error:r}=await G.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}),eVe=()=>{const t=ti();return Ct({queryKey:["innercircle-contact-counts",t],queryFn:async()=>{const{data:s,error:r}=await G.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})},Yoe=()=>{const t=ns(),s=ti();return Ot({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 G.from("innercircle_contacts").insert(o).select().single();if(i)throw i;if(n&&n.length>0){const{error:d}=await G.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"]}),an({title:"Contact created successfully"})},onError:r=>{an({title:"Error creating contact",description:r.message,variant:"destructive"})}})},tbe=()=>{const t=ns();return Ot({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 G.from("innercircle_contacts").update(l).eq("id",s).select().single();if(d)throw d;if(n!==void 0&&(await G.from("innercircle_contact_tags").delete().eq("contact_id",s),n.length>0)){const{error:u}=await G.from("innercircle_contact_tags").insert(n.map(p=>({contact_id:s,relationship_type_id:p})));if(u)throw u}return i},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),an({title:"Contact updated successfully"})},onError:s=>{an({title:"Error updating contact",description:s.message,variant:"destructive"})}})},tVe=()=>{const t=ns();return Ot({mutationFn:async({contactId:s,spouseContactId:r})=>{if(r){const{error:n}=await G.from("innercircle_contacts").update({spouse_contact_id:r}).eq("id",s);if(n)throw n;const{error:a}=await G.from("innercircle_contacts").update({spouse_contact_id:s}).eq("id",r);if(a)throw a}else{const{data:n}=await G.from("innercircle_contacts").select("spouse_contact_id").eq("id",s).single(),a=n==null?void 0:n.spouse_contact_id,{error:o}=await G.from("innercircle_contacts").update({spouse_contact_id:null}).eq("id",s);if(o)throw o;if(a){const{error:l}=await G.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"]}),an({title:"Spouse link updated"})},onError:s=>{an({title:"Error linking spouse",description:s.message,variant:"destructive"})}})},sbe=()=>{const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("innercircle_contacts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),an({title:"Contact deleted successfully"})},onError:s=>{an({title:"Error deleting contact",description:s.message,variant:"destructive"})}})},IL=()=>Ct({queryKey:["action-types"],queryFn:async()=>{const{data:t,error:s}=await G.from("action_types").select("*").order("sort_order");if(s)throw s;return t}}),H4t=t=>Ct({queryKey:["action-scripts",t],queryFn:async()=>{let s=G.from("action_scripts").select("*, action_type:action_types(*)");const{data:r,error:n}=await s;if(n)throw n;return r}}),W4t=()=>Ct({queryKey:["touchpoint-plans"],queryFn:async()=>{const{data:t,error:s}=await G.from("touchpoint_plans").select(` *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) `).order("name");if(s)throw s;return t}}),G4t=()=>{const t=ns(),s=ti();return Ot({mutationFn:async({name:r,description:n})=>{const{data:a,error:o}=await G.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"]}),an({title:"Plan created successfully"})},onError:r=>{an({title:"Error creating plan",description:r.message,variant:"destructive"})}})},K4t=()=>{const t=ns(),s=ti();return Ot({mutationFn:async({sourcePlanId:r,newName:n})=>{const{data:a,error:o}=await G.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 G.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(p=>({plan_id:l.id,month_number:p.month_number,action_type_id:p.action_type_id,default_script_id:p.default_script_id,notes:p.notes})),{error:u}=await G.from("touchpoint_plan_items").insert(d);if(u)throw u}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),an({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{an({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},Z4t=()=>{const t=ns();return Ot({mutationFn:async({id:s,name:r,description:n})=>{const{data:a,error:o}=await G.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"]}),an({title:"Plan updated successfully"})}})},Y4t=()=>{const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("touchpoint_plans").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),an({title:"Plan deleted successfully"})}})},X4t=()=>{const t=ns();return Ot({mutationFn:async({planId:s,items:r})=>{if(await G.from("touchpoint_plan_items").delete().eq("plan_id",s),r.length>0){const{error:n}=await G.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"]}),an({title:"Plan schedule updated"})}})},Q4t=()=>{const t=ns();return Ot({mutationFn:async({actionTypeId:s,title:r,scriptBody:n,emailSubject:a,tone:o})=>{const{data:{user:l}}=await G.auth.getUser(),{data:i,error:d}=await G.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"]}),an({title:"Script created successfully"})},onError:s=>{an({title:"Error creating script",description:s.message,variant:"destructive"})}})},J4t=()=>{const t=ti();return Ct({queryKey:["user-plan-enrollments",t],queryFn:async()=>{const{data:s,error:r}=await G.from("user_plan_enrollments").select(` *, plan:touchpoint_plans(*), relationship_type:relationship_types(*) `);if(r)throw r;return s},enabled:!!t})},e5t=()=>{const t=ns(),s=ti();return Ot({mutationFn:async({planId:r,relationshipTypeId:n,active:a})=>{const{data:o}=await G.from("user_plan_enrollments").select("id").eq("plan_id",r).eq("relationship_type_id",n).maybeSingle();if(o){const{error:l}=await G.from("user_plan_enrollments").update({active:a}).eq("id",o.id);if(l)throw l}else if(a){const{error:l}=await G.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"]}),an({title:"Plan enrollment updated"})}})},LL=(t=7)=>{const s=ti();return Ct({queryKey:["contact-touch-logs",s,t],queryFn:async()=>{const r=new Date;r.setDate(r.getDate()-t);const{data:n,error:a}=await G.from("contact_touch_logs").select(` *, contact:innercircle_contacts(*), action_type:action_types(*) `).eq("owner_user_id",s).gte("completed_at",r.toISOString()).order("completed_at",{ascending:!1});if(a)throw a;return n},enabled:!!s})},sVe=()=>{const t=ti();return Ct({queryKey:["contacts-last-touch",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_touch_logs").select("contact_id, completed_at").eq("owner_user_id",t).order("completed_at",{ascending:!1});if(r)throw r;const n={};return s==null||s.forEach(a=>{n[a.contact_id]||(n[a.contact_id]=a.completed_at)}),n},enabled:!!t})},t5t=(t=90)=>{const{data:s}=Jh(),{data:r}=sVe();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=ns(),s=ti();return Ot({mutationFn:async({contactId:r,actionTypeId:n,scriptUsedId:a,notes:o,completedAt:l})=>{const{data:i,error:d}=await G.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"]}),an({title:"Action completed!"});try{const[l,i]=await Promise.all([G.from("innercircle_contacts").select("email").eq("id",n.contactId).single(),G.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&&G.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{}}})},rVe="agentos_weekly_touch_goal",VMe=20,One=()=>{if(typeof window>"u")return VMe;const t=localStorage.getItem(rVe);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return VMe},nVe=t=>{localStorage.setItem(rVe,t.toString())},nbe=()=>{const{data:t}=LL(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=One();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},s5t=()=>{const t=ti();return Ct({queryKey:["contact-plan-cycles",t],queryFn:async()=>{const{data:s,error:r}=await G.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})},r5t=()=>{const t=ns();return ti(),Ot({mutationFn:async()=>{const{data:s}=await G.from("user_plan_enrollments").select("*").eq("active",!0);if(!s||s.length===0)return;const{data:r}=await G.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(!r)return;const{data:n}=await G.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 G.from("contact_plan_cycles").insert(o);if(l)throw l}return o.length},onSuccess:s=>{t.invalidateQueries({queryKey:["contact-plan-cycles"]}),s&&s>0&&an({title:`${s} contact(s) enrolled in plans`})}})},aVe=()=>{const t=ti(),{data:s}=s5t(),{data:r}=LL(30);return Ct({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 G.from("contact_snoozes").select("contact_id").gte("snoozed_until",new Date().toISOString()),a=new Set((n==null?void 0:n.map(j=>j.contact_id))||[]),o=new Date,l=[],i=new Date(o.getFullYear(),o.getMonth(),1),d=new Set((r==null?void 0:r.filter(j=>new Date(j.completed_at)>=i).map(j=>`${j.contact_id}-${j.action_type_id}`))||[]);for(const j of s){if(!((b=j.plan)!=null&&b.items)||j.plan.items.length===0||!j.contact||a.has(j.contact_id))continue;const w=new Date(j.cycle_start_date),C=Math.floor((o.getTime()-w.getTime())/(30.44*24*60*60*1e3))%12+1,A=j.plan.items.find(I=>I.month_number===C);if(A&&A.action_type){const I=`${j.contact_id}-${A.action_type_id}`;if(!d.has(I)){const{data:L}=await G.from("relationship_types").select("name").eq("id",j.relationship_type_id).single();l.push({contact:j.contact,actionType:A.action_type,script:A.default_script||void 0,planName:j.plan.name,relationshipTypeName:(L==null?void 0:L.name)||"",monthNumber:C})}}}const u=5,p=o.getDate(),f=l.sort((j,w)=>j.contact.first_name.localeCompare(w.contact.first_name)),v=(p-1)%Math.max(1,f.length);return[...f.slice(v),...f.slice(0,v)].slice(0,u)},enabled:!!t&&!!s})};function n5t(){const t=Dr(),{data:s,isLoading:r}=aVe(),{data:n}=Jh(),a=nbe(),[o,l]=S.useState(One()),[i,d]=S.useState(""),[u,p]=S.useState(!1);S.useEffect(()=>{l(One())},[]);const f=()=>{const R=parseInt(i,10);if(isNaN(R)||R<1){an({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(R),nVe(R),p(!1),an({title:"Goal updated",description:`Weekly touch goal set to ${R}`})},v=()=>{d(o.toString()),p(!0)},_=Gh(new Date),b=ml(_,7),j=R=>{if(!R)return null;const $=R.split(/[-/T]/);if($.length<3)return null;const q=parseInt($[1],10)-1,U=parseInt($[2],10);return isNaN(q)||isNaN(U)?null:new Date(_.getFullYear(),q,U)},w=(n==null?void 0:n.map(R=>{const $=j(R.birthday),q=j(R.home_anniversary),U=[];return $&&$>=_&&$<=b&&U.push({contact:R,type:"birthday",date:$,isToday:cl($,_)}),q&&q>=_&&q<=b&&U.push({contact:R,type:"anniversary",date:q,isToday:cl(q,_)}),U}).flat().sort((R,$)=>R.date.getTime()-$.date.getTime()).slice(0,3))||[],N=(n==null?void 0:n.filter(R=>{const $=j(R.birthday),q=j(R.home_anniversary);return $&&cl($,_)||q&&cl(q,_)}).length)||0,C=(s==null?void 0:s.length)||0,A=N+C,I=(a==null?void 0:a.actionsThisWeek)||0,L=(a==null?void 0:a.streak)||0;return r?e.jsx(Ee,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-primary/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-primary/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-primary/10 rounded w-1/2"})]})]})})}):e.jsxs(Ee,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:[e.jsxs(Lt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5 text-primary"}),"Agent OS"]}),e.jsx("div",{className:"flex items-center gap-2",children:L>0&&e.jsxs(at,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[e.jsx($h,{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(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:R=>{R.stopPropagation(),t("/mission-control/contacts?new=true")},children:[e.jsx(xc,{className:"h-3.5 w-3.5"}),"Add Contact"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:R=>{R.stopPropagation(),t("/mission-control")},children:[e.jsx(Zn,{className:"h-3.5 w-3.5"}),"Log Touch"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-emerald-200 text-emerald-700 hover:bg-emerald-50 hover:text-emerald-800",onClick:R=>{R.stopPropagation(),t("/mission-control/video/record")},children:[e.jsx(kn,{className:"h-3.5 w-3.5"}),"Quick Video"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:R=>{R.stopPropagation(),t("/mission-control/popbys")},children:[e.jsx(Ai,{className:"h-3.5 w-3.5"}),"Pop-by Map"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-purple-200 text-purple-700 hover:bg-purple-50 hover:text-purple-800",onClick:R=>{R.stopPropagation(),t("/mission-control/pipeline")},children:[e.jsx(Wx,{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(Hh,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Weekly Goal"}),e.jsxs(vs,{open:u,onOpenChange:p,children:[e.jsx(Ei,{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($l,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})}),e.jsxs(ys,{className:"sm:max-w-[360px]",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{htmlFor:"weekly-goal",children:"Weekly touch goal"}),e.jsx(Re,{id:"weekly-goal",type:"number",min:"1",value:i,onChange:R=>d(R.target.value),placeholder:"20",onKeyDown:R=>{R.key==="Enter"&&f()}})]}),e.jsx(K,{onClick:f,className:"w-full",children:"Save Goal"})]})]})]})]}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium text-primary",children:I}),e.jsxs("span",{className:"text-muted-foreground",children:[" / ",o," touches"]})]})]}),e.jsx(Ti,{value:Math.min(I/o*100,100),className:"h-2 bg-muted [&>div]:bg-primary"}),I>=o&&e.jsxs("p",{className:"text-xs text-emerald-600 mt-1.5 flex items-center gap-1",children:[e.jsx("span",{children:"🎉"})," Goal achieved! Keep the momentum going."]}),I0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5",children:[o-I," more to hit your weekly goal"]})]}),w.length>0&&e.jsxs("div",{className:"pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ru,{className:"h-4 w-4 text-pink-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Upcoming Milestones"})]}),e.jsx("div",{className:"space-y-2",children:w.map((R,$)=>e.jsxs("div",{className:`flex items-center justify-between p-2 rounded-lg cursor-pointer transition-colors ${R.isToday?"bg-pink-500/10 hover:bg-pink-500/15":"bg-muted/50 hover:bg-muted"}`,onClick:q=>{q.stopPropagation(),t(`/mission-control/contacts/${R.contact.id}`)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[R.type==="birthday"?e.jsx(Ru,{className:"h-3.5 w-3.5 text-pink-500"}):e.jsx(Un,{className:"h-3.5 w-3.5 text-blue-500"}),e.jsxs("span",{className:"text-sm",children:[R.contact.first_name," ",R.contact.last_name]}),R.isToday&&e.jsx(at,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-pink-500/20 text-pink-600",children:"Today!"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:R.isToday?R.type==="birthday"?"🎂":"🏠":ws(R.date,"EEE, MMM d")}),e.jsx(Ha,{className:"h-3 w-3"})]})]},`${R.contact.id}-${R.type}-${$}`))})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full gap-1 text-muted-foreground hover:text-primary",onClick:()=>t("/mission-control"),children:["Open Agent OS",e.jsx(Fi,{className:"h-4 w-4"})]})]})]})}function a5t(t){return Ct({queryKey:["brokerage-content-categories",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("brokerage_content_categories").select("*").eq("brokerage_id",t).order("sort_order");if(r)throw r;return s},enabled:!!t})}function i5t(t,s){return Ct({queryKey:["brokerage-content",t,s],queryFn:async()=>{if(!t)return[];let r=G.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 o5t(t,s=4){return Ct({queryKey:["brokerage-content-recent",t,s],queryFn:async()=>{if(!t)return[];const{data:r,error:n}=await G.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 l5t(t){const s=ns();return Ot({mutationFn:async r=>{const{data:n,error:a}=await G.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 c5t(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("brokerage_content").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content"]}),t.invalidateQueries({queryKey:["brokerage-content-recent"]})}})}function d5t(t){const s=ns();return Ot({mutationFn:async r=>{const{data:n,error:a}=await G.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 u5t(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("brokerage_content_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}function h5t(t){const s=ns();return Ot({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 G.from("brokerage_content_categories").upsert(r,{onConflict:"brokerage_id,name"});if(n)throw n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}const m5t={video:ul,pdf:In,link:Ho,event:on,graphic:Bl},p5t={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 f5t(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 g5t(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 x5t({item:t}){const s=Dr(),r=m5t[t.content_type]||Ho,n=p5t[t.content_type]||"",[a,o]=S.useState(null),l=t.thumbnail_url||(t.content_type==="graphic"&&t.file_url?t.file_url:null)||(t.content_type==="video"?f5t(t.url):null);S.useEffect(()=>{l||!t.url||t.content_type!=="video"||!g5t(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(Ee,{className:"group cursor-pointer overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",onClick:()=>s(`/brokerage-content/${t.id}`),children:[i?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:i,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/20 flex items-center justify-center",children:e.jsx(r,{className:"h-8 w-8 text-muted-foreground/30"})}),e.jsxs(Oe,{className:"p-3",children:[e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsxs(at,{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:ws(new Date(t.event_date),"MMM d · h:mm a")})]})]})}function y5t(){const{brokerageId:t}=Gs(),s=Dr(),{data:r=[],isLoading:n}=o5t(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(Aa,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Brokerage Content"})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/brokerage-content"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Fi,{className:"h-4 w-4"})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:r.map(a=>e.jsx(x5t,{item:a},a.id))})]})}const iVe=()=>Ct({queryKey:["listing-exchange-enabled"],queryFn:async()=>{const{data:t,error:s}=await G.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").maybeSingle();if(s)throw s;return(t==null?void 0:t.enabled)??!1}}),oVe=t=>{const{user:s,brokerageId:r}=Gs();return Ct({queryKey:["listings",t,r],queryFn:async()=>{let n=G.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 G.from("profiles").select("id").eq("brokerage_id",r);if(i&&i.length>0){const d=i.map(f=>f.id);let u=G.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:p}=await u;if(p){const f=new Set(l.map(_=>_.id)),v=p.filter(_=>!f.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}})},lVe=()=>{const{user:t}=Gs();return Ct({queryKey:["my-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("listings").select(` *, photos:listing_photos(*) `).eq("agent_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})},cVe=t=>{const{user:s}=Gs();return Ct({queryKey:["listing",t],queryFn:async()=>{const{data:r,error:n}=await G.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 G.from("listing_views").insert({listing_id:t,viewer_id:s.id}),r},enabled:!!t})},v5t=()=>{const t=ns(),{user:s}=Gs();return Ot({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n,error:a}=await G.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"]})}})},_5t=()=>{const t=ns();return Ot({mutationFn:async({agentId:s,...r})=>{const{data:n,error:a}=await G.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"]})}})},b5t=()=>{const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.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]})}})},dVe=()=>{const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("listings").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},w5t=()=>{const t=ns();return Ot({mutationFn:async({listingId:s,photoUrl:r,isPrimary:n=!1})=>{const{data:a,error:o}=await G.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"]})}})},j5t=()=>{const t=ns();return Ot({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await G.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"]})}})},k5t=()=>{const t=ns();return Ot({mutationFn:async({photos:s})=>{var o;const r=s.map(l=>G.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"]})}})},N5t=()=>{const t=ns();return Ot({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await G.from("listing_photos").update({is_primary:!1}).eq("listing_id",r);if(n)throw n;const{error:a}=await G.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"]})}})},S5t=()=>{const{user:t}=Gs();return Ct({queryKey:["saved-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.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})},uVe=()=>{const t=ns(),{user:s}=Gs();return Ot({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await G.from("listing_saves").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await G.from("listing_saves").delete().eq("id",n.id),{saved:!1}):(await G.from("listing_saves").insert({listing_id:r,agent_id:s.id}),{saved:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["saved-listings"]}),t.invalidateQueries({queryKey:["listings"]})}})},hVe=t=>{const{user:s}=Gs();return Ct({queryKey:["listing-saved",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await G.from("listing_saves").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},C5t=()=>{const t=ns(),{user:s}=Gs();return Ot({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await G.from("listing_follows").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await G.from("listing_follows").delete().eq("id",n.id),{following:!1}):(await G.from("listing_follows").insert({listing_id:r,agent_id:s.id}),{following:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["listing-following"]})}})},M5t=t=>{const{user:s}=Gs();return Ct({queryKey:["listing-following",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await G.from("listing_follows").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},T5t=()=>{const{user:t}=Gs();return Ot({mutationFn:async({listingId:s,shareType:r})=>{if(!t)throw new Error("Not authenticated");const{error:n}=await G.from("listing_shares").insert({listing_id:s,sharing_agent_id:t.id,share_type:r});if(n)throw n}})},A5t=()=>{const{user:t}=Gs();return Ct({queryKey:["my-referrals",t==null?void 0:t.id],queryFn:async()=>{if(!t)return{sent:[],received:[]};const[s,r]=await Promise.all([G.from("listing_referrals").select(` *, listing:listings(*,photos:listing_photos(*)) `).eq("sender_agent_id",t.id).order("created_at",{ascending:!1}),G.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})},E5t=()=>{const t=ns(),{user:s}=Gs();return Ot({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 G.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"]})}})},P5t=()=>Ct({queryKey:["listing-leaderboard"],queryFn:async()=>{const{data:t}=await G.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 G.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}}}),I5t=()=>{const{user:t,brokerageId:s}=Gs();return Ct({queryKey:["brokerage-listings",s],queryFn:async()=>{if(!t||!s)return[];const{data:r}=await G.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 G.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})},mVe=({className:t,variant:s="default"})=>e.jsx(at,{variant:"outline",className:Pt("text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0 h-4",s==="default"?"border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10":"border-muted-foreground/30 text-muted-foreground",t),children:"Beta"}),L5t={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"},D5t={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function O5t(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function R5t(){const t=Dr(),{data:s,isLoading:r}=iVe(),{data:n,isLoading:a}=oVe({status:void 0,propertyType:void 0,sortBy:"newest"}),o=(n==null?void 0:n.filter(p=>p.is_approved&&p.is_public))||[],l=o.filter(p=>p.is_featured),i=o.filter(p=>!p.is_featured),d=[...l,...i].slice(0,6),u=r||a;return!u&&!s?null:u?e.jsx(Ee,{className:"bg-gradient-to-br from-emerald-500/5 via-emerald-500/10 to-emerald-500/5 border-emerald-500/20",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-emerald-500/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-emerald-500/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-emerald-500/10 rounded w-1/2"})]})]})})}):e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Listing Exchange"}),e.jsx(mVe,{})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control/listings"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Fi,{className:"h-4 w-4"})]})]}),d.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Un,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No listings available yet"}),e.jsx(K,{variant:"link",size:"sm",onClick:()=>t("/mission-control/listings/new"),className:"mt-2",children:"Add the first listing"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:d.map(p=>{var v,_;const f=((v=p.photos)==null?void 0:v.find(b=>b.is_primary))||((_=p.photos)==null?void 0:_[0]);return e.jsxs("div",{onClick:()=>t(`/mission-control/listings/${p.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"aspect-[4/3] bg-muted/50 overflow-hidden relative",children:[f!=null&&f.photo_url?e.jsx("img",{src:f.photo_url,alt:`${p.city}, ${p.state}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Un,{className:"h-8 w-8 text-muted-foreground/50"})}),p.is_featured&&e.jsx("div",{className:"absolute top-1.5 left-1.5",children:e.jsxs(at,{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(at,{className:`text-[10px] px-1.5 py-0.5 ${L5t[p.status]}`,children:D5t[p.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:O5t(p.price)}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[p.city,", ",p.state]}),(p.bedrooms||p.bathrooms)&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[p.bedrooms&&`${p.bedrooms} bed`,p.bedrooms&&p.bathrooms&&" · ",p.bathrooms&&`${p.bathrooms} bath`]})]})]},p.id)})})]})}function pVe(t=10,s){return Ct({queryKey:["event-leaderboard",t,s],queryFn:async()=>{const{data:r}=await G.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 G.from("profiles").select("id").eq("brokerage_id",s);a=new Set((v==null?void 0:v.map(_=>_.id))||[])}const{data:o,error:l}=await G.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:p}=await G.from("profiles").select("id, name").in("id",u),f=new Map((p==null?void 0:p.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:f.get(v.user_id)||null}))}})}function fVe(t){return Ct({queryKey:["user-attendance-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("agent_attendance_stats").select("*").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return s},enabled:!!t})}function gVe(t){return Ct({queryKey:["user-badges",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("agent_badges").select("*").eq("user_id",t).order("earned_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function xVe(t,s){return Ct({queryKey:["user-rank",t,s],queryFn:async()=>{if(!t)return null;const{data:r}=await G.from("agent_attendance_stats").select("total_points").eq("user_id",t).single();if(!r)return null;const{data:n}=await G.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 G.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 G.from("profiles").select("id").eq("brokerage_id",s),u=new Set((d==null?void 0:d.map(p=>p.id))||[]);i=i.filter(p=>u.has(p.user_id))}return i.length+1},enabled:!!t})}function F5t(){const{user:t,brokerageId:s,isAdmin:r}=Gs();Dr();const n=!!s,[a,o]=S.useState("brokerage"),l=()=>{if(r)return null;if(n)return a==="global"?null:s},{data:i,isLoading:d}=pVe(5,l()),{data:u}=fVe(t==null?void 0:t.id),{data:p}=xVe(t==null?void 0:t.id,l()),{data:f}=gVe(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(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Ki,{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((j,w)=>e.jsx(gs,{className:"h-10 w-full"},w))})})]});const b=j=>j===0?e.jsx(Ki,{className:"h-4 w-4 text-yellow-500 mx-auto"}):j===1?e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"2"}):j===2?e.jsx("span",{className:"text-sm font-medium text-amber-600",children:"3"}):e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:j+1});if(v){const j=(i==null?void 0:i.slice(0,5))||[];return e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"pb-2",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Ki,{className:"h-4 w-4 text-yellow-500"}),_()]}),!r&&n&&e.jsxs("div",{className:"flex gap-1 mt-2",children:[e.jsx(K,{variant:a==="brokerage"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("brokerage"),children:"My Brokerage"}),e.jsx(K,{variant:a==="global"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("global"),children:"All LevelUp"})]})]}),e.jsxs(Oe,{children:[!r&&u&&e.jsx("div",{className:"mb-3 p-2 rounded-lg bg-primary/5 border border-primary/10",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Your Rank:"}),e.jsxs("span",{className:"font-bold text-primary",children:["#",p||"-"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-primary",children:u.total_points})," pts"]}),e.jsxs("span",{children:[e.jsx("strong",{children:u.total_events_attended})," events"]})]})]})}),e.jsxs("div",{className:"space-y-2",children:[j.map((w,N)=>{var C,A,I;return e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${w.user_id===(t==null?void 0:t.id)?"bg-primary/10 border border-primary/20":N===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:b(N)}),e.jsx(gn,{className:"h-6 w-6",children:e.jsx(xn,{className:"text-xs",children:((A=(C=w.profile)==null?void 0:C.name)==null?void 0:A.charAt(0))||"?"})}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((I=w.profile)==null?void 0:I.name)||"Unknown"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:w.total_points})]},w.user_id)}),j.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-2 text-sm",children:"No data yet"})]}),e.jsxs(vo,{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(io,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(Ha,{className:"h-4 w-4"})]})]})]})}return e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Ki,{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($h,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Current Streak"})]}),e.jsxs("span",{className:"font-bold text-orange-500",children:[u.current_streak," 🔥"]})]}),f&&f.length>0&&e.jsxs("div",{className:"pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[e.jsx(rc,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Badges"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[f.slice(0,4).map(j=>e.jsx("span",{className:"text-xs px-2 py-1 rounded-full bg-yellow-500/10 text-yellow-600 border border-yellow-500/20",children:j.badge_name},j.id)),f.length>4&&e.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1",children:["+",f.length-4," more"]})]})]}),e.jsxs(vo,{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(io,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(Ha,{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(vo,{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(io,{className:"h-4 w-4"}),"Visit Reward Store",e.jsx(Ha,{className:"h-4 w-4"})]})]})})]})}const wM=()=>Ct({queryKey:["lead-sources"],queryFn:async()=>{const{data:t,error:s}=await G.from("lead_sources").select("*").eq("is_active",!0).order("sort_order");if(s)throw s;return t}}),abe=()=>{const t=ns(),{user:s}=Gs();return Ot({mutationFn:async r=>{const{data:n}=await G.from("lead_sources").select("id, name").eq("is_active",!0).ilike("name",r.trim()),a=(n||[]).find(i=>i.name.toLowerCase()===r.trim().toLowerCase()&&!0);if(a)throw new Error(`Lead source "${a.name}" already exists`);const{data:o,error:l}=await G.from("lead_sources").insert({name:r,owner_user_id:s==null?void 0:s.id,sort_order:100}).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),fe.success("Lead source added")},onError:r=>{fe.error("Failed to add lead source"),console.error(r)}})},z5t=()=>{const t=ns();return Ot({mutationFn:async({id:s,name:r})=>{const{error:n}=await G.from("lead_sources").update({name:r}).eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),fe.success("Lead source updated")},onError:s=>{fe.error(s.message||"Failed to update lead source")}})},B5t=()=>{const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("lead_sources").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),fe.success("Lead source removed")},onError:s=>{fe.error(s.message||"Failed to remove lead source")}})},ibe=(t,s)=>{const{user:r,isAdmin:n}=Gs(),a=n&&s?s:r==null?void 0:r.id;return Ct({queryKey:["scorecard-transactions",t,a],queryFn:async()=>{let o=G.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})},obe=t=>{const{user:s,isAdmin:r}=Gs(),n=r&&t?t:s==null?void 0:s.id;return Ct({queryKey:["scorecard-transactions-all",n],queryFn:async()=>{const{data:a,error:o}=await G.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})},Xoe=()=>{const t=ns(),{user:s}=Gs();return Ot({mutationFn:async r=>{const{data:n,error:a}=await G.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"]}),fe.success("Transaction added")},onError:r=>{fe.error("Failed to add transaction"),console.error(r)}})},$5t=()=>{const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.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"]}),fe.success("Transaction updated")},onError:s=>{fe.error("Failed to update transaction"),console.error(s)}})},q5t=()=>{const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("scorecard_transactions").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),fe.success("Transaction deleted")},onError:s=>{fe.error("Failed to delete transaction"),console.error(s)}})},yVe=(t,s)=>{const{user:r,isAdmin:n}=Gs(),a=n&&s?s:r==null?void 0:r.id;return Ct({queryKey:["scorecard-goals",t,a],queryFn:async()=>{const{data:o,error:l}=await G.from("scorecard_goals").select("*").eq("owner_user_id",a).eq("year",t).maybeSingle();if(l)throw l;return o},enabled:!!a})},U5t=()=>{const t=ns(),{user:s}=Gs();return Ot({mutationFn:async r=>{const{data:n,error:a}=await G.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]}),fe.success("Goals saved")},onError:r=>{fe.error("Failed to save goals"),console.error(r)}})},Qoe=()=>{const{user:t}=Gs();return Ct({queryKey:["scorecard-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("scorecard_settings").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s},enabled:!!(t!=null&&t.id)})},V5t=()=>{const t=ns(),{user:s}=Gs();return Ot({mutationFn:async r=>{const{data:n,error:a}=await G.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"]}),fe.success("Settings saved")},onError:r=>{fe.error("Failed to save settings"),console.error(r)}})},vVe=(t,s)=>{const{data:r,isLoading:n}=ibe(t,s),{data:a,isLoading:o}=obe(s),{data:l}=Qoe(),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 p=u.filter(L=>L.transaction_type==="buyer").length,f=u.filter(L=>L.transaction_type==="seller").length,v=u.reduce((L,R)=>L+Number(R.sale_price),0),_=u.reduce((L,R)=>L+(Number(R.commission_amount)||0),0),b=u.reduce((L,R)=>{const $=Number(R.commission_amount)||0;if(!$)return L;let q=$;return R.brokerage_split_pct&&(q-=$*(R.brokerage_split_pct/100)),R.team_split_pct&&(q-=$*(R.team_split_pct/100)),R.franchise_fee_pct&&(q-=$*(R.franchise_fee_pct/100)),R.referral_fee_pct&&(q-=$*(R.referral_fee_pct/100)),R.transaction_fee&&(q-=R.transaction_fee),L+Math.max(0,q)},0),j={};u.forEach(L=>{var $;const R=(($=L.lead_source)==null?void 0:$.name)||"Unknown";j[R]=(j[R]||0)+1});const w=Object.entries(j).map(([L,R])=>({name:L,count:R})).sort((L,R)=>R.count-L.count),N=w[0]||null,C={};u.forEach(L=>{const R=fl(L.close_date).toLocaleString("default",{month:"short"});C[R]=(C[R]||0)+1});const I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(L=>({month:L,count:C[L]||0}));return{totalTransactions:u.length,buyerCount:p,sellerCount:f,totalVolume:v,averagePrice:u.length>0?v/u.length:0,totalCommission:i?_:0,totalNetToAgent:i?b:0,topLeadSource:N,transactionsByMonth:I,leadSourceBreakdown:w}};return{yearStats:d(r),lifetimeStats:d(a),isLoading:n||o,showCommission:i}},H5t=()=>{const{isAdmin:t}=Gs();return Ct({queryKey:["agents-with-transactions"],queryFn:async()=>{const{data:s,error:r}=await G.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 G.from("profiles").select("id, name, email").in("id",n);if(o)throw o;return a},enabled:t})},l1={recency:40,touchpoints:30,transactions:20},HMe={warm:70,cooling:40};function W5t(t){return t===null?0:t<=14?l1.recency:t<=30?l1.recency*.85:t<=60?l1.recency*.65:t<=90?l1.recency*.4:t<=180?l1.recency*.2:l1.recency*.05}function G5t(t){const s=Math.min(t/12,1);return Math.round(l1.touchpoints*s)}function K5t(t){return t?l1.transactions:0}function Z5t(){return 0}function Y5t(t){return t>=HMe.warm?"warm":t>=HMe.cooling?"cooling":"at-risk"}function Joe(){const{data:t,isLoading:s}=Jh(),{data:r}=sVe(),{data:n}=LL(365),{data:a}=obe(),o=S.useMemo(()=>{if(!t)return[];const i=new Date,d=Mk(i,12),u={};n==null||n.forEach(f=>{new Date(f.completed_at)>=d&&(u[f.contact_id]=(u[f.contact_id]||0)+1)});const p=new Set((a==null?void 0:a.filter(f=>f.contact_id).map(f=>f.contact_id))||[]);return t.map(f=>{const v=(r==null?void 0:r[f.id])||null,_=v?Gg(i,new Date(v)):null,b=u[f.id]||0,j=p.has(f.id),w=W5t(_),N=G5t(b),C=K5t(j),A=Z5t(),I=Math.round(w+N+C+A),L={score:I,status:Y5t(I),breakdown:{recency:Math.round(w),touchpoints:Math.round(N),transactions:Math.round(C),referrals:Math.round(A)},lastTouchDate:v,daysSinceTouch:_,touchCountLast12Months:b,hasTransaction:j};return{...f,relationshipScore:L}})},[t,r,n,a]),l=S.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,p=o.length,f=p>0?Math.round(o.reduce((v,_)=>v+_.relationshipScore.score,0)/p):0;return{warm:i,cooling:d,atRisk:u,total:p,averageScore:f}},[o]);return{contactsWithScores:o,stats:l,isLoading:s}}function _Ve(){const t=Dr(),{stats:s,contactsWithScores:r,isLoading:n}=Joe();if(n)return e.jsxs(Ee,{children:[e.jsx(Lt,{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(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Relationship Health"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add contacts to see your relationship health scores."}),e.jsx(K,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>t("/mission-control/contacts?new=true"),children:"Add Your First Contact"})]})]});const a=Math.round(s.warm/s.total*100),o=Math.round(s.cooling/s.total*100),l=Math.round(s.atRisk/s.total*100),i=r.filter(d=>d.relationshipScore.status==="at-risk").sort((d,u)=>d.relationshipScore.score-u.relationshipScore.score).slice(0,3);return e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Cc,{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(Ti,{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(Ti,{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(Ti,{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(dN,{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(Ha,{className:"h-3 w-3"})]})]},d.id))})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t("/mission-control/contacts?filter=at-risk"),children:["View All At-Risk Contacts",e.jsx(Ha,{className:"h-4 w-4 ml-1"})]})]})]})}const X5t=()=>{var ie;const{user:t,isAdmin:s}=Gs(),r=Dr(),[n,a]=S.useState([]),[o,l]=S.useState([]),[i,d]=S.useState([]),[u,p]=S.useState([]),[f,v]=S.useState([]),[_,b]=S.useState([]),[j,w]=S.useState(new Set),[N,C]=S.useState([]),[A,I]=S.useState([]),[L,R]=S.useState([]),[$,q]=S.useState(null),[U,V]=S.useState(!0);S.useEffect(()=>{X()},[t]);const X=async()=>{var ae,le,pe,be,ye;try{const[we,ke,Ze,_e,Ce,Te,Fe,Ae,We,ht,De]=await Promise.all([G.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),G.from("app_tiles").select("*").order("name"),G.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),G.from("events").select("*").order("event_date",{ascending:!0}),G.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",t==null?void 0:t.id),G.from("canva_templates").select("id, name, preview_image_url, publish_date").order("publish_date",{ascending:!1}).limit(4),G.from("resource_kits").select("id, name, description, featured_image_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),G.from("academy_videos").select("id, title, description, thumbnail_url, duration, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),G.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),G.from("dashboard_banners").select("id, title, description, image_url, link_url, link_text, placement, section_after").eq("is_active",!0).order("sort_order"),G.from("profiles").select("name").eq("id",t==null?void 0:t.id).single()]);(ae=De.data)!=null&&ae.name&&q(De.data.name);const Dt=((le=we.data)==null?void 0:le.map(it=>it.tag))||[],he=new Set(((pe=Ze.data)==null?void 0:pe.map(it=>it.app_id))||[]);w(he);const ot=(((be=ke.data)==null?void 0:be.filter(it=>!it.required_tags||it.required_tags.length===0?!0:it.required_tags.some(qe=>Dt.includes(qe))))||[]).sort((it,qe)=>it.name==="LevelUp Members Portal"?-1:qe.name==="LevelUp Members Portal"?1:0);a(ot.slice(0,6));const rt=((ye=_e.data)==null?void 0:ye.filter(it=>P5(it.event_date)!=="ended"))||[];l(rt.slice(0,4)),C(Ce.data||[]),d(Te.data||[]),p(Fe.data||[]),v(Ae.data||[]),b(We.data||[]);const Ne=ht.data||[];I(Ne.filter(it=>it.placement==="top")),R(Ne.filter(it=>it.placement==="between"))}catch(we){console.error("Error loading dashboard:",we),fe.error("Failed to load dashboard data")}finally{V(!1)}},se=async ae=>{var pe;const le=window.open("about:blank","_blank");try{await G.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:ae.app_id,app_name:ae.name,user_agent:navigator.userAgent});const{data:be,error:ye}=await G.functions.invoke("sso-launch",{body:{app_id:ae.app_id}});if(ye)throw ye;be!=null&&be.redirect_url?le&&!le.closed?(le.location.href=be.redirect_url,(pe=le.focus)==null||pe.call(le)):window.location.assign(be.redirect_url):(le==null||le.close(),fe.error("Launch link unavailable"))}catch(be){le==null||le.close(),console.error("Error launching app:",be),fe.error("Failed to launch app")}},te=ae=>N==null?void 0:N.some(le=>le.event_id===ae),Y=ae=>{const le=N==null?void 0:N.find(pe=>pe.event_id===ae);return le==null?void 0:le.zoom_join_url};if(U)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 de=ae=>L.filter(le=>le.section_after===ae);return e.jsxs(Ms,{title:"Dashboard",children:[e.jsx(P4t,{events:o,registrations:N,onNavigateToEvents:()=>r("/events")}),A.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(rE,{banners:A})}),e.jsx(U4t,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",($||((ie=t==null?void 0:t.user_metadata)==null?void 0:ie.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(n5t,{}),e.jsx(_Ve,{}),e.jsx(F5t,{})]}),e.jsx(y5t,{}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Upcoming Events"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/events"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Fi,{className:"h-4 w-4"})]})]}),o.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(on,{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(ae=>{const le=te(ae.id),pe=Y(ae.id)||ae.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 ${$Me(ae.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[$Me(ae.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(lN,{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(ae.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(ae.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:ae.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(ae.event_date))," at ",s6(new Date(ae.event_date))]})]}),e.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:le?e.jsxs(K,{size:"sm",variant:"default",className:"gap-1",onClick:be=>{be.stopPropagation(),window.open(pe,"_blank")},children:[e.jsx(sn,{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(Ha,{className:"h-4 w-4"})]})})]},ae.id)})})]}),de("events").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(rE,{banners:de("events")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Academy Videos"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/academy"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Fi,{className:"h-4 w-4"})]})]}),f.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ym,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No academy videos available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:f.map(ae=>e.jsxs("div",{onClick:()=>r(`/academy/${ae.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:[ae.thumbnail_url?e.jsx("img",{src:ae.thumbnail_url,alt:ae.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(ym,{className:"h-8 w-8 text-muted-foreground/50"})}),ae.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:ae.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:ae.title})})]},ae.id))})]}),de("academy").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(rE,{banners:de("academy")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Resource Kits"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/toolbox"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Fi,{className:"h-4 w-4"})]})]}),u.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(qh,{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(ae=>e.jsxs("div",{onClick:()=>r(`/toolbox/${ae.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:ae.featured_image_url?e.jsx("img",{src:ae.featured_image_url,alt:ae.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(qh,{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:ae.name})})]},ae.id))})]}),de("toolbox").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(rE,{banners:de("toolbox")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"New Templates"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/templates"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Fi,{className:"h-4 w-4"})]})]}),i.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(e_,{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(ae=>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:ae.preview_image_url?e.jsx("img",{src:ae.preview_image_url,alt:ae.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(e_,{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:ae.name})})]},ae.id))})]}),de("templates").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(rE,{banners:de("templates")})}),e.jsx("div",{className:"mb-10",children:e.jsx(R5t,{})}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Your Apps"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/apps"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Fi,{className:"h-4 w-4"})]})]}),n.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Dg,{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(ae=>{const le=j.has(ae.id);return e.jsxs("div",{onClick:()=>se(ae),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:ae.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:ae.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:ae.description})]}),le&&e.jsx(Dg,{className:"h-5 w-5 text-primary fill-current flex-shrink-0"})]},ae.id)})})]}),e.jsxs("section",{className:"mt-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Additional Services"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/additional-services"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Fi,{className:"h-4 w-4"})]})]}),_.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional services available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:_.map(ae=>e.jsxs("div",{onClick:()=>window.open(ae.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:ae.preview_image_url?e.jsx("img",{src:ae.preview_image_url,alt:ae.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(hn,{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:ae.name}),ae.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:ae.description})]})]},ae.id))})]})]})};var bVe="AlertDialog",[Q5t]=Ac(bVe,[nBe]),sv=nBe(),wVe=t=>{const{__scopeAlertDialog:s,...r}=t,n=sv(s);return e.jsx(xoe,{...n,...r,modal:!0})};wVe.displayName=bVe;var J5t="AlertDialogTrigger",jVe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=sv(r);return e.jsx(q1e,{...a,...n,ref:s})});jVe.displayName=J5t;var e3t="AlertDialogPortal",kVe=t=>{const{__scopeAlertDialog:s,...r}=t,n=sv(s);return e.jsx(yoe,{...n,...r})};kVe.displayName=e3t;var t3t="AlertDialogOverlay",NVe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=sv(r);return e.jsx(mM,{...a,...n,ref:s})});NVe.displayName=t3t;var I5="AlertDialogContent",[s3t,r3t]=Q5t(I5),n3t=$8e("AlertDialogContent"),SVe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=sv(r),l=S.useRef(null),i=Pa(s,l),d=S.useRef(null);return e.jsx(ayt,{contentName:I5,titleName:CVe,docsSlug:"alert-dialog",children:e.jsx(s3t,{scope:r,cancelRef:d,children:e.jsxs(pM,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:Cr(a.onOpenAutoFocus,u=>{var p;u.preventDefault(),(p=d.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[e.jsx(n3t,{children:n}),e.jsx(i3t,{contentRef:l})]})})})});SVe.displayName=I5;var CVe="AlertDialogTitle",MVe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=sv(r);return e.jsx(wL,{...a,...n,ref:s})});MVe.displayName=CVe;var TVe="AlertDialogDescription",AVe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=sv(r);return e.jsx(jL,{...a,...n,ref:s})});AVe.displayName=TVe;var a3t="AlertDialogAction",EVe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=sv(r);return e.jsx(kL,{...a,...n,ref:s})});EVe.displayName=a3t;var PVe="AlertDialogCancel",IVe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=r3t(PVe,r),o=sv(r),l=Pa(s,a);return e.jsx(kL,{...o,...n,ref:l})});IVe.displayName=PVe;var i3t=({contentRef:t})=>{const s=`\`${I5}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${I5}\` by passing a \`${TVe}\` 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 \`${I5}\`. 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 S.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},o3t=wVe,l3t=jVe,c3t=kVe,LVe=NVe,DVe=SVe,OVe=EVe,RVe=IVe,FVe=MVe,zVe=AVe;const nc=o3t,Lh=l3t,d3t=c3t,BVe=S.forwardRef(({className:t,...s},r)=>e.jsx(LVe,{className:Pt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));BVe.displayName=LVe.displayName;const El=S.forwardRef(({className:t,...s},r)=>e.jsxs(d3t,{children:[e.jsx(BVe,{}),e.jsx(DVe,{ref:r,className:Pt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s})]}));El.displayName=DVe.displayName;const Pl=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col space-y-2 text-center sm:text-left",t),...s});Pl.displayName="AlertDialogHeader";const Il=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});Il.displayName="AlertDialogFooter";const Ll=S.forwardRef(({className:t,...s},r)=>e.jsx(FVe,{ref:r,className:Pt("text-lg font-semibold",t),...s}));Ll.displayName=FVe.displayName;const Dl=S.forwardRef(({className:t,...s},r)=>e.jsx(zVe,{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));Dl.displayName=zVe.displayName;const xl=S.forwardRef(({className:t,...s},r)=>e.jsx(OVe,{ref:r,className:Pt(WI(),t),...s}));xl.displayName=OVe.displayName;const Ol=S.forwardRef(({className:t,...s},r)=>e.jsx(RVe,{ref:r,className:Pt(WI({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));Ol.displayName=RVe.displayName;const u3t=[{key:"contacts",label:"Contacts",icon:Zn,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:nN,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:qh,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:kn,description:"View and upload videos"},{key:"listings",label:"Listings",icon:Un,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:J1,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:Ai,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:uf,description:"Create and edit digital business card"},{key:"guest_book",label:"Guest Book",icon:Ou,description:"Manage open house guest books"},{key:"presentations",label:"Presentations",icon:Bg,description:"Create and manage smart presentations"}];function h3t(){var $;const{user:t}=Gs(),[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(null),[f,v]=S.useState({email:"",name:"",password:""}),[_,b]=S.useState("create"),[j,w]=S.useState(!1),[N,C]=S.useState(null);S.useEffect(()=>{t&&A()},[t]);const A=async()=>{if(t){a(!0);try{const{data:q,error:U}=await G.from("agent_assistant_assignments").select("id, assistant_id, permissions, created_at").eq("agent_id",t.id);if(U)throw U;if(q&&q.length>0){const V=q.map(te=>te.assistant_id),{data:X}=await G.from("profiles").select("id, name, email").in("id",V),se=q.map(te=>{const Y=X==null?void 0:X.find(de=>de.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(!f.email.trim()){fe.error("Please enter the assistant's email");return}w(!0);try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const{data:U,error:V}=await G.from("profiles").select("id, name, email").eq("email",f.email.trim().toLowerCase()).single();if(V||!U){fe.error("No account found with that email. Try creating a new assistant instead.");return}const{data:X}=await G.from("agent_assistant_assignments").select("id").eq("agent_id",t.id).eq("assistant_id",U.id);if(X&&X.length>0){fe.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:U.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 G.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:U.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;fe.success(`${U.name||U.email} linked as your assistant`),l(!1),v({email:"",name:"",password:""}),A()}catch(q){console.error("Error linking assistant:",q),fe.error(q.message||"Failed to link assistant")}finally{w(!1)}return}if(!f.email.trim()||!f.name.trim()||!f.password.trim()){fe.error("Please fill in all fields");return}if(f.password.length<6){fe.error("Password must be at least 6 characters");return}w(!0);try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const U=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:f.email.trim(),password:f.password,name:f.name.trim(),purpose:"assistant"})}),V=await U.json();if(!U.ok)throw new Error(V.error||"Failed to create assistant account");const X=V.userId||V.id;if(!X)throw new Error("No user ID returned");const 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:X,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 G.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:X,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(Y)throw Y;fe.success(`Assistant account created for ${f.name.trim()}`),l(!1),v({email:"",name:"",password:""}),A()}catch(q){console.error("Error adding assistant:",q),fe.error(q.message||"Failed to add assistant")}finally{w(!1)}}},L=async()=>{if(!(!u||!t))try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const{error:U}=await G.from("agent_assistant_assignments").delete().eq("id",u.id);if(U)throw U;const{data:V}=await G.from("agent_assistant_assignments").select("id").eq("assistant_id",u.assistant_id);(!V||V.length===0)&&await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:u.assistant_id,role:"assistant",action:"remove"})}),fe.success("Assistant removed"),d(!1),p(null),A()}catch(q){console.error("Error removing assistant:",q),fe.error(q.message||"Failed to remove assistant")}},R=async(q,U,V)=>{C(q);try{const X=s.find(Y=>Y.id===q);if(!X)return;const se={...X.permissions,[U]:V},{error:te}=await G.from("agent_assistant_assignments").update({permissions:se}).eq("id",q);if(te)throw te;r(Y=>Y.map(de=>de.id===q?{...de,permissions:se}:de))}catch(X){console.error("Error updating permissions:",X),fe.error("Failed to update permissions")}finally{C(null)}};return n?e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"My Assistants"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(yr,{children:"Add assistants to help manage your Agent OS"})]}),e.jsxs(K,{size:"sm",onClick:()=>{b("create"),l(!0)},children:[e.jsx(Zs,{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 U,V,X,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(gn,{className:"h-10 w-10",children:e.jsx(xn,{children:((V=(U=q.assistant_profile)==null?void 0:U.name)==null?void 0:V.split(" ").map(te=>te[0]).join("").toUpperCase())||"A"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((X=q.assistant_profile)==null?void 0:X.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((se=q.assistant_profile)==null?void 0:se.email)||""})]}),e.jsxs(at,{variant:"secondary",className:"ml-2",children:[e.jsx(rh,{className:"h-3 w-3 mr-1"}),"Assistant"]})]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{p(q),d(!0)},children:e.jsx(br,{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:u3t.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(Br,{checked:q.permissions[te.key]||!1,onCheckedChange:de=>R(q.id,te.key,de),disabled:N===q.id})]},te.key)})})]})]},q.id)})})})]}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(K,{variant:_==="create"?"default":"outline",size:"sm",onClick:()=>b("create"),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"}),"Create New"]}),e.jsxs(K,{variant:_==="link"?"default":"outline",size:"sm",onClick:()=>b("link"),children:[e.jsx(Lo,{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(ve,{htmlFor:"assistant-name",children:"Name"}),e.jsx(Re,{id:"assistant-name",value:f.name,onChange:q=>v({...f,name:q.target.value}),placeholder:"Assistant's full name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"assistant-email",children:"Email"}),e.jsx(Re,{id:"assistant-email",type:"email",value:f.email,onChange:q=>v({...f,email:q.target.value}),placeholder:"assistant@email.com"})]}),_==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"assistant-password",children:"Temporary Password"}),e.jsx(Re,{id:"assistant-password",type:"password",value:f.password,onChange:q=>v({...f,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(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:I,disabled:j,children:[j&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),_==="create"?"Create Assistant":"Link Assistant"]})]})]})}),e.jsx(nc,{open:i,onOpenChange:d,children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Remove Assistant?"}),e.jsxs(Dl,{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(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:L,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function Au(t){this.content=t}Au.prototype={constructor:Au,find:function(t){for(var s=0;s>1}};Au.from=function(t){if(t instanceof Au)return t;var s=[];if(t)for(var r in t)s.push(r,t[r]);return new Au(s)};function $Ve(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=$Ve(a.content,o.content,r+1);if(l!=null)return l}r+=a.nodeSize}}function qVe(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,p=Math.min(l.text.length,i.text.length);for(;us&&n(d,a+i,o||null,l)!==!1&&d.content.size){let p=i+1;d.nodesBetween(Math.max(0,s-p),Math.min(d.content.size,r-p),n,a+p)}i=u}}descendants(s){this.nodesBetween(0,this.size,s)}textBetween(s,r,n,a){let o="",l=!0;return this.nodesBetween(s,r,(i,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 Tr(n,a)}cutByIndex(s,r){return s==r?Tr.empty:s==0&&r==this.content.length?this:new Tr(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 Tr(a,o)}addToStart(s){return new Tr([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new Tr(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?$8(r+1,o):$8(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 Tr.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Tr(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return Tr.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}};pl.none=[];class Fne extends Error{}class pn{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=VVe(this.content,s+this.openStart,r);return n&&new pn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new pn(UVe(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 pn.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 pn(Tr.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 pn(s,n,a)}}pn.empty=new pn(Tr.empty,0,0);function UVe(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(UVe(o.content,s-a-1,r-a-1)))}function VVe(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=VVe(l.content,s-o-1,r,l);return i&&t.replaceChild(a,l.copy(i))}function m3t(t,s,r){if(r.openStart>t.depth)throw new Fne("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new Fne("Inconsistent open depths");return HVe(t,s,r,0)}function HVe(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 JP(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&&(pN(t.nodeAfter,n),o++));for(let i=o;ia&&yxe(t,s,a+1),l=n.depth>a&&yxe(r,n,a+1),i=[];return JP(null,t,a,i),o&&l&&s.index(a)==r.index(a)?(WVe(o,l),pN(fN(o,GVe(t,s,r,n,a+1)),i)):(o&&pN(fN(o,zne(t,s,a+1)),i),JP(s,r,a,i),l&&pN(fN(l,zne(r,n,a+1)),i)),JP(n,null,a,i),new Tr(i)}function zne(t,s,r){let n=[];if(JP(null,t,r,n),t.depth>r){let a=yxe(t,s,r+1);pN(fN(a,zne(t,s,r+1)),n)}return JP(s,null,r,n),new Tr(n)}function p3t(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(Tr.from(a));return{start:a.resolveNoCache(t.openStart+r),end:a.resolveNoCache(a.content.size-t.openEnd-r)}}class r6{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 Bne(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 r6(r,n,o)}static resolveCached(s,r){let n=WMe.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()+")"),KVe(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=Tr.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=Tr.fromJSON(s,r.content),o=s.nodeType(r.type).create(r.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};p_.prototype.text=void 0;class $ne extends p_{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):KVe(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 $ne(this.type,this.attrs,this.text,s)}withText(s){return s==this.text?this:new $ne(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 KVe(t,s){for(let r=t.length-1;r>=0;r--)s=t[r].type.name+"("+s+")";return s}class ON{constructor(s){this.validEnd=s,this.next=[],this.wrapCache=[]}static parse(s,r){let n=new y3t(s,r);if(n.next==null)return ON.empty;let a=ZVe(n);n.next&&n.err("Unexpected trailing text");let o=N3t(k3t(a));return S3t(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(` `)}}ON.empty=new ON(!0);class y3t{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 ZVe(t){let s=[];do s.push(v3t(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function v3t(t){let s=[];do s.push(_3t(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function _3t(t){let s=j3t(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=b3t(t,s);else break;return s}function GMe(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let s=Number(t.next);return t.pos++,s}function b3t(t,s){let r=GMe(t),n=r;return t.eat(",")&&(t.next!="}"?n=GMe(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function w3t(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 j3t(t){if(t.eat("(")){let s=ZVe(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=w3t(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 k3t(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 p=0;p{u||a.push([i,u=[]]),u.indexOf(p)==-1&&u.push(p)})})});let o=s[n.join(",")]=new ON(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:QVe(this.attrs,s)}create(s=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new p_(this,this.computeAttrs(s),Tr.from(r),pl.setFrom(n))}createChecked(s=null,r,n){return r=Tr.from(r),this.checkContent(r),new p_(this,this.computeAttrs(s),r,pl.setFrom(n))}createAndFill(s=null,r,n){if(s=this.computeAttrs(s),r=Tr.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(Tr.empty,!0);return o?new p_(this,s,r.append(o),pl.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 tHe(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 C3t(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 M3t{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?C3t(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class ele{constructor(s,r,n,a){this.name=s,this.rank=r,this.schema=n,this.spec=a,this.attrs=eHe(s,a.attrs),this.excluded=null;let o=XVe(this.attrs);this.instance=o?new pl(this,o):null}create(s=null){return!s&&this.instance?this.instance:new pl(this,QVe(this.attrs,s))}static compile(s,r){let n=Object.create(null),a=0;return s.forEach((o,l)=>n[o]=new ele(o,a++,r,l)),n}removeFromSet(s){for(var r=0;r-1}}class sHe{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=Au.from(s.nodes),r.marks=Au.from(s.marks||{}),this.nodes=ZMe.compile(this.spec.nodes,this),this.marks=ele.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]=ON.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?YMe(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==""?[]:YMe(this,l.split(" "))}this.nodeFromJSON=a=>p_.fromJSON(this,a),this.markFromJSON=a=>pl.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 ZMe){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 $ne(n,n.defaultAttrs,s,pl.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 YMe(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 T3t(t){return t.tag!=null}function A3t(t){return t.style!=null}let eI=class _xe{constructor(s,r){this.schema=s,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(a=>{if(T3t(a))this.tags.push(a);else if(A3t(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 QMe(this,r,!1);return n.addAll(s,pl.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new QMe(this,r,!0);return n.addAll(s,pl.none,r.from,r.to),pn.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=JMe(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=JMe(l)),l.node||l.ignore||l.mark||(l.node=a)})}return r}static fromSchema(s){return s.cached.domParser||(s.cached.domParser=new _xe(s,_xe.schemaRules(s)))}};const rHe={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},E3t={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},nHe={ol:!0,ul:!0},n6=1,bxe=2,tI=4;function XMe(t,s,r){return s!=null?(s?n6:0)|(s==="full"?bxe:0):t&&t.whitespace=="pre"?n6|bxe:r&~tI}class q8{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=pl.none,this.match=o||(l&tI?null:s.contentMatch)}findWrapping(s){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Tr.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&n6)){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=Tr.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(Tr.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&&!rHe.hasOwnProperty(s.parentNode.nodeName.toLowerCase())}}class QMe{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=XMe(null,r.preserveWhitespace,0)|(n?tI:0);a?o=new q8(a.type,a.attrs,pl.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new q8(null,null,pl.none,!0,null,l):o=new q8(s.schema.topNodeType,null,pl.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&bxe?"full":this.localPreserveWS||(a.options&n6)>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):eTe(u.type,s))?(d=u.addToSet(d),!1):!0),this.nodes.push(new q8(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|=n6)}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 p=d>0||d==0&&a?this.nodes[d].type:n&&d>=o?n.node(d-o).type:null;if(!p||p.name!=u&&!p.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 P3t(t){for(let s=t.firstChild,r=null;s;s=s.nextSibling){let n=s.nodeType==1?s.nodeName.toLowerCase():null;n&&nHe.hasOwnProperty(n)&&r?(r.appendChild(s),s=r):n=="li"?r=s:n&&(r=null)}}function I3t(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function JMe(t){let s={};for(let r in t)s[r]=t[r];return s}function eTe(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&&mre(ime(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return mre(s,r,n,a)}static fromSchema(s){return s.cached.domSerializer||(s.cached.domSerializer=new nS(this.nodesFromSchema(s),this.marksFromSchema(s)))}static nodesFromSchema(s){let r=tTe(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return tTe(s.marks)}}function tTe(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function ime(t){return t.document||window.document}const sTe=new WeakMap;function L3t(t){let s=sTe.get(t);return s===void 0&&sTe.set(t,s=D3t(t)),s}function D3t(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],p=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){p=2;for(let f in u)if(u[f]!=null){let v=f.indexOf(" ");v>0?d.setAttributeNS(f.slice(0,v),f.slice(v+1),u[f]):f=="style"&&d.style?d.style.cssText=u[f]:d.setAttribute(f,u[f])}}for(let f=p;fp)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:_,contentDOM:b}=mre(t,v,r,n);if(d.appendChild(_),b){if(i)throw new RangeError("Multiple content holes");i=b}}}return{dom:d,contentDOM:i}}const aHe=65535,iHe=Math.pow(2,16);function O3t(t,s){return t+s*iHe}function rTe(t){return t&aHe}function R3t(t){return(t-(t&aHe))/iHe}const oHe=1,lHe=2,pre=4,cHe=8;class wxe{constructor(s,r,n){this.pos=s,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&cHe)>0}get deletedBefore(){return(this.delInfo&(oHe|pre))>0}get deletedAfter(){return(this.delInfo&(lHe|pre))>0}get deletedAcross(){return(this.delInfo&pre)>0}}class op{constructor(s,r=!1){if(this.ranges=s,this.inverted=r,!s.length&&op.empty)return op.empty}recover(s){let r=0,n=rTe(s);if(!this.inverted)for(let a=0;as)break;let u=this.ranges[i+o],p=this.ranges[i+l],f=d+u;if(s<=f){let v=u?s==d?-1:s==f?1:r:r,_=d+a+(v<0?0:p);if(n)return _;let b=s==(r<0?d:f)?null:O3t(i/3,s-d),j=s==d?lHe:s==f?oHe:pre;return(r<0?s!=d:s!=f)&&(j|=cHe),new wxe(_,j,b)}a+=p-u}return n?s+a:new wxe(s+a,0,null)}touches(s,r){let n=0,a=rTe(r),o=this.inverted?2:1,l=this.inverted?1:2;for(let i=0;is)break;let u=this.ranges[i+o],p=d+u;if(s<=p&&i==a*3)return!0;n+=this.ranges[i+l]-u}return!1}forEach(s){let r=this.inverted?2:1,n=this.inverted?1:2;for(let a=0,o=0;a=0;r--){let a=s.getMirror(r);this.appendMap(s._maps[r].invert(),a!=null&&a>r?n-a-1:void 0)}}invert(){let s=new a6;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 Nd.fromReplace(s,this.from,this.to,o)}invert(){return new Bx(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 z1(r.pos,n.pos,this.mark)}merge(s){return s instanceof z1&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new z1(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 z1(r.from,r.to,s.markFromJSON(r.mark))}}ch.jsonID("addMark",z1);class Bx extends ch{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 pn(lbe(r.content,a=>a.mark(this.mark.removeFromSet(a.marks)),s),r.openStart,r.openEnd);return Nd.fromReplace(s,this.from,this.to,n)}invert(){return new z1(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 Bx(r.pos,n.pos,this.mark)}merge(s){return s instanceof Bx&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new Bx(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 Bx(r.from,r.to,s.markFromJSON(r.mark))}}ch.jsonID("removeMark",Bx);class B1 extends ch{constructor(s,r){super(),this.pos=s,this.mark=r}apply(s){let r=s.nodeAt(this.pos);if(!r)return Nd.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return Nd.fromReplace(s,this.pos,this.pos+1,new pn(Tr.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 fu(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 fu(r.from,r.to,r.gapFrom,r.gapTo,pn.fromJSON(s,r.slice),r.insert,!!r.structure)}}ch.jsonID("replaceAround",fu);function jxe(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 F3t(t,s,r,n){let a=[],o=[],l,i;t.doc.nodesBetween(s,r,(d,u,p)=>{if(!d.isInline)return;let f=d.marks;if(!n.isInSet(f)&&p.type.allowsMarkType(n.type)){let v=Math.max(u,s),_=Math.min(u+d.nodeSize,r),b=n.addToSet(f);for(let j=0;jt.step(d)),o.forEach(d=>t.step(d))}function z3t(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 ele){let u=l.marks,p;for(;p=n.isInSet(u);)(d||(d=[])).push(p),u=p.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 p=0;pt.step(new Bx(l.from,l.to,l.style)))}function cbe(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 B3t(t,s,r){return(s==0||t.canReplace(s,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function jM(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--)j||n.index(b)>0?(j=!0,p=Tr.from(n.node(b).copy(p)),f++):d--;let v=Tr.empty,_=0;for(let b=o,j=!1;b>r;b--)j||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=Tr.from(r[l].type.create(r[l].attrs,n))}let a=s.start,o=s.end;t.step(new fu(a,o,a,o,new pn(n,0,0),r.length,!0))}function H3t(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)&&W3t(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&&uHe(t,l,i,o),cbe(t,t.mapping.slice(o).map(i,1),n,void 0,u===null);let p=t.mapping.slice(o),f=p.map(i,1),v=p.map(i+l.nodeSize,1);return t.step(new fu(f,v,f+1,v-1,new pn(Tr.from(n.create(d,null,l.marks)),0,0),1,!0)),u===!0&&dHe(t,l,i,o),!1}})}function dHe(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 uHe(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 W3t(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function G3t(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 fu(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new pn(Tr.from(l),0,0),1,!0))}function R0(t,s,r=1,n){let a=t.resolve(s),o=a.depth-r,l=n&&n[n.length-1]||a.parent;if(o<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!l.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let u=a.depth-1,p=r-2;u>o;u--,p--){let f=a.node(u),v=a.index(u);if(f.type.spec.isolating)return!1;let _=f.content.cutByIndex(v,f.childCount),b=n&&n[p+1];b&&(_=_.replaceChild(0,b.type.create(b.attrs)));let j=n&&n[p]||f;if(!f.canReplace(v+1,f.childCount)||!j.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 K3t(t,s,r=1,n){let a=t.doc.resolve(s),o=Tr.empty,l=Tr.empty;for(let i=a.depth,d=a.depth-r,u=r-1;i>d;i--,u--){o=Tr.from(a.node(i).copy(o));let p=n&&n[u];l=Tr.from(p?p.type.create(p.attrs,l):a.node(i).copy(l))}t.step(new du(s,s,new pn(o.append(l),r,r),!0))}function G_(t,s){let r=t.resolve(s),n=r.index();return hHe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function Z3t(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&&hHe(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 Y3t(t,s,r){let n=null,{linebreakReplacement:a}=t.doc.type.schema,o=t.doc.resolve(s-r),l=o.node().type;if(a&&l.inlineContent){let p=l.whitespace=="pre",f=!!l.contentMatch.matchType(a);p&&!f?n=!1:!p&&f&&(n=!0)}let i=t.steps.length;if(n===!1){let p=t.doc.resolve(s+r);uHe(t,p.node(),p.before(),i)}l.inlineContent&&cbe(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 du(u,d.map(s+r,-1),pn.empty,!0)),n===!0){let p=t.doc.resolve(u);dHe(t,p.node(),p.before(),t.steps.length)}return t}function X3t(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),p=!1;if(o==1)p=u.canReplace(d,d,a);else{let f=u.contentMatchAt(d).findWrapping(a.firstChild.type);p=f&&u.canReplaceWith(d,d,f[0])}if(p)return i==0?n.pos:i<0?n.before(l+1):n.after(l+1)}return null}function sle(t,s,r=s,n=pn.empty){if(s==r&&!n.size)return null;let a=t.resolve(s),o=t.resolve(r);return pHe(a,o,n)?new du(s,r,n):new Q3t(a,o,n).fit()}function pHe(t,s,r){return!r.openStart&&!r.openEnd&&t.start()==s.start()&&t.parent.canReplace(t.index(),s.index(),r.content)}class Q3t{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Tr.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=Tr.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 pn(o,l,i);return s>-1?new fu(n.pos,s,this.$to.pos,this.$to.end(),d,r):d.size||n.pos!=this.$to.pos?new du(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=lme(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],p,f=null;if(r==1&&(l?u.matchType(l.type)||(f=u.fillBefore(Tr.from(l),!1)):o&&d.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:i,parent:o,inject:f};if(r==2&&l&&(p=u.findWrapping(l.type)))return{sliceDepth:n,frontierDepth:i,parent:o,wrap:p};if(o&&u.matchType(o.type))break}}}openMore(){let{content:s,openStart:r,openEnd:n}=this.unplaced,a=lme(s,r);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new pn(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=lme(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new pn(AE(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new pn(AE(s,r,1),r,n)}placeNodes({sliceDepth:s,frontierDepth:r,parent:n,inject:a,wrap:o}){for(;this.depth>r;)this.closeFrontierNode();if(o)for(let j=0;j1||d==0||j.content.size)&&(f=w,p.push(fHe(j.mark(v.allowedMarks(j.marks)),u==1?d:0,u==i.childCount?_:-1)))}let b=u==i.childCount;b||(_=-1),this.placed=EE(this.placed,r,Tr.from(p)),this.frontier[r].match=f,b&&_<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let j=0,w=i;j<_;j++){let N=w.lastChild;this.frontier.push({type:N.type,match:N.contentMatchAt(N.childCount)}),w=N.content}this.unplaced=b?s==0?pn.empty:new pn(AE(l.content,s-1,1),s-1,_<0?l.openEnd:s-1):new pn(AE(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||!cme(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],p=cme(s,i,u,d,!0);if(!p||p.childCount)continue e}return{depth:r,fit:l,move:o?s.doc.resolve(s.after(r+1)):s}}}}close(s){let r=this.findCloseLevel(s);if(!r)return null;for(;this.depth>r.depth;)this.closeFrontierNode();r.fit.childCount&&(this.placed=EE(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=EE(this.placed,this.depth,Tr.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Tr.empty,!0);r.childCount&&(this.placed=EE(this.placed,this.frontier.length,r))}}function AE(t,s,r){return s==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(AE(t.firstChild.content,s-1,r)))}function EE(t,s,r){return s==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(EE(t.lastChild.content,s-1,r)))}function lme(t,s){for(let r=0;r1&&(n=n.replaceChild(0,fHe(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(Tr.empty,!0)))),t.copy(n)}function cme(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&&!J3t(r,o.content,l)?i:null}function J3t(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=[],p=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=p-1;v>=0;v--){let _=u[v],b=eMt(_.type);if(b&&!_.sameMarkup(a.node(Math.abs(i)-1)))p=v;else if(b||!_.type.isTextblock)break}for(let v=n.openStart;v>=0;v--){let _=(v+p+1)%(n.openStart+1),b=u[_];if(b)for(let j=0;j=0&&(t.replace(s,r,n),!(t.steps.length>f));v--){let _=l[v];_<0||(s=a.before(_),r=o.after(_))}}function gHe(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(Tr.empty,!0))}return t}function sMt(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=X3t(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new pn(Tr.from(n),0,0))}function rMt(t,s,r){let n=t.doc.resolve(s),a=t.doc.resolve(r),o=xHe(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 xHe(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 L5 extends ch{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 Nd.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 Nd.fromReplace(s,this.pos,this.pos+1,new pn(Tr.from(a),0,r.isLeaf?0:1))}getMap(){return op.empty}invert(s){return new L5(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 L5(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 L5(r.pos,r.attr,r.value)}}ch.jsonID("attr",L5);class i6 extends ch{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 Nd.ok(n)}getMap(){return op.empty}invert(s){return new i6(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 i6(r.attr,r.value)}}ch.jsonID("docAttr",i6);let b3=class extends Error{};b3=function t(s){let r=Error.call(this,s);return r.__proto__=t.prototype,r};b3.prototype=Object.create(Error.prototype);b3.prototype.constructor=b3;b3.prototype.name="TransformError";class ube{constructor(s){this.doc=s,this.steps=[],this.docs=[],this.mapping=new a6}get before(){return this.docs.length?this.docs[0]:this.doc}step(s){let r=this.maybeStep(s);if(r.failed)throw new b3(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=pn.empty){let a=sle(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new pn(Tr.from(n),0,0))}delete(s,r){return this.replace(s,r,pn.empty)}insert(s,r){return this.replaceWith(s,s,r)}replaceRange(s,r,n){return tMt(this,s,r,n),this}replaceRangeWith(s,r,n){return sMt(this,s,r,n),this}deleteRange(s,r){return rMt(this,s,r),this}lift(s,r){return $3t(this,s,r),this}join(s,r=1){return Y3t(this,s,r),this}wrap(s,r){return V3t(this,s,r),this}setBlockType(s,r=s,n,a=null){return H3t(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return G3t(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new L5(s,r,n)),this}setDocAttribute(s,r){return this.step(new i6(s,r)),this}addNodeMark(s,r){return this.step(new B1(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 pl)r.isInSet(n.marks)&&this.step(new RN(s,r));else{let a=n.marks,o,l=[];for(;o=r.isInSet(a);)l.push(new RN(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 K3t(this,s,r,n),this}addMark(s,r,n){return F3t(this,s,r,n),this}removeMark(s,r,n){return z3t(this,s,r,n),this}clearIncompatible(s,r,n){return cbe(this,s,r,n),this}}const dme=Object.create(null);class ri{constructor(s,r,n){this.$anchor=s,this.$head=r,this.ranges=n||[new yHe(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?b4(s.node(0),s.node(o),s.before(o+1),s.index(o),r,n):b4(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 xp(s.node(0))}static atStart(s){return b4(s,s,0,0,1)||new xp(s)}static atEnd(s){return b4(s,s,s.content.size,s.childCount,-1)||new xp(s)}static fromJSON(s,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=dme[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 dme)throw new RangeError("Duplicate use of selection JSON ID "+s);return dme[s]=r,r.prototype.jsonID=s,r}getBookmark(){return Va.between(this.$anchor,this.$head).getBookmark()}}ri.prototype.visible=!0;class yHe{constructor(s,r){this.$from=s,this.$to=r}}let aTe=!1;function iTe(t){!aTe&&!t.parent.inlineContent&&(aTe=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Va extends ri{constructor(s,r=s){iTe(s),iTe(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 ri.near(n);let a=s.resolve(r.map(this.anchor));return new Va(a.parent.inlineContent?a:n,n)}replace(s,r=pn.empty){if(super.replace(s,r),r==pn.empty){let n=this.$from.marksAcross(this.$to);n&&s.ensureMarks(n)}}eq(s){return s instanceof Va&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new rle(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 Va(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=ri.findFrom(r,n,!0)||ri.findFrom(r,-n,!0);if(o)r=o.$head;else return ri.near(r,n)}return s.parent.inlineContent||(a==0?s=r:(s=(ri.findFrom(s,-n,!0)||ri.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&&Da.isSelectable(i))return Da.create(t,r-(a<0?i.nodeSize:0))}else{let d=b4(t,i,r+a,a<0?i.childCount:0,a,o);if(d)return d}r+=i.nodeSize*a}return null}function oTe(t,s,r){let n=t.steps.length-1;if(n{l==null&&(l=p)}),t.setSelection(ri.near(t.doc.resolve(l),r))}const lTe=1,U8=2,cTe=4;class aMt extends ube{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|=U8,this}ensureMarks(s){return pl.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&U8)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~U8,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)||pl.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(ri.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|=cTe,this}get scrolledIntoView(){return(this.updated&cTe)>0}}function dTe(t,s){return!s||!t?t:t.bind(s)}class PE{constructor(s,r,n){this.name=s,this.init=dTe(r.init,n),this.apply=dTe(r.apply,n)}}const iMt=[new PE("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new PE("selection",{init(t,s){return t.selection||ri.atStart(s.doc)},apply(t){return t.selection}}),new PE("storedMarks",{init(t){return t.storedMarks||null},apply(t,s,r,n){return n.selection.$cursor?t.storedMarks:null}}),new PE("scrollToSelection",{init(){return 0},apply(t,s){return t.scrolledIntoView?s+1:s}})];class ume{constructor(s,r){this.schema=s,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=iMt.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 PE(n.key,n.spec.state,n))})}}class $4{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 ume(s.schema,s.plugins),o=new $4(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=p_.fromJSON(s.schema,r.doc);else if(l.name=="selection")o.selection=ri.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 vHe(t,s,r){for(let n in t){let a=t[n];a instanceof Function?a=a.bind(s):n=="handleDOMEvents"&&(a=vHe(a,s,{})),r[n]=a}return r}class Yd{constructor(s){this.spec=s,this.props={},s.props&&vHe(s.props,this,this.props),this.key=s.key?s.key.key:_He("plugin")}getState(s){return s[this.key]}}const hme=Object.create(null);function _He(t){return t in hme?t+"$"+ ++hme[t]:(hme[t]=0,t+"$")}class dh{constructor(s="key"){this.key=_He(s)}get(s){return s.config.pluginsByKey[this.key]}getState(s){return s[this.key]}}const Pu=function(t){for(var s=0;;s++)if(t=t.previousSibling,!t)return s},w3=function(t){let s=t.assignedSlot||t.parentNode;return s&&s.nodeType==11?s.host:s};let kxe=null;const r0=function(t,s,r){let n=kxe||(kxe=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,s||0),n},oMt=function(){kxe=null},FN=function(t,s,r,n){return r&&(uTe(t,s,r,n,-1)||uTe(t,s,r,n,1))},lMt=/^(img|br|input|textarea|hr)$/i;function uTe(t,s,r,n,a){for(var o;;){if(t==r&&s==n)return!0;if(s==(a<0?0:sf(t))){let l=t.parentNode;if(!l||l.nodeType!=1||DL(t)||lMt.test(t.nodeName)||t.contentEditable=="false")return!1;s=Pu(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?sf(t):0}else return!1}}function sf(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function cMt(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=sf(t)}else if(t.parentNode&&!DL(t))s=Pu(t),t=t.parentNode;else return null}}function dMt(t,s){for(;;){if(t.nodeType==3&&s2),Zp=j3||(ay?/Mac/.test(ay.platform):!1),jHe=ay?/Win/.test(ay.platform):!1,v0=/Android \d/.test(K_),OL=!!hTe&&"webkitFontSmoothing"in hTe.documentElement.style,pMt=OL?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function fMt(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 Wy(t,s){return typeof t=="number"?t:t[s]}function gMt(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 mTe(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=w3(l);continue}let i=l,d=i==o.body,u=d?fMt(o):gMt(i),p=0,f=0;if(s.topu.bottom-Wy(n,"bottom")&&(f=s.bottom-s.top>u.bottom-u.top?s.top+Wy(a,"top")-u.top:s.bottom-u.bottom+Wy(a,"bottom")),s.leftu.right-Wy(n,"right")&&(p=s.right-u.right+Wy(a,"right")),p||f)if(d)o.defaultView.scrollBy(p,f);else{let _=i.scrollLeft,b=i.scrollTop;f&&(i.scrollTop+=f),p&&(i.scrollLeft+=p);let j=i.scrollLeft-_,w=i.scrollTop-b;s={left:s.left-j,top:s.top-w,right:s.right-j,bottom:s.bottom-w}}let v=d?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(v))break;l=v=="absolute"?l.offsetParent:w3(l)}}function xMt(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:kHe(t.dom)}}function kHe(t){let s=[],r=t.ownerDocument;for(let n=t;n&&(s.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=w3(n));return s}function yMt({refDOM:t,refTop:s,stack:r}){let n=t?t.getBoundingClientRect().top:0;NHe(r,n==0?0:n-s)}function NHe(t,s){for(let r=0;r=i){l=Math.max(b.bottom,l),i=Math.min(b.top,i);let j=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=p,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=f+1)}}return!r&&d&&(r=d,a=u,n=0),r&&r.nodeType==3?_Mt(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:SHe(r,a)}function _Mt(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 mbe(t,s){return t.left>=s.left-1&&t.left<=s.right+1&&t.top>=s.top-1&&t.top<=s.bottom+1}function bMt(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 jMt(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 CHe(t,s,r){let n=t.childNodes.length;if(n&&r.tops.top&&a++}let u;OL&&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=jMt(t,n,a,s))}i==null&&(i=wMt(t,l,s));let d=t.docView.nearestDesc(l,!0);return{pos:i,inside:d?d.posAtStart-d.border:-1}}function pTe(t){return t.top=0&&a==n.nodeValue.length?(d--,p=1):r<0?d--:u++,nE(r1(r0(n,d,u),p),p<0)}if(!t.state.doc.resolve(s-(o||0)).parent.inlineContent){if(o==null&&a&&(r<0||a==sf(n))){let d=n.childNodes[a-1];if(d.nodeType==1)return mme(d.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(r<0||a==sf(n))){let d=n.childNodes[a-1],u=d.nodeType==3?r0(d,sf(d)-(l?0:1)):d.nodeType==1&&(d.nodeName!="BR"||!d.nextSibling)?d:null;if(u)return nE(r1(u,1),!1)}if(o==null&&a=0)}function nE(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 mme(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 THe(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 SMt(t,s,r){let n=s.selection,a=r=="up"?n.$from:n.$to;return THe(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=MHe(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=r0(i,0,i.nodeValue.length).getClientRects();else continue;for(let u=0;up.top+1&&(r=="up"?l.top-p.top>(p.bottom-l.top)*2:p.bottom-l.bottom>(l.bottom-p.top)*2))return!1}}return!0})}const CMt=/[\u0590-\u08ac]/;function MMt(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?!CMt.test(n.parent.textContent)||!i.modify?r=="left"||r=="backward"?o:l:THe(t,s,()=>{let{focusNode:d,focusOffset:u,anchorNode:p,anchorOffset:f}=t.domSelectionRange(),v=i.caretBidiLevel;i.modify("move",r,"character");let _=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:b,focusOffset:j}=t.domSelectionRange(),w=b&&!_.contains(b.nodeType==1?b:b.parentNode)||d==b&&u==j;try{i.collapse(p,f),d&&(d!=p||u!=f)&&i.extend&&i.extend(d,u)}catch{}return v!=null&&(i.caretBidiLevel=v),w}):n.pos==n.start()||n.pos==n.end()}let fTe=null,gTe=null,xTe=!1;function TMt(t,s,r){return fTe==s&&gTe==r?xTe:(fTe=s,gTe=r,xTe=r=="up"||r=="down"?SMt(t,s,r):MMt(t,s,r))}const yf=0,yTe=1,Pk=2,iy=3;class RL{constructor(s,r,n,a){this.parent=s,this.children=r,this.dom=n,this.contentDOM=a,this.dirty=yf,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;rPu(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 EHe){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 AHe&&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?Pu(o.dom)+1:0}}else{let o,l=!0;for(;o=n=p&&r<=u-d.border&&d.node&&d.contentDOM&&this.contentDOM.contains(d.contentDOM))return d.parseRange(s,r,p);s=l;for(let f=i;f>0;f--){let v=this.children[f-1];if(v.size&&v.dom.parentNode==this.contentDOM&&!v.emptyChildAt(1)){a=Pu(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 p=i+1;pb&&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?Pk:yTe,s==i&&r==d&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=iy:o.markDirty(s-i,r-i);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Pk:iy}n=l}this.dirty=Pk}markParentsDirty(){let s=1;for(let r=this.parent;r;r=r.parent,s++){let n=s==1?Pk:yTe;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==yf&&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 AMt extends RL{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 zN extends RL{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=nS.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new zN(s,r,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&iy||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(s){return this.dirty!=iy&&this.mark.eq(s)}markDirty(s,r){if(super.markDirty(s,r),this.dirty!=yf){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=Txe(o,0,s,n));for(let i=0;i{if(!d)return l;if(d.parent)return d.parent.posBeforeChild(d)},n,a),p=u&&u.dom,f=u&&u.contentDOM;if(r.isText){if(!p)p=document.createTextNode(r.text);else if(p.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else p||({dom:p,contentDOM:f}=nS.renderSpec(document,r.type.spec.toDOM(r),null,r.attrs));!f&&!r.isText&&p.nodeName!="BR"&&(p.hasAttribute("contenteditable")||(p.contentEditable="false"),r.type.spec.draggable&&(p.draggable=!0));let v=p;return p=LHe(p,n,r),u?d=new EMt(s,r,n,a,p,f||null,v,u,o,l+1):r.isText?new ale(s,r,n,a,p,v,o):new g_(s,r,n,a,p,f||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=()=>Tr.empty)}return s}matchesNode(s,r,n){return this.dirty==yf&&s.eq(this.node)&&qne(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 IMt(this,l&&l.node,s);OMt(this.node,this.innerDeco,(u,p,f)=>{u.spec.marks?d.syncToMarks(u.spec.marks,n,s):u.type.side>=0&&!f&&d.syncToMarks(p==this.node.childCount?pl.none:this.node.child(p).marks,n,s),d.placeWidget(u,s,a)},(u,p,f,v)=>{d.syncToMarks(u.marks,n,s);let _;d.findNodeMatch(u,p,f,v)||i&&s.state.selection.from>a&&s.state.selection.to-1&&d.updateNodeAt(u,p,f,_,s)||d.updateNextNode(u,p,f,s,v,a)||d.addNode(u,p,f,s,a),a+=u.nodeSize}),d.syncToMarks([],n,s),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||this.dirty==Pk)&&(l&&this.protectLocalComposition(s,l),PHe(this.contentDOM,this.children,s),j3&&RMt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof Va)||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=FMt(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 AMt(this,o,r,a);s.input.compositionNodes.push(l),this.children=Txe(this.children,n,n+a.length,s,l)}update(s,r,n,a){return this.dirty==iy||!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=yf}updateOuterDeco(s){if(qne(s,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=IHe(this.dom,this.nodeDOM,Mxe(this.outerDeco,this.node,r),Mxe(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 vTe(t,s,r,n,a){LHe(n,s,t);let o=new g_(void 0,t,s,r,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class ale extends g_{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==iy||this.dirty!=yf&&!this.inParent()||!s.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=yf||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=yf,!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 ale(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=iy)}get domAtom(){return!1}isText(s){return this.node.text==s}}class EHe extends RL{parseRule(){return{ignore:!0}}matchesHack(s){return this.dirty==yf&&this.dom.nodeName==s}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class EMt extends g_{constructor(s,r,n,a,o,l,i,d,u,p){super(s,r,n,a,o,l,i,u,p),this.spec=d}update(s,r,n,a){if(this.dirty==iy)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 PHe(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=zN.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 zN)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 DMt(t,s){return t.type.side-s.type.side}function OMt(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 w=b;l!w.inline):i.slice();n(v,j,s.forChild(o,v),_),o=b}}function RMt(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 FMt(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 Txe(t,s,r,n,a){let o=[];for(let l=0,i=0;l=r||p<=s?o.push(d):(ur&&o.push(d.slice(r-u,d.size,n)))}return o}function pbe(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(nle(r)){for(d=l;a&&!a.node;)a=a.parent;let f=a.node;if(a&&f.isAtom&&Da.isSelectable(f)&&a.parent&&!(f.isInline&&uMt(r.focusNode,r.focusOffset,a.dom))){let v=a.posBefore;u=new Da(l==v?i:n.resolve(v))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let f=l,v=l;for(let _=0;_{(r.anchorNode!=n||r.anchorOffset!=a)&&(s.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!DHe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function BMt(t){let s=t.domSelection();if(!s)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?s.collapse(r.parentNode,Pu(r)+1):s.collapse(r,0),!n&&!t.state.selection.visible&&Om&&f_<=11&&(r.disabled=!0,r.disabled=!1)}function OHe(t,s){if(s instanceof Da){let r=t.docView.descAt(s.from);r!=t.lastSelectedViewDesc&&(kTe(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else kTe(t)}function kTe(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function fbe(t,s,r,n){return t.someProp("createSelectionBetween",a=>a(t,s,r))||Va.between(s,r,n)}function NTe(t){return t.editable&&!t.hasFocus()?!1:RHe(t)}function RHe(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 $Mt(t){let s=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return FN(s.node,s.offset,r.anchorNode,r.anchorOffset)}function Axe(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&&ri.findFrom(o,s)}function c1(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function STe(t,s,r){let n=t.state.selection;if(n instanceof Va)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 c1(t,new Va(n.$anchor,l))}else if(n.empty){if(t.endOfTextblock(s>0?"forward":"backward")){let a=Axe(t.state,s);return a&&a instanceof Da?c1(t,a):!1}else if(!(Zp&&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?Da.isSelectable(o)?c1(t,new Da(s<0?t.state.doc.resolve(a.pos-o.nodeSize):a)):OL?c1(t,new Va(t.state.doc.resolve(s<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof Da&&n.node.isInline)return c1(t,new Va(s>0?n.$to:n.$from));{let a=Axe(t.state,s);return a?c1(t,a):!1}}}function Une(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function rI(t,s){let r=t.pmViewDesc;return r&&r.size==0&&(s<0||t.nextSibling||t.nodeName!="BR")}function i4(t,s){return s<0?qMt(t):UMt(t)}function qMt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a,o,l=!1;for(xf&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let i=r.childNodes[n-1];if(rI(i,-1))a=r,o=--n;else if(i.nodeType==3)r=i,n=r.nodeValue.length;else break}}else{if(FHe(r))break;{let i=r.previousSibling;for(;i&&rI(i,-1);)a=r.parentNode,o=Pu(i),i=i.previousSibling;if(i)r=i,n=Une(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}l?Exe(t,r,n):a&&Exe(t,a,o)}function UMt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=Une(r),o,l;for(;;)if(n{t.state==a&&F0(t)},50)}function CTe(t,s){let r=t.state.doc.resolve(s);if(!(hu||jHe)&&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 MTe(t,s,r){let n=t.state.selection;if(n instanceof Va&&!n.empty||r.indexOf("s")>-1||Zp&&r.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||t.endOfTextblock(s<0?"up":"down")){let l=Axe(t.state,s);if(l&&l instanceof Da)return c1(t,l)}if(!a.parent.inlineContent){let l=s<0?a:o,i=n instanceof xp?ri.near(l,s):ri.findFrom(l,s);return i?c1(t,i):!1}return!1}function TTe(t,s){if(!(t.state.selection instanceof Va))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 ATe(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function WMt(t){if(!oh||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;ATe(t,n,"true"),setTimeout(()=>ATe(t,n,"false"),20)}return!1}function GMt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function KMt(t,s){let r=s.keyCode,n=GMt(s);if(r==8||Zp&&r==72&&n=="c")return TTe(t,-1)||i4(t,-1);if(r==46&&!s.shiftKey||Zp&&r==68&&n=="c")return TTe(t,1)||i4(t,1);if(r==13||r==27)return!0;if(r==37||Zp&&r==66&&n=="c"){let a=r==37?CTe(t,t.state.selection.from)=="ltr"?-1:1:-1;return STe(t,a,n)||i4(t,a)}else if(r==39||Zp&&r==70&&n=="c"){let a=r==39?CTe(t,t.state.selection.from)=="ltr"?1:-1:1;return STe(t,a,n)||i4(t,a)}else{if(r==38||Zp&&r==80&&n=="c")return MTe(t,-1,n)||i4(t,-1);if(r==40||Zp&&r==78&&n=="c")return WMt(t)||MTe(t,1,n)||i4(t,1);if(n==(Zp?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function gbe(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")||nS.fromSchema(t.state.schema),i=VHe(),d=i.createElement("div");d.appendChild(l.serializeFragment(n,{document:i}));let u=d.firstChild,p,f=0;for(;u&&u.nodeType==1&&(p=UHe[u.nodeName.toLowerCase()]);){for(let _=p.length-1;_>=0;_--){let b=i.createElement(p[_]);for(;d.firstChild;)b.appendChild(d.firstChild);d.appendChild(b),f++}u=d.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${a} ${o}${f?` -${f}`:""} ${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 zHe(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 pn(Tr.from(t.state.schema.text(s.replace(/\r\n?/g,` `))),0,0),t.someProp("transformPasted",v=>{i=v(i,t,!0)}),i;let f=t.someProp("clipboardTextParser",v=>v(s,a,n,t));if(f)i=f;else{let v=a.marks(),{schema:_}=t.state,b=nS.fromSchema(_);l=document.createElement("div"),s.split(/(?:\r\n?|\n)+/).forEach(j=>{let w=l.appendChild(document.createElement("p"));j&&w.appendChild(b.serializeNode(_.text(j,v)))})}}else t.someProp("transformPastedHTML",f=>{r=f(r,t)}),l=QMt(r),OL&&JMt(l);let u=l&&l.querySelector("[data-pm-slice]"),p=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(p&&p[3])for(let f=+p[3];f>0;f--){let 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")||eI.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(d||p),context:a,ruleFromNode(v){return v.nodeName=="BR"&&!v.nextSibling&&v.parentNode&&!ZMt.test(v.parentNode.nodeName)?{ignore:!0}:null}})),p)i=eTt(ETe(i,+p[1],+p[2]),p[4]);else if(i=pn.maxOpen(YMt(i.content,a),!0),i.openStart||i.openEnd){let f=0,v=0;for(let _=i.content.firstChild;f{i=f(i,t,d)}),i}const ZMt=/^(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 YMt(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&&$He(d,o,i,l[l.length-1],0))l[l.length-1]=u;else{l.length&&(l[l.length-1]=qHe(l[l.length-1],o.length));let p=BHe(i,d);l.push(p),a=a.matchType(p.type),o=d}}),l)return Tr.from(l)}return t}function BHe(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,Tr.from(t));return t}function $He(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(Tr.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function ETe(t,s,r){return sr})),fme.createHTML(t)):t}function QMt(t){let s=/^(\s*]*>)*/.exec(t);s&&(t=t.slice(s[0].length));let r=VHe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),a;if((a=n&&UHe[n[1].toLowerCase()])&&(t=a.map(o=>"<"+o+">").join("")+t+a.map(o=>"").reverse().join("")),r.innerHTML=XMt(t),a)for(let o=0;o=0;i-=2){let d=r.nodes[n[i]];if(!d||d.hasRequiredAttrs())break;a=Tr.from(d.create(n[i+1],a)),o++,l++}return new pn(a,o,l)}const Kh={},Zh={},tTt={touchstart:!0,touchmove:!0};class sTt{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 rTt(t){for(let s in Kh){let r=Kh[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{aTt(t,n)&&!xbe(t,n)&&(t.editable||!(n.type in Zh))&&r(t,n)},tTt[s]?{passive:!0}:void 0)}oh&&t.dom.addEventListener("input",()=>null),Ixe(t)}function $1(t,s){t.input.lastSelectionOrigin=s,t.input.lastSelectionTime=Date.now()}function nTt(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 Ixe(t){t.someProp("handleDOMEvents",s=>{for(let r in s)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>xbe(t,n))})}function xbe(t,s){return t.someProp("handleDOMEvents",r=>{let n=r[s.type];return n?n(t,s)||s.defaultPrevented:!1})}function aTt(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 iTt(t,s){!xbe(t,s)&&Kh[s.type]&&(t.editable||!(s.type in Zh))&&Kh[s.type](t,s)}Zh.keydown=(t,s)=>{let r=s;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!WHe(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(v0&&hu&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),j3&&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,_k(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||KMt(t,r)?r.preventDefault():$1(t,"key")};Zh.keyup=(t,s)=>{s.keyCode==16&&(t.input.shiftKey=!1)};Zh.keypress=(t,s)=>{let r=s;if(WHe(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||Zp&&r.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof Va)||!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 ile(t){return{left:t.clientX,top:t.clientY}}function oTt(t,s){let r=s.x-t.clientX,n=s.y-t.clientY;return r*r+n*n<100}function ybe(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 D5(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 lTt(t,s){if(s==-1)return!1;let r=t.state.doc.resolve(s),n=r.nodeAfter;return n&&n.isAtom&&Da.isSelectable(n)?(D5(t,new Da(r)),!0):!1}function cTt(t,s){if(s==-1)return!1;let r=t.state.selection,n,a;r instanceof Da&&(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(Da.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?(D5(t,Da.create(t.state.doc,a)),!0):!1}function dTt(t,s,r,n,a){return ybe(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?cTt(t,r):lTt(t,r))}function uTt(t,s,r,n){return ybe(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function hTt(t,s,r,n){return ybe(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||mTt(t,r,n)}function mTt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(D5(t,Va.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)D5(t,Va.create(n,i+1,i+1+l.content.size));else if(Da.isSelectable(l))D5(t,Da.create(n,i));else continue;return!0}}function vbe(t){return Vne(t)}const HHe=Zp?"metaKey":"ctrlKey";Kh.mousedown=(t,s)=>{let r=s;t.input.shiftKey=r.shiftKey;let n=vbe(t),a=Date.now(),o="singleClick";a-t.input.lastClick.time<500&&oTt(r,t.input.lastClick)&&!r[HHe]&&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(ile(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new pTt(t,l,r,!!n)):(o=="doubleClick"?uTt:hTt)(t,l.pos,l.inside,r)?r.preventDefault():$1(t,"pointer"))};class pTt{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[HHe],this.allowDefault=n.shiftKey;let o,l;if(r.inside>-1)o=s.state.doc.nodeAt(r.inside),l=r.inside;else{let p=s.state.doc.resolve(r.pos);o=p.parent,l=p.depth?p.before():0}const i=a?null:n.target,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 Da&&u.from<=l&&u.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&xf&&!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)),$1(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(()=>F0(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(ile(s))),this.updateAllowDefault(s),this.allowDefault||!r?$1(this.view,"pointer"):dTt(this.view,r.pos,r.inside,s,this.selectNode)?s.preventDefault():s.button==0&&(this.flushed||oh&&this.mightDrag&&!this.mightDrag.node.isAtom||hu&&!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)?(D5(this.view,ri.near(this.view.state.doc.resolve(r.pos))),s.preventDefault()):$1(this.view,"pointer")}move(s){this.updateAllowDefault(s),$1(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)}}Kh.touchstart=t=>{t.input.lastTouch=Date.now(),vbe(t),$1(t,"pointer")};Kh.touchmove=t=>{t.input.lastTouch=Date.now(),$1(t,"pointer")};Kh.contextmenu=t=>vbe(t);function WHe(t,s){return t.composing?!0:oh&&Math.abs(s.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const fTt=v0?5e3:-1;Zh.compositionstart=Zh.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:s}=t,r=s.selection.$to;if(s.selection instanceof Va&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||hu&&jHe&&gTt(t)))t.markCursor=t.state.storedMarks||r.marks(),Vne(t,!0),t.markCursor=null;else if(Vne(t,!s.selection.empty),xf&&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}GHe(t,fTt)};function gTt(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"}Zh.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++,GHe(t,20))};function GHe(t,s){clearTimeout(t.input.composingTimeout),s>-1&&(t.input.composingTimeout=setTimeout(()=>Vne(t),s))}function KHe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=yTt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function xTt(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=cMt(s.focusNode,s.focusOffset),n=dMt(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 yTt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Vne(t,s=!1){if(!(v0&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),KHe(t),s||t.docView&&t.docView.dirty){let r=pbe(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 vTt(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 o6=Om&&f_<15||j3&&pMt<604;Kh.copy=Zh.cut=(t,s)=>{let r=s,n=t.state.selection,a=r.type=="cut";if(n.empty)return;let o=o6?null:r.clipboardData,l=n.content(),{dom:i,text:d}=gbe(t,l);o?(r.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",d)):vTt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function _Tt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function bTt(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?l6(t,n.value,null,a,s):l6(t,n.textContent,n.innerHTML,a,s)},50)}function l6(t,s,r,n,a){let o=zHe(t,s,r,n,t.state.selection.$from);if(t.someProp("handlePaste",d=>d(t,a,o||pn.empty)))return!0;if(!o)return!1;let l=_Tt(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 ZHe(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," "):""}Zh.paste=(t,s)=>{let r=s;if(t.composing&&!v0)return;let n=o6?null:r.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&l6(t,ZHe(n),n.getData("text/html"),a,r)?r.preventDefault():bTt(t,r)};class YHe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const wTt=Zp?"altKey":"ctrlKey";function XHe(t,s){let r=t.someProp("dragCopies",n=>!n(s));return r??!s[wTt]}Kh.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(ile(r)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof Da?a.to-1:a.to))){if(n&&n.mightDrag)l=Da.create(t.state.doc,n.mightDrag.pos);else if(r.target&&r.target.nodeType==1){let f=t.docView.nearestDesc(r.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(l=Da.create(t.state.doc,f.posBefore))}}let i=(l||t.state.selection).content(),{dom:d,text:u,slice:p}=gbe(t,i);(!r.dataTransfer.files.length||!hu||wHe>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(o6?"Text":"text/html",d.innerHTML),r.dataTransfer.effectAllowed="copyMove",o6||r.dataTransfer.setData("text/plain",u),t.dragging=new YHe(p,XHe(t,r),l)};Kh.dragend=t=>{let s=t.dragging;window.setTimeout(()=>{t.dragging==s&&(t.dragging=null)},50)};Zh.dragover=Zh.dragenter=(t,s)=>s.preventDefault();Zh.drop=(t,s)=>{try{jTt(t,s,t.dragging)}finally{t.dragging=null}};function jTt(t,s,r){if(!s.dataTransfer)return;let n=t.posAtCoords(ile(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=zHe(t,ZHe(s.dataTransfer),o6?null:s.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&XHe(t,s));if(t.someProp("handleDrop",_=>_(t,s,o||pn.empty,l))){s.preventDefault();return}if(!o)return;s.preventDefault();let i=o?mHe(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),p=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=d.doc;if(p?d.replaceRangeWith(u,u,o.content.firstChild):d.replaceRange(u,u,o),d.doc.eq(f))return;let v=d.doc.resolve(u);if(p&&Da.isSelectable(o.content.firstChild)&&v.nodeAfter&&v.nodeAfter.sameMarkup(o.content.firstChild))d.setSelection(new Da(v));else{let _=d.mapping.map(i);d.mapping.maps[d.mapping.maps.length-1].forEach((b,j,w,N)=>_=N),d.setSelection(fbe(t,v,d.doc.resolve(_)))}t.focus(),t.dispatch(d.setMeta("uiEvent","drop"))}Kh.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())&&F0(t)},20))};Kh.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)};Kh.beforeinput=(t,s)=>{if(hu&&v0&&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,_k(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 Zh)Kh[t]=Zh[t];function c6(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 Hne{constructor(s,r){this.toDOM=s,this.spec=r||gN,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 Dh(o-n,o-n,this)}valid(){return!0}eq(s){return this==s||s instanceof Hne&&(this.spec.key&&this.spec.key==s.spec.key||this.toDOM==s.toDOM&&c6(this.spec,s.spec))}destroy(s){this.spec.destroy&&this.spec.destroy(s)}}class x_{constructor(s,r){this.attrs=s,this.spec=r||gN}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 Dh(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==Zu||s.maps.length==0?this:this.mapInner(s,r,0,0,n||gN)}mapInner(s,r,n,a,o){let l;for(let i=0;i{let u=d+n,p;if(p=JHe(r,i,u)){for(a||(a=this.children.slice());oi&&f.to=s){this.children[i]==s&&(n=this.children[i+2]);break}let o=s+1,l=o+r.content.size;for(let i=0;io&&d.type instanceof x_){let u=Math.max(o,d.from)-o,p=Math.min(l,d.to)-o;ua.map(s,r,gN));return v1.from(n)}forChild(s,r){if(r.isLeaf)return Bc.empty;let n=[];for(let a=0;ar instanceof Bc)?s:s.reduce((r,n)=>r.concat(n instanceof Bc?n:n.members),[]))}}forEachSet(s){for(let r=0;r{let w=j-b-(_-v);for(let N=0;NC+p-f)continue;let A=i[N]+p-f;_>=A?i[N+1]=v<=A?-2:-1:v>=p&&w&&(i[N]+=w,i[N+1]+=w)}f+=w}),p=r.maps[u].map(p,-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:j}=n.content.findIndex(f),w=n.maybeChild(b);if(w&&j==f&&j+w.nodeSize==_){let N=i[u+2].mapInner(r,w,p+1,t[u]+o+1,l);N!=Zu?(i[u]=f,i[u+1]=_,i[u+2]=N):(i[u+1]=-2,d=!0)}else d=!0}if(d){let u=NTt(i,t,s,r,a,o,l),p=Wne(u,n,0,l);s=p.local;for(let f=0;fr&&l.to{let u=JHe(t,i,d+r);if(u){o=!0;let p=Wne(u,i,r+d+1,n);p!=Zu&&a.push(d,d+i.nodeSize,p)}});let l=QHe(o?eWe(t):t,-r).sort(xN);for(let i=0;i0;)s++;t.splice(s,0,r)}function gme(t){let s=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=Zu&&s.push(n)}),t.cursorWrapper&&s.push(Bc.create(t.state.doc,[t.cursorWrapper.deco])),v1.from(s)}const STt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},CTt=Om&&f_<=11;class MTt{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 TTt{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new MTt,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()}),CTt&&(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,STt)),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(NTe(this.view)){if(this.suppressingSelectionUpdates)return F0(this.view);if(Om&&f_<=11&&!this.view.state.selection.empty){let s=this.view.domSelectionRange();if(s.focusNode&&FN(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=w3(o))r.add(o);for(let o=s.anchorNode;o;o=w3(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)&&NTe(s)&&!this.ignoreSelectionChange(n),o=-1,l=-1,i=!1,d=[];if(s.editable)for(let p=0;pf.nodeName=="BR");if(p.length==2){let[f,v]=p;f.parentNode&&f.parentNode.parentNode==v.parentNode?v.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let v of p){let _=v.parentNode;_&&_.nodeName=="LI"&&(!f||PTt(s,f)!=_)&&v.remove()}}}else if((hu||oh)&&d.some(p=>p.nodeName=="BR")&&(s.input.lastKeyCode==8||s.input.lastKeyCode==46)){for(let p of d)if(p.nodeName=="BR"&&p.parentNode){let f=p.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&p.parentNode.removeChild(p)}}let u=null;o<0&&a&&s.input.lastFocus>Date.now()-200&&Math.max(s.input.lastTouch,s.input.lastClick.time)-1||a)&&(o>-1&&(s.docView.markDirty(o,l),ATt(s)),this.handleDOMChange(o,l,i,d),s.docView&&s.docView.dirty?s.updateState(s.state):this.currentSelection.eq(n)||F0(s),this.currentSelection.set(n))}registerMutation(s,r){if(r.indexOf(s.target)>-1)return null;let n=this.view.docView.nearestDesc(s.target);if(s.type=="attributes"&&(n==this.view.docView||s.attributeName=="contenteditable"||s.attributeName=="style"&&!s.oldValue&&!s.target.getAttribute("style"))||!n||n.ignoreMutation(s))return null;if(s.type=="childList"){for(let p=0;pa;w--){let N=n.childNodes[w-1],C=N.pmViewDesc;if(N.nodeName=="BR"&&!C){o=w;break}if(!C||C.size)break}let f=t.state.doc,v=t.someProp("domParser")||eI.fromSchema(t.state.schema),_=f.resolve(l),b=null,j=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:LTt,context:_});if(u&&u[0].pos!=null){let w=u[0].pos,N=u[1]&&u[1].pos;N==null&&(N=w),b={anchor:w+l,head:N+l}}return{doc:j,sel:b,from:l,to:i}}function LTt(t){let s=t.pmViewDesc;if(s)return s.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(oh&&/^(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||oh&&/^(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 DTt=/^(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 OTt(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=pbe(t,$);if(q&&!t.state.selection.eq(q)){if(hu&&v0&&t.input.lastKeyCode===13&&Date.now()-100V(t,_k(13,"Enter"))))return;let U=t.state.tr.setSelection(q);$=="pointer"?U.setMeta("pointer",!0):$=="key"&&U.scrollIntoView(),o&&U.setMeta("composition",o),t.dispatch(U)}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=ITt(t,s,r),p=t.state.doc,f=p.slice(u.from,u.to),v,_;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||v0)&&a.some($=>$.nodeType==1&&!DTt.test($.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",$=>$(t,_k(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(n&&d instanceof Va&&!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 $=RTe(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)),Om&&f_<=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 j=u.doc.resolveNoCache(b.start-u.from),w=u.doc.resolveNoCache(b.endB-u.from),N=p.resolve(b.start),C=j.sameParent(w)&&j.parent.inlineContent&&N.end()>=b.endA;if((j3&&t.input.lastIOSEnter>Date.now()-225&&(!C||a.some($=>$.nodeName=="DIV"||$.nodeName=="P"))||!C&&j.pos$(t,_k(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&FTt(p,b.start,b.endA,j,w)&&t.someProp("handleKeyDown",$=>$(t,_k(8,"Backspace")))){v0&&hu&&t.domObserver.suppressSelectionUpdates();return}hu&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),v0&&!C&&j.start()!=w.start()&&w.parentOffset==0&&j.depth==w.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==b.endA&&(b.endB-=2,w=u.doc.resolveNoCache(b.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function($){return $(t,_k(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 U=RTe(t,q.doc,u.sel);U&&!(hu&&t.composing&&U.empty&&(b.start!=b.endB||t.input.lastChromeDeleteF0(t),20));let $=L(t.state.tr.delete(A,I)),q=p.resolve(b.start).marksAcross(p.resolve(b.endA));q&&$.ensureMarks(q),t.dispatch($)}else if(b.endA==b.endB&&(R=RTt(j.parent.content.cut(j.parentOffset,w.parentOffset),N.parent.content.cut(N.parentOffset,b.endA-N.start())))){let $=L(t.state.tr);R.type=="add"?$.addMark(A,I,R.mark):$.removeMark(A,I,R.mark),t.dispatch($)}else if(j.parent.child(j.index()).isText&&j.index()==w.index()-(w.textOffset?0:1)){let $=j.parent.textBetween(j.parentOffset,w.parentOffset),q=()=>L(t.state.tr.insertText($,A,I));t.someProp("handleTextInput",U=>U(t,A,I,$,q))||t.dispatch(q())}else t.dispatch(L());else t.dispatch(L())}function RTe(t,s,r){return Math.max(r.anchor,r.head)>s.content.size?null:fbe(t,s.resolve(r.anchor),s.resolve(r.head))}function RTt(t,s){let r=t.firstChild.marks,n=s.firstChild.marks,a=r,o=n,l,i,d;for(let p=0;pp.mark(i.addToSet(p.marks));else if(a.length==0&&o.length==1)i=o[0],l="remove",d=p=>p.mark(i.removeFromSet(p.marks));else return null;let u=[];for(let p=0;pr||xme(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 zTt(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 tWe{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 sTt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(UTe),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=$Te(this),BTe(this),this.nodeViews=qTe(this),this.docView=vTe(this.state.doc,zTe(this),gme(this),this.dom,this),this.domObserver=new TTt(this,(n,a,o,l)=>OTt(this,n,a,o,l)),this.domObserver.start(),rTt(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&&Ixe(this);let r=this._props;this._props=s,s.plugins&&(s.plugins.forEach(UTe),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&&(KHe(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 _=qTe(this);$Tt(_,this.nodeViews)&&(this.nodeViews=_,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&Ixe(this),this.editable=$Te(this),BTe(this);let d=gme(this),u=zTe(this),p=a.plugins!=s.plugins&&!a.doc.eq(s.doc)?"reset":s.scrollToSelection>a.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(s.doc,u,d);(f||!s.selection.eq(a.selection))&&(l=!0);let v=p=="preserve"&&l&&this.dom.style.overflowAnchor==null&&xMt(this);if(l){this.domObserver.stop();let _=f&&(Om||hu)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&BTt(a.selection,s.selection);if(f){let b=hu?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=xTt(this)),(o||!this.docView.update(s.doc,u,d,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=vTe(s.doc,u,d,this.dom,this)),b&&!this.trackWrites&&(_=!0)}_||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&$Mt(this))?F0(this,_):(OHe(this,s.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(a),!((n=this.dragging)===null||n===void 0)&&n.node&&!a.doc.eq(s.doc)&&this.updateDraggedNode(this.dragging,a),p=="reset"?this.dom.scrollTop=0:p=="to selection"?this.scrollToSelection():v&&yMt(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 Da){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&mTe(this,r.getBoundingClientRect(),s)}else mTe(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 YHe(s.slice,s.move,a<0?void 0:Da.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 kMt(this,s)}coordsAtPos(s,r=1){return MHe(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 TMt(this,r||this.state,s)}pasteHTML(s,r){return l6(this,"",s,!1,r||new ClipboardEvent("paste"))}pasteText(s,r){return l6(this,s,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(s){return gbe(this,s)}destroy(){this.docView&&(nTt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],gme(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,oMt())}get isDestroyed(){return this.docView==null}dispatchEvent(s){return iTt(this,s)}domSelectionRange(){let s=this.domSelection();return s?oh&&this.root.nodeType===11&&hMt(this.dom.ownerDocument)==this.dom&&ETt(this,s)||s:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}tWe.prototype.dispatch=function(t){let s=this._props.dispatchTransaction;s?s.call(this,t):this.updateState(this.state.apply(t))};function zTe(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"),[Dh.node(0,t.state.doc.content.size,s)]}function BTe(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:Dh.widget(t.state.selection.from,s,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function $Te(t){return!t.someProp("editable",s=>s(t.state)===!1)}function BTt(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 qTe(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 $Tt(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 UTe(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 I_={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:"'"},Gne={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},qTt=typeof navigator<"u"&&/Mac/.test(navigator.platform),UTt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Iu=0;Iu<10;Iu++)I_[48+Iu]=I_[96+Iu]=String(Iu);for(var Iu=1;Iu<=24;Iu++)I_[Iu+111]="F"+Iu;for(var Iu=65;Iu<=90;Iu++)I_[Iu]=String.fromCharCode(Iu+32),Gne[Iu]=String.fromCharCode(Iu);for(var yme in I_)Gne.hasOwnProperty(yme)||(Gne[yme]=I_[yme]);function VTt(t){var s=qTt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||UTt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?Gne:I_)[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 HTt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),WTt=typeof navigator<"u"&&/Win/.test(navigator.platform);function GTt(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 sWe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const rWe=(t,s,r)=>{let n=sWe(t,r);if(!n)return!1;let a=kbe(n);if(!a){let l=n.blockRange(),i=l&&jM(l);return i==null?!1:(s&&s(t.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(hWe(t,a,s,-1))return!0;if(n.parent.content.size==0&&(k3(o,"end")||Da.isSelectable(o)))for(let l=n.depth;;l--){let i=sle(t.doc,n.before(l),n.after(l),pn.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},YTt=(t,s,r)=>{let n=sWe(t,r);if(!n)return!1;let a=kbe(n);return a?nWe(t,a,s):!1},XTt=(t,s,r)=>{let n=iWe(t,r);if(!n)return!1;let a=Nbe(n);return a?nWe(t,a,s):!1};function nWe(t,s,r){let n=s.nodeBefore,a=n,o=s.pos-1;for(;!a.isTextblock;o--){if(a.type.spec.isolating)return!1;let p=a.lastChild;if(!p)return!1;a=p}let l=s.nodeAfter,i=l,d=s.pos+1;for(;!i.isTextblock;d++){if(i.type.spec.isolating)return!1;let p=i.firstChild;if(!p)return!1;i=p}let u=sle(t.doc,o,d,pn.empty);if(!u||u.from!=o||u instanceof du&&u.slice.size>=d-o)return!1;if(r){let p=t.tr.step(u);p.setSelection(Va.create(p.doc,o)),r(p.scrollIntoView())}return!0}function k3(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 aWe=(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=kbe(n)}let l=o&&o.nodeBefore;return!l||!Da.isSelectable(l)?!1:(s&&s(t.tr.setSelection(Da.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function kbe(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 iWe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("forward",t):r.parentOffset{let n=iWe(t,r);if(!n)return!1;let a=Nbe(n);if(!a)return!1;let o=a.nodeAfter;if(hWe(t,a,s,1))return!0;if(n.parent.content.size==0&&(k3(o,"start")||Da.isSelectable(o))){let l=sle(t.doc,n.before(),n.after(),pn.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 Da,a;if(n){if(r.node.isTextblock||!G_(t.doc,r.from))return!1;a=r.from}else if(a=tle(t.doc,r.from,-1),a==null)return!1;if(s){let o=t.tr.join(a);n&&o.setSelection(Da.create(o.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),s(o.scrollIntoView())}return!0},JTt=(t,s)=>{let r=t.selection,n;if(r instanceof Da){if(r.node.isTextblock||!G_(t.doc,r.to))return!1;n=r.to}else if(n=tle(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},eAt=(t,s)=>{let{$from:r,$to:n}=t.selection,a=r.blockRange(n),o=a&&jM(a);return o==null?!1:(s&&s(t.tr.lift(a,o).scrollIntoView()),!0)},cWe=(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 Sbe(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=Sbe(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(ri.near(d.doc.resolve(i),1)),s(d.scrollIntoView())}return!0},dWe=(t,s)=>{let r=t.selection,{$from:n,$to:a}=r;if(r instanceof xp||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=Sbe(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(R0(t.doc,o))return s&&s(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),a=n&&jM(n);return a==null?!1:(s&&s(t.tr.lift(n,a).scrollIntoView()),!0)};function sAt(t){return(s,r)=>{let{$from:n,$to:a}=s.selection;if(s.selection instanceof Da&&s.selection.node.isBlock)return!n.parentOffset||!R0(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=Sbe(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 p=s.tr;(s.selection instanceof Va||s.selection instanceof xp)&&p.deleteSelection();let f=p.mapping.map(n.pos),v=R0(p.doc,f,o.length,o);if(v||(o[0]=i?{type:i}:null,v=R0(p.doc,f,o.length,o)),!v)return!1;if(p.split(f,o.length,o),!d&&u&&n.node(l).type!=i){let _=p.mapping.map(n.before(l)),b=p.doc.resolve(_);i&&n.node(l-1).canReplaceWith(b.index(),b.index()+1,i)&&p.setNodeMarkup(p.mapping.map(n.before(l)),i)}return r&&r(p.scrollIntoView()),!0}}const rAt=sAt(),nAt=(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(Da.create(t.doc,a))),!0)};function aAt(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||G_(t.doc,s.pos))?!1:(r&&r(t.tr.join(s.pos).scrollIntoView()),!0)}function hWe(t,s,r,n){let a=s.nodeBefore,o=s.nodeAfter,l,i,d=a.type.spec.isolating||o.type.spec.isolating;if(!d&&aAt(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=Tr.empty;for(let N=l.length-1;N>=0;N--)b=Tr.from(l[N].create(null,b));b=Tr.from(a.copy(b));let j=t.tr.step(new fu(s.pos-1,_,s.pos,_,new pn(b,1,0),l.length,!0)),w=j.doc.resolve(_+2*l.length);w.nodeAfter&&w.nodeAfter.type==a.type&&G_(j.doc,w.pos)&&j.join(w.pos),r(j.scrollIntoView())}return!0}let p=o.type.spec.isolating||n>0&&d?null:ri.findFrom(s,1),f=p&&p.$from.blockRange(p.$to),v=f&&jM(f);if(v!=null&&v>=s.depth)return r&&r(t.tr.lift(f,v).scrollIntoView()),!0;if(u&&k3(o,"start",!0)&&k3(a,"end")){let _=a,b=[];for(;b.push(_),!_.isTextblock;)_=_.lastChild;let j=o,w=1;for(;!j.isTextblock;j=j.firstChild)w++;if(_.canReplace(_.childCount,_.childCount,j.content)){if(r){let N=Tr.empty;for(let A=b.length-1;A>=0;A--)N=Tr.from(b[A].copy(N));let C=t.tr.step(new fu(s.pos-b.length,s.pos+o.nodeSize,s.pos+w,s.pos+o.nodeSize-w,new pn(N,b.length,0),0,!0));r(C.scrollIntoView())}return!0}}return!1}function mWe(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(Va.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const iAt=mWe(-1),oAt=mWe(1);function lAt(t,s=null){return function(r,n){let{$from:a,$to:o}=r.selection,l=a.blockRange(o),i=l&&dbe(l,t,s);return i?(n&&n(r.tr.wrap(l,i).scrollIntoView()),!0):!1}}function VTe(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 p=r.doc.resolve(u),f=p.index();a=p.parent.canReplaceWith(f,f+1,t)}})}if(!a)return!1;if(n){let o=r.tr;for(let l=0;l=2&&s.$from.node(s.depth-1).type.compatibleContent(r)&&s.startIndex==0){if(s.$from.index(s.depth-1)==0)return!1;let d=l.resolve(s.start-2);o=new Bne(d,d,s.depth),s.endIndex=0;p--)o=Tr.from(r[p].type.create(r[p].attrs,o));t.step(new fu(s.start-(n?2:0),s.end,s.start,s.end,new pn(o,0,0),r.length,!0));let l=0;for(let p=0;pl.childCount>0&&l.firstChild.type==t);return o?r?n.node(o.depth-1).type==t?mAt(s,r,t,o):pAt(s,r,o):!0:!1}}function mAt(t,s,r,n){let a=t.tr,o=n.end,l=n.$to.end(n.depth);oj;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),p=o.index(-1);if(!u.canReplace(p+(i?0:1),p+1,l.content.append(d?Tr.empty:Tr.from(a))))return!1;let f=o.pos,v=f+l.nodeSize;return n.step(new fu(f-(i?1:0),v+(d?1:0),f+1,v-1,new pn((i?Tr.empty:Tr.from(a.copy(Tr.empty))).append(d?Tr.empty:Tr.from(a.copy(Tr.empty))),i?0:1,d?0:1),i?0:1)),s(n.scrollIntoView()),!0}function fAt(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,p=Tr.from(u?t.create():null),f=new pn(Tr.from(t.create(null,Tr.from(i.type.create(null,p)))),u?3:1,0),v=o.start,_=o.end;r(s.tr.step(new fu(v-(u?3:1),_,v,_,f,1,!0)).scrollIntoView())}return!0}}function ole(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 lle{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,(...p)=>{const f=d(...p)(l);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(o),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i=[],d=!!s,u=s||o.tr,p=()=>(!d&&r&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(u),i.every(v=>v===!0)),f={...Object.fromEntries(Object.entries(n).map(([v,_])=>[v,(...j)=>{const w=this.buildProps(u,r),N=_(...j)(w);return i.push(N),f}])),run:p};return f}createCan(s){const{rawCommands:r,state:n}=this,a=!1,o=s||n.tr,l=this.buildProps(o,a);return{...Object.fromEntries(Object.entries(r).map(([d,u])=>[d,(...p)=>u(...p)({...l,dispatch:void 0})])),chain:()=>this.createChain(o,a)}}buildProps(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i={tr:s,editor:a,view:l,state:ole({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,(...p)=>u(...p)(i)]))}};return i}}let gAt=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 Jn(t,s,r){return t.config[s]===void 0&&t.parent?Jn(t.parent,s,r):typeof t.config[s]=="function"?t.config[s].bind({...r,parent:t.parent?Jn(t.parent,s,r):null}):t.config[s]}function cle(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 pWe(t){const s=[],{nodeExtensions:r,markExtensions:n}=cle(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=Jn(l,"addGlobalAttributes",i);if(!d)return;d().forEach(p=>{p.types.forEach(f=>{Object.entries(p.attributes).forEach(([v,_])=>{s.push({type:f,name:v,attribute:{...o,..._}})})})})}),a.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage},d=Jn(l,"addAttributes",i);if(!d)return;const u=d();Object.entries(u).forEach(([p,f])=>{const v={...o,...f};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:p,attribute:v})})}),s}function yu(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 Tc(...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(p=>!d.includes(p));n[a]=[...d,...u].join(" ")}else if(a==="style"){const i=o?o.split(";").map(p=>p.trim()).filter(Boolean):[],d=n[a]?n[a].split(";").map(p=>p.trim()).filter(Boolean):[],u=new Map;d.forEach(p=>{const[f,v]=p.split(":").map(_=>_.trim());u.set(f,v)}),i.forEach(p=>{const[f,v]=p.split(":").map(_=>_.trim());u.set(f,v)}),n[a]=Array.from(u.entries()).map(([p,f])=>`${p}: ${f}`).join("; ")}else n[a]=o}),n},{})}function Lxe(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)=>Tc(r,n),{})}function fWe(t){return typeof t=="function"}function Vi(t,s=void 0,...r){return fWe(t)?s?t.bind(s)(...r):t(...r):t}function xAt(t={}){return Object.keys(t).length===0&&t.constructor===Object}function yAt(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function HTe(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):yAt(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function WTe(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&xAt(r)?!1:r!=null))}function vAt(t,s){var r;const n=pWe(t),{nodeExtensions:a,markExtensions:o}=cle(t),l=(r=a.find(u=>Jn(u,"topNode")))===null||r===void 0?void 0:r.name,i=Object.fromEntries(a.map(u=>{const p=n.filter(N=>N.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},v=t.reduce((N,C)=>{const A=Jn(C,"extendNodeSchema",f);return{...N,...A?A(u):{}}},{}),_=WTe({...v,content:Vi(Jn(u,"content",f)),marks:Vi(Jn(u,"marks",f)),group:Vi(Jn(u,"group",f)),inline:Vi(Jn(u,"inline",f)),atom:Vi(Jn(u,"atom",f)),selectable:Vi(Jn(u,"selectable",f)),draggable:Vi(Jn(u,"draggable",f)),code:Vi(Jn(u,"code",f)),whitespace:Vi(Jn(u,"whitespace",f)),linebreakReplacement:Vi(Jn(u,"linebreakReplacement",f)),defining:Vi(Jn(u,"defining",f)),isolating:Vi(Jn(u,"isolating",f)),attrs:Object.fromEntries(p.map(N=>{var C;return[N.name,{default:(C=N==null?void 0:N.attribute)===null||C===void 0?void 0:C.default}]}))}),b=Vi(Jn(u,"parseHTML",f));b&&(_.parseDOM=b.map(N=>HTe(N,p)));const j=Jn(u,"renderHTML",f);j&&(_.toDOM=N=>j({node:N,HTMLAttributes:Lxe(N,p)}));const w=Jn(u,"renderText",f);return w&&(_.toText=w),[u.name,_]})),d=Object.fromEntries(o.map(u=>{const p=n.filter(w=>w.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},v=t.reduce((w,N)=>{const C=Jn(N,"extendMarkSchema",f);return{...w,...C?C(u):{}}},{}),_=WTe({...v,inclusive:Vi(Jn(u,"inclusive",f)),excludes:Vi(Jn(u,"excludes",f)),group:Vi(Jn(u,"group",f)),spanning:Vi(Jn(u,"spanning",f)),code:Vi(Jn(u,"code",f)),attrs:Object.fromEntries(p.map(w=>{var N;return[w.name,{default:(N=w==null?void 0:w.attribute)===null||N===void 0?void 0:N.default}]}))}),b=Vi(Jn(u,"parseHTML",f));b&&(_.parseDOM=b.map(w=>HTe(w,p)));const j=Jn(u,"renderHTML",f);return j&&(_.toDOM=w=>j({mark:w,HTMLAttributes:Lxe(w,p)})),[u.name,_]}));return new sHe({topNode:l,nodes:i,marks:d})}function _me(t,s){return s.nodes[t]||s.marks[t]||null}function GTe(t,s){return Array.isArray(s)?s.some(r=>(typeof r=="string"?r:r.name)===t.name):s}function Mbe(t,s){const r=nS.fromSchema(s).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(r),a.innerHTML}const _At=(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 p=((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?p:p.slice(0,Math.max(0,n-o))}),r};function Tbe(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class dle{constructor(s){this.find=s.find,this.handler=s.handler}}const bAt=(t,s)=>{if(Tbe(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 V8(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 p=!1;const f=_At(u)+o;return l.forEach(v=>{if(p)return;const _=bAt(f,v.find);if(!_)return;const b=d.state.tr,j=ole({state:d.state,transaction:b}),w={from:n-(_[0].length-o.length),to:a},{commands:N,chain:C,can:A}=new lle({editor:r,state:j});v.handler({state:j,range:w,match:_,commands:N,chain:C,can:A})===null||!b.steps.length||(b.setMeta(i,{transform:b,from:n,to:a,text:o}),d.dispatch(b),p=!0)}),p}function wAt(t){const{editor:s,rules:r}=t,n=new Yd({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:p}=d;typeof p=="string"?p=p:p=Mbe(Tr.from(p),l.schema);const{from:f}=d,v=f+p.length;V8({editor:s,from:f,to:v,text:p,rules:r,plugin:n})}),a.selectionSet||a.docChanged?null:o}},props:{handleTextInput(a,o,l,i){return V8({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&V8({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?V8({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function jAt(t){return Object.prototype.toString.call(t).slice(8,-1)}function H8(t){return jAt(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function ule(t,s){const r={...t};return H8(t)&&H8(s)&&Object.keys(s).forEach(n=>{H8(s[n])&&H8(t[n])?r[n]=ule(t[n],s[n]):r[n]=s[n]}),r}class oy{constructor(s={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Vi(Jn(this,"addOptions",{name:this.name}))),this.storage=Vi(Jn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new oy(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>ule(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new oy(s);return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=Vi(Jn(r,"addOptions",{name:r.name})),r.storage=Vi(Jn(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 kAt(t){return typeof t=="number"}class NAt{constructor(s){this.find=s.find,this.handler=s.handler}}const SAt=(t,s,r)=>{if(Tbe(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 CAt(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:d,chain:u,can:p}=new lle({editor:s,state:r}),f=[];return r.doc.nodesBetween(n,a,(_,b)=>{if(!_.isTextblock||_.type.spec.code)return;const j=Math.max(n,b),w=Math.min(a,b+_.content.size),N=_.textBetween(j-b,w-b,void 0,"");SAt(N,o.find,l).forEach(A=>{if(A.index===void 0)return;const I=j+A.index+1,L=I+A[0].length,R={from:r.tr.mapping.map(I),to:r.tr.mapping.map(L)},$=o.handler({state:r,range:R,match:A,commands:d,chain:u,can:p,pasteEvent:l,dropEvent:i});f.push($)})}),f.every(_=>_!==null)}let W8=null;const MAt=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 TAt(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:p,from:f,to:v,rule:_,pasteEvt:b})=>{const j=p.tr,w=ole({state:p,transaction:j});if(!(!CAt({editor:s,state:w,from:Math.max(f-1,0),to:v.b-1,rule:_,pasteEvent:b,dropEvent:i})||!j.steps.length)){try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,j}};return r.map(p=>new Yd({view(f){const v=b=>{var j;n=!((j=f.dom.parentElement)===null||j===void 0)&&j.contains(b.target)?f.dom.parentElement:null,n&&(W8=s)},_=()=>{W8&&(W8=null)};return window.addEventListener("dragstart",v),window.addEventListener("dragend",_),{destroy(){window.removeEventListener("dragstart",v),window.removeEventListener("dragend",_)}}},props:{handleDOMEvents:{drop:(f,v)=>{if(o=n===f.dom.parentElement,i=v,!o){const _=W8;_!=null&&_.isEditable&&setTimeout(()=>{const b=_.state.selection;b&&_.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(f,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:(f,v,_)=>{const b=f[0],j=b.getMeta("uiEvent")==="paste"&&!a,w=b.getMeta("uiEvent")==="drop"&&!o,N=b.getMeta("applyPasteRules"),C=!!N;if(!j&&!w&&!C)return;if(C){let{text:L}=N;typeof L=="string"?L=L:L=Mbe(Tr.from(L),_.schema);const{from:R}=N,$=R+L.length,q=MAt(L);return d({rule:p,state:_,from:R,to:{b:$},pasteEvt:q})}const A=v.doc.content.findDiffStart(_.doc.content),I=v.doc.content.findDiffEnd(_.doc.content);if(!(!kAt(A)||!I||A===I.b))return d({rule:p,state:_,from:A,to:I,pasteEvt:l})}}))}function AAt(t){const s=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(s))}class q4{constructor(s,r){this.splittableMarks=[],this.editor=r,this.extensions=q4.resolve(s),this.schema=vAt(this.extensions,r),this.setupExtensions()}static resolve(s){const r=q4.sort(q4.flatten(s)),n=AAt(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=Jn(r,"addExtensions",n);return a?[r,...this.flatten(a())]:r}).flat(10)}static sort(s){return s.sort((n,a)=>{const o=Jn(n,"priority")||100,l=Jn(a,"priority")||100;return o>l?-1:o{const n={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:_me(r.name,this.schema)},a=Jn(r,"addCommands",n);return a?{...s,...a()}:s},{})}get plugins(){const{editor:s}=this,r=q4.sort([...this.extensions].reverse()),n=[],a=[],o=r.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:s,type:_me(l.name,this.schema)},d=[],u=Jn(l,"addKeyboardShortcuts",i);let p={};if(l.type==="mark"&&Jn(l,"exitable",i)&&(p.ArrowRight=()=>oy.handleExit({editor:s,mark:l})),u){const j=Object.fromEntries(Object.entries(u()).map(([w,N])=>[w,()=>N({editor:s})]));p={...p,...j}}const f=ZTt(p);d.push(f);const v=Jn(l,"addInputRules",i);GTe(l,s.options.enableInputRules)&&v&&n.push(...v());const _=Jn(l,"addPasteRules",i);GTe(l,s.options.enablePasteRules)&&_&&a.push(..._());const b=Jn(l,"addProseMirrorPlugins",i);if(b){const j=b();d.push(...j)}return d}).flat();return[wAt({editor:s,rules:n}),...TAt({editor:s,rules:a}),...o]}get attributes(){return pWe(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=cle(this.extensions);return Object.fromEntries(r.filter(n=>!!Jn(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:yu(n.name,this.schema)},l=Jn(n,"addNodeView",o);if(!l)return[];const i=(d,u,p,f,v)=>{const _=Lxe(d,a);return l()({node:d,view:u,getPos:p,decorations:f,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:_me(s.name,this.schema)};s.type==="mark"&&(!((r=Vi(Jn(s,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(s.name);const a=Jn(s,"onBeforeCreate",n),o=Jn(s,"onCreate",n),l=Jn(s,"onUpdate",n),i=Jn(s,"onSelectionUpdate",n),d=Jn(s,"onTransaction",n),u=Jn(s,"onFocus",n),p=Jn(s,"onBlur",n),f=Jn(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),p&&this.editor.on("blur",p),f&&this.editor.on("destroy",f)})}}class qu{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=Vi(Jn(this,"addOptions",{name:this.name}))),this.storage=Vi(Jn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new qu(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>ule(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new qu({...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=Vi(Jn(r,"addOptions",{name:r.name})),r.storage=Vi(Jn(r,"addStorage",{name:r.name,options:r.options})),r}}function gWe(t,s,r){const{from:n,to:a}=s,{blockSeparator:o=` `,textSerializers:l={}}=r||{};let i="";return t.nodesBetween(n,a,(d,u,p,f)=>{var v;d.isBlock&&u>n&&(i+=o);const _=l==null?void 0:l[d.type.name];if(_)return p&&(i+=_({node:d,pos:u,parent:p,index:f,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 xWe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,s])=>s.spec.toText).map(([s,r])=>[s,r.spec.toText]))}const EAt=qu.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Yd({key:new dh("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:s,schema:r}=t,{doc:n,selection:a}=s,{ranges:o}=a,l=Math.min(...o.map(p=>p.$from.pos)),i=Math.max(...o.map(p=>p.$to.pos)),d=xWe(r);return gWe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),PAt=()=>({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),IAt=(t=!1)=>({commands:s})=>s.setContent("",t),LAt=()=>({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:p}=s,f=u.resolve(p.map(d)),v=u.resolve(p.map(d+i.nodeSize)),_=f.blockRange(v);if(!_)return;const b=jM(_);if(i.type.isTextblock){const{defaultType:j}=f.parent.contentMatchAt(f.index());s.setNodeMarkup(_.start,j)}(b||b===0)&&s.lift(_,b)})}),!0},DAt=t=>s=>t(s),OAt=()=>({state:t,dispatch:s})=>dWe(t,s),RAt=(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 Va(n.doc.resolve(Math.max(l-1,0)))),!0},FAt=()=>({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},zAt=t=>({tr:s,state:r,dispatch:n})=>{const a=yu(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},BAt=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},$At=()=>({state:t,dispatch:s})=>jbe(t,s),qAt=()=>({commands:t})=>t.keyboardShortcut("Enter"),UAt=()=>({state:t,dispatch:s})=>tAt(t,s);function Kne(t,s,r={strict:!0}){const n=Object.keys(s);return n.length?n.every(a=>r.strict?s[a]===t[a]:Tbe(s[a])?s[a].test(t[a]):s[a]===t[a]):!0}function yWe(t,s,r={}){return t.find(n=>n.type===s&&Kne(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function KTe(t,s,r={}){return!!yWe(t,s,r)}function Abe(t,s,r){var n;if(!t||!s)return;let a=t.parent.childAfter(t.parentOffset);if((!a.node||!a.node.marks.some(p=>p.type===s))&&(a=t.parent.childBefore(t.parentOffset)),!a.node||!a.node.marks.some(p=>p.type===s)||(r=r||((n=a.node.marks[0])===null||n===void 0?void 0:n.attrs),!yWe([...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&&KTe([...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:p}=i;if(a){const f=Abe(d,o,s);if(f&&f.from<=u&&f.to>=p){const v=Va.create(l,f.from,f.to);r.setSelection(v)}}return!0},HAt=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=()=>{(Ebe()||WAt())&&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&&!vWe(r.state.selection))return l(),!0;const i=_We(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},KAt=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),ZAt=(t,s)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,s),bWe=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&&bWe(n)}return t};function G8(t){const s=`${t}`,r=new window.DOMParser().parseFromString(s,"text/html").body;return bWe(r)}function d6(t,s,r){if(t instanceof p_||t instanceof Tr)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 Tr.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),d6("",s,r)}if(a){if(r.errorOnInvalidContent){let l=!1,i="";const d=new sHe({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?eI.fromSchema(d).parseSlice(G8(t),r.parseOptions):eI.fromSchema(d).parse(G8(t),r.parseOptions),r.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=eI.fromSchema(s);return r.slice?o.parseSlice(G8(t),r.parseOptions).content:o.parse(G8(t),r.parseOptions)}return d6("",s,r)}function YAt(t,s,r){const n=t.steps.length-1;if(n{l===0&&(l=p)}),t.setSelection(ri.near(t.doc.resolve(l),r))}const XAt=t=>!("type"in t),QAt=(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=w=>{o.emit("contentError",{editor:o,error:w,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{d6(s,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(w){d(w)}try{i=d6(s,o.schema,{parseOptions:u,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})}catch(w){return d(w),!1}let{from:p,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},v=!0,_=!0;if((XAt(i)?i:[i]).forEach(w=>{w.check(),v=v?w.isText&&w.marks.length===0:!1,_=_?w.isBlock:!1}),p===f&&_){const{parent:w}=n.doc.resolve(p);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(p-=1,f+=1)}let j;if(v){if(Array.isArray(s))j=s.map(w=>w.text||"").join("");else if(s instanceof Tr){let w="";s.forEach(N=>{N.text&&(w+=N.text)}),j=w}else typeof s=="object"&&s&&s.text?j=s.text:j=s;n.insertText(j,p,f)}else j=i,n.replaceWith(p,f,j);r.updateSelection&&YAt(n,n.steps.length-1,-1),r.applyInputRules&&n.setMeta("applyInputRules",{from:p,text:j}),r.applyPasteRules&&n.setMeta("applyPasteRules",{from:p,text:j})}return!0},JAt=()=>({state:t,dispatch:s})=>QTt(t,s),eEt=()=>({state:t,dispatch:s})=>JTt(t,s),tEt=()=>({state:t,dispatch:s})=>rWe(t,s),sEt=()=>({state:t,dispatch:s})=>oWe(t,s),rEt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=tle(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},nEt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=tle(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},aEt=()=>({state:t,dispatch:s})=>YTt(t,s),iEt=()=>({state:t,dispatch:s})=>XTt(t,s);function wWe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function oEt(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=oEt(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 p=u.map(n.mapping);p&&a&&n.maybeStep(p)}),!0};function u6(t,s,r={}){const{from:n,to:a,empty:o}=t.selection,l=s?yu(s,t.schema):null,i=[];t.doc.nodesBetween(n,a,(f,v)=>{if(f.isText)return;const _=Math.max(n,v),b=Math.min(a,v+f.nodeSize);i.push({node:f,from:_,to:b})});const d=a-n,u=i.filter(f=>l?l.name===f.node.type.name:!0).filter(f=>Kne(f.node.attrs,r,{strict:!1}));return o?!!u.length:u.reduce((f,v)=>f+v.to-v.from,0)>=d}const cEt=(t,s={})=>({state:r,dispatch:n})=>{const a=yu(t,r.schema);return u6(r,a,s)?eAt(r,n):!1},dEt=()=>({state:t,dispatch:s})=>uWe(t,s),uEt=t=>({state:s,dispatch:r})=>{const n=yu(t,s.schema);return hAt(n)(s,r)},hEt=()=>({state:t,dispatch:s})=>cWe(t,s);function hle(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function ZTe(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 mEt=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=hle(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=yu(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,p)=>{o&&o===u.type&&r.setNodeMarkup(p,void 0,ZTe(u.attrs,s)),l&&u.marks.length&&u.marks.forEach(f=>{l===f.type&&r.addMark(p,p+u.nodeSize,l.create(ZTe(f.attrs,s)))})})}),!0):!1},pEt=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),fEt=()=>({tr:t,dispatch:s})=>{if(s){const r=new xp(t.doc);t.setSelection(r)}return!0},gEt=()=>({state:t,dispatch:s})=>aWe(t,s),xEt=()=>({state:t,dispatch:s})=>lWe(t,s),yEt=()=>({state:t,dispatch:s})=>nAt(t,s),vEt=()=>({state:t,dispatch:s})=>oAt(t,s),_Et=()=>({state:t,dispatch:s})=>iAt(t,s);function Dxe(t,s,r={},n={}){return d6(t,s,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const bEt=(t,s=!1,r={},n={})=>({editor:a,tr:o,dispatch:l,commands:i})=>{var d,u;const{doc:p}=o;if(r.preserveWhitespace!=="full"){const f=Dxe(t,a.schema,r,{errorOnInvalidContent:(d=n.errorOnInvalidContent)!==null&&d!==void 0?d:a.options.enableContentCheck});return l&&o.replaceWith(0,p.content.size,f).setMeta("preventUpdate",!s),!0}return l&&o.setMeta("preventUpdate",!s),i.insertContentAt({from:0,to:p.content.size},t,{parseOptions:r,errorOnInvalidContent:(u=n.errorOnInvalidContent)!==null&&u!==void 0?u:a.options.enableContentCheck})};function jWe(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 wEt(t,s){const r=new ube(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function jEt(t){for(let s=0;s{r(a)&&n.push({node:a,pos:o})}),n}function kWe(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 Pbe(t){return s=>kWe(s.$from,t)}function NEt(t,s){const r={from:0,to:t.content.size};return gWe(t,r,s)}function SEt(t,s){const r=yu(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 NWe(t,s){const r=hle(typeof s=="string"?s:s.name,t.schema);return r==="node"?SEt(t,s):r==="mark"?jWe(t,s):{}}function CEt(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 MEt(t){const s=CEt(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 TEt(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),p=s.slice(o).map(d),f=s.invert().map(u,-1),v=s.invert().map(p);n.push({oldRange:{from:f,to:v},newRange:{from:u,to:p}})})}),MEt(n)}function Ibe(t,s,r){const n=[];return t===s?r.resolve(t).marks().forEach(a=>{const o=r.resolve(t),l=Abe(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 fre(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 Oxe(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(f=>o?o.name===f.type.name:!0).find(f=>Kne(f.attrs,r,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:f,$to:v})=>{const _=f.pos,b=v.pos;t.doc.nodesBetween(_,b,(j,w)=>{if(!j.isText&&!j.marks.length)return;const N=Math.max(_,w),C=Math.min(b,w+j.nodeSize),A=C-N;l+=A,i.push(...j.marks.map(I=>({mark:I,from:N,to:C})))})}),l===0)return!1;const d=i.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>Kne(f.mark.attrs,r,{strict:!1})).reduce((f,v)=>f+v.to-v.from,0),u=i.filter(f=>o?f.mark.type!==o&&f.mark.type.excludes(o):!0).reduce((f,v)=>f+v.to-v.from,0);return(d>0?d+u:d)>=l}function AEt(t,s,r={}){if(!s)return u6(t,null,r)||Oxe(t,null,r);const n=hle(s,t.schema);return n==="node"?u6(t,s,r):n==="mark"?Oxe(t,s,r):!1}function YTe(t,s){const{nodeExtensions:r}=cle(s),n=r.find(l=>l.name===t);if(!n)return!1;const a={name:n.name,options:n.options,storage:n.storage},o=Vi(Jn(n,"group",a));return typeof o!="string"?!1:o.split(" ").includes("list")}function Lbe(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&&(Lbe(o,{ignoreWhitespace:r,checkChildren:s})||(a=!1))}),a}return!1}function EEt(t){return t instanceof Da}function PEt(t,s,r){var n;const{selection:a}=s;let o=null;if(vWe(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,(p,f,v)=>{if(u)return!1;if(p.isInline){const _=!v||v.type.allowsMarkType(r),b=!!r.isInSet(p.marks)||!p.marks.some(j=>j.type.excludes(r));u=_&&b}return!u}),u})}const IEt=(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=jWe(n,d);r.addStoredMark(d.create({...u,...s}))}else i.forEach(u=>{const p=u.$from.pos,f=u.$to.pos;n.doc.nodesBetween(p,f,(v,_)=>{const b=Math.max(_,p),j=Math.min(_+v.nodeSize,f);v.marks.find(N=>N.type===d)?v.marks.forEach(N=>{d===N.type&&r.addMark(b,j,d.create({...N.attrs,...s}))}):r.addMark(b,j,d.create(s))})});return PEt(n,r,d)},LEt=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),DEt=(t,s={})=>({state:r,dispatch:n,chain:a})=>{const o=yu(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})=>VTe(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>VTe(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},OEt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,a=Lk(t,0,n.content.size),o=Da.create(n,a);s.setSelection(o)}return!0},REt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=Va.atStart(n).from,i=Va.atEnd(n).to,d=Lk(a,l,i),u=Lk(o,l,i),p=Va.create(n,d,u);s.setSelection(p)}return!0},FEt=t=>({state:s,dispatch:r})=>{const n=yu(t,s.schema);return fAt(n)(s,r)};function XTe(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 zEt=({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,p=fre(u,i.node().type.name,i.node().attrs);if(o instanceof Da&&o.node.isBlock)return!i.parentOffset||!R0(l,i.pos)?!1:(n&&(t&&XTe(r,a.extensionManager.splittableMarks),s.split(i.pos).scrollIntoView()),!0);if(!i.parent.isBlock)return!1;const f=d.parentOffset===d.parent.content.size,v=i.depth===0?void 0:jEt(i.node(-1).contentMatchAt(i.indexAfter(-1)));let _=f&&v?[{type:v,attrs:p}]:void 0,b=R0(s.doc,s.mapping.map(i.pos),1,_);if(!_&&!b&&R0(s.doc,s.mapping.map(i.pos),1,v?[{type:v}]:void 0)&&(b=!0,_=v?[{type:v,attrs:p}]:void 0),n){if(b&&(o instanceof Va&&s.deleteSelection(),s.split(s.mapping.map(i.pos),1,_),v&&!f&&!i.parentOffset&&i.parent.type!==v)){const j=s.mapping.map(i.before()),w=s.doc.resolve(j);i.node(-1).canReplaceWith(w.index(),w.index()+1,v)&&s.setNodeMarkup(s.mapping.map(i.before()),v)}t&&XTe(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return b},BEt=(t,s={})=>({tr:r,state:n,dispatch:a,editor:o})=>{var l;const i=yu(t,n.schema),{$from:d,$to:u}=n.selection,p=n.selection.node;if(p&&p.isBlock||d.depth<2||!d.sameParent(u))return!1;const f=d.node(-1);if(f.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=Tr.empty;const C=d.index(-1)?1:d.index(-2)?2:3;for(let q=d.depth-C;q>=d.depth-3;q-=1)N=Tr.from(d.node(q).copy(N));const A=d.indexAfter(-1){if($>-1)return!1;q.isTextblock&&q.content.size===0&&($=U+1)}),$>-1&&r.setSelection(Va.near(r.doc.resolve($))),r.scrollIntoView()}return!0}const _=u.pos===d.end()?f.contentMatchAt(0).defaultType:null,b={...fre(v,f.type.name,f.attrs),...s},j={...fre(v,d.node().type.name,d.node().attrs),...s};r.delete(d.pos,u.pos);const w=_?[{type:i,attrs:b},{type:_,attrs:j}]:[{type:i,attrs:b}];if(!R0(r.doc,d.pos,2))return!1;if(a){const{selection:N,storedMarks:C}=n,{splittableMarks:A}=o.extensionManager,I=C||N.$to.parentOffset&&N.$from.marks();if(r.split(d.pos,2,w).scrollIntoView(),!I||!a)return!0;const L=I.filter(R=>A.includes(R.type.name));r.ensureMarks(L)}return!0},bme=(t,s)=>{const r=Pbe(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)&&G_(t.doc,r.pos)&&t.join(r.pos),!0},wme=(t,s)=>{const r=Pbe(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)&&G_(t.doc,n)&&t.join(n),!0},$Et=(t,s,r,n={})=>({editor:a,tr:o,state:l,dispatch:i,chain:d,commands:u,can:p})=>{const{extensions:f,splittableMarks:v}=a.extensionManager,_=yu(t,l.schema),b=yu(s,l.schema),{selection:j,storedMarks:w}=l,{$from:N,$to:C}=j,A=N.blockRange(C),I=w||j.$to.parentOffset&&j.$from.marks();if(!A)return!1;const L=Pbe(R=>YTe(R.type.name,f))(j);if(A.depth>=1&&L&&A.depth-L.depth<=1){if(L.node.type===_)return u.liftListItem(b);if(YTe(L.node.type.name,f)&&_.validContent(L.node.content)&&i)return d().command(()=>(o.setNodeMarkup(L.pos,_),!0)).command(()=>bme(o,_)).command(()=>wme(o,_)).run()}return!r||!I||!i?d().command(()=>p().wrapInList(_,n)?!0:u.clearNodes()).wrapInList(_,n).command(()=>bme(o,_)).command(()=>wme(o,_)).run():d().command(()=>{const R=p().wrapInList(_,n),$=I.filter(q=>v.includes(q.type.name));return o.ensureMarks($),R?!0:u.clearNodes()}).wrapInList(_,n).command(()=>bme(o,_)).command(()=>wme(o,_)).run()},qEt=(t,s={},r={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=r,l=Z_(t,n.schema);return Oxe(n,l,s)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,s)},UEt=(t,s,r={})=>({state:n,commands:a})=>{const o=yu(t,n.schema),l=yu(s,n.schema),i=u6(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})},VEt=(t,s={})=>({state:r,commands:n})=>{const a=yu(t,r.schema);return u6(r,a,s)?n.lift(a):n.wrapIn(a,s)},HEt=()=>({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},WEt=()=>({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},GEt=(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:p,ranges:f}=i;if(!a)return!0;if(p&&l){let{from:v,to:_}=i;const b=(o=u.marks().find(w=>w.type===d))===null||o===void 0?void 0:o.attrs,j=Abe(u,d,b);j&&(v=j.from,_=j.to),r.removeMark(v,_,d)}else f.forEach(v=>{r.removeMark(v.$from.pos,v.$to.pos,d)});return r.removeStoredMark(d),!0},KEt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=hle(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=yu(t,n.schema)),i==="mark"&&(l=Z_(t,n.schema)),a&&r.selection.ranges.forEach(d=>{const u=d.$from.pos,p=d.$to.pos;let f,v,_,b;r.selection.empty?n.doc.nodesBetween(u,p,(j,w)=>{o&&o===j.type&&(_=Math.max(w,u),b=Math.min(w+j.nodeSize,p),f=w,v=j)}):n.doc.nodesBetween(u,p,(j,w)=>{w=u&&w<=p&&(o&&o===j.type&&r.setNodeMarkup(w,void 0,{...j.attrs,...s}),l&&j.marks.length&&j.marks.forEach(N=>{if(l===N.type){const C=Math.max(w,u),A=Math.min(w+j.nodeSize,p);r.addMark(C,A,l.create({...N.attrs,...s}))}}))}),v&&(f!==void 0&&r.setNodeMarkup(f,void 0,{...v.attrs,...s}),l&&v.marks.length&&v.marks.forEach(j=>{l===j.type&&r.addMark(_,b,l.create({...j.attrs,...s}))}))}),!0):!1},ZEt=(t,s={})=>({state:r,dispatch:n})=>{const a=yu(t,r.schema);return lAt(a,s)(r,n)},YEt=(t,s={})=>({state:r,dispatch:n})=>{const a=yu(t,r.schema);return cAt(a,s)(r,n)};var XEt=Object.freeze({__proto__:null,blur:PAt,clearContent:IAt,clearNodes:LAt,command:DAt,createParagraphNear:OAt,cut:RAt,deleteCurrentNode:FAt,deleteNode:zAt,deleteRange:BAt,deleteSelection:$At,enter:qAt,exitCode:UAt,extendMarkRange:VAt,first:HAt,focus:GAt,forEach:KAt,insertContent:ZAt,insertContentAt:QAt,joinBackward:tEt,joinDown:eEt,joinForward:sEt,joinItemBackward:rEt,joinItemForward:nEt,joinTextblockBackward:aEt,joinTextblockForward:iEt,joinUp:JAt,keyboardShortcut:lEt,lift:cEt,liftEmptyBlock:dEt,liftListItem:uEt,newlineInCode:hEt,resetAttributes:mEt,scrollIntoView:pEt,selectAll:fEt,selectNodeBackward:gEt,selectNodeForward:xEt,selectParentNode:yEt,selectTextblockEnd:vEt,selectTextblockStart:_Et,setContent:bEt,setMark:IEt,setMeta:LEt,setNode:DEt,setNodeSelection:OEt,setTextSelection:REt,sinkListItem:FEt,splitBlock:zEt,splitListItem:BEt,toggleList:$Et,toggleMark:qEt,toggleNode:UEt,toggleWrap:VEt,undoInputRule:HEt,unsetAllMarks:WEt,unsetMark:GEt,updateAttributes:KEt,wrapIn:ZEt,wrapInList:YEt});const QEt=qu.create({name:"commands",addCommands(){return{...XEt}}}),JEt=qu.create({name:"drop",addProseMirrorPlugins(){return[new Yd({key:new dh("tiptapDrop"),props:{handleDrop:(t,s,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:s,slice:r,moved:n})}}})]}}),ePt=qu.create({name:"editable",addProseMirrorPlugins(){return[new Yd({key:new dh("editable"),props:{editable:()=>this.editor.options.editable}})]}}),tPt=new dh("focusEvents"),sPt=qu.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Yd({key:tPt,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}}}})]}}),rPt=qu.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:p,$anchor:f}=d,{pos:v,parent:_}=f,b=f.parent.isTextblock&&v>0?i.doc.resolve(v-1):f,j=b.parent.type.spec.isolating,w=f.pos-f.parentOffset,N=j&&b.parent.childCount===1?w===f.pos:ri.atStart(u).from===v;return!p||!_.type.isTextblock||_.textContent.length||!N||N&&f.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),s=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:s,"Mod-Delete":s,"Mod-a":()=>this.editor.commands.selectAll()},a={...n},o={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":s,"Ctrl-Alt-Backspace":s,"Alt-Delete":s,"Alt-d":s,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ebe()||wWe()?o:a},addProseMirrorPlugins(){return[new Yd({key:new dh("clearDocument"),appendTransaction:(t,s,r)=>{if(t.some(j=>j.getMeta("composition")))return;const n=t.some(j=>j.docChanged)&&!s.doc.eq(r.doc),a=t.some(j=>j.getMeta("preventClearDocument"));if(!n||a)return;const{empty:o,from:l,to:i}=s.selection,d=ri.atStart(s.doc).from,u=ri.atEnd(s.doc).to;if(o||!(l===d&&i===u)||!Lbe(r.doc))return;const v=r.tr,_=ole({state:r,transaction:v}),{commands:b}=new lle({editor:this.editor,state:_});if(b.clearNodes(),!!v.steps.length)return v}})]}}),nPt=qu.create({name:"paste",addProseMirrorPlugins(){return[new Yd({key:new dh("tiptapPaste"),props:{handlePaste:(t,s,r)=>{this.editor.emit("paste",{editor:this.editor,event:s,slice:r})}}})]}}),aPt=qu.create({name:"tabindex",addProseMirrorPlugins(){return[new Yd({key:new dh("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class bk{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 bk(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 bk(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 bk(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 bk(i,this.editor,a,a?r:null);a&&(d.actualDepth=this.depth+1),s.push(new bk(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 iPt=`.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 oPt(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 lPt extends gAt{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=oPt(iPt,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=fWe(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?[ePt,EAt.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),QEt,sPt,rPt,aPt,JEt,nPt].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 q4(a,this)}createCommandManager(){this.commandManager=new lle({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var s;let r;try{r=Dxe(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=Dxe(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=_We(r,this.options.autofocus);this.view=new tWe(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:$4.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 NWe(this.state,s)}isActive(s,r){const n=typeof s=="string"?s:null,a=typeof s=="string"?r:s;return AEt(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Mbe(this.state.doc.content,this.schema)}getText(s){const{blockSeparator:r=` `,textSerializers:n={}}=s||{};return NEt(this.state.doc,{blockSeparator:r,textSerializers:{...xWe(this.schema),...n}})}get isEmpty(){return Lbe(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 bk(r,this)}get $doc(){return this.$pos(0)}}function N3(t){return new dle({find:t.find,handler:({state:s,range:r,match:n})=>{const a=Vi(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),p=u+l.length;if(Ibe(r.from,r.to,s.doc).filter(_=>_.mark.type.excluded.find(j=>j===t.type&&j!==_.mark.type)).filter(_=>_.to>u).length)return null;pr.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 SWe(t){return new dle({find:t.find,handler:({state:s,range:r,match:n})=>{const a=Vi(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 p=l+u;p>i?p=i:i=p+n[1].length;const f=n[0][n[0].length-1];o.insertText(f,l+n[0].length-1),o.replaceWith(p,i,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 Rxe(t){return new dle({find:t.find,handler:({state:s,range:r,match:n})=>{const a=s.doc.resolve(r.from),o=Vi(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 h6(t){return new dle({find:t.find,handler:({state:s,range:r,match:n,chain:a})=>{const o=Vi(t.getAttributes,void 0,n)||{},l=s.tr.delete(r.from,r.to),d=l.doc.resolve(r.from).blockRange(),u=d&&dbe(d,t.type,o);if(!u)return null;if(l.wrap(d,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:v}=s,{splittableMarks:_}=t.editor.extensionManager,b=v||f.$to.parentOffset&&f.$from.marks();if(b){const j=b.filter(w=>_.includes(w.type.name));l.ensureMarks(j)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(f,o).run()}const p=l.doc.resolve(r.from-1).nodeBefore;p&&p.type===t.type&&G_(l.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,p))&&l.join(r.from-1)}})}let uh=class Fxe{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=Vi(Jn(this,"addOptions",{name:this.name}))),this.storage=Vi(Jn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new Fxe(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>ule(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new Fxe(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=Vi(Jn(r,"addOptions",{name:r.name})),r.storage=Vi(Jn(r,"addStorage",{name:r.name,options:r.options})),r}};function BN(t){return new NAt({find:t.find,handler:({state:s,range:r,match:n,pasteEvent:a})=>{const o=Vi(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 p=d.search(/\S/),f=r.from+d.indexOf(i),v=f+i.length;if(Ibe(r.from,r.to,s.doc).filter(b=>b.mark.type.excluded.find(w=>w===t.type&&w!==b.mark.type)).filter(b=>b.to>f).length)return null;vr.from&&l.delete(r.from+p,f),u=r.from+p+i.length,l.addMark(r.from+p,u,t.type.create(o||{})),l.removeStoredMark(t.type)}}})}function cPt(t,s){const{selection:r}=t,{$from:n}=r;if(r instanceof Da){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 dPt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var CWe={exports:{}},jme={};/** * @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 QTe;function uPt(){if(QTe)return jme;QTe=1;var t=mt;function s(f,v){return f===v&&(f!==0||1/f===1/v)||f!==f&&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(f,v){var _=v(),b=n({inst:{value:_,getSnapshot:v}}),j=b[0].inst,w=b[1];return o(function(){j.value=_,j.getSnapshot=v,d(j)&&w({inst:j})},[f,_,v]),a(function(){return d(j)&&w({inst:j}),f(function(){d(j)&&w({inst:j})})},[f]),l(_),_}function d(f){var v=f.getSnapshot;f=f.value;try{var _=v();return!r(f,_)}catch{return!0}}function u(f,v){return v()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:i;return jme.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,jme}CWe.exports=uPt();var Dbe=CWe.exports;const hPt=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},mPt=({contentComponent:t})=>{const s=Dbe.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return mt.createElement(mt.Fragment,null,Object.values(s))};function pPt(){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]:Hve.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 fPt extends mt.Component{constructor(s){var r;super(s),this.editorContentRef=mt.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=pPt(),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 mt.createElement(mt.Fragment,null,mt.createElement("div",{ref:hPt(r,this.editorContentRef),...n}),(s==null?void 0:s.contentComponent)&&mt.createElement(mPt,{contentComponent:s.contentComponent}))}}const gPt=S.forwardRef((t,s)=>{const r=mt.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return mt.createElement(fPt,{key:r,innerRef:s,...t})}),MWe=mt.memo(gPt);var xPt=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},yPt=dPt(xPt),TWe={exports:{}},kme={};/** * @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 JTe;function vPt(){if(JTe)return kme;JTe=1;var t=mt,s=Dbe;function r(u,p){return u===p&&(u!==0||1/u===1/p)||u!==u&&p!==p}var n=typeof Object.is=="function"?Object.is:r,a=s.useSyncExternalStore,o=t.useRef,l=t.useEffect,i=t.useMemo,d=t.useDebugValue;return kme.useSyncExternalStoreWithSelector=function(u,p,f,v,_){var b=o(null);if(b.current===null){var j={hasValue:!1,value:null};b.current=j}else j=b.current;b=i(function(){function N(R){if(!C){if(C=!0,A=R,R=v(R),_!==void 0&&j.hasValue){var $=j.value;if(_($,R))return I=$}return I=R}if($=I,n(A,R))return $;var q=v(R);return _!==void 0&&_($,q)?$:(A=R,I=q)}var C=!1,A,I,L=f===void 0?null:f;return[function(){return N(p())},L===null?void 0:function(){return N(L())}]},[p,f,v,_]);var w=a(u,b[0],b[1]);return l(function(){j.hasValue=!0,j.value=w},[w]),d(w),w},kme}TWe.exports=vPt();var _Pt=TWe.exports;const bPt=typeof window<"u"?S.useLayoutEffect:S.useEffect;class wPt{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 jPt(t){var s;const[r]=S.useState(()=>new wPt(t.editor)),n=_Pt.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:yPt);return bPt(()=>r.watch(t.editor),[t.editor,r]),S.useDebugValue(n),n}const kPt=!1,zxe=typeof window>"u",NPt=zxe||!!(typeof window<"u"&&window.next);class Obe{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?zxe||NPt?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 lPt(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?Obe.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 AWe(t={},s=[]){const r=S.useRef(t);r.current=t;const[n]=S.useState(()=>new Obe(r)),a=Dbe.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return S.useDebugValue(a),S.useEffect(n.onRender(s)),jPt({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const SPt=S.createContext({editor:null});SPt.Consumer;const CPt=S.createContext({onDragStart:void 0}),MPt=()=>S.useContext(CPt);mt.forwardRef((t,s)=>{const{onDragStart:r}=MPt(),n=t.as||"div";return mt.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const TPt=/^\s*>\s$/,APt=uh.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",Tc(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[h6({find:TPt,type:this.type})]}}),EPt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,PPt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,IPt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,LPt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,DPt=oy.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",Tc(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[N3({find:EPt,type:this.type}),N3({find:IPt,type:this.type})]},addPasteRules(){return[BN({find:PPt,type:this.type}),BN({find:LPt,type:this.type})]}}),OPt="listItem",eAe="textStyle",tAe=/^\s*([-+*])\s$/,RPt=uh.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",Tc(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(OPt,this.editor.getAttributes(eAe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=h6({find:tAe,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=h6({find:tAe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(eAe),editor:this.editor})),[t]}}),FPt=/(^|[^`])`([^`]+)`(?!`)/,zPt=/(^|[^`])`([^`]+)`(?!`)/g,BPt=oy.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Tc(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[N3({find:FPt,type:this.type})]},addPasteRules(){return[BN({find:zPt,type:this.type})]}}),$Pt=/^```([a-z]+)?[\s\n]$/,qPt=/^~~~([a-z]+)?[\s\n]$/,UPt=uh.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",Tc(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(ri.near(n.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[Rxe({find:$Pt,type:this.type,getAttributes:t=>({language:t[1]})}),Rxe({find:qPt,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Yd({key:new dh("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(Va.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),VPt=uh.create({name:"doc",topNode:!0,content:"block+"});function HPt(t={}){return new Yd({view(s){return new WPt(s,t)}})}class WPt{constructor(s,r){var n;this.editorView=s,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=r.width)!==null&&n!==void 0?n:1,this.color=r.color===!1?void 0:r.color||"black",this.class=r.class,this.handlers=["dragover","dragend","drop","dragleave"].map(a=>{let o=l=>{this[a](l)};return s.dom.addEventListener(a,o),{name:a,handler:o}})}destroy(){this.handlers.forEach(({name:s,handler:r})=>this.editorView.dom.removeEventListener(s,r))}update(s,r){this.cursorPos!=null&&r.doc!=s.state.doc&&(this.cursorPos>s.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(s){s!=this.cursorPos&&(this.cursorPos=s,s==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let s=this.editorView.state.doc.resolve(this.cursorPos),r=!s.parent.inlineContent,n,a=this.editorView.dom,o=a.getBoundingClientRect(),l=o.width/a.offsetWidth,i=o.height/a.offsetHeight;if(r){let f=s.nodeBefore,v=s.nodeAfter;if(f||v){let _=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(_){let b=_.getBoundingClientRect(),j=f?b.bottom:b.top;f&&v&&(j=(j+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*i;n={left:b.left,right:b.right,top:j-w,bottom:j+w}}}}if(!n){let f=this.editorView.coordsAtPos(this.cursorPos),v=this.width/2*l;n={left:f.left-v,right:f.left+v,top:f.top,bottom:f.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,p;if(!d||d==document.body&&getComputedStyle(d).position=="static")u=-pageXOffset,p=-pageYOffset;else{let f=d.getBoundingClientRect(),v=f.width/d.offsetWidth,_=f.height/d.offsetHeight;u=f.left-d.scrollLeft*v,p=f.top-d.scrollTop*_}this.element.style.left=(n.left-u)/l+"px",this.element.style.top=(n.top-p)/i+"px",this.element.style.width=(n.right-n.left)/l+"px",this.element.style.height=(n.bottom-n.top)/i+"px"}scheduleRemoval(s){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),s)}dragover(s){if(!this.editorView.editable)return;let r=this.editorView.posAtCoords({left:s.clientX,top:s.clientY}),n=r&&r.inside>=0&&this.editorView.state.doc.nodeAt(r.inside),a=n&&n.type.spec.disableDropCursor,o=typeof a=="function"?a(this.editorView,r,s):a;if(r&&!o){let l=r.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let i=mHe(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 GPt=qu.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[HPt(this.options)]}});class $c extends ri{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return $c.valid(n)?new $c(n):ri.near(n)}content(){return pn.empty}eq(s){return s instanceof $c&&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 $c(s.resolve(r.pos))}getBookmark(){return new Rbe(this.anchor)}static valid(s){let r=s.parent;if(r.isTextblock||!KPt(s)||!ZPt(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&&$c.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($c.valid(d))return d}for(;;){let l=r>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!Da.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($c.valid(i))return i}return null}}}$c.prototype.visible=!1;$c.findFrom=$c.findGapCursorFrom;ri.jsonID("gapcursor",$c);class Rbe{constructor(s){this.pos=s}map(s){return new Rbe(s.map(this.pos))}resolve(s){let r=s.resolve(this.pos);return $c.valid(r)?new $c(r):ri.near(r)}}function EWe(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function KPt(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||EWe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function ZPt(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||EWe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function YPt(){return new Yd({props:{decorations:eIt,createSelectionBetween(t,s,r){return s.pos==r.pos&&$c.valid(r)?new $c(r):null},handleClick:QPt,handleKeyDown:XPt,handleDOMEvents:{beforeinput:JPt}}})}const XPt=wbe({ArrowLeft:K8("horiz",-1),ArrowRight:K8("horiz",1),ArrowUp:K8("vert",-1),ArrowDown:K8("vert",1)});function K8(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 Va){if(!o.endOfTextblock(r)||i.depth==0)return!1;d=!1,i=n.doc.resolve(s>0?i.after():i.before())}let u=$c.findGapCursorFrom(i,s,d);return u?(a&&a(n.tr.setSelection(new $c(u))),!0):!1}}function QPt(t,s,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(s);if(!$c.valid(n))return!1;let a=t.posAtCoords({left:r.clientX,top:r.clientY});return a&&a.inside>-1&&Da.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new $c(n))),!0)}function JPt(t,s){if(s.inputType!="insertCompositionText"||!(t.state.selection instanceof $c))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=Tr.empty;for(let l=n.length-1;l>=0;l--)a=Tr.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new pn(a,0,0));return o.setSelection(Va.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function eIt(t){if(!(t.selection instanceof $c))return null;let s=document.createElement("div");return s.className="ProseMirror-gapcursor",Bc.create(t.doc,[Dh.widget(t.selection.head,s,{key:"gapcursor"})])}const tIt=qu.create({name:"gapCursor",addProseMirrorPlugins(){return[YPt()]},extendNodeSchema(t){var s;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(s=Vi(Jn(t,"allowGapCursor",r)))!==null&&s!==void 0?s:null}}}),sIt=uh.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",Tc(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:p})=>{if(p&&d&&l){const f=d.filter(v=>i.includes(v.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),rIt=uh.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]}`,Tc(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=>Rxe({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var Zne=200,gu=function(){};gu.prototype.append=function(s){return s.length?(s=gu.from(s),!this.length&&s||s.length=r?gu.empty:this.sliceInner(Math.max(0,s),Math.min(this.length,r))};gu.prototype.get=function(s){if(!(s<0||s>=this.length))return this.getInner(s)};gu.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)};gu.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};gu.from=function(s){return s instanceof gu?s:s&&s.length?new PWe(s):gu.empty};var PWe=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<=Zne)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=Zne)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}(gu);gu.empty=new PWe([]);var nIt=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}(gu);const aIt=500;class Mg{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=[],p=[];return this.items.forEach((f,v)=>{if(!f.step){a||(a=this.remapping(n,v+1),o=a.maps.length),o--,p.push(f);return}if(a){p.push(new Sx(f.map));let _=f.step.map(a.slice(o)),b;_&&l.maybeStep(_).doc&&(b=l.mapping.maps[l.mapping.maps.length-1],u.push(new Sx(b,void 0,void 0,u.length+p.length))),o--,b&&a.appendMap(b,o)}else l.maybeStep(f.step);if(f.selection)return i=a?f.selection.map(a.slice(o)):f.selection,d=new Mg(this.items.slice(0,n).append(p.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 p=0;poIt&&(i=iIt(i,u),l-=u),new Mg(i.append(o),l)}remapping(s,r){let n=new a6;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 Mg(this.items.append(s.map(r=>new Sx(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 j=s.steps[_].invert(s.docs[_]),w=v.selection&&v.selection.map(o.slice(d+1,_));w&&i++,n.push(new Sx(b,j,w))}else n.push(new Sx(b))},a);let u=[];for(let v=r;vaIt&&(f=f.compress(this.items.length-n.length)),f}emptyItemCount(){let s=0;return this.items.forEach(r=>{r.step||s++}),s}compress(s=this.items.length){let r=this.remapping(0,s),n=r.maps.length,a=[],o=0;return this.items.forEach((l,i)=>{if(i>=s)a.push(l),l.selection&&o++;else if(l.step){let d=l.step.map(r.slice(n)),u=d&&d.getMap();if(n--,u&&r.appendMap(u,n),d){let p=l.selection&&l.selection.map(r.slice(n));p&&o++;let f=new Sx(u.invert(),d,p),v,_=a.length-1;(v=a.length&&a[_].merge(f))?a[_]=v:a.push(f)}}else l.map&&n--},this.items.length,0),new Mg(gu.from(a.reverse()),o)}}Mg.empty=new Mg(gu.empty,0);function iIt(t,s){let r;return t.forEach((n,a)=>{if(n.selection&&s--==0)return r=a,!1}),t.slice(r)}class Sx{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 Sx(r.getMap().invert(),r,this.selection)}}}class d1{constructor(s,r,n,a,o){this.done=s,this.undone=r,this.prevRanges=n,this.prevTime=a,this.prevComposition=o}}const oIt=20;function lIt(t,s,r,n){let a=r.getMeta(yN),o;if(a)return a.historyState;r.getMeta(uIt)&&(t=new d1(t.done,t.undone,null,0,-1));let l=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(l&&l.getMeta(yN))return l.getMeta(yN).redo?new d1(t.done.addTransform(r,void 0,n,gre(s)),t.undone,sAe(r.mapping.maps),t.prevTime,t.prevComposition):new d1(t.done,t.undone.addTransform(r,void 0,n,gre(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||!cIt(r,t.prevRanges)),u=l?Nme(t.prevRanges,r.mapping):sAe(r.mapping.maps);return new d1(t.done.addTransform(r,d?s.selection.getBookmark():void 0,n,gre(s)),Mg.empty,u,r.time,i??t.prevComposition)}else return(o=r.getMeta("rebased"))?new d1(t.done.rebased(r,o),t.undone.rebased(r,o),Nme(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new d1(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),Nme(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function cIt(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 sAe(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 Nme(t,s){if(!t)return null;let r=[];for(let n=0;n{let a=yN.getState(r);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(n){let o=dIt(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const LWe=IWe(!1,!0),DWe=IWe(!0,!0),mIt=qu.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:s})=>LWe(t,s),redo:()=>({state:t,dispatch:s})=>DWe(t,s)}},addProseMirrorPlugins(){return[hIt(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()}}}),pIt=uh.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Tc(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:s})=>{if(!cPt(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}):EEt(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,p=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?l.setSelection(Va.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(Da.create(l.doc,u.pos)):l.setSelection(Va.create(l.doc,u.pos));else{const f=(d=u.parent.type.contentMatch.defaultType)===null||d===void 0?void 0:d.create();f&&(l.insert(p,f),l.setSelection(Va.create(l.doc,p+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[SWe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),fIt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,gIt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,xIt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,yIt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,vIt=oy.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Tc(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[N3({find:fIt,type:this.type}),N3({find:xIt,type:this.type})]},addPasteRules(){return[BN({find:gIt,type:this.type}),BN({find:yIt,type:this.type})]}}),_It=uh.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Tc(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)}}}),bIt="listItem",nAe="textStyle",aAe=/^(\d+)\.\s$/,wIt=uh.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",Tc(this.options.HTMLAttributes,r),0]:["ol",Tc(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(bIt,this.editor.getAttributes(nAe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=h6({find:aAe,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=h6({find:aAe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(nAe)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),jIt=uh.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Tc(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),kIt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,NIt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,SIt=oy.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Tc(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[N3({find:kIt,type:this.type})]},addPasteRules(){return[BN({find:NIt,type:this.type})]}}),CIt=uh.create({name:"text",group:"inline"}),OWe=qu.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(DPt.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(APt.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(RPt.configure(this.options.bulletList)),this.options.code!==!1&&t.push(BPt.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(UPt.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(VPt.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(GPt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(tIt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(sIt.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(rIt.configure(this.options.heading)),this.options.history!==!1&&t.push(mIt.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(pIt.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(vIt.configure(this.options.italic)),this.options.listItem!==!1&&t.push(_It.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(wIt.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(jIt.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(SIt.configure(this.options.strike)),this.options.text!==!1&&t.push(CIt.configure(this.options.text)),t}}),MIt="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",TIt="ελ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",Bxe="numeric",$xe="ascii",qxe="alpha",nI="asciinumeric",IE="alphanumeric",Uxe="domain",RWe="emoji",AIt="scheme",EIt="slashscheme",Cme="whitespace";function PIt(t,s){return t in s||(s[t]=[]),s[t]}function Dk(t,s,r){s[Bxe]&&(s[nI]=!0,s[IE]=!0),s[$xe]&&(s[nI]=!0,s[qxe]=!0),s[nI]&&(s[IE]=!0),s[qxe]&&(s[IE]=!0),s[IE]&&(s[Uxe]=!0),s[RWe]&&(s[Uxe]=!0);for(const n in s){const a=PIt(n,r);a.indexOf(t)<0&&a.push(t)}}function IIt(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function _m(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}_m.groups={};_m.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),Ic=(t,s,r,n,a)=>t.tr(s,r,n,a),iAe=(t,s,r,n,a)=>t.ts(s,r,n,a),Wr=(t,s,r,n,a)=>t.tt(s,r,n,a),Jy="WORD",Vxe="UWORD",FWe="ASCIINUMERICAL",zWe="ALPHANUMERICAL",m6="LOCALHOST",Hxe="TLD",Wxe="UTLD",xre="SCHEME",j4="SLASH_SCHEME",Fbe="NUM",Gxe="WS",zbe="NL",aI="OPENBRACE",iI="CLOSEBRACE",Yne="OPENBRACKET",Xne="CLOSEBRACKET",Qne="OPENPAREN",Jne="CLOSEPAREN",eae="OPENANGLEBRACKET",tae="CLOSEANGLEBRACKET",sae="FULLWIDTHLEFTPAREN",rae="FULLWIDTHRIGHTPAREN",nae="LEFTCORNERBRACKET",aae="RIGHTCORNERBRACKET",iae="LEFTWHITECORNERBRACKET",oae="RIGHTWHITECORNERBRACKET",lae="FULLWIDTHLESSTHAN",cae="FULLWIDTHGREATERTHAN",dae="AMPERSAND",uae="APOSTROPHE",hae="ASTERISK",u1="AT",mae="BACKSLASH",pae="BACKTICK",fae="CARET",_1="COLON",Bbe="COMMA",gae="DOLLAR",Cx="DOT",xae="EQUALS",$be="EXCLAMATION",Up="HYPHEN",oI="PERCENT",yae="PIPE",vae="PLUS",_ae="POUND",lI="QUERY",qbe="QUOTE",BWe="FULLWIDTHMIDDLEDOT",Ube="SEMI",Mx="SLASH",cI="TILDE",bae="UNDERSCORE",$We="EMOJI",wae="SYM";var qWe=Object.freeze({__proto__:null,ALPHANUMERICAL:zWe,AMPERSAND:dae,APOSTROPHE:uae,ASCIINUMERICAL:FWe,ASTERISK:hae,AT:u1,BACKSLASH:mae,BACKTICK:pae,CARET:fae,CLOSEANGLEBRACKET:tae,CLOSEBRACE:iI,CLOSEBRACKET:Xne,CLOSEPAREN:Jne,COLON:_1,COMMA:Bbe,DOLLAR:gae,DOT:Cx,EMOJI:$We,EQUALS:xae,EXCLAMATION:$be,FULLWIDTHGREATERTHAN:cae,FULLWIDTHLEFTPAREN:sae,FULLWIDTHLESSTHAN:lae,FULLWIDTHMIDDLEDOT:BWe,FULLWIDTHRIGHTPAREN:rae,HYPHEN:Up,LEFTCORNERBRACKET:nae,LEFTWHITECORNERBRACKET:iae,LOCALHOST:m6,NL:zbe,NUM:Fbe,OPENANGLEBRACKET:eae,OPENBRACE:aI,OPENBRACKET:Yne,OPENPAREN:Qne,PERCENT:oI,PIPE:yae,PLUS:vae,POUND:_ae,QUERY:lI,QUOTE:qbe,RIGHTCORNERBRACKET:aae,RIGHTWHITECORNERBRACKET:oae,SCHEME:xre,SEMI:Ube,SLASH:Mx,SLASH_SCHEME:j4,SYM:wae,TILDE:cI,TLD:Hxe,UNDERSCORE:bae,UTLD:Wxe,UWORD:Vxe,WORD:Jy,WS:Gxe});const Gy=/[a-z]/,aE=new RegExp("\\p{L}","u"),Mme=new RegExp("\\p{Emoji}","u"),Ky=/\d/,Tme=/\s/,oAe="\r",Ame=` `,LIt="️",DIt="‍",Eme="";let Z8=null,Y8=null;function OIt(t=[]){const s={};_m.groups=s;const r=new _m;Z8==null&&(Z8=lAe(MIt)),Y8==null&&(Y8=lAe(TIt)),Wr(r,"'",uae),Wr(r,"{",aI),Wr(r,"}",iI),Wr(r,"[",Yne),Wr(r,"]",Xne),Wr(r,"(",Qne),Wr(r,")",Jne),Wr(r,"<",eae),Wr(r,">",tae),Wr(r,"(",sae),Wr(r,")",rae),Wr(r,"「",nae),Wr(r,"」",aae),Wr(r,"『",iae),Wr(r,"』",oae),Wr(r,"<",lae),Wr(r,">",cae),Wr(r,"&",dae),Wr(r,"*",hae),Wr(r,"@",u1),Wr(r,"`",pae),Wr(r,"^",fae),Wr(r,":",_1),Wr(r,",",Bbe),Wr(r,"$",gae),Wr(r,".",Cx),Wr(r,"=",xae),Wr(r,"!",$be),Wr(r,"-",Up),Wr(r,"%",oI),Wr(r,"|",yae),Wr(r,"+",vae),Wr(r,"#",_ae),Wr(r,"?",lI),Wr(r,'"',qbe),Wr(r,"/",Mx),Wr(r,";",Ube),Wr(r,"~",cI),Wr(r,"_",bae),Wr(r,"\\",mae),Wr(r,"・",BWe);const n=Ic(r,Ky,Fbe,{[Bxe]:!0});Ic(n,Ky,n);const a=Ic(n,Gy,FWe,{[nI]:!0}),o=Ic(n,aE,zWe,{[IE]:!0}),l=Ic(r,Gy,Jy,{[$xe]:!0});Ic(l,Ky,a),Ic(l,Gy,l),Ic(a,Ky,a),Ic(a,Gy,a);const i=Ic(r,aE,Vxe,{[qxe]:!0});Ic(i,Gy),Ic(i,Ky,o),Ic(i,aE,i),Ic(o,Ky,o),Ic(o,Gy),Ic(o,aE,o);const d=Wr(r,Ame,zbe,{[Cme]:!0}),u=Wr(r,oAe,Gxe,{[Cme]:!0}),p=Ic(r,Tme,Gxe,{[Cme]:!0});Wr(r,Eme,p),Wr(u,Ame,d),Wr(u,Eme,p),Ic(u,Tme,p),Wr(p,oAe),Wr(p,Ame),Ic(p,Tme,p),Wr(p,Eme,p);const f=Ic(r,Mme,$We,{[RWe]:!0});Wr(f,"#"),Ic(f,Mme,f),Wr(f,LIt,f);const v=Wr(f,DIt);Wr(v,"#"),Ic(v,Mme,f);const _=[[Gy,l],[Ky,a]],b=[[Gy,null],[aE,i],[Ky,o]];for(let j=0;jj[0]>w[0]?1:-1);for(let j=0;j=0?C[Uxe]=!0:Gy.test(w)?Ky.test(w)?C[nI]=!0:C[$xe]=!0:C[Bxe]=!0,iAe(r,w,w,C)}return iAe(r,"localhost",m6,{ascii:!0}),r.jd=new _m(wae),{start:r,tokens:Object.assign({groups:s},qWe)}}function UWe(t,s){const r=RIt(s.replace(/[A-Z]/g,i=>i.toLowerCase())),n=r.length,a=[];let o=0,l=0;for(;l=0&&(f+=r[l].length,v++),u+=r[l].length,o+=r[l].length,l++;o-=f,l-=v,u-=f,a.push({t:p.t,v:s.slice(o-u,o),s:o-u,e:o})}return a}function RIt(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 Xv(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 p6={defaultProtocol:"http",events:null,format:cAe,formatHref:cAe,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Vbe(t,s=null){let r=Object.assign({},p6);t&&(r=Object.assign(r,t instanceof Vbe?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=p6.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),p=t.getObj("attributes",r,s),f=t.getObj("events",r,s);return l.href=n,i&&(l.class=i),d&&(l.target=d),u&&(l.rel=u),p&&Object.assign(l,p),{tagName:a,attributes:l,content:o,eventListeners:f}}};function mle(t,s){class r extends VWe{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 dAe=mle("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),uAe=mle("text"),FIt=mle("nl"),X8=mle("url",{isLink:!0,toHref(t=p6.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==m6&&t[1].t===_1}}),zp=t=>new _m(t);function zIt({groups:t}){const s=t.domain.concat([dae,hae,u1,mae,pae,fae,gae,xae,Up,Fbe,oI,yae,vae,_ae,Mx,wae,cI,bae]),r=[uae,_1,Bbe,Cx,$be,oI,lI,qbe,Ube,eae,tae,aI,iI,Xne,Yne,Qne,Jne,sae,rae,nae,aae,iae,oae,lae,cae],n=[dae,uae,hae,mae,pae,fae,gae,xae,Up,aI,iI,oI,yae,vae,_ae,lI,Mx,wae,cI,bae],a=zp(),o=Wr(a,cI);Ui(o,n,o),Ui(o,t.domain,o);const l=zp(),i=zp(),d=zp();Ui(a,t.domain,l),Ui(a,t.scheme,i),Ui(a,t.slashscheme,d),Ui(l,n,o),Ui(l,t.domain,l);const u=Wr(l,u1);Wr(o,u1,u),Wr(i,u1,u),Wr(d,u1,u);const p=Wr(o,Cx);Ui(p,n,o),Ui(p,t.domain,o);const f=zp();Ui(u,t.domain,f),Ui(f,t.domain,f);const v=Wr(f,Cx);Ui(v,t.domain,f);const _=zp(dAe);Ui(v,t.tld,_),Ui(v,t.utld,_),Wr(u,m6,_);const b=Wr(f,Up);Wr(b,Up,b),Ui(b,t.domain,f),Ui(_,t.domain,f),Wr(_,Cx,v),Wr(_,Up,b);const j=Wr(_,_1);Ui(j,t.numeric,dAe);const w=Wr(l,Up),N=Wr(l,Cx);Wr(w,Up,w),Ui(w,t.domain,l),Ui(N,n,o),Ui(N,t.domain,l);const C=zp(X8);Ui(N,t.tld,C),Ui(N,t.utld,C),Ui(C,t.domain,l),Ui(C,n,o),Wr(C,Cx,N),Wr(C,Up,w),Wr(C,u1,u);const A=Wr(C,_1),I=zp(X8);Ui(A,t.numeric,I);const L=zp(X8),R=zp();Ui(L,s,L),Ui(L,r,R),Ui(R,s,L),Ui(R,r,R),Wr(C,Mx,L),Wr(I,Mx,L);const $=Wr(i,_1),q=Wr(d,_1),U=Wr(q,Mx),V=Wr(U,Mx);Ui(i,t.domain,l),Wr(i,Cx,N),Wr(i,Up,w),Ui(d,t.domain,l),Wr(d,Cx,N),Wr(d,Up,w),Ui($,t.domain,L),Wr($,Mx,L),Wr($,lI,L),Ui(V,t.domain,L),Ui(V,s,L),Wr(V,Mx,L);const X=[[aI,iI],[Yne,Xne],[Qne,Jne],[eae,tae],[sae,rae],[nae,aae],[iae,oae],[lae,cae]];for(let se=0;se=0&&v++,a++,p++;if(v<0)a-=p,a0&&(o.push(Pme(uAe,s,l)),l=[]),a-=v,p-=v;const _=f.t,b=r.slice(a-p,a);o.push(Pme(_,s,b))}}return l.length>0&&o.push(Pme(uAe,s,l)),o}function Pme(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 $It=typeof console<"u"&&console&&console.warn||(()=>{}),qIt="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Ql={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function UIt(){return _m.groups={},Ql.scanner=null,Ql.parser=null,Ql.tokenQueue=[],Ql.pluginQueue=[],Ql.customSchemes=[],Ql.initialized=!1,Ql}function hAe(t,s=!1){if(Ql.initialized&&$It(`linkifyjs: already initialized - will not register custom scheme "${t}" ${qIt}`),!/^[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`);Ql.customSchemes.push([t,s])}function VIt(){Ql.scanner=OIt(Ql.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=wEt(r.doc,[...s]);if(TEt(i).forEach(({newRange:u})=>{const p=kEt(n.doc,u,_=>_.isTextblock);let f,v;if(p.length>1)f=p[0],v=n.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(p.length){const _=n.doc.textBetween(u.from,u.to," "," ");if(!WIt.test(_))return;f=p[0],v=n.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&v){const _=v.split(HIt).filter(Boolean);if(_.length<=0)return!1;const b=_[_.length-1],j=f.pos+v.lastIndexOf(b);if(!b)return!1;const w=Hbe(b).map(N=>N.toObject(t.defaultProtocol));if(!KIt(w))return!1;w.filter(N=>N.isLink).map(N=>({...N,from:j+N.start+1,to:j+N.end+1})).filter(N=>n.schema.marks.code?!n.doc.rangeHasMark(N.from,N.to,n.schema.marks.code):!0).filter(N=>t.validate(N.value)).filter(N=>t.shouldAutoLink(N.value)).forEach(N=>{Ibe(N.from,N.to,n.doc).some(C=>C.mark.type===t.type)||l.addMark(N.from,N.to,t.type.create({href:N.href}))})}}),!!l.steps.length)return l}})}function YIt(t){return new Yd({key:new dh("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=NWe(s.state,t.type.name),u=n.target,p=(a=u==null?void 0:u.href)!==null&&a!==void 0?a:d.href,f=(o=u==null?void 0:u.target)!==null&&o!==void 0?o:d.target;return u&&p?(window.open(p,f),!0):!1}}})}function XIt(t){return new Yd({key:new dh("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=HWe(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 Yb(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(GIt,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const WWe=oy.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){hAe(t);return}hAe(t.scheme,t.optionalSlashes)})},onDestroy(){UIt()},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)=>!!Yb(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=>!!Yb(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=>!!Yb(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Tc(this.options.HTMLAttributes,t),0]:["a",Tc(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!Yb(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=>!!Yb(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[BN({find:t=>{const s=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,a=HWe(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!Yb(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(ZIt({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!Yb(a,s),protocols:s,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(YIt({type:this.type})),this.options.linkOnPaste&&t.push(XIt({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),GWe=qu.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")}}}),QIt=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}`)})},KWe=oy.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&QIt(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Tc(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}}}}),JIt=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,e6t=uh.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",Tc(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:s})=>s.insertContent({type:this.name,attrs:t})}},addInputRules(){return[SWe({find:JIt,type:this.type,getAttributes:t=>{const[,,s,r,n]=t;return{src:r,alt:s,title:n}}})]}});let Kxe,Zxe;if(typeof WeakMap<"u"){let t=new WeakMap;Kxe=s=>t.get(s),Zxe=(s,r)=>(t.set(s,r),r)}else{const t=[];let r=0;Kxe=n=>{for(let a=0;a(r==10&&(r=0),t[r++]=n,t[r++]=a)}var Uc=class{constructor(t,s,r,n){this.width=t,this.height=s,this.map=r,this.problems=n}findCell(t){for(let s=0;s=r){(o||(o=[])).push({type:"overlong_rowspan",pos:p,n:N-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 r6t(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 a6t(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 Xg(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 ple(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=kM(s.$head)||i6t(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function i6t(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 Yxe(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function o6t(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Gbe(t,s){return t.depth==s.depth&&t.pos>=s.start(-1)&&t.pos<=s.end(-1)}function ZWe(t,s,r){const n=t.node(-1),a=Uc.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 $N(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 YWe(t,s,r=1){const n={...t,colspan:t.colspan+r};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let a=0;ap!=r.pos-o);d.unshift(r.pos-o);const u=d.map(p=>{const f=n.nodeAt(p);if(!f)throw new RangeError(`No cell with offset ${p} found`);const v=o+p+1;return new yHe(i.resolve(v),i.resolve(v+f.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=s,this.$headCell=r}map(s,r){const n=s.resolve(r.map(this.$anchorCell.pos)),a=s.resolve(r.map(this.$headCell.pos));if(Yxe(n)&&Yxe(a)&&Gbe(n,a)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?e0.rowSelection(n,a):o&&this.isColSelection()?e0.colSelection(n,a):new e0(n,a)}return Va.between(n,a)}content(){const s=this.$anchorCell.node(-1),r=Uc.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||w>0){let N=b.attrs;if(j>0&&(N=$N(N,0,j)),w>0&&(N=$N(N,N.colspan-w,w)),_.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=Uc.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 e0&&s.$anchorCell.pos==this.$anchorCell.pos&&s.$headCell.pos==this.$headCell.pos}static rowSelection(s,r=s){const n=s.node(-1),a=Uc.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(Dh.node(n,n+r.nodeSize,{class:"selectedCell"}))}),Bc.create(t.doc,s)}function u6t({$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 h6t({$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 m6t(t,s,r){const n=(s||t).selection,a=(s||t).doc;let o,l;if(n instanceof Da&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=ql.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=ql.rowSelection(i,i)}else if(!r){const i=Uc.get(n.node),d=n.from+1,u=d+i.map[i.width*i.height-1];o=ql.create(a,d+1,u)}}else n instanceof Va&&u6t(n)?o=Va.create(a,n.from):n instanceof Va&&h6t(n)&&(o=Va.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const p6t=new dh("fix-tables");function QWe(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=f6t(t,a,o,r))};return s?s.doc!=t.doc&&QWe(s.doc,t.doc,0,n):t.doc.descendants(n),r}function f6t(t,s,r,n){const a=Uc.get(s);if(!a.problems)return n;n||(n=t.tr);const o=[];for(let d=0;d0){let _="cell";p.firstChild&&(_=p.firstChild.type.spec.tableRole);const b=[];for(let w=0;w0?-1:0;l6t(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;_6t(s,n,a+i)&&(i=a==0||a==s.height?null:0);for(let u=0,p=s.width*a;u0&&a0&&f==s.map[p-s.width]){const v=r.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(i).map(f+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 p=d+1+u.content.size,f=mAe(u)?d+1:p;o.replaceWith(f+n.tableStart,p+n.tableStart,i)}o.setSelection(new ql(o.doc.resolve(d+n.tableStart))),s(o)}return!0}function fAe(t,s){const r=lh(t.schema);return S6t(({node:n})=>r[n.type.spec.tableRole])(t,s)}function S6t(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof ql){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=a6t(n.$from),!a)return!1;o=(l=kM(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 p=fy(s),f=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 M6t(t){return function(s,r){if(!Xg(s))return!1;if(r){const n=lh(s.schema),a=fy(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(_,f,b.attrs)}),n(l)}return!0}}f6("row",{useDeprecatedLogic:!0});f6("column",{useDeprecatedLogic:!0});const T6t=f6("cell",{useDeprecatedLogic:!0});function A6t(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 Q8(t,s){const r=t.selection;if(!(r instanceof ql))return!1;if(s){const n=t.tr,a=lh(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 pn(a,0,0))}),n.docChanged&&s(n)}return!0}function P6t(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(Tr.empty),r[a]n&&(v=v.type.createChecked($N(v.attrs,v.attrs.colspan,p+v.attrs.colspan-n),v.content)),u.push(v),p+=v.attrs.colspan;for(let _=1;_a&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,a-f.attrs.rowspan)},f.content)),d.push(f)}o.push(Tr.from(d))}r=o,s=a}return{width:t,height:s,rows:r}}function D6t(t,s,r,n,a,o,l){const i=t.doc.type.schema,d=lh(i);let u,p;if(a>s.width)for(let f=0,v=0;fs.height){const f=[];for(let b=0,j=(s.height-1)*s.width;b=s.width?!1:r.nodeAt(s.map[j+b]).type==d.header_cell;f.push(w?p||(p=d.header_cell.createAndFill()):u||(u=d.cell.createAndFill()))}const v=d.row.create(null,Tr.from(f)),_=[];for(let b=s.height;b{if(!a)return!1;const o=r.selection;if(o instanceof ql)return yre(r,n,ri.near(o.$headCell,s));if(t!="horiz"&&!o.empty)return!1;const l=sGe(a,t,s);if(l==null)return!1;if(t=="horiz")return yre(r,n,ri.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),d=ZWe(i,t,s);let u;return d?u=ri.near(d,1):s<0?u=ri.near(r.doc.resolve(i.before(-1)),-1):u=ri.near(r.doc.resolve(i.after(-1)),1),yre(r,n,u)}}}function eR(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof ql)l=o;else{const d=sGe(a,t,s);if(d==null)return!1;l=new ql(r.doc.resolve(d))}const i=ZWe(l.$headCell,t,s);return i?yre(r,n,new ql(l.$anchorCell,i)):!1}}function R6t(t,s){const r=t.state.doc,n=kM(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new ql(n))),!0):!1}function F6t(t,s,r){if(!Xg(t.state))return!1;let n=P6t(r);const a=t.state.selection;if(a instanceof ql){n||(n={width:1,height:1,rows:[Tr.from(Xxe(lh(t.state.schema).cell,r))]});const o=a.$anchorCell.node(-1),l=a.$anchorCell.start(-1),i=Uc.get(o).rectBetween(a.$anchorCell.pos-l,a.$headCell.pos-l);return n=L6t(n,i.right-i.left,i.bottom-i.top),_Ae(t.state,t.dispatch,l,i,n),!0}else if(n){const o=ple(t.state),l=o.start(-1);return _Ae(t.state,t.dispatch,l,Uc.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function z6t(t,s){var r;if(s.ctrlKey||s.metaKey)return;const n=bAe(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof ql)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=kM(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 p=Ime(t,u);const f=b1.getState(t.state)==null;if(!p||!Gbe(d,p))if(f)p=d;else return;const v=new ql(d,p);if(f||!t.state.selection.eq(v)){const _=t.state.tr.setSelection(v);f&&_.setMeta(b1,d.pos),t.dispatch(_)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",i),b1.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(b1,-1))}function i(d){const u=d,p=b1.getState(t.state);let f;if(p!=null)f=t.state.doc.resolve(p);else if(bAe(t,u.target)!=n&&(f=Ime(t,s),!f))return l();f&&o(f,u)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",i)}function sGe(t,s,r){if(!(t.state.selection instanceof Va))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 bAe(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 kM(t.state.doc.resolve(n))}var B6t=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")),Qxe(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,Qxe(s,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(s){return s.type=="attributes"&&(s.target==this.table||this.colgroup.contains(s.target))}};function Qxe(t,s,r,n,a,o){let l=0,i=!0,d=s.firstChild;const u=t.firstChild;if(u){for(let f=0,v=0;fnew n(f,r,v)),new q6t(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=lp.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{U6t(l,i,t,a)},mouseleave:l=>{V6t(l)},mousedown:(l,i)=>{H6t(l,i,s,r)}},decorations:l=>{const i=lp.getState(l);if(i&&i.activeHandle>-1)return Y6t(l,i.activeHandle)},nodeViews:{}}});return o}var q6t=class vre{constructor(s,r){this.activeHandle=s,this.dragging=r}apply(s){const r=this,n=s.getMeta(lp);if(n&&n.setHandle!=null)return new vre(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new vre(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&s.docChanged){let a=s.mapping.map(r.activeHandle,-1);return Yxe(s.doc.resolve(a))||(a=-1),new vre(a,r.dragging)}return r}};function U6t(t,s,r,n){if(!t.editable)return;const a=lp.getState(t.state);if(a&&!a.dragging){const o=G6t(s.target);let l=-1;if(o){const{left:i,right:d}=o.getBoundingClientRect();s.clientX-i<=r?l=wAe(t,s,"left",r):d-s.clientX<=r&&(l=wAe(t,s,"right",r))}if(l!=a.activeHandle){if(!n&&l!==-1){const i=t.state.doc.resolve(l),d=i.node(-1),u=Uc.get(d),p=i.start(-1);if(u.colCount(i.pos-p)+i.nodeAfter.attrs.colspan-1==u.width-1)return}rGe(t,l)}}}function V6t(t){if(!t.editable)return;const s=lp.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&rGe(t,-1)}function H6t(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=lp.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=t.state.doc.nodeAt(l.activeHandle),d=W6t(t,l.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(lp,{setDragging:{startX:s.clientX,startWidth:d}}));function u(f){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",p);const v=lp.getState(t.state);v!=null&&v.dragging&&(K6t(t,v.activeHandle,jAe(v.dragging,f,r)),t.dispatch(t.state.tr.setMeta(lp,{setDragging:null})))}function p(f){if(!f.which)return u(f);const v=lp.getState(t.state);if(v&&v.dragging){const _=jAe(v.dragging,f,r);kAe(t,v.activeHandle,_,n)}}return kAe(t,l.activeHandle,d,n),o.addEventListener("mouseup",u),o.addEventListener("mousemove",p),s.preventDefault(),!0}function W6t(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 tLt(t,s,r,n,a){const o=eLt(t),l=[],i=[];for(let u=0;u{const{selection:s}=t.state;if(!sLt(s))return!1;let r=0;const n=kWe(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},rLt=uh.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Q6t,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}=J6t(t,this.options.cellMinWidth),o=["table",Tc(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=tLt(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(Va.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>g6t(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>x6t(t,s),deleteColumn:()=>({state:t,dispatch:s})=>v6t(t,s),addRowBefore:()=>({state:t,dispatch:s})=>b6t(t,s),addRowAfter:()=>({state:t,dispatch:s})=>w6t(t,s),deleteRow:()=>({state:t,dispatch:s})=>k6t(t,s),deleteTable:()=>({state:t,dispatch:s})=>E6t(t,s),mergeCells:()=>({state:t,dispatch:s})=>pAe(t,s),splitCell:()=>({state:t,dispatch:s})=>fAe(t,s),toggleHeaderColumn:()=>({state:t,dispatch:s})=>f6("column")(t,s),toggleHeaderRow:()=>({state:t,dispatch:s})=>f6("row")(t,s),toggleHeaderCell:()=>({state:t,dispatch:s})=>T6t(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>pAe(t,s)?!0:fAe(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>C6t(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>xAe(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>xAe(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&JWe(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=ql.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:tR,"Mod-Backspace":tR,Delete:tR,"Mod-Delete":tR}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[$6t({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],X6t({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:Vi(Jn(t,"tableRole",s))}}}),nLt=uh.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Tc(this.options.HTMLAttributes,t),0]}}),aLt=uh.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",Tc(this.options.HTMLAttributes,t),0]}}),iLt=uh.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",Tc(this.options.HTMLAttributes,t),0]}});function Qg({content:t,onChange:s,placeholder:r="Enter content...",minHeight:n="150px",compact:a=!1}){const[o,l]=S.useState(!1),[i,d]=S.useState(""),[u,p]=S.useState(!0),f=AWe({extensions:[OWe,WWe.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),GWe.configure({types:["heading","paragraph"]}),KWe,e6t.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),width:{default:null},height:{default:null},style:{default:null}}}}).configure({inline:!0,allowBase64:!0}),rLt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null},width:{default:null},cellpadding:{default:null},cellspacing:{default:null},border:{default:null}}}}).configure({resizable:!1}),nLt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null}}}}),aLt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1},valign:{default:null}}}}),iLt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1}}}})],content:t,onUpdate:({editor:j})=>{s(j.getHTML())},editorProps:{attributes:{class:"outline-none","data-placeholder":r},handlePaste:(j,w)=>{var C;const N=(C=w.clipboardData)==null?void 0:C.items;if(!N)return!1;for(const A of Array.from(N))if(A.type.startsWith("image/")){w.preventDefault();const I=A.getAsFile();if(!I)continue;const L=new FileReader;return L.onload=R=>{var q;const $=(q=R.target)==null?void 0:q.result;j.dispatch(j.state.tr.replaceSelectionWith(j.state.schema.nodes.image.create({src:$})))},L.readAsDataURL(I),!0}return!1}}});S.useEffect(()=>{f&&t!==f.getHTML()&&f.commands.setContent(t)},[t,f]);const v=()=>{if(!f)return;const j=f.getAttributes("link").href||"",w=f.getAttributes("link").target;d(j),p(w==="_blank"),l(!0)},_=()=>{f&&(i===""?f.chain().focus().extendMarkRange("link").unsetLink().run():f.chain().focus().extendMarkRange("link").setLink({href:i,target:u?"_blank":null,rel:u?"noopener noreferrer nofollow":null}).run(),l(!1),d(""))},b=()=>{f&&f.chain().focus().extendMarkRange("link").unsetLink().run()};return f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleHeading({level:1}).run(),className:f.isActive("heading",{level:1})?"bg-muted":"",title:"Heading 1",children:e.jsx(oP,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleHeading({level:2}).run(),className:f.isActive("heading",{level:2})?"bg-muted":"",title:"Heading 2",children:e.jsx(lP,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleBold().run(),className:f.isActive("bold")?"bg-muted":"",title:"Bold",children:e.jsx(a5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleItalic().run(),className:f.isActive("italic")?"bg-muted":"",title:"Italic",children:e.jsx(h5,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleBulletList().run(),className:f.isActive("bulletList")?"bg-muted":"",title:"Bullet List",children:e.jsx(Uh,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleOrderedList().run(),className:f.isActive("orderedList")?"bg-muted":"",title:"Numbered List",children:e.jsx(A0,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("left").run(),className:f.isActive({textAlign:"left"})?"bg-muted":"",title:"Align Left",children:e.jsx(s5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("center").run(),className:f.isActive({textAlign:"center"})?"bg-muted":"",title:"Align Center",children:e.jsx(t5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("right").run(),className:f.isActive({textAlign:"right"})?"bg-muted":"",title:"Align Right",children:e.jsx(r5,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:v,className:f.isActive("link")?"bg-muted":"",title:"Add Link",children:e.jsx(Lo,{className:"h-4 w-4"})}),f.isActive("link")&&e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:b,title:"Remove Link",children:e.jsx(Lo,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().undo().run(),disabled:!f.can().undo(),title:"Undo",children:e.jsx(j5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().redo().run(),disabled:!f.can().redo(),title:"Redo",children:e.jsx(b5,{className:"h-4 w-4"})})]}),e.jsx(MWe,{editor:f,className:"prose prose-sm max-w-none p-3 focus:outline-none [&_.ProseMirror]:outline-none [&_.ProseMirror_img]:max-w-none [&_.ProseMirror_table]:border-none [&_.ProseMirror_table]:border-collapse [&_.ProseMirror_td]:border-none [&_.ProseMirror_td]:p-0 [&_.ProseMirror_td]:align-top [&_.ProseMirror_th]:border-none [&_.ProseMirror_th]:p-0 [&_.ProseMirror_tr]:border-none",style:{minHeight:n}})]}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Insert Link"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"link-url",children:"URL"}),e.jsx(Re,{id:"link-url",value:i,onChange:j=>d(j.target.value),placeholder:"https://example.com"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Br,{id:"link-new-tab",checked:u,onCheckedChange:p}),e.jsx(ve,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),e.jsxs(On,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"button",onClick:_,children:i?"Apply Link":"Remove Link"})]})]})})]}):null}var oLt=Object.defineProperty,lLt=(t,s,r)=>s in t?oLt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,cc=(t,s,r)=>lLt(t,typeof s!="symbol"?s+"":s,r);const jae={x:0,y:0,width:0,height:0,unit:"px"},o4=(t,s,r)=>Math.min(Math.max(t,s),r),cLt=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),CAe=(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 dLt(t,s,r,n){const a=Tx(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==="%"?h1(a,r,n):a}function uLt(t,s,r){const n=Tx(t,s,r);return n.x=(s-n.width)/2,n.y=(r-n.height)/2,t.unit==="%"?h1(n,s,r):n}function h1(t,s,r){return t.unit==="%"?{...jae,...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 Tx(t,s,r){return t.unit?t.unit==="px"?{...jae,...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}:{...jae,...t,unit:"px"}}function MAe(t,s,r,n,a,o=0,l=0,i=n,d=a){const u={...t};let p=Math.min(o,n),f=Math.min(l,a),v=Math.min(i,n),_=Math.min(d,a);s&&(s>1?(p=l?l*s:p,f=p/s,v=i*s):(f=o?o/s:f,p=f*s,_=d/s)),u.y<0&&(u.height=Math.max(u.height+u.y,f),u.y=0),u.x<0&&(u.width=Math.max(u.width+u.x,p),u.x=0);const b=n-(u.x+u.width);b<0&&(u.x=Math.min(u.x,n-p),u.width+=b);const j=a-(u.y+u.height);if(j<0&&(u.y=Math.min(u.y,a-f),u.height+=j),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 w=u.width/u.height;if(ws){const N=Math.max(u.height*s,p);(r==="sw"||r=="nw")&&(u.x-=N-u.width),u.width=N}}return u}function hLt(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 l4={capture:!0,passive:!1};let mLt=0;const n1=class mg extends S.PureComponent{constructor(){super(...arguments),cc(this,"docMoveBound",!1),cc(this,"mouseDownOnCrop",!1),cc(this,"dragStarted",!1),cc(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),cc(this,"componentRef",S.createRef()),cc(this,"mediaRef",S.createRef()),cc(this,"resizeObserver"),cc(this,"initChangeCalled",!1),cc(this,"instanceId",`rc-${mLt++}`),cc(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),cc(this,"onCropPointerDown",s=>{const{crop:r,disabled:n}=this.props,a=this.getBox();if(!r)return;const o=Tx(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,p=o.x,f=o.y;if(l){const v=s.clientX-a.x,_=s.clientY-a.y;let b=0,j=0;l==="ne"||l=="e"?(b=v-(o.x+o.width),j=_-o.y,p=o.x,f=o.y+o.height):l==="se"||l==="s"?(b=v-(o.x+o.width),j=_-(o.y+o.height),p=o.x,f=o.y):l==="sw"||l=="w"?(b=v-o.x,j=_-(o.y+o.height),p=o.x+o.width,f=o.y):(l==="nw"||l=="n")&&(b=v-o.x,j=_-o.y,p=o.x+o.width,f=o.y+o.height),d=p+a.x+b,u=f+a.y+j}this.evData={startClientX:d,startClientY:u,startCropX:p,startCropY:f,clientX:s.clientX,clientY:s.clientY,isResize:i,ord:l},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),cc(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,p={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(Tx(p,i.width,i.height),h1(p,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),cc(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(),CAe(r,d)||a(Tx(d,l.width,l.height),h1(d,l.width,l.height))}),cc(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),p=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?mg.nudgeStepLarge:s.shiftKey?mg.nudgeStepMedium:mg.nudgeStep;if(l==="ArrowLeft"?(u.x-=p,i=!0):l==="ArrowRight"?(u.x+=p,i=!0):l==="ArrowUp"?(u.y-=p,i=!0):l==="ArrowDown"&&(u.y+=p,i=!0),i){s.cancelable&&s.preventDefault(),u.x=o4(u.x,0,d.width-u.width),u.y=o4(u.y,0,d.height-u.height);const f=Tx(u,d.width,d.height),v=h1(u,d.width,d.height);a(f,v),o&&o(f,v)}}),cc(this,"onHandlerKeyDown",(s,r)=>{const{aspect:n=0,crop:a,disabled:o,minWidth:l=0,minHeight:i=0,maxWidth:d,maxHeight:u,onChange:p,onComplete:f}=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)?mg.nudgeStepLarge:s.shiftKey?mg.nudgeStepMedium:mg.nudgeStep,b=Tx(a,v.width,v.height),j=hLt(b,s.key,_,r),w=MAe(j,n,r,v.width,v.height,l,i,d,u);if(!CAe(a,w)){const N=h1(w,v.width,v.height);p(w,N),f&&f(w,N)}}),cc(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(Tx(r,l.width,l.height),h1(r,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),cc(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(Tx(r,a,o),h1(r,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,l4),this.document.addEventListener("pointerup",this.onDocPointerDone,l4),this.document.addEventListener("pointercancel",this.onDocPointerDone,l4),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,l4),this.document.removeEventListener("pointerup",this.onDocPointerDone,l4),this.document.removeEventListener("pointercancel",this.onDocPointerDone,l4),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=o4(s.startCropX+a,0,r.width-n.width),n.y=o4(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),p=s.ord||u;let f=s.clientX-s.startClientX,v=s.clientY-s.startClientY;(l&&p==="nw"||p==="w"||p==="sw")&&(f=Math.min(f,-l)),(i&&p==="nw"||p==="n"||p==="ne")&&(v=Math.min(v,-i));const _={unit:"px",x:0,y:0,width:0,height:0};u==="ne"?(_.x=s.startCropX,_.width=f,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=f,r?_.height=_.width/r:_.height=v):u==="sw"?(_.x=s.startCropX+f,_.y=s.startCropY,_.width=Math.abs(f),r?_.height=_.width/r:_.height=v):u==="nw"&&(_.x=s.startCropX+f,_.width=Math.abs(f),r?(_.height=_.width/r,_.y=s.startCropY-_.height):(_.height=Math.abs(v),_.y=s.startCropY+v));const b=MAe(_,r,u,o.width,o.height,l,i,n,a);return r||mg.xyOrds.indexOf(p)>-1?d=b:mg.xOrds.indexOf(p)>-1?(d.x=b.x,d.width=b.width):mg.yOrds.indexOf(p)>-1&&(d.y=b.y,d.height=b.height),d.x=o4(d.x,0,o.width-d.width),d.y=o4(d.y,0,o.height-d.height),d}renderCropSelection(){const{ariaLabels:s=mg.defaultProps.ariaLabels,disabled:r,locked:n,renderSelectionAddon:a,ruleOfThirds:o,crop:l}=this.props,i=this.getCropStyle();if(l)return mt.createElement("div",{style:i,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":s.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!r&&!n&&mt.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},mt.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),mt.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),mt.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),mt.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),mt.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"}),mt.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"}),mt.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"}),mt.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"}),mt.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"}),mt.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"}),mt.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"}),mt.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&&mt.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:d=>d.stopPropagation()},a(this.state)),o&&mt.createElement(mt.Fragment,null,mt.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),mt.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(s){const r={...jae,...this.props.crop||{}};return Tx(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:p,newCropIsBeingDrawn:f}=this.state,v=o?this.renderCropSelection():null,_=cLt("ReactCrop",a,p&&"ReactCrop--active",l&&"ReactCrop--disabled",i&&"ReactCrop--locked",f&&"ReactCrop--new-crop",o&&s&&"ReactCrop--fixed-aspect",o&&n&&"ReactCrop--circular-crop",o&&u&&"ReactCrop--rule-of-thirds",!this.dragStarted&&o&&!o.width&&!o.height&&"ReactCrop--invisible-crop",n&&"ReactCrop--no-animate");return mt.createElement("div",{ref:this.componentRef,className:_,style:d},mt.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},r),o?mt.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},mt.createElement("defs",null,mt.createElement("mask",{id:`hole-${this.instanceId}`},mt.createElement("rect",{width:"100%",height:"100%",fill:"white"}),n?mt.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"}):mt.createElement("rect",{x:`${o.x}${o.unit}`,y:`${o.y}${o.unit}`,width:`${o.width}${o.unit}`,height:`${o.height}${o.unit}`,fill:"black"}))),mt.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,v)}};cc(n1,"xOrds",["e","w"]),cc(n1,"yOrds",["n","s"]),cc(n1,"xyOrds",["nw","ne","se","sw"]),cc(n1,"nudgeStep",1),cc(n1,"nudgeStepMedium",10),cc(n1,"nudgeStepLarge",100),cc(n1,"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 pLt=n1;var nGe=["PageUp","PageDown"],aGe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],iGe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},NM="Slider",[eye,fLt,gLt]=cL(NM),[oGe]=Ac(NM,[gLt]),[xLt,fle]=oGe(NM),lGe=S.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:p,onValueChange:f=()=>{},onValueCommit:v=()=>{},inverted:_=!1,form:b,...j}=t,w=S.useRef(new Set),N=S.useRef(0),A=l==="horizontal"?yLt:vLt,[I=[],L]=xu({prop:p,defaultProp:u,onChange:X=>{var te;(te=[...w.current][N.current])==null||te.focus(),f(X)}}),R=S.useRef(I);function $(X){const se=kLt(I,X);V(X,se)}function q(X){V(X,N.current)}function U(){const X=R.current[N.current];I[N.current]!==X&&v(I)}function V(X,se,{commit:te}={commit:!1}){const Y=MLt(o),de=TLt(Math.round((X-n)/o)*o+n,Y),ie=ZI(de,[n,a]);L((ae=[])=>{const le=wLt(ae,ie,se);if(CLt(le,d*o)){N.current=le.indexOf(ie);const pe=String(le)!==String(ae);return pe&&te&&v(le),pe?le:ae}else return ae})}return e.jsx(xLt,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:N,thumbs:w.current,values:I,orientation:l,form:b,children:e.jsx(eye.Provider,{scope:t.__scopeSlider,children:e.jsx(eye.Slot,{scope:t.__scopeSlider,children:e.jsx(A,{"aria-disabled":i,"data-disabled":i?"":void 0,...j,ref:s,onPointerDown:Cr(j.onPointerDown,()=>{i||(R.current=I)}),min:n,max:a,inverted:_,onSlideStart:i?void 0:$,onSlideMove:i?void 0:q,onSlideEnd:i?void 0:U,onHomeKeyDown:()=>!i&&V(n,0,{commit:!0}),onEndKeyDown:()=>!i&&V(a,I.length-1,{commit:!0}),onStepKeyDown:({event:X,direction:se})=>{if(!i){const de=nGe.includes(X.key)||X.shiftKey&&aGe.includes(X.key)?10:1,ie=N.current,ae=I[ie],le=o*de*se;V(ae+le,ie,{commit:!0})}}})})})})});lGe.displayName=NM;var[cGe,dGe]=oGe(NM,{startEdge:"left",endEdge:"right",size:"width",direction:1}),yLt=S.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:d,onStepKeyDown:u,...p}=t,[f,v]=S.useState(null),_=Pa(s,A=>v(A)),b=S.useRef(void 0),j=$_(a),w=j==="ltr",N=w&&!o||!w&&o;function C(A){const I=b.current||f.getBoundingClientRect(),L=[0,I.width],$=Kbe(L,N?[r,n]:[n,r]);return b.current=I,$(A-I.left)}return e.jsx(cGe,{scope:t.__scopeSlider,startEdge:N?"left":"right",endEdge:N?"right":"left",direction:N?1:-1,size:"width",children:e.jsx(uGe,{dir:j,"data-orientation":"horizontal",...p,ref:_,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:A=>{const I=C(A.clientX);l==null||l(I)},onSlideMove:A=>{const I=C(A.clientX);i==null||i(I)},onSlideEnd:()=>{b.current=void 0,d==null||d()},onStepKeyDown:A=>{const L=iGe[N?"from-left":"from-right"].includes(A.key);u==null||u({event:A,direction:L?-1:1})}})})}),vLt=S.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:d,...u}=t,p=S.useRef(null),f=Pa(s,p),v=S.useRef(void 0),_=!a;function b(j){const w=v.current||p.current.getBoundingClientRect(),N=[0,w.height],A=Kbe(N,_?[n,r]:[r,n]);return v.current=w,A(j-w.top)}return e.jsx(cGe,{scope:t.__scopeSlider,startEdge:_?"bottom":"top",endEdge:_?"top":"bottom",size:"height",direction:_?1:-1,children:e.jsx(uGe,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:j=>{const w=b(j.clientY);o==null||o(w)},onSlideMove:j=>{const w=b(j.clientY);l==null||l(w)},onSlideEnd:()=>{v.current=void 0,i==null||i()},onStepKeyDown:j=>{const N=iGe[_?"from-bottom":"from-top"].includes(j.key);d==null||d({event:j,direction:N?-1:1})}})})}),uGe=S.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:d,...u}=t,p=fle(NM,r);return e.jsx(Qr.span,{...u,ref:s,onKeyDown:Cr(t.onKeyDown,f=>{f.key==="Home"?(l(f),f.preventDefault()):f.key==="End"?(i(f),f.preventDefault()):nGe.concat(aGe).includes(f.key)&&(d(f),f.preventDefault())}),onPointerDown:Cr(t.onPointerDown,f=>{const v=f.target;v.setPointerCapture(f.pointerId),f.preventDefault(),p.thumbs.has(v)?v.focus():n(f)}),onPointerMove:Cr(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:Cr(t.onPointerUp,f=>{const v=f.target;v.hasPointerCapture(f.pointerId)&&(v.releasePointerCapture(f.pointerId),o(f))})})}),hGe="SliderTrack",mGe=S.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=fle(hGe,r);return e.jsx(Qr.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});mGe.displayName=hGe;var tye="SliderRange",pGe=S.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=fle(tye,r),o=dGe(tye,r),l=S.useRef(null),i=Pa(s,l),d=a.values.length,u=a.values.map(v=>xGe(v,a.min,a.max)),p=d>1?Math.min(...u):0,f=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]:p+"%",[o.endEdge]:f+"%"}})});pGe.displayName=tye;var sye="SliderThumb",fGe=S.forwardRef((t,s)=>{const r=fLt(t.__scopeSlider),[n,a]=S.useState(null),o=Pa(s,i=>a(i)),l=S.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(_Lt,{...t,ref:o,index:l})}),_Lt=S.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=fle(sye,r),i=dGe(sye,r),[d,u]=S.useState(null),p=Pa(s,C=>u(C)),f=d?l.form||!!d.closest("form"):!0,v=hL(d),_=l.values[n],b=_===void 0?0:xGe(_,l.min,l.max),j=jLt(n,l.values.length),w=v==null?void 0:v[i.size],N=w?NLt(w,b,i.direction):0;return S.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(eye.ItemSlot,{scope:t.__scopeSlider,children:e.jsx(Qr.span,{role:"slider","aria-label":t["aria-label"]||j,"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:p,style:_===void 0?{display:"none"}:t.style,onFocus:Cr(t.onFocus,()=>{l.valueIndexToChangeRef.current=n})})}),f&&e.jsx(gGe,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:_},n)]})});fGe.displayName=sye;var bLt="RadioBubbleInput",gGe=S.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=S.useRef(null),o=Pa(a,n),l=NL(s);return S.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&p){const f=new Event("input",{bubbles:!0});p.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(Qr.input,{style:{display:"none"},...r,ref:o,defaultValue:s})});gGe.displayName=bLt;function wLt(t=[],s,r){const n=[...t];return n[r]=s,n.sort((a,o)=>a-o)}function xGe(t,s,r){const o=100/(r-s)*(t-s);return ZI(o,[0,100])}function jLt(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function kLt(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 NLt(t,s,r){const n=t/2,o=Kbe([0,50],[0,n]);return(n-o(s)*r)*r}function SLt(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function CLt(t,s){if(s>0){const r=SLt(t);return Math.min(...r)>=s}return!0}function Kbe(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 MLt(t){return(String(t).split(".")[1]||"").length}function TLt(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var yGe=lGe,ALt=mGe,ELt=pGe,PLt=fGe;const Pg=S.forwardRef(({className:t,...s},r)=>e.jsxs(yGe,{ref:r,className:Pt("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx(ALt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(ELt,{className:"absolute h-full bg-primary"})}),e.jsx(PLt,{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"})]}));Pg.displayName=yGe.displayName;function ILt(t,s,r){return uLt(dLt({unit:"%",width:90},r,t,s),t,s)}const Zbe=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=S.useRef(null),[l,i]=S.useState(),[d,u]=S.useState(),[p,f]=S.useState(1),[v,_]=S.useState(0),b=S.useCallback(N=>{const{width:C,height:A}=N.currentTarget;i(ILt(C,A,a))},[a]),j=S.useCallback(async()=>{const N=o.current;if(!N||!d)return;const C=document.createElement("canvas"),A=C.getContext("2d");if(!A)return;const I=N.naturalWidth/N.width,L=N.naturalHeight/N.height,R=400;C.width=R,C.height=R,A.imageSmoothingQuality="high";const $=d.x*I,q=d.y*L,U=d.width*I,V=d.height*L,X=v*Math.PI/180,se=C.width/2,te=C.height/2;return A.save(),A.translate(se,te),A.rotate(X),A.scale(p,p),A.translate(-se,-te),A.drawImage(N,$,q,U,V,0,0,R,R),A.restore(),new Promise((Y,de)=>{C.toBlob(ie=>{ie?Y(ie):de(new Error("Canvas is empty"))},"image/jpeg",.95)})},[d,p,v]),w=async()=>{try{const N=await j();N&&(n(N),s())}catch(N){console.error("Error cropping image:",N)}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsx(Ss,{children:e.jsx(Ns,{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(pLt,{crop:l,onChange:(N,C)=>i(C),onComplete:N=>u(N),aspect:a,circularCrop:!0,className:"max-h-[400px]",children:e.jsx("img",{ref:o,src:r,alt:"Crop preview",style:{transform:`scale(${p}) rotate(${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(k5,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Pg,{value:[p],min:.5,max:3,step:.1,onValueChange:([N])=>f(N),className:"flex-1"}),e.jsx(c_,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(NP,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Pg,{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(On,{children:[e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(K,{onClick:w,children:"Save Photo"})]})]})})},LLt=()=>{const{user:t}=Gs(),{toast:s}=Ia(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(null);S.useEffect(()=>{t&&d()},[t]);const d=async()=>{n(!0);try{const{data:f}=await G.from("profiles").select("subscription_status, subscription_product_id, subscription_end_date, is_grandfathered").eq("id",t==null?void 0:t.id).single();f&&i({status:f.subscription_status||"none",productId:f.subscription_product_id,endDate:f.subscription_end_date,isGrandfathered:f.is_grandfathered||!1})}catch(f){console.error("Error loading subscription:",f)}finally{n(!1)}},u=async()=>{o(!0);try{const{data:{session:f}}=await G.auth.getSession();if(!f)throw new Error("Not authenticated");const{data:v,error:_}=await G.functions.invoke("customer-portal",{headers:{Authorization:`Bearer ${f.access_token}`}});if(_)throw _;v!=null&&v.url&&window.open(v.url,"_blank")}catch(f){console.error("Error opening customer portal:",f),s({title:"Error",description:f.message||"Failed to open billing portal",variant:"destructive"})}finally{o(!1)}},p=()=>{if(l!=null&&l.isGrandfathered)return e.jsx(at,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return e.jsx(at,{className:"bg-green-500",children:"Active"});case"trialing":return e.jsx(at,{className:"bg-blue-500",children:"Trial"});case"past_due":return e.jsx(at,{variant:"destructive",children:"Past Due"});case"canceled":return e.jsx(at,{variant:"secondary",children:"Canceled"});default:return e.jsx(at,{variant:"outline",children:"No Subscription"})}};return r?e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(uf,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(uf,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(yr,{children:"Manage your subscription and billing"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Status"}),e.jsx("div",{className:"mt-1",children:p()})]}),(l==null?void 0:l.endDate)&&l.status==="active"&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Next billing date"}),e.jsx("p",{className:"font-medium",children:new Date(l.endDate).toLocaleDateString()})]})]}),l!=null&&l.isGrandfathered?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your account was upgraded from LevelUp 1.0. To update/manage your subscription please reach out to support."}):(l==null?void 0:l.status)==="active"||(l==null?void 0:l.status)==="trialing"?e.jsxs(e.Fragment,{children:[(l==null?void 0:l.status)==="trialing"&&(l==null?void 0:l.endDate)&&e.jsxs("p",{className:"text-sm text-muted-foreground mb-3",children:["Your trial ends on ",new Date(l.endDate).toLocaleDateString(),". After the trial, you'll be charged automatically."]}),e.jsxs(K,{onClick:u,variant:"outline",disabled:a,children:[a?e.jsx(As,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(sn,{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."})]})]})},DLt=()=>{const{user:t}=Gs(),s=Dr(),{toast:r}=Ia(),[n]=Ec(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:d,subscribe:u,unsubscribe:p}=aqe(),[f,v]=S.useState(!1),[_,b]=S.useState(""),[j,w]=S.useState(!1),[N,C]=S.useState(!1),[A,I]=S.useState(""),[L,R]=S.useState({name:"",email:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[$,q]=S.useState(!1),[U,V]=S.useState(!1),[X,se]=S.useState({newPassword:"",confirmPassword:""});S.useEffect(()=>{t&&te()},[t]),S.useEffect(()=>{o&&t&&setTimeout(()=>{var le;(le=document.getElementById("change-password-section"))==null||le.scrollIntoView({behavior:"smooth",block:"center"})},500)},[o,t]);const te=async()=>{var le,pe,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:we}=await G.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(we)throw console.error("Profile query error:",we),we;ye?(console.log("Profile loaded successfully:",ye),R({name:ye.name||"",email:ye.email||"",title:ye.title||"",bio:ye.bio||"",areas_served:ye.areas_served||"",years_experience:((le=ye.years_experience)==null?void 0:le.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"),R({name:((pe=t.user_metadata)==null?void 0:pe.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 G.storage.from("avatars").list(`${t.id}`);if(ke&&ke.length>0){const{data:Ze}=G.storage.from("avatars").getPublicUrl(`${t.id}/${ke[0].name}`);b(Ze.publicUrl)}}catch(ye){console.error("Error loading profile:",ye),r({title:"Error",description:ye.message||"Failed to load profile",variant:"destructive"})}},Y=le=>{var ye;const pe=(ye=le.target.files)==null?void 0:ye[0];if(!pe)return;const be=new FileReader;be.onloadend=()=>{I(be.result),C(!0)},be.readAsDataURL(pe),le.target.value=""},de=async le=>{if(t){w(!0);try{const{data:pe}=await G.storage.from("avatars").list(`${t.id}`);pe&&pe.length>0&&await G.storage.from("avatars").remove(pe.map(_e=>`${t.id}/${_e.name}`));const ye=`${t.id}/avatar.jpg`,{error:we}=await G.storage.from("avatars").upload(ye,le,{upsert:!0,contentType:"image/jpeg"});if(we)throw we;const{data:ke}=G.storage.from("avatars").getPublicUrl(ye),Ze=ke.publicUrl;b(`${Ze}?t=${Date.now()}`),await G.from("profiles").update({avatar_url:Ze}).eq("id",t.id),r({title:"Success",description:"Profile photo updated successfully"})}catch(pe){console.error("Error uploading avatar:",pe),r({title:"Error",description:pe.message||"Failed to upload photo",variant:"destructive"})}finally{w(!1)}}},ie=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:le}=await G.from("profiles").update({name:L.name.trim(),email:L.email.trim(),title:L.title.trim()||null,bio:L.bio.trim()||null,areas_served:L.areas_served.trim()||null,years_experience:L.years_experience?parseInt(L.years_experience):null,instagram_url:L.instagram_url.trim()||null,facebook_url:L.facebook_url.trim()||null,linkedin_url:L.linkedin_url.trim()||null,email_signature:L.email_signature||"",use_email_signature:L.use_email_signature}).eq("id",t==null?void 0:t.id);if(le)throw le;r({title:"Success",description:"Profile updated successfully"})}catch(le){console.error("Error updating profile:",le),r({title:"Error",description:le.message||"Failed to update profile",variant:"destructive"})}finally{v(!1)}},ae=async()=>{if(!X.newPassword){r({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(X.newPassword.length<6){r({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(X.newPassword!==X.confirmPassword){r({title:"Error",description:"Passwords do not match",variant:"destructive"});return}v(!0);try{const{error:le}=await G.auth.updateUser({password:X.newPassword});if(le)throw le;r({title:"Success",description:"Password updated successfully"}),se({newPassword:"",confirmPassword:""}),a&&setTimeout(()=>s("/dashboard"),1e3)}catch(le){console.error("Error updating password:",le),r({title:"Error",description:le.message||"Failed to update password",variant:"destructive"})}finally{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(K,{variant:"outline",onClick:()=>{var le;(le=document.getElementById("change-password-section"))==null||le.scrollIntoView({behavior:"smooth",block:"center"})},className:"gap-2",children:[e.jsx(rN,{className:"h-4 w-4"}),"Change Password"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Profile Photo"}),e.jsx(yr,{children:"Upload a professional photo for your profile"})]}),e.jsxs(Oe,{className:"flex items-center gap-6",children:[e.jsxs(gn,{className:"h-24 w-24",children:[e.jsx(Ea,{src:_}),e.jsx(xn,{className:"text-2xl",children:L.name.split(" ").map(le=>le[0]).join("").toUpperCase()||"U"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{type:"file",id:"avatar-upload",accept:"image/*",className:"hidden",onChange:Y,disabled:j}),e.jsxs(K,{variant:"outline",onClick:()=>{var le;return(le=document.getElementById("avatar-upload"))==null?void 0:le.click()},disabled:j,children:[e.jsx(Ya,{className:"mr-2 h-4 w-4"}),j?"Uploading...":"Upload Photo"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Upload an image and crop it to your liking."})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Personal Information"}),e.jsx(yr,{children:"Update your profile details"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",value:L.name,onChange:le=>R({...L,name:le.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:L.email,onChange:le=>R({...L,email:le.target.value}),maxLength:255})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Job Title"}),e.jsx(Re,{id:"title",value:L.title,onChange:le=>R({...L,title:le.target.value}),placeholder:"e.g., Broker Associate, Team Lead",maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"bio",children:"Bio"}),e.jsx(Mr,{id:"bio",value:L.bio,onChange:le=>R({...L,bio:le.target.value}),placeholder:"A short description about yourself",maxLength:500,className:"min-h-[120px] resize-y"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"areas_served",children:"Areas Served"}),e.jsx(Re,{id:"areas_served",value:L.areas_served,onChange:le=>R({...L,areas_served:le.target.value}),placeholder:"e.g., Downtown, Suburbs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"years_experience",children:"Years Experience"}),e.jsx(Re,{id:"years_experience",type:"number",min:"0",value:L.years_experience,onChange:le=>R({...L,years_experience:le.target.value}),placeholder:"e.g., 5"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Social Links"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsx(Re,{value:L.linkedin_url,onChange:le=>R({...L,linkedin_url:le.target.value}),placeholder:"LinkedIn URL"}),e.jsx(Re,{value:L.instagram_url,onChange:le=>R({...L,instagram_url:le.target.value}),placeholder:"Instagram URL"}),e.jsx(Re,{value:L.facebook_url,onChange:le=>R({...L,facebook_url:le.target.value}),placeholder:"Facebook URL"})]})]}),e.jsxs(K,{onClick:ie,disabled:f,children:[e.jsx(Bu,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(c0,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(yr,{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(Br,{checked:L.use_email_signature,onCheckedChange:le=>R({...L,use_email_signature:le})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Signature"}),e.jsx(Qg,{content:L.email_signature,onChange:le=>R({...L,email_signature:le}),placeholder:"Paste your Gmail signature here or create one...",minHeight:"120px",compact:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tip: Copy your signature from Gmail Settings and paste it here — images and formatting will be preserved."})]}),e.jsxs(K,{onClick:ie,disabled:f,children:[e.jsx(Bu,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),e.jsxs(Ee,{id:"change-password-section",children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:a?"Set Your Password":"Change Password"}),e.jsx(yr,{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(ve,{htmlFor:"newPassword",children:"New Password"}),e.jsx(Re,{id:"newPassword",type:"password",value:X.newPassword,onChange:le=>se({...X,newPassword:le.target.value}),placeholder:"Min 6 characters"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(Re,{id:"confirmPassword",type:"password",value:X.confirmPassword,onChange:le=>se({...X,confirmPassword:le.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(K,{onClick:ae,disabled:f,children:[e.jsx(Bu,{className:"mr-2 h-4 w-4"}),a?"Complete Setup":"Update Password"]}),a&&e.jsx(K,{variant:"outline",onClick:()=>s("/dashboard"),className:"ml-2",children:"Skip for Now"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[i?e.jsx(cf,{className:"h-5 w-5"}):e.jsx(X1,{className:"h-5 w-5"}),"Push Notifications"]}),e.jsx(yr,{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(Br,{checked:i,onCheckedChange:le=>{le?u():p()},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(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[$?e.jsx(uP,{className:"h-5 w-5"}):e.jsx(_r,{className:"h-5 w-5"}),"Email Preferences"]}),e.jsx(yr,{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(Br,{checked:!$,onCheckedChange:async le=>{V(!0);try{const{error:pe}=await G.from("profiles").update({digest_opt_out:!le}).eq("id",t==null?void 0:t.id);if(pe)throw pe;q(!le),r({title:le?"Subscribed":"Unsubscribed",description:le?"You will now receive weekly digest emails":"You will no longer receive weekly digest emails"})}catch(pe){r({title:"Error",description:pe.message||"Failed to update preference",variant:"destructive"})}finally{V(!1)}},disabled:U})]})})]}),e.jsx(h3t,{}),e.jsx(LLt,{})]}),e.jsx(Zbe,{open:N,onClose:()=>C(!1),imageSrc:A,onCropComplete:de,aspectRatio:1})]})})};var OLt="AspectRatio",vGe=S.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}})})});vGe.displayName=OLt;var RLt=vGe;const FLt=RLt;function zLt(){const{user:t}=Gs(),s=ns(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),{data:l,isLoading:i}=Ct({queryKey:["calendar-token",t==null?void 0:t.id],queryFn:async()=>{const{data:b,error:j}=await G.from("profiles").select("calendar_token").eq("id",t==null?void 0:t.id).single();if(j)throw j;return b},enabled:!!t&&a}),d=Ot({mutationFn:async()=>{const b=new Uint8Array(12);crypto.getRandomValues(b);const j=btoa(String.fromCharCode(...b)).replace(/\+/g,"x").replace(/\//g,"y").replace(/=/g,"").substring(0,16),{error:w}=await G.from("profiles").update({calendar_token:j}).eq("id",t==null?void 0:t.id);if(w)throw w;return j},onSuccess:()=>{s.invalidateQueries({queryKey:["calendar-token",t==null?void 0:t.id]}),fe.success("Calendar subscription URL generated!")},onError:b=>{fe.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,p=async()=>{u&&(await navigator.clipboard.writeText(u),n(!0),fe.success("Calendar URL copied to clipboard!"),setTimeout(()=>n(!1),2e3))},f=()=>{u&&(window.location.href=u.replace("https://","webcal://"))},v=()=>{if(u){const b=u.replace("https://","webcal://"),j=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(b)}`;window.open(j,"_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(vs,{open:a,onOpenChange:o,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(on,{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(As,{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(K,{variant:"outline",size:"icon",onClick:p,children:r?e.jsx(ua,{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(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:f,children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),"Add to Apple Calendar",e.jsx(sn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:v,children:[e.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(sn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{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(sn,{className:"h-3 w-3 ml-auto opacity-50"})]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center pt-2",children:"Events sync automatically. If your membership expires, the calendar will show as empty."})]}):e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generate your personal calendar subscription URL to get started."}),e.jsx(K,{onClick:()=>d.mutate(),disabled:d.isPending,className:"w-full",children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(on,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}var gle="Tabs",[BLt]=Ac(gle,[q_]),_Ge=q_(),[$Lt,Ybe]=BLt(gle),bGe=S.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:d="automatic",...u}=t,p=$_(i),[f,v]=xu({prop:n,onChange:a,defaultProp:o??"",caller:gle});return e.jsx($Lt,{scope:r,baseId:Gd(),value:f,onValueChange:v,orientation:l,dir:p,activationMode:d,children:e.jsx(Qr.div,{dir:p,"data-orientation":l,...u,ref:s})})});bGe.displayName=gle;var wGe="TabsList",jGe=S.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=Ybe(wGe,r),l=_Ge(r);return e.jsx(coe,{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})})});jGe.displayName=wGe;var kGe="TabsTrigger",NGe=S.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=t,l=Ybe(kGe,r),i=_Ge(r),d=MGe(l.baseId,n),u=TGe(l.baseId,n),p=n===l.value;return e.jsx(doe,{asChild:!0,...i,focusable:!a,active:p,children:e.jsx(Qr.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...o,ref:s,onMouseDown:Cr(t.onMouseDown,f=>{!a&&f.button===0&&f.ctrlKey===!1?l.onValueChange(n):f.preventDefault()}),onKeyDown:Cr(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&l.onValueChange(n)}),onFocus:Cr(t.onFocus,()=>{const f=l.activationMode!=="manual";!p&&!a&&f&&l.onValueChange(n)})})})});NGe.displayName=kGe;var SGe="TabsContent",CGe=S.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...l}=t,i=Ybe(SGe,r),d=MGe(i.baseId,n),u=TGe(i.baseId,n),p=n===i.value,f=S.useRef(p);return S.useEffect(()=>{const v=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(v)},[]),e.jsx(hd,{present:a||p,children:({present:v})=>e.jsx(Qr.div,{"data-state":p?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":d,hidden:!v,id:u,tabIndex:0,...l,ref:s,style:{...t.style,animationDuration:f.current?"0s":void 0},children:v&&o})})});CGe.displayName=SGe;function MGe(t,s){return`${t}-trigger-${s}`}function TGe(t,s){return`${t}-content-${s}`}var qLt=bGe,AGe=jGe,EGe=NGe,PGe=CGe;const Na=qLt,va=S.forwardRef(({className:t,...s},r)=>e.jsx(AGe,{ref:r,className:Pt("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));va.displayName=AGe.displayName;const ks=S.forwardRef(({className:t,...s},r)=>e.jsx(EGe,{ref:r,className:Pt("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t),...s}));ks.displayName=EGe.displayName;const zs=S.forwardRef(({className:t,...s},r)=>e.jsx(PGe,{ref:r,className:Pt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));zs.displayName=PGe.displayName;const ULt={first_timer:Gn,regular:E0,dedicated:rc,veteran:Ki,streak_master:$h,century:Ki},VLt={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 TAe(t){return t===1?e.jsx(Ki,{className:"h-5 w-5 text-yellow-500"}):t===2?e.jsx(E0,{className:"h-5 w-5 text-gray-400"}):t===3?e.jsx(rc,{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 IGe({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=Gs(),{data:o,isLoading:l}=pVe(s?5:10,r),{data:i}=fVe(a==null?void 0:a.id),{data:d}=xVe(a==null?void 0:a.id),{data:u}=gVe(a==null?void 0:a.id);return l?e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Ki,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((p,f)=>e.jsx(gs,{className:"h-12 w-full"},f))})})]}):e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Ki,{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(at,{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($h,{className:"h-4 w-4 text-orange-500"}),e.jsx("div",{className:"text-lg font-bold",children:i.current_streak}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Streak"})]})]}),u&&u.length>0&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1",children:[u.slice(0,4).map(p=>{const f=ULt[p.badge_type]||Gn;return e.jsxs(at,{variant:"outline",className:`text-xs ${VLt[p.badge_type]||""}`,title:p.badge_description||"",children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),p.badge_name]},p.id)}),u.length>4&&e.jsxs(at,{variant:"outline",className:"text-xs",children:["+",u.length-4," more"]})]})]}),e.jsxs(Na,{defaultValue:"points",className:"w-full",children:[e.jsxs(va,{className:"w-full mb-3",children:[e.jsx(ks,{value:"points",className:"flex-1",children:"By Points"}),e.jsx(ks,{value:"events",className:"flex-1",children:"By Events"})]}),e.jsx(zs,{value:"points",className:"mt-0",children:e.jsxs("div",{className:"space-y-2",children:[o==null?void 0:o.map((p,f)=>{var v,_,b;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${p.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${f===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:TAe(f+1)}),e.jsx(gn,{className:"h-8 w-8",children:e.jsx(xn,{className:"text-xs",children:((_=(v=p.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=p.profile)==null?void 0:b.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_events_attended," events"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold text-primary",children:p.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"pts"})]})]},p.user_id)}),(!o||o.length===0)&&e.jsx("div",{className:"text-center text-muted-foreground py-4 text-sm",children:"No attendance data yet. Attend an event to get on the leaderboard!"})]})}),e.jsx(zs,{value:"events",className:"mt-0",children:e.jsx("div",{className:"space-y-2",children:[...o||[]].sort((p,f)=>f.total_events_attended-p.total_events_attended).map((p,f)=>{var v,_,b;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${p.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${f===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:TAe(f+1)}),e.jsx(gn,{className:"h-8 w-8",children:e.jsx(xn,{className:"text-xs",children:((_=(v=p.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=p.profile)==null?void 0:b.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_points," points"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold",children:p.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"events"})]})]},p.user_id)})})})]})]})]})}function HLt(){const t=Dr(),{user:s,isAdmin:r}=Gs(),n=ns(),{data:a,isLoading:o}=Ct({queryKey:["public-events"],queryFn:async()=>{const{data:j,error:w}=await G.from("events").select("*").order("event_date",{ascending:!0});if(w)throw w;return j}}),{data:l}=Ct({queryKey:["my-registrations"],queryFn:async()=>{if(!s)return[];const{data:j,error:w}=await G.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",s.id);if(w)throw w;return j},enabled:!!s}),{data:i}=Ct({queryKey:["event-registration-counts"],queryFn:async()=>{let j=[],w=0;const N=1e3;for(;;){const{data:A,error:I}=await G.from("event_registrations").select("event_id").range(w,w+N-1);if(I)throw I;if(!A||A.length===0||(j=j.concat(A),A.length{C[A.event_id]=(C[A.event_id]||0)+1}),C}}),d=Ot({mutationFn:async j=>{await G.auth.refreshSession();const{data:w,error:N}=await G.functions.invoke("zoom-register",{body:{event_id:j}});if(N)throw N;if(w!=null&&w.error)throw new Error(w.error);return w},onSuccess:j=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),j!=null&&j.join_url?fe.success("Successfully registered! You'll receive a Zoom confirmation email."):fe.success("Successfully registered for the event!")},onError:j=>{fe.error("Failed to register: "+j.message)}}),u=Ot({mutationFn:async j=>{const{data:w,error:N}=await G.functions.invoke("zoom-unregister",{body:{event_id:j}});if(N)throw N;if(w!=null&&w.error)throw new Error(w.error);return w},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),fe.success("Registration cancelled and removed from Zoom")},onError:j=>{fe.error("Failed to cancel: "+j.message)}}),p=j=>l==null?void 0:l.some(w=>w.event_id===j),f=j=>{const w=l==null?void 0:l.find(N=>N.event_id===j);return w==null?void 0:w.zoom_join_url},v=j=>j.capacity?((i==null?void 0:i[j.id])||0)>=j.capacity:!1,_=(a==null?void 0:a.filter(j=>P5(j.event_date)!=="ended"))||[],b=(a==null?void 0:a.filter(j=>P5(j.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(zLt,{}),r&&e.jsx(K,{variant:"outline",onClick:()=>t("/admin/events"),children:"Manage Events"})]})]}),e.jsxs("div",{className:`grid grid-cols-1 ${r?"lg:grid-cols-3":""} gap-6`,children:[e.jsxs("div",{className:r?"lg:col-span-2":"",children:[o?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading events..."}):_.length===0?e.jsx(Ee,{className:"text-center py-12",children:e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground",children:"No upcoming events at the moment. Check back soon!"})})}):e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:_.map(j=>{const w=P5(j.event_date),N=Q_e(j.event_date),C=w==="live",A=w==="starting_soon";return e.jsxs(Ee,{className:`flex flex-col overflow-hidden cursor-pointer hover:shadow-lg transition-all ${C?"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/${j.id}`),children:[N&&e.jsxs("div",{className:`${C?"bg-red-500":"bg-amber-500"} text-white px-3 py-1.5 flex items-center gap-2 text-sm font-medium`,children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-white opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-white"})]}),C?e.jsxs(e.Fragment,{children:[e.jsx(lN,{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"]})]}),j.image_url&&e.jsx(FLt,{ratio:3/2,className:"overflow-hidden",children:e.jsx("img",{src:j.image_url,alt:j.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"})}),e.jsxs(Lt,{children:[e.jsx(zt,{className:"line-clamp-2",children:j.title}),j.description&&e.jsx(yr,{className:"line-clamp-2",children:j.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(on,{className:"h-4 w-4"}),new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(j.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Tn,{className:"h-4 w-4"}),s6(new Date(j.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(hr,{className:"h-4 w-4"}),(i==null?void 0:i[j.id])||0," registered",j.capacity&&` / ${j.capacity} spots`]})]}),e.jsx(UP,{className:"flex gap-2",onClick:I=>I.stopPropagation(),children:p(j.id)?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>u.mutate(j.id),disabled:u.isPending,children:[e.jsx(Ur,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(K,{className:"flex-1",onClick:()=>window.open(f(j.id)||j.zoom_link,"_blank"),children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):e.jsx(K,{className:"w-full",onClick:()=>d.mutate(j.id),disabled:d.isPending||v(j),children:v(j)?"Event Full":e.jsxs(e.Fragment,{children:[e.jsx(ua,{className:"h-4 w-4 mr-2"}),"Register"]})})})]},j.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(j=>e.jsx(Ee,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>t(`/events/${j.id}`),children:e.jsxs(Lt,{children:[e.jsx(zt,{className:"text-base line-clamp-1",children:j.title}),e.jsx(yr,{children:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(j.event_date))})]})},j.id))})]})]}),r&&e.jsx("div",{className:"lg:col-span-1",children:e.jsx(IGe,{showUserStats:!0})})]})]})})}const Lme=[{value:"all",label:"All Roles",icon:hr},{value:"newest",label:"Newest Members",icon:Tn},{value:"brokerage_manager",label:"Brokerage Managers",icon:OP},{value:"admin",label:"Admins",icon:rh}];function WLt({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var We,ht;const{user:o,isAdmin:l,isBrokerageManager:i}=Gs(),[d,u]=S.useState([]),[p,f]=S.useState([]),[v,_]=S.useState([]),[b,j]=S.useState([]),[w,N]=S.useState(""),[C,A]=S.useState(""),[I,L]=S.useState(""),[R,$]=S.useState(!1),[q,U]=S.useState(!1),[V,X]=S.useState("agents"),[se,te]=S.useState("all"),[Y,de]=S.useState({}),ie=l||i;S.useEffect(()=>{t&&o&&(l?ae():le())},[t,o,l]),S.useEffect(()=>{t||(_([]),j([]),N(""),A(""),L(""),X("agents"),te("all"))},[t]);const ae=async()=>{if(o){$(!0);try{const{data:De,error:Dt}=await G.from("brokerages").select("id, name").order("name");if(Dt)throw Dt;const he=1e3,Qe={};let ot=0,rt=!0;for(;rt;){const{data:qe,error:Xe}=await G.from("profiles").select("brokerage_id").range(ot*he,(ot+1)*he-1);if(Xe)throw Xe;qe==null||qe.forEach($e=>{$e.brokerage_id&&(Qe[$e.brokerage_id]=(Qe[$e.brokerage_id]||0)+1)}),rt=(qe==null?void 0:qe.length)===he,ot++}f((De==null?void 0:De.map(qe=>({...qe,agent_count:Qe[qe.id]||0})))||[]);const Ne=[];for(ot=0,rt=!0;rt;){const{data:qe,error:Xe}=await G.from("profiles").select("id, name, email, brokerage_id, created_at, brokerages(name)").neq("id",o.id).order("name").range(ot*he,(ot+1)*he-1);if(Xe)throw Xe;qe&&Ne.push(...qe),rt=(qe==null?void 0:qe.length)===he,ot++}const it={};for(ot=0,rt=!0;rt;){const{data:qe,error:Xe}=await G.from("user_roles").select("user_id, role").range(ot*he,(ot+1)*he-1);if(Xe)throw Xe;qe==null||qe.forEach($e=>{it[$e.user_id]||(it[$e.user_id]=[]),it[$e.user_id].push($e.role)}),rt=(qe==null?void 0:qe.length)===he,ot++}de(it),u(Ne.map(qe=>{var Xe;return{id:qe.id,name:qe.name,email:qe.email,brokerage_name:((Xe=qe.brokerages)==null?void 0:Xe.name)||"No Brokerage",roles:it[qe.id]||[],created_at:qe.created_at}}))}catch(De){console.error("Error loading data:",De),fe.error("Failed to load agents and brokerages")}finally{$(!1)}}},le=async()=>{if(o){$(!0);try{const{data:De}=await G.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(De!=null&&De.brokerage_id)){fe.error("You must be part of a brokerage to share resources"),s(!1);return}const{data:Dt,error:he}=await G.from("profiles").select("id, name, email").eq("brokerage_id",De.brokerage_id).neq("id",o.id).order("name");if(he)throw he;u(Dt||[])}catch(De){console.error("Error loading agents:",De),fe.error("Failed to load agents")}finally{$(!1)}}},pe=d.filter(De=>{var he;const Dt=De.name.toLowerCase().includes(w.toLowerCase())||De.email.toLowerCase().includes(w.toLowerCase())||((he=De.brokerage_name)==null?void 0:he.toLowerCase().includes(w.toLowerCase()));if(l&&se!=="all"&&se!=="newest"){const Qe=Y[De.id]||[];return Dt&&Qe.includes(se)}return Dt}).sort((De,Dt)=>se==="newest"?(Dt.created_at||"").localeCompare(De.created_at||""):0),be=p.filter(De=>De.name.toLowerCase().includes(C.toLowerCase())),ye=()=>{v.length===pe.length?_([]):_(pe.map(De=>De.id))},we=()=>{b.length===be.length?j([]):j(be.map(De=>De.id))},ke=De=>{if(!ie){_([De]);return}_(Dt=>Dt.includes(De)?Dt.filter(he=>he!==De):[...Dt,De])},Ze=De=>{j(Dt=>Dt.includes(De)?Dt.filter(he=>he!==De):[...Dt,De])},_e=async()=>{if(!(v.length>0||b.length>0)){fe.error("Please select at least one agent or brokerage to share with");return}U(!0);try{const{data:Dt,error:he}=await G.functions.invoke("send-share-notification",{body:{recipientIds:v,brokerageIds:b,resourceType:r,resourceId:n,resourceTitle:a,message:I.trim()||void 0}});if(he)throw he;const Qe=(Dt==null?void 0:Dt.sharesCreated)||v.length;fe.success(`Shared with ${Qe} agent${Qe!==1?"s":""}`),s(!1)}catch(Dt){console.error("Error sharing resource:",Dt),fe.error("Failed to share resource")}finally{U(!1)}},Ce=De=>De.split(" ").map(Dt=>Dt[0]).join("").toUpperCase().slice(0,2),Te=De=>{const Dt=Y[De]||[];return Dt.includes("admin")?e.jsx(at,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):Dt.includes("brokerage_manager")?e.jsx(at,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},Fe=v.length+b.length,Ae=se!=="all"&&se!=="newest"?pe.length:null;return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-lg max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs(Ss,{className:"flex-shrink-0",children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(ka,{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(Na,{value:V,onValueChange:X,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(va,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[e.jsxs(ks,{value:"agents",className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{children:"Agents"}),v.length>0&&e.jsx(at,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:v.length})]}),e.jsxs(ks,{value:"brokerages",className:"flex items-center gap-2",children:[e.jsx(Aa,{className:"h-4 w-4"}),e.jsx("span",{children:"Brokerages"}),b.length>0&&e.jsx(at,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:b.length})]})]}),e.jsxs(zs,{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(fn,{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:w,onChange:De=>N(De.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:se,onValueChange:te,children:[e.jsxs(Js,{className:"w-[180px]",children:[e.jsx(Hx,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(sr,{placeholder:"Filter by role"})]}),e.jsx(er,{children:Lme.map(De=>e.jsx(At,{value:De.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De.icon,{className:"h-4 w-4"}),e.jsx("span",{children:De.label})]})},De.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:ye,className:"text-xs h-8",disabled:pe.length===0,children:[e.jsx(hr,{className:"h-3.5 w-3.5 mr-1.5"}),v.length===pe.length&&pe.length>0?"Deselect All":"Select All"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[Ae!==null&&e.jsxs("span",{className:"text-primary font-medium",children:[Ae," ",(We=Lme.find(De=>De.value===se))==null?void 0:We.label]}),e.jsxs("span",{className:"font-medium",children:[v.length," selected"]})]})]}),e.jsx(Bi,{className:"h-[300px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):pe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(hr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:se!=="all"?`No ${(ht=Lme.find(De=>De.value===se))==null?void 0:ht.label.toLowerCase()} found`:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:pe.map(De=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${v.includes(De.id)?"bg-accent":""}`,onClick:()=>ke(De.id),children:[e.jsx(zo,{checked:v.includes(De.id),onCheckedChange:()=>ke(De.id),className:"flex-shrink-0"}),e.jsx(gn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(xn,{className:"text-xs bg-primary/10 text-primary",children:Ce(De.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:De.name}),Te(De.id)]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[De.email,De.brokerage_name&&e.jsxs("span",{className:"ml-1 opacity-75",children:["• ",De.brokerage_name]})]})]})]},De.id))})})]}),e.jsxs(zs,{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(fn,{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:C,onChange:De=>A(De.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:we,className:"text-xs h-8",disabled:be.length===0,children:[e.jsx(Aa,{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(Bi,{className:"h-[250px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[180px]",children:e.jsx(As,{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(Aa,{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(De=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${b.includes(De.id)?"bg-accent":""}`,onClick:()=>Ze(De.id),children:[e.jsx(zo,{checked:b.includes(De.id),onCheckedChange:()=>Ze(De.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(Aa,{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:De.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[De.agent_count," agent",De.agent_count!==1?"s":""]})]})]},De.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(fn,{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:w,onChange:De=>N(De.target.value),className:"pl-9"})]}),ie&&e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:ye,className:"text-xs h-8",disabled:pe.length===0,children:[e.jsx(hr,{className:"h-3.5 w-3.5 mr-1.5"}),v.length===pe.length&&pe.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[v.length," selected"]})]}),e.jsx(Bi,{className:"h-[300px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):pe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(hr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:pe.map(De=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${v.includes(De.id)?"bg-accent":""}`,onClick:()=>ke(De.id),children:[e.jsx(zo,{checked:v.includes(De.id),onCheckedChange:()=>ke(De.id),className:"flex-shrink-0"}),e.jsx(gn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(xn,{className:"text-xs bg-primary/10 text-primary",children:Ce(De.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:De.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:De.email})]})]},De.id))})})]}),e.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[e.jsx(ve,{htmlFor:"message",className:"text-sm font-medium",children:"Add a message (optional)"}),e.jsx(Mr,{id:"message",placeholder:"I thought you might find this useful...",value:I,onChange:De=>L(De.target.value),rows:2,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2 flex-shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:_e,disabled:Fe===0||q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ka,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function SM({resourceType:t,resourceId:s,resourceTitle:r,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=S.useState(!1),{user:d}=Gs();return d?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:n,size:a,onClick:()=>i(!0),className:o,children:[e.jsx(cd,{className:"h-4 w-4 mr-2"}),"Share"]}),e.jsx(WLt,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function GLt(){const{eventId:t}=Mo(),s=Dr(),{user:r}=Gs(),[n,a]=S.useState(null),[o,l]=S.useState(null),[i,d]=S.useState(0),[u,p]=S.useState(!0),[f,v]=S.useState(!1);S.useEffect(()=>{t&&_()},[t,r]);const _=async()=>{try{const{data:A,error:I}=await G.from("events").select("*").eq("id",t).single();if(I)throw I;a(A);const{count:L}=await G.from("event_registrations").select("*",{count:"exact",head:!0}).eq("event_id",t);if(d(L||0),r){const{data:R}=await G.from("event_registrations").select("id, zoom_join_url").eq("event_id",t).eq("user_id",r.id).maybeSingle();l(R)}}catch(A){console.error("Error loading event:",A),fe.error("Failed to load event"),s("/events")}finally{p(!1)}},b=async()=>{if(!(!r||!n)){v(!0);try{const{error:A}=await G.auth.refreshSession();if(A){console.error("Session refresh failed:",A),fe.error("Your session has expired. Please log in again.");return}if(o){const{error:I}=await G.functions.invoke("zoom-unregister",{body:{event_id:n.id}});if(I)throw I;fe.success("Successfully cancelled registration"),l(null),d(L=>L-1)}else{const{data:I,error:L}=await G.functions.invoke("zoom-register",{body:{event_id:n.id}});if(L)throw L;fe.success("Successfully registered for event!"),l({id:I.registration_id,zoom_join_url:I.zoom_join_url}),d(R=>R+1)}}catch(A){console.error("Registration error:",A),fe.error(o?"Failed to cancel registration":"Failed to register for event")}finally{v(!1)}}},j=A=>{var I,L,R;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 $=(R=A.split("vimeo.com/")[1])==null?void 0:R.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(K,{onClick:()=>s("/events"),className:"mt-4",children:"Back to Events"})]})});const w=Xx(new Date(n.event_date)),N=n.capacity&&i>=n.capacity,C=(o==null?void 0:o.zoom_join_url)||n.zoom_link;return e.jsx(Ms,{title:n.title,children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs(K,{variant:"ghost",className:"mb-6 gap-2",onClick:()=>s("/events"),children:[e.jsx(Ua,{className:"h-4 w-4"}),"Back to Events"]}),n.image_url&&e.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden mb-6",children:[e.jsx("img",{src:n.image_url,alt:n.title,className:"w-full h-full object-cover"}),w&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(at,{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(SM,{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(ym,{className:"h-5 w-5"}),"Event Preview"]}),e.jsx("div",{className:"relative w-full aspect-video rounded-xl overflow-hidden border bg-muted",children:e.jsx("iframe",{src:j(n.video_url),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Event Preview Video"})})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(on,{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:s6(new Date(n.event_date))})]})]}),n.capacity&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(hr,{className:"h-5 w-5 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[i," / ",n.capacity]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Registered"})]})]}),o&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-500/10 rounded-lg",children:[e.jsx(gi,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:"You're registered!"})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[!w&&e.jsx(e.Fragment,{children:o?e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"w-full gap-2",onClick:()=>window.open(C,"_blank"),children:[e.jsx(sn,{className:"h-4 w-4"}),"Join Event"]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:b,disabled:f,children:[f?e.jsx(As,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):e.jsx(K,{className:"w-full gap-2",onClick:b,disabled:f||(N??!1),children:f?e.jsx(As,{className:"h-4 w-4 animate-spin"}):N?"Event Full":"Register Now"})}),w&&o&&e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[e.jsx(sn,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const KLt=[{id:"quickvid",name:"QuickVid",description:"Record, manage, and share personalized video messages",icon:e.jsx(kn,{className:"h-6 w-6"}),path:"/mission-control/video-library",category:"Marketing"},{id:"smart-card",name:"Smart Card",description:"Your digital business card — share your info with a single link",icon:e.jsx(uf,{className:"h-6 w-6"}),path:"/mission-control/my-card",category:"Marketing"},{id:"smart-presentations",name:"Smart Presentations",description:"Create beautiful listing and buyer presentations",icon:e.jsx(Bg,{className:"h-6 w-6"}),path:"/mission-control/presentations",category:"Marketing"},{id:"landing-pages",name:"Landing Pages",description:"Build custom landing pages to capture leads",icon:e.jsx(In,{className:"h-6 w-6"}),path:"/mission-control/landing-pages",category:"Marketing"},{id:"guest-book",name:"Guest Book",description:"Digital open house sign-in to capture visitor info",icon:e.jsx(Ou,{className:"h-6 w-6"}),path:"/mission-control/guest-book",category:"Open House"},{id:"card-studio",name:"Card Studio",description:"Send beautiful animated digital cards for birthdays, anniversaries & milestones",icon:e.jsx(hn,{className:"h-6 w-6"}),path:"/mission-control/card-studio",category:"Marketing"},{id:"direct-mail",name:"Direct Mail",description:"Send professional postcards to your contacts via direct mail",icon:e.jsx(_r,{className:"h-6 w-6"}),path:"/mission-control/direct-mail",category:"Marketing",adminOnly:!0,beta:!0}],ZLt=()=>{const{user:t,isAdmin:s}=Gs(),r=Dr(),[n,a]=S.useState([]),[o,l]=S.useState(!0),[i,d]=S.useState(""),[u,p]=S.useState("all"),[f,v]=S.useState(new Set);S.useEffect(()=>{_()},[t]);const _=async()=>{try{const{data:R}=await G.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),$=(R==null?void 0:R.map(Y=>Y.tag))||[],{data:q,error:U}=await G.from("app_tiles").select("*").order("name");if(U)throw U;const{data:V}=await G.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),X=new Set((V==null?void 0:V.map(Y=>Y.app_id))||[]);v(X);const te=((q==null?void 0:q.filter(Y=>!Y.required_tags||Y.required_tags.length===0?!0:Y.required_tags.some(de=>$.includes(de))))||[]).sort((Y,de)=>Y.name==="LevelUp Members Portal"?-1:de.name==="LevelUp Members Portal"?1:0);a(te)}catch(R){console.error("Error loading apps:",R),fe.error("Failed to load apps")}finally{l(!1)}},b=async R=>{var q;const $=window.open("about:blank","_blank");try{const{data:U,error:V}=await G.auth.getSession();if(V||!U.session){$==null||$.close(),fe.error("Session expired. Please refresh the page and try again.");return}const X=U.session.access_token;await G.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:R.app_id,app_name:R.name,user_agent:navigator.userAgent});const{data:se,error:te}=await G.functions.invoke("sso-launch",{body:{app_id:R.app_id},headers:{Authorization:`Bearer ${X}`}});if(te)throw te;se!=null&&se.redirect_url?$&&!$.closed?($.location.href=se.redirect_url,(q=$.focus)==null||q.call($)):window.location.assign(se.redirect_url):($==null||$.close(),fe.error("Launch link unavailable"))}catch(U){$==null||$.close(),console.error("Error launching app:",U),fe.error("Failed to launch app. Please try again.")}},j=async(R,$)=>{R.stopPropagation();const q=f.has($);try{if(q){const{error:U}=await G.from("user_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("app_id",$);if(U)throw U;v(V=>{const X=new Set(V);return X.delete($),X}),fe.success("Removed from favorites")}else{const{error:U}=await G.from("user_favorites").insert({user_id:t==null?void 0:t.id,app_id:$});if(U)throw U;v(V=>new Set(V).add($)),fe.success("Added to favorites")}}catch(U){console.error("Error toggling favorite:",U),fe.error("Failed to update favorites")}},w=n.filter(R=>{var q;const $=R.name.toLowerCase().includes(i.toLowerCase())||((q=R.description)==null?void 0:q.toLowerCase().includes(i.toLowerCase()));return u==="favorites"?$&&f.has(R.id):$}),N=KLt.filter(R=>R.adminOnly&&!s?!1:R.name.toLowerCase().includes(i.toLowerCase())||R.description.toLowerCase().includes(i.toLowerCase())),C=N.reduce((R,$)=>(R[$.category]||(R[$.category]=[]),R[$.category].push($),R),{}),A=[{id:"all",label:"All"},{id:"tools",label:"Built-in Tools"},{id:"apps",label:"Connected Apps"},{id:"favorites",label:"Favorites"}];if(o)return e.jsx(Ms,{title:"Apps & Tools",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading apps & tools..."})]})})});const I=u==="all"||u==="tools",L=u==="all"||u==="apps"||u==="favorites";return e.jsxs(Ms,{title:"Apps & Tools",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"Apps & Tools"}),e.jsxs("div",{className:"relative max-w-sm w-full",children:[e.jsx(fn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search apps & tools...",className:"pl-10 bg-muted/50 border-0 focus-visible:ring-1",value:i,onChange:R=>d(R.target.value)})]})]}),e.jsx("div",{className:"flex gap-6 border-b border-border mb-8",children:A.map(R=>e.jsxs("button",{onClick:()=>p(R.id),className:Pt("pb-3 text-sm font-medium transition-colors relative",u===R.id?"text-primary":"text-muted-foreground hover:text-foreground"),children:[R.label,u===R.id&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]},R.id))}),I&&Object.keys(C).length>0&&e.jsxs("div",{className:"mb-10",children:[u==="all"&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx($g,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Built-in Tools"})]}),Object.entries(C).map(([R,$])=>e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground bg-muted px-2.5 py-1 rounded-full",children:R})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:$.map(q=>e.jsxs("div",{onClick:()=>r(q.path),className:"group flex items-start gap-4 p-5 bg-card rounded-xl border border-border transition-all duration-200 hover:shadow-lg hover:border-primary/30 cursor-pointer",children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 text-primary flex items-center justify-center",children:q.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate flex items-center gap-2",children:[q.name,q.beta&&e.jsx("span",{className:"text-[10px] font-medium bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:"Beta"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:q.description})]})]},q.id))})]},R))]}),L&&e.jsxs("div",{children:[u==="all"&&w.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(sn,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Connected Apps"})]}),w.length===0&&u!=="all"?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(Dg,{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(zu,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No apps available"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:s?"Get started by adding apps in the admin panel":"Contact your administrator to get access to apps"}),s&&e.jsx(K,{className:"mt-4",onClick:()=>r("/admin/apps"),children:"Add Apps"})]})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:w.map(R=>{const $=f.has(R.id),q=R.name.toLowerCase().includes("agent review")||R.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(R),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:R.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:R.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:R.description})]}),e.jsx("button",{className:Pt("flex-shrink-0 p-1 transition-colors",$?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:U=>j(U,R.id),children:e.jsx(Dg,{className:Pt("h-5 w-5",$&&"fill-current")})})]}),q&&e.jsx("a",{href:"https://forms.gle/vXnrzgSnPbw7CKPV6",target:"_blank",rel:"noopener noreferrer",onClick:U=>U.stopPropagation(),className:"mt-3 text-sm text-primary hover:underline flex items-center gap-1",children:"Create your account with this link →"})]},R.id)})})]}),I&&L&&w.length===0&&N.length===0&&i&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:[e.jsx(fn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No results found"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:"Try a different search term"})]})]})},YLt=()=>{const t=Dr(),[s,r]=S.useState(""),[n,a]=S.useState("all"),[o,l]=S.useState("all"),[i,d]=S.useState("grid"),{data:u=[]}=Ct({queryKey:["template-categories"],queryFn:async()=>{const{data:N,error:C}=await G.from("template_categories").select("*").order("name");if(C)throw C;return N}}),{data:p=[]}=Ct({queryKey:["template-types"],queryFn:async()=>{const{data:N,error:C}=await G.from("template_types").select("*").order("name");if(C)throw C;return N}}),{data:f=[],isLoading:v}=Ct({queryKey:["canva-templates"],queryFn:async()=>{const{data:N,error:C}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(C)throw C;const{data:A,error:I}=await G.from("template_links").select("*").order("sort_order");if(I)throw I;const{data:L}=await G.from("template_likes").select("template_id"),{data:R}=await G.from("template_comments").select("template_id"),$=new Map;L==null||L.forEach(V=>{$.set(V.template_id,($.get(V.template_id)||0)+1)});const q=new Map;return R==null||R.forEach(V=>{q.set(V.template_id,(q.get(V.template_id)||0)+1)}),(N||[]).map(V=>({...V,links:(A||[]).filter(X=>X.template_id===V.id)||[],likesCount:$.get(V.id)||0,commentsCount:q.get(V.id)||0}))}}),_=f.filter(N=>{var L;const C=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 C&&A&&I}),b=()=>{r(""),a("all"),l("all")},j=s||n!=="all"||o!=="all",w=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(fn,{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(sr,{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(sr,{placeholder:"All Types"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Types"}),p.map(N=>e.jsx(At,{value:N.id,children:N.name},N.id))]})]}),e.jsxs("div",{className:"flex gap-2",children:[j&&e.jsx(K,{variant:"outline",size:"sm",onClick:b,children:"Clear Filters"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:i==="grid"?"secondary":"outline",size:"icon",onClick:()=>d("grid"),className:"rounded-full",children:e.jsx(mp,{className:"h-4 w-4"})}),e.jsx(K,{variant:i==="list"?"secondary":"outline",size:"icon",onClick:()=>d("list"),className:"rounded-full",children:e.jsx(Uh,{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,C)=>e.jsx(Ee,{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"})]})]})},C))}),!v&&_.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:j?"No templates match your filters":"No templates available yet"}),j&&e.jsx(K,{variant:"outline",onClick: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(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>w(N.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${i==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[N.preview_image_url?e.jsx("img",{src:N.preview_image_url,alt:N.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),N.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(at,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[e.jsx(Lo,{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:Qie(N.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[N.category&&e.jsx(at,{variant:"secondary",className:"text-xs",children:N.category.name}),N.type&&e.jsx(at,{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(pu,{className:"h-3.5 w-3.5"}),N.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gc,{className:"h-3.5 w-3.5"}),N.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:C=>{C.stopPropagation(),w(N.id)},children:[e.jsx(sn,{className:"h-4 w-4"}),"View Template"]})]})]},N.id))})]})})};var XLt="Separator",AAe="horizontal",QLt=["horizontal","vertical"],LGe=S.forwardRef((t,s)=>{const{decorative:r,orientation:n=AAe,...a}=t,o=JLt(n)?n:AAe,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})});LGe.displayName=XLt;function JLt(t){return QLt.includes(t)}var DGe=LGe;const Rl=S.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(DGe,{ref:a,decorative:r,orientation:s,className:Pt("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));Rl.displayName=DGe.displayName;const FL=()=>({trackEngagement:S.useCallback(async(s,r,n,a="view")=>{try{const{data:{user:o}}=await G.auth.getUser();if(!o)return;await G.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)}},[])}),eDt=()=>{const{templateId:t}=Mo(),s=Dr(),{user:r,isAdmin:n}=Gs(),{toast:a}=Ia(),o=ns(),{trackEngagement:l}=FL(),[i,d]=S.useState(""),{data:u,isLoading:p}=Ct({queryKey:["template-detail",t],queryFn:async()=>{const{data:I,error:L}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("id",t).single();if(L)throw L;const{data:R}=await G.from("template_links").select("*").eq("template_id",t).order("sort_order"),{data:$}=await G.from("template_guides").select("*").eq("template_id",t).order("sort_order");return{...I,links:R||[],guides:$||[]}},enabled:!!t}),{data:f=[]}=Ct({queryKey:["template-linked-toolkits",t],queryFn:async()=>{const{data:I,error:L}=await G.from("resource_kit_templates").select("kit_id, resource_kits:kit_id(id, name, featured_image_url)").eq("template_id",t);if(L)throw L;return(I||[]).map(R=>R.resource_kits).filter(Boolean)},enabled:!!t});S.useEffect(()=>{u&&l("template",u.id,u.name,"view")},[u==null?void 0:u.id]);const{data:v=[]}=Ct({queryKey:["template-likes",t],queryFn:async()=>{const{data:I,error:L}=await G.from("template_likes").select("*").eq("template_id",t);if(L)throw L;return I},enabled:!!t}),{data:_=[]}=Ct({queryKey:["template-comments",t],queryFn:async()=>{const{data:I,error:L}=await G.from("template_comments").select("*").eq("template_id",t).order("created_at",{ascending:!1});if(L)throw L;const R=[...new Set(I.map(U=>U.user_id))],{data:$}=await G.from("profiles").select("id, name").in("id",R),q=new Map(($==null?void 0:$.map(U=>[U.id,U.name]))||[]);return I.map(U=>({...U,user_name:q.get(U.user_id)||"Unknown User"}))},enabled:!!t}),b=Ot({mutationFn:async I=>{const{error:L}=await G.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"})}}),j=Ot({mutationFn:async I=>{const{error:L}=await G.from("template_comments").delete().eq("id",I);if(L)throw L},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),a({title:"Comment deleted"})}}),w=Ot({mutationFn:async()=>{const I=v.find(L=>L.user_id===(r==null?void 0:r.id));if(I){const{error:L}=await G.from("template_likes").delete().eq("id",I.id);if(L)throw L}else{const{error:L}=await G.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)),C=I=>I.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),A=I=>{I.preventDefault(),!(!i.trim()||!r)&&b.mutate(i.trim())};return p?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(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(vo,{to:"/templates",children:[e.jsx(Ua,{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(at,{variant:"secondary",children:u.category.name}),u.type&&e.jsx(at,{variant:"outline",children:u.type.name})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(vo,{to:`/admin/templates?edit=${u.id}`,children:[e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(SM,{resourceType:"template",resourceId:u.id,resourceTitle:u.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:N?"default":"outline",className:"gap-2 rounded-full",onClick:()=>w.mutate(),disabled:!r||w.isPending,children:[e.jsx(pu,{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(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Lo,{className:"h-4 w-4"}),u.links.length===1?"Template Link":"Template Links"]}),e.jsx("div",{className:"grid gap-2",children:u.links.map(I=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_canva"),window.open(I.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:I.title}),e.jsx(sn,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),u.video_url&&e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsx("div",{className:"aspect-video w-full rounded-lg overflow-hidden",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})}),u.guides&&u.guides.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(In,{className:"h-4 w-4"}),"Guide Files"]}),e.jsx("div",{className:"grid gap-2",children:u.guides.map(I=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_pdf"),window.open(I.file_url,"_blank")},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(In,{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(xi,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),f.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(dl,{className:"h-4 w-4"}),"Related Toolkits"]}),e.jsx("div",{className:"grid gap-2",children:f.map(I=>e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-3 h-auto py-3",onClick:()=>s(`/toolbox/${I.id}`),children:[I.featured_image_url?e.jsx("img",{src:I.featured_image_url,alt:"",className:"w-10 h-10 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(dl,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"font-medium",children:I.name})]},I.id))})]})}),e.jsx(Rl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(gc,{className:"h-5 w-5"}),"Comments (",_.length,")"]}),r?e.jsxs("form",{onSubmit:A,className:"flex gap-2",children:[e.jsx(Mr,{placeholder:"Add a comment...",value:i,onChange:I=>d(I.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!i.trim()||b.isPending,children:e.jsx(ka,{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(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):_.map(I=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(gn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(xn,{className:"text-sm",children:C(I.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:I.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Cd(new Date(I.created_at),{addSuffix:!0})}),I.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>j.mutate(I.id),children:e.jsx(br,{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(Lo,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Template not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This template may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(vo,{to:"/templates",children:"Back to Templates"})})]})})},tDt=()=>{const{user:t}=Gs(),[s,r]=S.useState(""),[n,a]=S.useState("all"),{data:o=[]}=Ct({queryKey:["academy-categories"],queryFn:async()=>{const{data:v,error:_}=await G.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(_)throw _;return v}}),{data:l=[],isLoading:i}=Ct({queryKey:["academy-videos"],queryFn:async()=>{const{data:v,error:_}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("is_published",!0).order("publish_date",{ascending:!1});if(_)throw _;const{data:b,error:j}=await G.from("academy_resources").select("*").order("sort_order");if(j)throw j;return v.map(N=>({...N,resources:(b==null?void 0:b.filter(C=>C.video_id===N.id))||[]}))}}),{data:d=[]}=Ct({queryKey:["academy-video-likes"],queryFn:async()=>{const{data:v,error:_}=await G.from("academy_video_likes").select("video_id, user_id");if(_)throw _;return v}}),u=l.filter(v=>{var j;const _=s===""||v.title.toLowerCase().includes(s.toLowerCase())||((j=v.description)==null?void 0:j.toLowerCase().includes(s.toLowerCase())),b=n==="all"||v.category_id===n;return _&&b}),p=v=>d.filter(_=>_.video_id===v).length,f=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(fn,{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(Na,{value:n,onValueChange:a,children:e.jsxs(va,{className:"w-full justify-start flex-wrap h-auto gap-2 bg-transparent p-0",children:[e.jsx(ks,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(v=>e.jsx(ks,{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(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(kn,{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(vo,{to:`/academy/${v.id}`,children:e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow group h-full",children:[e.jsxs("div",{className:"relative aspect-video bg-muted",children:[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(kn,{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(ul,{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(Lt,{className:"pb-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsx(zt,{className:"text-lg line-clamp-2",children:v.title})}),v.category&&e.jsx(at,{variant:"secondary",className:"w-fit",children:v.category.name})]}),e.jsxs(Oe,{className:"pt-0",children:[v.description&&e.jsx(yr,{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(pu,{className:`h-4 w-4 ${f(v.id)?"fill-primary text-primary":""}`}),p(v.id)]}),v.resources&&v.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-4 w-4"}),v.resources.length]})]})]})]})},v.id))})]})})};function OGe({resourceType:t,resourceId:s}){const{data:r=[]}=Ct({queryKey:["linked-templates",t,s],queryFn:async()=>{if(t==="academy_video"){const{data:n,error:a}=await G.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 G.from("resource_kit_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("kit_id",s);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}},enabled:!!s});return r.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-sm",children:[e.jsx(Bl,{className:"h-4 w-4"}),"Related Templates"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(n=>e.jsx(vo,{to:`/templates/${n.id}`,children:e.jsxs(at,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 transition-colors gap-1.5 px-3 py-1.5 text-xs font-medium rounded-full",children:[e.jsx(Bl,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const sDt=(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},rDt=()=>{const{videoId:t}=Mo();Dr();const{user:s,isAdmin:r}=Gs(),{toast:n}=Ia(),a=ns(),{trackEngagement:o}=FL(),[l,i]=S.useState(""),{data:d,isLoading:u}=Ct({queryKey:["academy-video",t],queryFn:async()=>{const{data:A,error:I}=await G.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 G.from("academy_resources").select("*").eq("video_id",t).order("sort_order");return{...A,resources:L||[]}},enabled:!!t});S.useEffect(()=>{d&&o("academy_video",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:p=[]}=Ct({queryKey:["academy-video-likes",t],queryFn:async()=>{const{data:A,error:I}=await G.from("academy_video_likes").select("*").eq("video_id",t);if(I)throw I;return A},enabled:!!t}),{data:f=[]}=Ct({queryKey:["academy-video-comments",t],queryFn:async()=>{const{data:A,error:I}=await G.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:R}=await G.from("profiles").select("id, name").in("id",L),$=new Map((R==null?void 0:R.map(q=>[q.id,q.name]))||[]);return A.map(q=>({...q,user_name:$.get(q.user_id)||"Unknown User"}))},enabled:!!t}),v=Ot({mutationFn:async A=>{const{error:I}=await G.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"})}}),_=Ot({mutationFn:async A=>{const{error:I}=await G.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=Ot({mutationFn:async()=>{const A=p.find(I=>I.user_id===(s==null?void 0:s.id));if(A){const{error:I}=await G.from("academy_video_likes").delete().eq("id",A.id);if(I)throw I}else{const{error:I}=await G.from("academy_video_likes").insert({video_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-likes",t]})}}),j=p.some(A=>A.user_id===(s==null?void 0:s.id)),w=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),C=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(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(vo,{to:"/academy",children:[e.jsx(Ua,{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:sDt(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(kn,{className:"h-16 w-16 opacity-50"}),e.jsx(K,{variant:"secondary",asChild:!0,children:e.jsxs("a",{href:d.video_url,target:"_blank",rel:"noopener noreferrer",className:"gap-2",children:[e.jsx(sn,{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(at,{variant:"secondary",children:d.category.name})]}),e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(vo,{to:`/admin/academy?edit=${d.id}`,children:[e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(SM,{resourceType:"academy_video",resourceId:d.id,resourceTitle:d.title}),e.jsxs(K,{variant:j?"default":"outline",className:"gap-2 w-fit",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(pu,{className:`h-4 w-4 ${j?"fill-current":""}`}),p.length," ",p.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(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(In,{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:w(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(xi,{className:"h-4 w-4 text-muted-foreground"})]},A.id))})]})}),e.jsx(OGe,{resourceType:"academy_video",resourceId:d.id}),e.jsx(Rl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(gc,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[e.jsx(Mr,{placeholder:"Add a comment...",value:l,onChange:A=>i(A.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||v.isPending,children:e.jsx(ka,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:f.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(A=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(gn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(xn,{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:Cd(new Date(A.created_at),{addSuffix:!0})}),A.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(A.id),children:e.jsx(br,{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(kn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Video not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This video may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(vo,{to:"/academy",children:"Back to Academy"})})]})})};function nDt(){const t=Dr(),[s,r]=S.useState(""),{data:n,isLoading:a}=Ct({queryKey:["resource-kits-published"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kits").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(b)throw b;return _}}),{data:o}=Ct({queryKey:["resource-kit-files-all"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(b)throw b;return _}}),{data:l}=Ct({queryKey:["resource-kit-likes-all"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kit_likes").select("kit_id");if(b)throw b;return _}}),{data:i}=Ct({queryKey:["resource-kit-comments-all"],queryFn:async()=>{const{data:_,error:b}=await G.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===_))||[],p=_=>(l==null?void 0:l.filter(b=>b.kit_id===_).length)||0,f=_=>(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(fn,{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(Ee,{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(Ee,{className:"p-12 text-center",children:[e.jsx(dl,{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,j=p(_.id),w=f(_.id);return e.jsxs(Ee,{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(dl,{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:Qie(_.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(In,{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(pu,{className:"h-3.5 w-3.5"}),j]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gc,{className:"h-3.5 w-3.5"}),w]})]})]})]})]},_.id)})})]})})}const aDt=()=>{const{kitId:t}=Mo(),{user:s,isAdmin:r}=Gs(),{toast:n}=Ia(),a=ns(),{trackEngagement:o}=FL(),[l,i]=S.useState(""),{data:d,isLoading:u}=Ct({queryKey:["resource-kit-detail",t],queryFn:async()=>{const{data:A,error:I}=await G.from("resource_kits").select("*").eq("id",t).eq("is_published",!0).single();if(I)throw I;const{data:L}=await G.from("resource_kit_files").select("*").eq("kit_id",t).order("sort_order"),{data:R}=await G.from("resource_kit_links").select("*").eq("kit_id",t).order("sort_order");return{...A,files:L||[],links:R||[]}},enabled:!!t});S.useEffect(()=>{d&&o("toolbox",d.id,d.name,"view")},[d==null?void 0:d.id]);const{data:p=[]}=Ct({queryKey:["resource-kit-likes",t],queryFn:async()=>{const{data:A,error:I}=await G.from("resource_kit_likes").select("*").eq("kit_id",t);if(I)throw I;return A},enabled:!!t}),{data:f=[]}=Ct({queryKey:["resource-kit-comments",t],queryFn:async()=>{const{data:A,error:I}=await G.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:R}=await G.from("profiles").select("id, name").in("id",L),$=new Map((R==null?void 0:R.map(q=>[q.id,q.name]))||[]);return A.map(q=>({...q,user_name:$.get(q.user_id)||"Unknown User"}))},enabled:!!t}),v=Ot({mutationFn:async A=>{const{error:I}=await G.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"})}}),_=Ot({mutationFn:async A=>{const{error:I}=await G.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=Ot({mutationFn:async()=>{const A=p.find(I=>I.user_id===(s==null?void 0:s.id));if(A){const{error:I}=await G.from("resource_kit_likes").delete().eq("id",A.id);if(I)throw I}else{const{error:I}=await G.from("resource_kit_likes").insert({kit_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-likes",t]})}}),j=p.some(A=>A.user_id===(s==null?void 0:s.id)),w=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":"",C=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(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(vo,{to:"/toolbox",children:[e.jsx(Ua,{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(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(vo,{to:`/admin/toolbox?edit=${d.id}`,children:[e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(SM,{resourceType:"resource_kit",resourceId:d.id,resourceTitle:d.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:j?"default":"outline",className:"gap-2 rounded-full",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(pu,{className:`h-4 w-4 ${j?"fill-current":""}`}),p.length," ",p.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(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(In,{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(In,{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(xi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},A.id))})]})}),d.links&&d.links.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(sn,{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(sn,{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(OGe,{resourceType:"resource_kit",resourceId:d.id}),e.jsx(Rl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(gc,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[e.jsx(Mr,{placeholder:"Add a comment...",value:l,onChange:A=>i(A.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||v.isPending,children:e.jsx(ka,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:f.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(A=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(gn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(xn,{className:"text-sm",children:w(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:Cd(new Date(A.created_at),{addSuffix:!0})}),A.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(A.id),children:e.jsx(br,{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(dl,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Resource kit not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This resource kit may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(vo,{to:"/toolbox",children:"Back to Toolbox"})})]})})},iDt=()=>{const t=Dr(),[s,r]=S.useState(""),[n,a]=S.useState("grid"),{data:o=[],isLoading:l}=Ct({queryKey:["social-swag"],queryFn:async()=>{const{data:u,error:p}=await G.from("social_swag").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(p)throw p;const{data:f,error:v}=await G.from("social_swag_links").select("*").order("sort_order");if(v)throw v;const{data:_}=await G.from("social_swag_likes").select("swag_id"),{data:b}=await G.from("social_swag_comments").select("swag_id"),j=new Map;_==null||_.forEach(C=>{j.set(C.swag_id,(j.get(C.swag_id)||0)+1)});const w=new Map;return b==null||b.forEach(C=>{w.set(C.swag_id,(w.get(C.swag_id)||0)+1)}),(u||[]).map(C=>({...C,links:(f||[]).filter(A=>A.swag_id===C.id)||[],likesCount:j.get(C.id)||0,commentsCount:w.get(C.id)||0}))}}),i=o.filter(u=>{var f;return u.title.toLowerCase().includes(s.toLowerCase())||((f=u.description)==null?void 0:f.toLowerCase().includes(s.toLowerCase()))}),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(fn,{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(K,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(mp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Uh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," item",i.length!==1?"s":""," found"]}),l&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(8)].map((u,p)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(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"})]})},p))}),!l&&i.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No items match your search":"No social swag available yet"}),s&&e.jsx(K,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&i.length>0&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:i.map(u=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${n==="list"?"flex flex-row":""}`,onClick:()=>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(at,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[e.jsx(Lo,{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(pu,{className:"h-3.5 w-3.5"}),u.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gc,{className:"h-3.5 w-3.5"}),u.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:p=>{p.stopPropagation(),d(u.id)},children:[e.jsx(sn,{className:"h-4 w-4"}),"View Details"]})]})]},u.id))})]})})};var ui=function(){return ui=Object.assign||function(s){for(var r,n=1,a=arguments.length;n1&&(d||!u),f=s>1&&(u||!d),v=function(){n&&o(n)},_=function(){a&&o(a)};return e.jsx(zDt,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:f,nextMonth:a,previousMonth:n,onPreviousClick:v,onNextClick:_})}function BDt(t){var s,r=Ul(),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:zGe,u;return a?u=e.jsx(d,{id:t.id,displayMonth:t.displayMonth}):l==="dropdown"?u=e.jsx(EAe,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?u=e.jsxs(e.Fragment,{children:[e.jsx(EAe,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(PAe,{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(PAe,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:u})}function $Dt(t){var s=Ul(),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 qDt(t,s,r){for(var n=r?Y0(new Date):ih(new Date,{locale:t,weekStartsOn:s}),a=[],o=0;o<7;o++){var l=ml(n,o);a.push(l)}return a}function UDt(){var t=Ul(),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=qDt(a,o,l);return e.jsxs("tr",{style:r.head_row,className:s.head_row,children:[n&&e.jsx("td",{style:r.head_cell,className:s.head_cell}),u.map(function(p,f){return e.jsx("th",{scope:"col",className:s.head_cell,style:r.head_cell,"aria-label":d(p,{locale:a}),children:i(p,{locale:a})},f)})]})}function VDt(){var t,s=Ul(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:UDt;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function HDt(t){var s=Ul(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var Xbe=S.createContext(void 0);function WDt(t){if(!zL(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(Xbe.Provider,{value:s,children:t.children})}return e.jsx(GDt,{initialProps:t.initialProps,children:t.children})}function GDt(t){var s=t.initialProps,r=t.children,n=s.selected,a=s.min,o=s.max,l=function(u,p,f){var v,_;(v=s.onDayClick)===null||v===void 0||v.call(s,u,p,f);var b=!!(p.selected&&a&&(n==null?void 0:n.length)===a);if(!b){var j=!!(!p.selected&&o&&(n==null?void 0:n.length)===o);if(!j){var w=n?RGe([],n):[];if(p.selected){var N=w.findIndex(function(C){return cl(u,C)});w.splice(N,1)}else w.push(u);(_=s.onSelect)===null||_===void 0||_.call(s,w,u,p,f)}}},i={disabled:[]};n&&i.disabled.push(function(u){var p=o&&n.length>o-1,f=n.some(function(v){return cl(v,u)});return!!(p&&!f)});var d={selected:n,onDayClick:l,modifiers:i};return e.jsx(Xbe.Provider,{value:d,children:r})}function Qbe(){var t=S.useContext(Xbe);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function KDt(t,s){var r=s||{},n=r.from,a=r.to;return n&&a?cl(a,t)&&cl(n,t)?void 0:cl(a,t)?{from:a,to:void 0}:cl(n,t)?void 0:PN(n,t)?{from:t,to:a}:{from:n,to:t}:a?PN(t,a)?{from:a,to:t}:{from:t,to:a}:n?IN(t,n)?{from:t,to:n}:{from:n,to:t}:{from:t,to:void 0}}var Jbe=S.createContext(void 0);function ZDt(t){if(!BL(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(Jbe.Provider,{value:s,children:t.children})}return e.jsx(YDt,{initialProps:t.initialProps,children:t.children})}function YDt(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,j){var w,N;(w=s.onDayClick)===null||w===void 0||w.call(s,_,b,j);var C=KDt(_,n);(N=s.onSelect)===null||N===void 0||N.call(s,C,_,b,j)},p={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(p.range_start=[o],l?(p.range_end=[l],cl(o,l)||(p.range_middle=[{after:o,before:l}])):p.range_end=[o]):l&&(p.range_start=[l],p.range_end=[l]),i&&(o&&!l&&p.disabled.push({after:sre(o,i-1),before:ml(o,i-1)}),o&&l&&p.disabled.push({after:o,before:ml(o,i-1)}),!o&&l&&p.disabled.push({after:sre(l,i-1),before:ml(l,i-1)})),d){if(o&&!l&&(p.disabled.push({before:ml(o,-d+1)}),p.disabled.push({after:ml(o,d-1)})),o&&l){var f=up(l,o)+1,v=d-f;p.disabled.push({before:sre(o,v)}),p.disabled.push({after:ml(l,v)})}!o&&l&&(p.disabled.push({before:ml(l,-d+1)}),p.disabled.push({after:ml(l,d-1)}))}return e.jsx(Jbe.Provider,{value:{selected:n,onDayClick:u,modifiers:p},children:r})}function ewe(){var t=S.useContext(Jbe);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function _re(t){return Array.isArray(t)?RGe([],t):t!==void 0?[t]:[]}function XDt(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=_re(a)}),s}var Kg;(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"})(Kg||(Kg={}));var QDt=Kg.Selected,Zy=Kg.Disabled,JDt=Kg.Hidden,eOt=Kg.Today,Dme=Kg.RangeEnd,Ome=Kg.RangeMiddle,Rme=Kg.RangeStart,tOt=Kg.Outside;function sOt(t,s,r){var n,a=(n={},n[QDt]=_re(t.selected),n[Zy]=_re(t.disabled),n[JDt]=_re(t.hidden),n[eOt]=[t.today],n[Dme]=[],n[Ome]=[],n[Rme]=[],n[tOt]=[],n);return t.fromDate&&a[Zy].push({before:t.fromDate}),t.toDate&&a[Zy].push({after:t.toDate}),zL(t)?a[Zy]=a[Zy].concat(s.modifiers[Zy]):BL(t)&&(a[Zy]=a[Zy].concat(r.modifiers[Zy]),a[Rme]=r.modifiers[Rme],a[Ome]=r.modifiers[Ome],a[Dme]=r.modifiers[Dme]),a}var qGe=S.createContext(void 0);function rOt(t){var s=Ul(),r=Qbe(),n=ewe(),a=sOt(s,r,n),o=XDt(s.modifiers),l=ui(ui({},a),o);return e.jsx(qGe.Provider,{value:l,children:t.children})}function UGe(){var t=S.useContext(qGe);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function nOt(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function aOt(t){return!!(t&&typeof t=="object"&&"from"in t)}function iOt(t){return!!(t&&typeof t=="object"&&"after"in t)}function oOt(t){return!!(t&&typeof t=="object"&&"before"in t)}function lOt(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function cOt(t,s){var r,n=s.from,a=s.to;if(n&&a){var o=up(a,n)<0;o&&(r=[a,n],n=r[0],a=r[1]);var l=up(t,n)>=0&&up(a,t)>=0;return l}return a?cl(a,t):n?cl(n,t):!1}function dOt(t){return K1e(t)}function uOt(t){return Array.isArray(t)&&t.every(K1e)}function hOt(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(dOt(r))return cl(t,r);if(uOt(r))return r.includes(t);if(aOt(r))return cOt(t,r);if(lOt(r))return r.dayOfWeek.includes(t.getDay());if(nOt(r)){var n=up(r.before,t),a=up(r.after,t),o=n>0,l=a<0,i=PN(r.before,r.after);return i?l&&o:o||l}return iOt(r)?up(t,r.after)>0:oOt(r)?up(r.before,t)>0:typeof r=="function"?r(t):!1})}function twe(t,s,r){var n=Object.keys(s).reduce(function(o,l){var i=s[l];return hOt(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!Aoe(t,r)&&(a.outside=!0),a}function mOt(t,s){for(var r=mc(t[0]),n=Kp(t[t.length-1]),a,o,l=r;l<=n;){var i=twe(l,s),d=!i.disabled&&!i.hidden;if(!d){l=ml(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=ml(l,1)}return o||a}var pOt=365;function VGe(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,p=a.toDate,f=a.locale,v={day:ml,week:Ck,month:Wh,year:rvt,startOfWeek:function(w){return a.ISOWeek?Y0(w):ih(w,{locale:f,weekStartsOn:d})},endOfWeek:function(w){return a.ISOWeek?A9e(w):Moe(w,{locale:f,weekStartsOn:d})}},_=v[r](t,n==="after"?1:-1);n==="before"&&u?_=nvt([u,_]):n==="after"&&p&&(_=avt([p,_]));var b=!0;if(o){var j=twe(_,o);b=!j.disabled&&!j.hidden}return b?_:i.count>pOt?i.lastFocused:VGe(_,{moveBy:r,direction:n,context:a,modifiers:o,retry:ui(ui({},i),{count:i.count+1})})}var HGe=S.createContext(void 0);function fOt(t){var s=$L(),r=UGe(),n=S.useState(),a=n[0],o=n[1],l=S.useState(),i=l[0],d=l[1],u=mOt(s.displayMonths,r),p=a??(i&&s.isDateDisplayed(i))?i:u,f=function(){d(a),o(void 0)},v=function(w){o(w)},_=Ul(),b=function(w,N){if(a){var C=VGe(a,{moveBy:w,direction:N,context:_,modifiers:r});cl(a,C)||(s.goToDate(C,a),v(C))}},j={focusedDay:a,focusTarget:p,blur:f,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(HGe.Provider,{value:j,children:t.children})}function swe(){var t=S.useContext(HGe);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function gOt(t,s){var r=UGe(),n=twe(t,r,s);return n}var rwe=S.createContext(void 0);function xOt(t){if(!xle(t.initialProps)){var s={selected:void 0};return e.jsx(rwe.Provider,{value:s,children:t.children})}return e.jsx(yOt,{initialProps:t.initialProps,children:t.children})}function yOt(t){var s=t.initialProps,r=t.children,n=function(o,l,i){var d,u,p;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}(p=s.onSelect)===null||p===void 0||p.call(s,o,o,l,i)},a={selected:s.selected,onDayClick:n};return e.jsx(rwe.Provider,{value:a,children:r})}function WGe(){var t=S.useContext(rwe);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function vOt(t,s){var r=Ul(),n=WGe(),a=Qbe(),o=ewe(),l=swe(),i=l.focusDayAfter,d=l.focusDayBefore,u=l.focusWeekAfter,p=l.focusWeekBefore,f=l.blur,v=l.focus,_=l.focusMonthBefore,b=l.focusMonthAfter,j=l.focusYearBefore,w=l.focusYearAfter,N=l.focusStartOfWeek,C=l.focusEndOfWeek,A=function(ae){var le,pe,be,ye;xle(r)?(le=n.onDayClick)===null||le===void 0||le.call(n,t,s,ae):zL(r)?(pe=a.onDayClick)===null||pe===void 0||pe.call(a,t,s,ae):BL(r)?(be=o.onDayClick)===null||be===void 0||be.call(o,t,s,ae):(ye=r.onDayClick)===null||ye===void 0||ye.call(r,t,s,ae)},I=function(ae){var le;v(t),(le=r.onDayFocus)===null||le===void 0||le.call(r,t,s,ae)},L=function(ae){var le;f(),(le=r.onDayBlur)===null||le===void 0||le.call(r,t,s,ae)},R=function(ae){var le;(le=r.onDayMouseEnter)===null||le===void 0||le.call(r,t,s,ae)},$=function(ae){var le;(le=r.onDayMouseLeave)===null||le===void 0||le.call(r,t,s,ae)},q=function(ae){var le;(le=r.onDayPointerEnter)===null||le===void 0||le.call(r,t,s,ae)},U=function(ae){var le;(le=r.onDayPointerLeave)===null||le===void 0||le.call(r,t,s,ae)},V=function(ae){var le;(le=r.onDayTouchCancel)===null||le===void 0||le.call(r,t,s,ae)},X=function(ae){var le;(le=r.onDayTouchEnd)===null||le===void 0||le.call(r,t,s,ae)},se=function(ae){var le;(le=r.onDayTouchMove)===null||le===void 0||le.call(r,t,s,ae)},te=function(ae){var le;(le=r.onDayTouchStart)===null||le===void 0||le.call(r,t,s,ae)},Y=function(ae){var le;(le=r.onDayKeyUp)===null||le===void 0||le.call(r,t,s,ae)},de=function(ae){var le;switch(ae.key){case"ArrowLeft":ae.preventDefault(),ae.stopPropagation(),r.dir==="rtl"?i():d();break;case"ArrowRight":ae.preventDefault(),ae.stopPropagation(),r.dir==="rtl"?d():i();break;case"ArrowDown":ae.preventDefault(),ae.stopPropagation(),u();break;case"ArrowUp":ae.preventDefault(),ae.stopPropagation(),p();break;case"PageUp":ae.preventDefault(),ae.stopPropagation(),ae.shiftKey?j():_();break;case"PageDown":ae.preventDefault(),ae.stopPropagation(),ae.shiftKey?w():b();break;case"Home":ae.preventDefault(),ae.stopPropagation(),N();break;case"End":ae.preventDefault(),ae.stopPropagation(),C();break}(le=r.onDayKeyDown)===null||le===void 0||le.call(r,t,s,ae)},ie={onClick:A,onFocus:I,onBlur:L,onKeyDown:de,onKeyUp:Y,onMouseEnter:R,onMouseLeave:$,onPointerEnter:q,onPointerLeave:U,onTouchCancel:V,onTouchEnd:X,onTouchMove:se,onTouchStart:te};return ie}function _Ot(){var t=Ul(),s=WGe(),r=Qbe(),n=ewe(),a=xle(t)?s.selected:zL(t)?r.selected:BL(t)?n.selected:void 0;return a}function bOt(t){return Object.values(Kg).includes(t)}function wOt(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(bOt(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function jOt(t,s){var r=ui({},t.styles.day);return Object.keys(s).forEach(function(n){var a;r=ui(ui({},r),(a=t.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function kOt(t,s,r){var n,a,o,l=Ul(),i=swe(),d=gOt(t,s),u=vOt(t,d),p=_Ot(),f=!!(l.onDayClick||l.mode!=="default");S.useEffect(function(){var R;d.outside||i.focusedDay&&f&&cl(i.focusedDay,t)&&((R=r.current)===null||R===void 0||R.focus())},[i.focusedDay,t,r,f,d.outside]);var v=wOt(l,d).join(" "),_=jOt(l,d),b=!!(d.outside&&!l.showOutsideDays||d.hidden),j=(o=(a=l.components)===null||a===void 0?void 0:a.DayContent)!==null&&o!==void 0?o:HDt,w=e.jsx(j,{date:t,displayMonth:s,activeModifiers:d}),N={style:_,className:v,children:w,role:"gridcell"},C=i.focusTarget&&cl(i.focusTarget,t)&&!d.outside,A=i.focusedDay&&cl(i.focusedDay,t),I=ui(ui(ui({},N),(n={disabled:d.disabled,role:"gridcell"},n["aria-selected"]=d.selected,n.tabIndex=A||C?0:-1,n)),u),L={isButton:f,isHidden:b,activeModifiers:d,selectedDays:p,buttonProps:I,divProps:N};return L}function NOt(t){var s=S.useRef(null),r=kOt(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(kae,ui({name:"day",ref:s},r.buttonProps)):e.jsx("div",ui({},r.divProps))}function SOt(t){var s=t.number,r=t.dates,n=Ul(),a=n.onWeekNumberClick,o=n.styles,l=n.classNames,i=n.locale,d=n.labels.labelWeekNumber,u=n.formatters.formatWeekNumber,p=u(Number(s),{locale:i});if(!a)return e.jsx("span",{className:l.weeknumber,style:o.weeknumber,children:p});var f=d(Number(s),{locale:i}),v=function(_){a(s,r,_)};return e.jsx(kae,{name:"week-number","aria-label":f,className:l.weeknumber,style:o.weeknumber,onClick:v,children:p})}function COt(t){var s,r,n=Ul(),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:NOt,u=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:SOt,p;return l&&(p=e.jsx("td",{className:o.cell,style:a.cell,children:e.jsx(u,{number:t.weekNumber,dates:t.dates})})),e.jsxs("tr",{className:o.row,style:a.row,children:[p,t.dates.map(function(f){return e.jsx("td",{className:o.cell,style:a.cell,role:"presentation",children:e.jsx(d,{displayMonth:t.displayMonth,date:f})},l1t(f))})]})}function IAe(t,s,r){for(var n=r!=null&&r.ISOWeek?A9e(s):Moe(s,r),a=r!=null&&r.ISOWeek?Y0(t):ih(t,r),o=up(n,a),l=[],i=0;i<=o;i++)l.push(ml(a,i));var d=l.reduce(function(u,p){var f=r!=null&&r.ISOWeek?Z1e(p):X1e(p,r),v=u.find(function(_){return _.weekNumber===f});return v?(v.dates.push(p),u):(u.push({weekNumber:f,dates:[p]}),u)},[]);return d}function MOt(t,s){var r=IAe(mc(t),Kp(t),s);if(s!=null&&s.useFixedWeeks){var n=d1t(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=Ck(o,6-n),i=IAe(Ck(o,1),l,s);r.push.apply(r,i)}}return r}function TOt(t){var s,r,n,a=Ul(),o=a.locale,l=a.classNames,i=a.styles,d=a.hideHead,u=a.fixedWeeks,p=a.components,f=a.weekStartsOn,v=a.firstWeekContainsDate,_=a.ISOWeek,b=MOt(t.displayMonth,{useFixedWeeks:!!u,ISOWeek:_,locale:o,weekStartsOn:f,firstWeekContainsDate:v}),j=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:VDt,w=(r=p==null?void 0:p.Row)!==null&&r!==void 0?r:COt,N=(n=p==null?void 0:p.Footer)!==null&&n!==void 0?n:$Dt;return e.jsxs("table",{id:t.id,className:l.table,style:i.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!d&&e.jsx(j,{}),e.jsx("tbody",{className:l.tbody,style:i.tbody,children:b.map(function(C){return e.jsx(w,{displayMonth:t.displayMonth,dates:C.dates,weekNumber:C.weekNumber},C.weekNumber)})}),e.jsx(N,{displayMonth:t.displayMonth})]})}function AOt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var EOt=AOt()?S.useLayoutEffect:S.useEffect,Fme=!1,POt=0;function LAe(){return"react-day-picker-".concat(++POt)}function IOt(t){var s,r=t??(Fme?LAe():null),n=S.useState(r),a=n[0],o=n[1];return EOt(function(){a===null&&o(LAe())},[]),S.useEffect(function(){Fme===!1&&(Fme=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function LOt(t){var s,r,n=Ul(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,d=$L().displayMonths,u=IOt(n.id?"".concat(n.id,"-").concat(t.displayIndex):void 0),p=n.id?"".concat(n.id,"-grid-").concat(t.displayIndex):void 0,f=[o.month],v=l.month,_=t.displayIndex===0,b=t.displayIndex===d.length-1,j=!_&&!b;a==="rtl"&&(s=[_,b],b=s[0],_=s[1]),_&&(f.push(o.caption_start),v=ui(ui({},v),l.caption_start)),b&&(f.push(o.caption_end),v=ui(ui({},v),l.caption_end)),j&&(f.push(o.caption_between),v=ui(ui({},v),l.caption_between));var w=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:BDt;return e.jsxs("div",{className:f.join(" "),style:v,children:[e.jsx(w,{id:u,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(TOt,{id:p,"aria-labelledby":u,displayMonth:t.displayMonth})]},t.displayIndex)}function DOt(t){var s=Ul(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function OOt(t){var s,r,n=t.initialProps,a=Ul(),o=swe(),l=$L(),i=S.useState(!1),d=i[0],u=i[1];S.useEffect(function(){a.initialFocus&&o.focusTarget&&(d||(o.focus(o.focusTarget),u(!0)))},[a.initialFocus,d,o.focus,o.focusTarget,o]);var p=[a.classNames.root,a.className];a.numberOfMonths>1&&p.push(a.classNames.multiple_months),a.showWeekNumber&&p.push(a.classNames.with_weeknumber);var f=ui(ui({},a.styles.root),a.style),v=Object.keys(n).filter(function(b){return b.startsWith("data-")}).reduce(function(b,j){var w;return ui(ui({},b),(w={},w[j]=n[j],w))},{}),_=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:DOt;return e.jsx("div",ui({className:p.join(" "),style:f,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,j){return e.jsx(LOt,{displayIndex:j,displayMonth:b},j)})})}))}function ROt(t){var s=t.children,r=oDt(t,["children"]);return e.jsx(SDt,{initialProps:r,children:e.jsx(ODt,{children:e.jsx(xOt,{initialProps:r,children:e.jsx(WDt,{initialProps:r,children:e.jsx(ZDt,{initialProps:r,children:e.jsx(rOt,{children:e.jsx(fOt,{children:s})})})})})})})}function FOt(t){return e.jsx(ROt,ui({},t,{children:e.jsx(OOt,{initialProps:t})}))}function yp({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(FOt,{showOutsideDays:r,className:Pt("p-3",t),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:Pt(WI({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:Pt(WI({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(zl,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(Ha,{className:"h-4 w-4"})},...n})}yp.displayName="Calendar";var yle="Popover",[GGe]=Ac(yle,[hy]),qL=hy(),[zOt,Y_]=GGe(yle),KGe=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=qL(s),d=S.useRef(null),[u,p]=S.useState(!1),[f,v]=xu({prop:n,defaultProp:a??!1,onChange:o,caller:yle});return e.jsx(mL,{...i,children:e.jsx(zOt,{scope:s,contentId:Gd(),triggerRef:d,open:f,onOpenChange:v,onOpenToggle:S.useCallback(()=>v(_=>!_),[v]),hasCustomAnchor:u,onCustomAnchorAdd:S.useCallback(()=>p(!0),[]),onCustomAnchorRemove:S.useCallback(()=>p(!1),[]),modal:l,children:r})})};KGe.displayName=yle;var ZGe="PopoverAnchor",BOt=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Y_(ZGe,r),o=qL(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return S.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx(oM,{...o,...n,ref:s})});BOt.displayName=ZGe;var YGe="PopoverTrigger",XGe=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Y_(YGe,r),o=qL(r),l=Pa(s,a.triggerRef),i=e.jsx(Qr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":sKe(a.open),...n,ref:l,onClick:Cr(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx(oM,{asChild:!0,...o,children:i})});XGe.displayName=YGe;var nwe="PopoverPortal",[$Ot,qOt]=GGe(nwe,{forceMount:void 0}),QGe=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=Y_(nwe,s);return e.jsx($Ot,{scope:s,forceMount:r,children:e.jsx(hd,{present:r||o.open,children:e.jsx(rM,{asChild:!0,container:a,children:n})})})};QGe.displayName=nwe;var S3="PopoverContent",JGe=S.forwardRef((t,s)=>{const r=qOt(S3,t.__scopePopover),{forceMount:n=r.forceMount,...a}=t,o=Y_(S3,t.__scopePopover);return e.jsx(hd,{present:n||o.open,children:o.modal?e.jsx(VOt,{...a,ref:s}):e.jsx(HOt,{...a,ref:s})})});JGe.displayName=S3;var UOt=j_("PopoverContent.RemoveScroll"),VOt=S.forwardRef((t,s)=>{const r=Y_(S3,t.__scopePopover),n=S.useRef(null),a=Pa(s,n),o=S.useRef(!1);return S.useEffect(()=>{const l=n.current;if(l)return uoe(l)},[]),e.jsx(vL,{as:UOt,allowPinchZoom:!0,children:e.jsx(eKe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Cr(t.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Cr(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:Cr(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),HOt=S.forwardRef((t,s)=>{const r=Y_(S3,t.__scopePopover),n=S.useRef(!1),a=S.useRef(!1);return e.jsx(eKe,{...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()}})}),eKe=S.forwardRef((t,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:p,...f}=t,v=Y_(S3,r),_=qL(r);return loe(),e.jsx(xL,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(R_,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:p,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>v.onOpenChange(!1),children:e.jsx(pL,{"data-state":sKe(v.open),role:"dialog",id:v.contentId,..._,...f,ref:s,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),tKe="PopoverClose",WOt=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Y_(tKe,r);return e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:Cr(t.onClick,()=>a.onOpenChange(!1))})});WOt.displayName=tKe;var GOt="PopoverArrow",KOt=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=qL(r);return e.jsx(fL,{...a,...n,ref:s})});KOt.displayName=GOt;function sKe(t){return t?"open":"closed"}var ZOt=KGe,YOt=XGe,XOt=QGe,rKe=JGe;const So=ZOt,Co=YOt,ko=S.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(XOt,{children:e.jsx(rKe,{ref:a,align:s,sideOffset:r,className:Pt("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));ko.displayName=rKe.displayName;const QOt=XN("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"}}),awe=S.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:Pt(QOt({variant:s}),t),...r}));awe.displayName="Alert";const JOt=S.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:Pt("mb-1 font-medium leading-none tracking-tight",t),...s}));JOt.displayName="AlertTitle";const iwe=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("text-sm [&_p]:leading-relaxed",t),...s}));iwe.displayName="AlertDescription";function e8t({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=ns(),[d,u]=S.useState(a),[p,f]=S.useState([]),[v,_]=S.useState(null),[b,j]=S.useState("now"),[w,N]=S.useState(E5e(R5e(new Date),1)),[C,A]=S.useState("12"),[I,L]=S.useState("00"),[R,$]=S.useState("PM");S.useEffect(()=>{if(t){u(a),j("now"),f([]);const ke=E5e(R5e(new Date),1);N(ke);const Ze=ke.getHours();A(String(Ze>12?Ze-12:Ze===0?12:Ze)),L("00"),$(Ze>=12?"PM":"AM")}},[t,a]);const q=()=>{if(!w)return null;let ke=parseInt(C);const Ze=parseInt(I);return R==="PM"&&ke!==12&&(ke+=12),R==="AM"&&ke===12&&(ke=0),HP(VP(w,ke),Ze)},{data:U,isLoading:V}=Ct({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:ke}}=await G.auth.getUser();if(!ke)return[];const{data:Ze,error:_e}=await G.from("social_accounts").select("*").eq("user_id",ke.id).eq("is_active",!0).order("platform",{ascending:!0});if(_e)throw _e;return console.log("Fetched social accounts for posting:",Ze),Ze},enabled:t,staleTime:0}),X=Ot({mutationFn:async({accountId:ke,platform:Ze})=>{_(ke);const{data:_e,error:Ce}=await G.functions.invoke("social-post",{body:{platform:Ze,accountId:ke,imageUrl:r,caption:d}});if(Ce)throw Ce;if(_e!=null&&_e.error)throw new Error(_e.error);return _e},onSuccess:ke=>{const Ze=ke.platform==="facebook"?"Facebook":ke.platform==="instagram"?"Instagram":ke.platform==="linkedin"?"LinkedIn":"Google Business";fe.success(`Posted to ${Ze}!`)},onError:ke=>{fe.error(`Failed to post: ${ke.message}`)},onSettled:()=>{_(null)}}),se=Ot({mutationFn:async({accountId:ke,platform:Ze,scheduledFor:_e})=>{const{data:{user:Ce}}=await G.auth.getUser();if(!Ce)throw new Error("Not authenticated");const{error:Te}=await G.from("scheduled_posts").insert({user_id:Ce.id,social_account_id:ke,platform:Ze,image_url:r,caption:d,swag_item_id:o||null,reel_id:l||null,scheduled_for:_e.toISOString(),status:"scheduled"});if(Te)throw Te;return{platform:Ze}},onSuccess:ke=>{const Ze=ke.platform==="facebook"?"Facebook":ke.platform==="instagram"?"Instagram":"LinkedIn";fe.success(`Post scheduled for ${Ze}!`)},onError:ke=>{fe.error(`Failed to schedule: ${ke.message}`)}}),te=async()=>{if(p.length===0){fe.error("Please select at least one account");return}if(b==="schedule"){const ke=q();if(!ke||ke<=new Date){fe.error("Please select a future date and time");return}for(const Ze of p){const _e=U==null?void 0:U.find(Ce=>Ce.id===Ze);_e&&await se.mutateAsync({accountId:Ze,platform:_e.platform,scheduledFor:ke})}i.invalidateQueries({queryKey:["scheduled-posts"]}),fe.success(`${p.length} post(s) scheduled for ${ws(ke,"PPp")}`)}else for(const ke of p){const Ze=U==null?void 0:U.find(_e=>_e.id===ke);Ze&&await X.mutateAsync({accountId:ke,platform:Ze.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),u(""),f([]),s(!1)},Y=ke=>{f(Ze=>Ze.includes(ke)?Ze.filter(_e=>_e!==ke):[...Ze,ke])},de=(U==null?void 0:U.filter(ke=>ke.platform==="facebook"))||[],ie=(U==null?void 0:U.filter(ke=>ke.platform==="instagram"))||[],ae=(U==null?void 0:U.filter(ke=>ke.platform==="linkedin"))||[],le=(U==null?void 0:U.filter(ke=>ke.platform==="google_business"))||[],pe=((U==null?void 0:U.length)||0)>0,be=X.isPending||se.isPending,ye=Array.from({length:12},(ke,Ze)=>String(Ze+1)),we=["00","15","30","45"];return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{htmlFor:"caption",children:"Caption"}),e.jsx(Mr,{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(ve,{children:"Publish Time"}),e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsx("button",{type:"button",onClick:()=>j("now"),className:Pt("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",b==="now"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Post Now"}),e.jsx("button",{type:"button",onClick:()=>j("schedule"),className:Pt("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",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(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("justify-start text-left font-normal flex-1",!w&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),w?ws(w,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(ko,{className:"w-auto p-0",align:"start",children:e.jsx(yp,{mode:"single",selected:w,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(sr,{})}),e.jsx(er,{children:we.map(ke=>e.jsx(At,{value:ke,children:ke},ke))})]}),e.jsxs(tr,{value:R,onValueChange:ke=>$(ke),children:[e.jsx(Js,{className:"w-[70px]",children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"AM",children:"AM"}),e.jsx(At,{value:"PM",children:"PM"})]})]})]})]}),w&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",ws(q()||new Date,"PPP 'at' p")]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Post to"}),V&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(As,{className:"h-6 w-6 animate-spin"})}),!V&&!pe&&e.jsxs(awe,{children:[e.jsx(Qo,{className:"h-4 w-4"}),e.jsxs(iwe,{className:"flex flex-col gap-2",children:[e.jsx("span",{children:"No social accounts connected yet."}),e.jsxs(vo,{to:"/social-connections",className:"inline-flex items-center gap-1.5 text-primary hover:underline font-medium",children:[e.jsx($l,{className:"h-3.5 w-3.5"}),"Connect your Facebook, Instagram & LinkedIn"]})]})]}),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(Hd,{className:"h-4 w-4 text-blue-600"})," Facebook"]}),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(zo,{checked:p.includes(ke.id),onCheckedChange:()=>Y(ke.id),disabled:v===ke.id}),e.jsxs(gn,{className:"h-8 w-8",children:[e.jsx(Ea,{src:ke.profile_picture_url||""}),e.jsx(xn,{children:e.jsx(Hd,{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(As,{className:"h-4 w-4 animate-spin"})]},ke.id))]}),ie.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(Wd,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),ie.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(zo,{checked:p.includes(ke.id),onCheckedChange:()=>Y(ke.id),disabled:v===ke.id}),e.jsxs(gn,{className:"h-8 w-8",children:[e.jsx(Ea,{src:ke.profile_picture_url||""}),e.jsx(xn,{children:e.jsx(Wd,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",ke.platform_username]}),v===ke.id&&e.jsx(As,{className:"h-4 w-4 animate-spin"})]},ke.id))]}),ae.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(Lm,{className:"h-4 w-4 text-blue-700"})," LinkedIn"]}),ae.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(zo,{checked:p.includes(ke.id),onCheckedChange:()=>Y(ke.id),disabled:v===ke.id}),e.jsxs(gn,{className:"h-8 w-8",children:[e.jsx(Ea,{src:ke.profile_picture_url||""}),e.jsx(xn,{children:e.jsx(Lm,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:ke.platform_username}),v===ke.id&&e.jsx(As,{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(Ai,{className:"h-4 w-4 text-red-600"})," Google Business"]}),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(zo,{checked:p.includes(ke.id),onCheckedChange:()=>Y(ke.id),disabled:v===ke.id}),e.jsxs(gn,{className:"h-8 w-8",children:[e.jsx(Ea,{src:ke.profile_picture_url||""}),e.jsx(xn,{children:e.jsx(Ai,{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(As,{className:"h-4 w-4 animate-spin"})]},ke.id))]})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:te,disabled:p.length===0||be,className:"gap-2",children:[be?e.jsx(As,{className:"h-4 w-4 animate-spin"}):b==="schedule"?e.jsx(on,{className:"h-4 w-4"}):e.jsx(ka,{className:"h-4 w-4"}),b==="schedule"?`Schedule ${p.length} post${p.length!==1?"s":""}`:`Post to ${p.length} account${p.length!==1?"s":""}`]})]})]})})}function t8t(){const t=ns(),[s,r]=S.useState(void 0),[n,a]=S.useState("all"),[o,l]=S.useState(null),[i,d]=S.useState(""),[u,p]=S.useState(void 0),[f,v]=S.useState("12"),[_,b]=S.useState("00"),[j,w]=S.useState("PM"),{data:N=[],isLoading:C}=Ct({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:le,error:pe}=await G.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(pe)throw pe;return le}}),A=N.filter(le=>{if(n!=="all"&&le.status!==n)return!1;if(s&&le.scheduled_for){const pe=new Date(le.scheduled_for);if(!cl(pe,s))return!1}return!0}),I=N.filter(le=>le.scheduled_for).map(le=>Gh(new Date(le.scheduled_for))),L=Ot({mutationFn:async le=>{const{error:pe}=await G.from("scheduled_posts").update({caption:le.caption,scheduled_for:le.scheduled_for}).eq("id",le.id);if(pe)throw pe},onSuccess:()=>{fe.success("Post updated!"),t.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:le=>{fe.error(`Failed to update: ${le.message}`)}}),R=Ot({mutationFn:async le=>{const{error:pe}=await G.from("scheduled_posts").update({status:"cancelled"}).eq("id",le);if(pe)throw pe},onSuccess:()=>{fe.success("Post cancelled"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{fe.error(`Failed to cancel: ${le.message}`)}}),$=Ot({mutationFn:async le=>{const{error:pe}=await G.from("scheduled_posts").delete().eq("id",le);if(pe)throw pe},onSuccess:()=>{fe.success("Post deleted"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{fe.error(`Failed to delete: ${le.message}`)}}),q=Ot({mutationFn:async le=>{const{data:pe,error:be}=await G.functions.invoke("social-post",{body:{platform:le.platform,accountId:le.social_account_id,imageUrl:le.image_url,caption:le.caption}});if(be)throw be;if(pe!=null&&pe.error)throw new Error(pe.error);return await G.from("scheduled_posts").update({status:"posted",posted_at:new Date().toISOString(),post_id:pe.postId}).eq("id",le.id),pe},onSuccess:le=>{const pe=le.platform==="facebook"?"Facebook":le.platform==="instagram"?"Instagram":"LinkedIn";fe.success(`Posted to ${pe}!`),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{fe.error(`Failed to post: ${le.message}`)}}),U=le=>{if(l(le),d(le.caption||""),le.scheduled_for){const pe=new Date(le.scheduled_for);p(pe);const be=pe.getHours();v(String(be>12?be-12:be===0?12:be)),b(String(pe.getMinutes()).padStart(2,"0")),w(be>=12?"PM":"AM")}},V=()=>{if(!o||!u)return;let le=parseInt(f);const pe=parseInt(_);j==="PM"&&le!==12&&(le+=12),j==="AM"&&le===12&&(le=0);const be=HP(VP(u,le),pe);L.mutate({id:o.id,caption:i,scheduled_for:be.toISOString()})},X=le=>{switch(le){case"facebook":return e.jsx(Hd,{className:"h-4 w-4 text-blue-600"});case"instagram":return e.jsx(Wd,{className:"h-4 w-4 text-pink-600"});case"linkedin":return e.jsx(Lm,{className:"h-4 w-4 text-blue-700"});default:return null}},se=le=>{switch(le){case"scheduled":return e.jsxs(at,{variant:"secondary",className:"gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(at,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(gi,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(at,{variant:"destructive",className:"gap-1",children:[e.jsx(kc,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return e.jsxs(at,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(Qo,{className:"h-3 w-3"}),"Cancelled"]});default:return e.jsx(at,{variant:"outline",children:le})}},te=Array.from({length:12},(le,pe)=>String(pe+1)),Y=["00","15","30","45"],de=N.filter(le=>le.status==="scheduled").length,ie=N.filter(le=>le.status==="posted").length,ae=N.filter(le=>le.status==="scheduled"&&le.scheduled_for&&u1t(new Date(le.scheduled_for))).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:de}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Scheduled"})]}),e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ae}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Upcoming"})]}),e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ie}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Posted"})]}),e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children: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(Ee,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(ld,{className:"h-5 w-5"}),e.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),e.jsx(yp,{mode:"single",selected:s,onSelect:r,className:Pt("pointer-events-auto"),modifiers:{hasPost:I},modifiersStyles:{hasPost:{fontWeight:"bold",backgroundColor:"hsl(var(--primary) / 0.1)",borderRadius:"50%"}}}),s&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>r(void 0),className:"w-full mt-2",children:"Clear date filter"})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hx,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:["all","scheduled","posted","failed","cancelled"].map(le=>e.jsx(K,{variant:n===le?"default":"outline",size:"sm",onClick:()=>a(le),className:"capitalize",children:le},le))})]}),C&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!C&&A.length===0&&e.jsxs(Ee,{className:"p-8 text-center",children:[e.jsx(on,{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 ${ws(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:A.map(le=>{var pe,be;return e.jsx(Ee,{className:"overflow-hidden",children:e.jsxs("div",{className:"flex flex-col sm:flex-row",children:[e.jsx("div",{className:"sm:w-32 h-32 sm:h-auto bg-muted flex-shrink-0",children:e.jsx("img",{src:le.image_url,alt:"Post preview",className:"w-full h-full object-cover"})}),e.jsxs(Oe,{className:"flex-1 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[X(le.platform),e.jsx("span",{className:"font-medium",children:((pe=le.social_accounts)==null?void 0:pe.page_name)||((be=le.social_accounts)==null?void 0:be.platform_username)||"Unknown"}),se(le.status)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[le.status==="scheduled"&&e.jsxs(QN,{children:[e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>U(le),children:e.jsx(Ra,{className:"h-4 w-4"})})}),e.jsx(Wc,{children:"Edit post"})]}),e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>q.mutate(le),disabled:q.isPending,children:q.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(ka,{className:"h-4 w-4"})})}),e.jsx(Wc,{children:"Post now"})]}),e.jsxs(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Cancel this scheduled post?"}),e.jsx(Dl,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Keep"}),e.jsx(xl,{onClick:()=>R.mutate(le.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),e.jsx(xl,{onClick:()=>$.mutate(le.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(le.status==="posted"||le.status==="cancelled"||le.status==="failed")&&e.jsxs(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete this post?"}),e.jsx(Dl,{children:"This will permanently remove this post from your history."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>$.mutate(le.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}),le.caption&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:le.caption}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),le.status==="posted"&&le.posted_at?`Posted ${ws(new Date(le.posted_at),"PPp")}`:le.scheduled_for?`Scheduled for ${ws(new Date(le.scheduled_for),"PPp")}`:"Not scheduled"]}),le.status==="failed"&&le.error_message&&e.jsxs("p",{className:"text-xs text-destructive mt-2",children:["Error: ",le.error_message]})]})]})},le.id)})})]})]}),e.jsx(vs,{open:!!o,onOpenChange:le=>!le&&l(null),children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{children:"Caption"}),e.jsx(Mr,{value:i,onChange:le=>d(le.target.value),rows:3})]}),e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[e.jsx(ve,{children:"Schedule for"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("justify-start text-left font-normal flex-1",!u&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),u?ws(u,"PPP"):"Pick a date"]})}),e.jsx(ko,{className:"w-auto p-0",align:"start",children:e.jsx(yp,{mode:"single",selected:u,onSelect:p,disabled:le=>lee.jsx(At,{value:le,children:le},le))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(tr,{value:_,onValueChange:b,children:[e.jsx(Js,{className:"w-[70px]",children:e.jsx(sr,{})}),e.jsx(er,{children:Y.map(le=>e.jsx(At,{value:le,children:le},le))})]}),e.jsxs(tr,{value:j,onValueChange:le=>w(le),children:[e.jsx(Js,{className:"w-[70px]",children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"AM",children:"AM"}),e.jsx(At,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{onClick:V,disabled:L.isPending,children:[L.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function sR(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 nKe={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */(function(t,s){(function(r){t.exports=r()})(function(){return function r(n,a,o){function l(u,p){if(!a[u]){if(!n[u]){var f=typeof sR=="function"&&sR;if(!p&&f)return f(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 j=n[u][1][b];return l(j||b)},_,_.exports,r,n,a,o)}return a[u].exports}for(var i=typeof sR=="function"&&sR,d=0;d>2,_=(3&u)<<4|p>>4,b=1>6:64,j=2>4,p=(15&v)<<4|(_=i.indexOf(d.charAt(j++)))>>2,f=(3&_)<<6|(b=i.indexOf(d.charAt(j++))),C[w++]=u,_!==64&&(C[w++]=p),b!==64&&(C[w++]=f);return C}},{"./support":30,"./utils":32}],2:[function(r,n,a){var o=r("./external"),l=r("./stream/DataWorker"),i=r("./stream/Crc32Probe"),d=r("./stream/DataLengthProbe");function u(p,f,v,_,b){this.compressedSize=p,this.uncompressedSize=f,this.crc32=v,this.compression=_,this.compressedContent=b}u.prototype={getContentWorker:function(){var p=new l(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new d("data_length")),f=this;return p.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),p},getCompressedWorker:function(){return new l(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(p,f,v){return p.pipe(new i).pipe(new d("uncompressedSize")).pipe(f.compressWorker(v)).pipe(new d("compressedSize")).withStreamInfo("compression",f)},n.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(r,n,a){var o=r("./stream/GenericWorker");a.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},a.DEFLATE=r("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(r,n,a){var o=r("./utils"),l=function(){for(var i,d=[],u=0;u<256;u++){i=u;for(var p=0;p<8;p++)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,p,f,v){var _=l,b=v+f;u^=-1;for(var j=v;j>>8^_[255&(u^p[j])];return-1^u}(0|d,i,i.length,0):function(u,p,f,v){var _=l,b=v+f;u^=-1;for(var j=v;j>>8^_[255&(u^p.charCodeAt(j))];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 p(f,v){d.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=v,this.meta={}}a.magic="\b\0",i.inherits(p,d),p.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(u,f.data),!1)},p.prototype.flush=function(){d.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},p.prototype.cleanUp=function(){d.prototype.cleanUp.call(this),this._pako=null},p.prototype._createPako=function(){this._pako=new l[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(v){f.push({data:v,meta:f.meta})}},a.compressWorker=function(f){return new p("Deflate",f)},a.uncompressWorker=function(){return new p("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,n,a){function o(_,b){var j,w="";for(j=0;j>>=8;return w}function l(_,b,j,w,N,C){var A,I,L=_.file,R=_.compression,$=C!==u.utf8encode,q=i.transformTo("string",C(L.name)),U=i.transformTo("string",u.utf8encode(L.name)),V=L.comment,X=i.transformTo("string",C(V)),se=i.transformTo("string",u.utf8encode(V)),te=U.length!==L.name.length,Y=se.length!==V.length,de="",ie="",ae="",le=L.dir,pe=L.date,be={crc32:0,compressedSize:0,uncompressedSize:0};b&&!j||(be.crc32=_.crc32,be.compressedSize=_.compressedSize,be.uncompressedSize=_.uncompressedSize);var ye=0;b&&(ye|=8),$||!te&&!Y||(ye|=2048);var we=0,ke=0;le&&(we|=16),N==="UNIX"?(ke=798,we|=function(_e,Ce){var Te=_e;return _e||(Te=Ce?16893:33204),(65535&Te)<<16}(L.unixPermissions,le)):(ke=20,we|=function(_e){return 63&(_e||0)}(L.dosPermissions)),A=pe.getUTCHours(),A<<=6,A|=pe.getUTCMinutes(),A<<=5,A|=pe.getUTCSeconds()/2,I=pe.getUTCFullYear()-1980,I<<=4,I|=pe.getUTCMonth()+1,I<<=5,I|=pe.getUTCDate(),te&&(ie=o(1,1)+o(p(q),4)+U,de+="up"+o(ie.length,2)+ie),Y&&(ae=o(1,1)+o(p(X),4)+se,de+="uc"+o(ae.length,2)+ae);var Ze="";return Ze+=` \0`,Ze+=o(ye,2),Ze+=R.magic,Ze+=o(A,2),Ze+=o(I,2),Ze+=o(be.crc32,4),Ze+=o(be.compressedSize,4),Ze+=o(be.uncompressedSize,4),Ze+=o(q.length,2),Ze+=o(de.length,2),{fileRecord:f.LOCAL_FILE_HEADER+Ze+q+de,dirRecord:f.CENTRAL_FILE_HEADER+o(ke,2)+Ze+o(X.length,2)+"\0\0\0\0"+o(we,4)+o(w,4)+q+de+X}}var i=r("../utils"),d=r("../stream/GenericWorker"),u=r("../utf8"),p=r("../crc32"),f=r("../signature");function v(_,b,j,w){d.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=j,this.encodeFileName=w,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,j=this.entriesCount,w=this._sources.length;this.accumulate?this.contentBuffer.push(_):(this.bytesWritten+=_.data.length,d.prototype.push.call(this,{data:_.data,meta:{currentFile:this.currentFile,percent:j?(b+100*(j-w-1))/j:100}}))},v.prototype.openedSource=function(_){this.currentSourceOffset=this.bytesWritten,this.currentFile=_.file.name;var b=this.streamFiles&&!_.file.dir;if(b){var j=l(_,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:j.fileRecord,meta:{percent:0}})}else this.accumulate=!0},v.prototype.closedSource=function(_){this.accumulate=!1;var b=this.streamFiles&&!_.file.dir,j=l(_,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(j.dirRecord),b)this.push({data:function(w){return f.DATA_DESCRIPTOR+o(w.crc32,4)+o(w.compressedSize,4)+o(w.uncompressedSize,4)}(_),meta:{percent:100}});else for(this.push({data:j.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"),p=r("./Uint8ArrayReader");n.exports=function(f){var v=o.getTypeOf(f);return o.checkSupport(v),v!=="string"||l.uint8array?v==="nodebuffer"?new u(f):l.uint8array?new p(o.transformTo("uint8array",f)):new i(o.transformTo("array",f)):new d(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(r,n,a){a.LOCAL_FILE_HEADER="PK",a.CENTRAL_FILE_HEADER="PK",a.CENTRAL_DIRECTORY_END="PK",a.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",a.ZIP64_CENTRAL_DIRECTORY_END="PK",a.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(r,n,a){var o=r("./GenericWorker"),l=r("../utils");function i(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(p){u.dataIsReady=!0,u.data=p,u.max=p&&p.length||0,u.type=o.getTypeOf(p),u.isPaused||u._tickAndRepeat()},function(p){u.error(p)})}o.inherits(i,l),i.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var 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"),p=r("../external"),f=null;if(u.nodestream)try{f=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function v(b,j){return new p.Promise(function(w,N){var C=[],A=b._internalType,I=b._outputType,L=b._mimeType;b.on("data",function(R,$){C.push(R),j&&j($)}).on("error",function(R){C=[],N(R)}).on("end",function(){try{var R=function($,q,U){switch($){case"blob":return o.newBlob(o.transformTo("arraybuffer",q),U);case"base64":return d.encode(q);default:return o.transformTo($,q)}}(I,function($,q){var U,V=0,X=null,se=0;for(U=0;U"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),p=0;p<256;p++)u[p]=252<=p?6:248<=p?5:240<=p?4:224<=p?3:192<=p?2:1;u[254]=u[254]=1;function f(){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 j,w,N,C,A,I=b.length,L=0;for(C=0;C>>6:(w<65536?j[A++]=224|w>>>12:(j[A++]=240|w>>>18,j[A++]=128|w>>>12&63),j[A++]=128|w>>>6&63),j[A++]=128|63&w);return j}(_)},a.utf8decode=function(_){return l.nodebuffer?o.transformTo("nodebuffer",_).toString("utf-8"):function(b){var j,w,N,C,A=b.length,I=new Array(2*A);for(j=w=0;j>10&1023,I[w++]=56320|1023&N)}return I.length!==w&&(I.subarray?I=I.subarray(0,w):I.length=w),o.applyFromCharCode(I)}(_=o.transformTo(l.uint8array?"uint8array":"array",_))},o.inherits(f,d),f.prototype.processChunk=function(_){var b=o.transformTo(l.uint8array?"uint8array":"array",_.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var j=b;(b=new Uint8Array(j.length+this.leftOver.length)).set(this.leftOver,0),b.set(j,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var w=function(C,A){var I;for((A=A||C.length)>C.length&&(A=C.length),I=A-1;0<=I&&(192&C[I])==128;)I--;return I<0||I===0?A:I+u[C[I]]>A?I:A}(b),N=b;w!==b.length&&(l.uint8array?(N=b.subarray(0,w),this.leftOver=b.subarray(w,b.length)):(N=b.slice(0,w),this.leftOver=b.slice(w,b.length))),this.push({data:a.utf8decode(N),meta:_.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:a.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},a.Utf8DecodeWorker=f,o.inherits(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(j){return j}function p(j,w){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,j,w,N=_.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});_.index+4>>6:(_<65536?v[w++]=224|_>>>12:(v[w++]=240|_>>>18,v[w++]=128|_>>>12&63),v[w++]=128|_>>>6&63),v[w++]=128|63&_);return v},a.buf2binstring=function(f){return p(f,f.length)},a.binstring2buf=function(f){for(var v=new o.Buf8(f.length),_=0,b=v.length;_>10&1023,C[b++]=56320|1023&j)}return p(C,b)},a.utf8border=function(f,v){var _;for((v=v||f.length)>f.length&&(v=f.length),_=v-1;0<=_&&(192&f[_])==128;)_--;return _<0||_===0?v:_+d[f[_]]>v?_:v}},{"./common":41}],43:[function(r,n,a){n.exports=function(o,l,i,d){for(var u=65535&o|0,p=o>>>16&65535|0,f=0;i!==0;){for(i-=f=2e3>>1:l>>>1;i[d]=l}return i}();n.exports=function(l,i,d,u){var p=o,f=u+d;l^=-1;for(var v=u;v>>8^p[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"),p=r("./messages"),f=0,v=4,_=0,b=-2,j=-1,w=4,N=2,C=8,A=9,I=286,L=30,R=19,$=2*I+1,q=15,U=3,V=258,X=V+U+1,se=42,te=113,Y=1,de=2,ie=3,ae=4;function le(he,Qe){return he.msg=p[Qe],Qe}function pe(he){return(he<<1)-(4he.avail_out&&(ot=he.avail_out),ot!==0&&(l.arraySet(he.output,Qe.pending_buf,Qe.pending_out,ot,he.next_out),he.next_out+=ot,Qe.pending_out+=ot,he.total_out+=ot,he.avail_out-=ot,Qe.pending-=ot,Qe.pending===0&&(Qe.pending_out=0))}function we(he,Qe){i._tr_flush_block(he,0<=he.block_start?he.block_start:-1,he.strstart-he.block_start,Qe),he.block_start=he.strstart,ye(he.strm)}function ke(he,Qe){he.pending_buf[he.pending++]=Qe}function Ze(he,Qe){he.pending_buf[he.pending++]=Qe>>>8&255,he.pending_buf[he.pending++]=255&Qe}function _e(he,Qe){var ot,rt,Ne=he.max_chain_length,it=he.strstart,qe=he.prev_length,Xe=he.nice_match,$e=he.strstart>he.w_size-X?he.strstart-(he.w_size-X):0,Ke=he.window,ct=he.w_mask,Ue=he.prev,Ve=he.strstart+V,Je=Ke[it+qe-1],Rt=Ke[it+qe];he.prev_length>=he.good_match&&(Ne>>=2),Xe>he.lookahead&&(Xe=he.lookahead);do if(Ke[(ot=Qe)+qe]===Rt&&Ke[ot+qe-1]===Je&&Ke[ot]===Ke[it]&&Ke[++ot]===Ke[it+1]){it+=2,ot++;do;while(Ke[++it]===Ke[++ot]&&Ke[++it]===Ke[++ot]&&Ke[++it]===Ke[++ot]&&Ke[++it]===Ke[++ot]&&Ke[++it]===Ke[++ot]&&Ke[++it]===Ke[++ot]&&Ke[++it]===Ke[++ot]&&Ke[++it]===Ke[++ot]&&it$e&&--Ne!=0);return qe<=he.lookahead?qe:he.lookahead}function Ce(he){var Qe,ot,rt,Ne,it,qe,Xe,$e,Ke,ct,Ue=he.w_size;do{if(Ne=he.window_size-he.lookahead-he.strstart,he.strstart>=Ue+(Ue-X)){for(l.arraySet(he.window,he.window,Ue,Ue,0),he.match_start-=Ue,he.strstart-=Ue,he.block_start-=Ue,Qe=ot=he.hash_size;rt=he.head[--Qe],he.head[Qe]=Ue<=rt?rt-Ue:0,--ot;);for(Qe=ot=Ue;rt=he.prev[--Qe],he.prev[Qe]=Ue<=rt?rt-Ue:0,--ot;);Ne+=Ue}if(he.strm.avail_in===0)break;if(qe=he.strm,Xe=he.window,$e=he.strstart+he.lookahead,Ke=Ne,ct=void 0,ct=qe.avail_in,Ke=U)for(it=he.strstart-he.insert,he.ins_h=he.window[it],he.ins_h=(he.ins_h<=U&&(he.ins_h=(he.ins_h<=U)if(rt=i._tr_tally(he,he.strstart-he.match_start,he.match_length-U),he.lookahead-=he.match_length,he.match_length<=he.max_lazy_match&&he.lookahead>=U){for(he.match_length--;he.strstart++,he.ins_h=(he.ins_h<=U&&(he.ins_h=(he.ins_h<=U&&he.match_length<=he.prev_length){for(Ne=he.strstart+he.lookahead-U,rt=i._tr_tally(he,he.strstart-1-he.prev_match,he.prev_length-U),he.lookahead-=he.prev_length-1,he.prev_length-=2;++he.strstart<=Ne&&(he.ins_h=(he.ins_h<he.pending_buf_size-5&&(ot=he.pending_buf_size-5);;){if(he.lookahead<=1){if(Ce(he),he.lookahead===0&&Qe===f)return Y;if(he.lookahead===0)break}he.strstart+=he.lookahead,he.lookahead=0;var rt=he.block_start+ot;if((he.strstart===0||he.strstart>=rt)&&(he.lookahead=he.strstart-rt,he.strstart=rt,we(he,!1),he.strm.avail_out===0)||he.strstart-he.block_start>=he.w_size-X&&(we(he,!1),he.strm.avail_out===0))return Y}return he.insert=0,Qe===v?(we(he,!0),he.strm.avail_out===0?ie:ae):(he.strstart>he.block_start&&(we(he,!1),he.strm.avail_out),Y)}),new Ae(4,4,8,4,Te),new Ae(4,5,16,8,Te),new Ae(4,6,32,32,Te),new Ae(4,4,16,16,Fe),new Ae(8,16,32,32,Fe),new Ae(8,16,128,128,Fe),new Ae(8,32,128,256,Fe),new Ae(32,128,258,1024,Fe),new Ae(32,258,258,4096,Fe)],a.deflateInit=function(he,Qe){return Dt(he,Qe,C,15,8,0)},a.deflateInit2=Dt,a.deflateReset=De,a.deflateResetKeep=ht,a.deflateSetHeader=function(he,Qe){return he&&he.state?he.state.wrap!==2?b:(he.state.gzhead=Qe,_):b},a.deflate=function(he,Qe){var ot,rt,Ne,it;if(!he||!he.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&&(he.adler=u(he.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 qe=C+(rt.w_bits-8<<4)<<8;qe|=(2<=rt.strategy||rt.level<2?0:rt.level<6?1:rt.level===6?2:3)<<6,rt.strstart!==0&&(qe|=32),qe+=31-qe%31,rt.status=te,Ze(rt,qe),rt.strstart!==0&&(Ze(rt,he.adler>>>16),Ze(rt,65535&he.adler)),he.adler=1}if(rt.status===69)if(rt.gzhead.extra){for(Ne=rt.pending;rt.gzindex<(65535&rt.gzhead.extra.length)&&(rt.pending!==rt.pending_buf_size||(rt.gzhead.hcrc&&rt.pending>Ne&&(he.adler=u(he.adler,rt.pending_buf,rt.pending-Ne,Ne)),ye(he),Ne=rt.pending,rt.pending!==rt.pending_buf_size));)ke(rt,255&rt.gzhead.extra[rt.gzindex]),rt.gzindex++;rt.gzhead.hcrc&&rt.pending>Ne&&(he.adler=u(he.adler,rt.pending_buf,rt.pending-Ne,Ne)),rt.gzindex===rt.gzhead.extra.length&&(rt.gzindex=0,rt.status=73)}else rt.status=73;if(rt.status===73)if(rt.gzhead.name){Ne=rt.pending;do{if(rt.pending===rt.pending_buf_size&&(rt.gzhead.hcrc&&rt.pending>Ne&&(he.adler=u(he.adler,rt.pending_buf,rt.pending-Ne,Ne)),ye(he),Ne=rt.pending,rt.pending===rt.pending_buf_size)){it=1;break}it=rt.gzindexNe&&(he.adler=u(he.adler,rt.pending_buf,rt.pending-Ne,Ne)),it===0&&(rt.gzindex=0,rt.status=91)}else rt.status=91;if(rt.status===91)if(rt.gzhead.comment){Ne=rt.pending;do{if(rt.pending===rt.pending_buf_size&&(rt.gzhead.hcrc&&rt.pending>Ne&&(he.adler=u(he.adler,rt.pending_buf,rt.pending-Ne,Ne)),ye(he),Ne=rt.pending,rt.pending===rt.pending_buf_size)){it=1;break}it=rt.gzindexNe&&(he.adler=u(he.adler,rt.pending_buf,rt.pending-Ne,Ne)),it===0&&(rt.status=103)}else rt.status=103;if(rt.status===103&&(rt.gzhead.hcrc?(rt.pending+2>rt.pending_buf_size&&ye(he),rt.pending+2<=rt.pending_buf_size&&(ke(rt,255&he.adler),ke(rt,he.adler>>8&255),he.adler=0,rt.status=te)):rt.status=te),rt.pending!==0){if(ye(he),he.avail_out===0)return rt.last_flush=-1,_}else if(he.avail_in===0&&pe(Qe)<=pe(ot)&&Qe!==v)return le(he,-5);if(rt.status===666&&he.avail_in!==0)return le(he,-5);if(he.avail_in!==0||rt.lookahead!==0||Qe!==f&&rt.status!==666){var Xe=rt.strategy===2?function($e,Ke){for(var ct;;){if($e.lookahead===0&&(Ce($e),$e.lookahead===0)){if(Ke===f)return Y;break}if($e.match_length=0,ct=i._tr_tally($e,0,$e.window[$e.strstart]),$e.lookahead--,$e.strstart++,ct&&(we($e,!1),$e.strm.avail_out===0))return Y}return $e.insert=0,Ke===v?(we($e,!0),$e.strm.avail_out===0?ie:ae):$e.last_lit&&(we($e,!1),$e.strm.avail_out===0)?Y:de}(rt,Qe):rt.strategy===3?function($e,Ke){for(var ct,Ue,Ve,Je,Rt=$e.window;;){if($e.lookahead<=V){if(Ce($e),$e.lookahead<=V&&Ke===f)return Y;if($e.lookahead===0)break}if($e.match_length=0,$e.lookahead>=U&&0<$e.strstart&&(Ue=Rt[Ve=$e.strstart-1])===Rt[++Ve]&&Ue===Rt[++Ve]&&Ue===Rt[++Ve]){Je=$e.strstart+V;do;while(Ue===Rt[++Ve]&&Ue===Rt[++Ve]&&Ue===Rt[++Ve]&&Ue===Rt[++Ve]&&Ue===Rt[++Ve]&&Ue===Rt[++Ve]&&Ue===Rt[++Ve]&&Ue===Rt[++Ve]&&Ve$e.lookahead&&($e.match_length=$e.lookahead)}if($e.match_length>=U?(ct=i._tr_tally($e,1,$e.match_length-U),$e.lookahead-=$e.match_length,$e.strstart+=$e.match_length,$e.match_length=0):(ct=i._tr_tally($e,0,$e.window[$e.strstart]),$e.lookahead--,$e.strstart++),ct&&(we($e,!1),$e.strm.avail_out===0))return Y}return $e.insert=0,Ke===v?(we($e,!0),$e.strm.avail_out===0?ie:ae):$e.last_lit&&(we($e,!1),$e.strm.avail_out===0)?Y:de}(rt,Qe):o[rt.level].func(rt,Qe);if(Xe!==ie&&Xe!==ae||(rt.status=666),Xe===Y||Xe===ie)return he.avail_out===0&&(rt.last_flush=-1),_;if(Xe===de&&(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(he),he.avail_out===0))return rt.last_flush=-1,_}return Qe!==v?_:rt.wrap<=0?1:(rt.wrap===2?(ke(rt,255&he.adler),ke(rt,he.adler>>8&255),ke(rt,he.adler>>16&255),ke(rt,he.adler>>24&255),ke(rt,255&he.total_in),ke(rt,he.total_in>>8&255),ke(rt,he.total_in>>16&255),ke(rt,he.total_in>>24&255)):(Ze(rt,he.adler>>>16),Ze(rt,65535&he.adler)),ye(he),0=ot.w_size&&(it===0&&(be(ot.head),ot.strstart=0,ot.block_start=0,ot.insert=0),Ke=new l.Buf8(ot.w_size),l.arraySet(Ke,Qe,ct-ot.w_size,ot.w_size,0),Qe=Ke,ct=ot.w_size),qe=he.avail_in,Xe=he.next_in,$e=he.input,he.avail_in=ct,he.next_in=0,he.input=Qe,Ce(ot);ot.lookahead>=U;){for(rt=ot.strstart,Ne=ot.lookahead-(U-1);ot.ins_h=(ot.ins_h<>>=U=q>>>24,A-=U,(U=q>>>16&255)===0)de[p++]=65535&q;else{if(!(16&U)){if(!(64&U)){q=I[(65535&q)+(C&(1<>>=U,A-=U),A<15&&(C+=Y[d++]<>>=U=q>>>24,A-=U,!(16&(U=q>>>16&255))){if(!(64&U)){q=L[(65535&q)+(C&(1<>>=U,A-=U,(U=p-f)>3,C&=(1<<(A-=V<<3))-1,o.next_in=d,o.next_out=p,o.avail_in=d>>24&255)+(se>>>8&65280)+((65280&se)<<8)+((255&se)<<24)}function C(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function 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(j),te.distcode=te.distdyn=new o.Buf32(w),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,de;return se&&se.state?(de=se.state,te<0?(Y=0,te=-te):(Y=1+(te>>4),te<48&&(te&=15)),te&&(te<8||15=ae.wsize?(o.arraySet(ae.window,te,Y-ae.wsize,ae.wsize,0),ae.wnext=0,ae.whave=ae.wsize):(de<(ie=ae.wsize-ae.wnext)&&(ie=de),o.arraySet(ae.window,te,Y-de,ie,ae.wnext),(de-=ie)?(o.arraySet(ae.window,te,Y-de,de,0),ae.wnext=de,ae.whave=ae.wsize):(ae.wnext+=ie,ae.wnext===ae.wsize&&(ae.wnext=0),ae.whave>>8&255,Y.check=i(Y.check,it,2,0),we=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(we-=4,he=8+(15&(ye>>>=4)),Y.wbits===0)Y.wbits=he;else if(he>Y.wbits){se.msg="invalid window size",Y.mode=30;break}Y.dmax=1<>8&1),512&Y.flags&&(it[0]=255&ye,it[1]=ye>>>8&255,Y.check=i(Y.check,it,2,0)),we=ye=0,Y.mode=3;case 3:for(;we<32;){if(pe===0)break e;pe--,ye+=de[ae++]<>>8&255,it[2]=ye>>>16&255,it[3]=ye>>>24&255,Y.check=i(Y.check,it,4,0)),we=ye=0,Y.mode=4;case 4:for(;we<16;){if(pe===0)break e;pe--,ye+=de[ae++]<>8),512&Y.flags&&(it[0]=255&ye,it[1]=ye>>>8&255,Y.check=i(Y.check,it,2,0)),we=ye=0,Y.mode=5;case 5:if(1024&Y.flags){for(;we<16;){if(pe===0)break e;pe--,ye+=de[ae++]<>>8&255,Y.check=i(Y.check,it,2,0)),we=ye=0}else Y.head&&(Y.head.extra=null);Y.mode=6;case 6:if(1024&Y.flags&&(pe<(_e=Y.length)&&(_e=pe),_e&&(Y.head&&(he=Y.head.extra_len-Y.length,Y.head.extra||(Y.head.extra=new Array(Y.head.extra_len)),o.arraySet(Y.head.extra,de,ae,_e,he)),512&Y.flags&&(Y.check=i(Y.check,de,_e,ae)),pe-=_e,ae+=_e,Y.length-=_e),Y.length))break e;Y.length=0,Y.mode=7;case 7:if(2048&Y.flags){if(pe===0)break e;for(_e=0;he=de[ae+_e++],Y.head&&he&&Y.length<65536&&(Y.head.name+=String.fromCharCode(he)),he&&_e>9&1,Y.head.done=!0),se.adler=Y.check=0,Y.mode=12;break;case 10:for(;we<32;){if(pe===0)break e;pe--,ye+=de[ae++]<>>=7&we,we-=7&we,Y.mode=27;break}for(;we<3;){if(pe===0)break e;pe--,ye+=de[ae++]<>>=1)){case 0:Y.mode=14;break;case 1:if(V(Y),Y.mode=20,te!==6)break;ye>>>=2,we-=2;break e;case 2:Y.mode=17;break;case 3:se.msg="invalid block type",Y.mode=30}ye>>>=2,we-=2;break;case 14:for(ye>>>=7&we,we-=7&we;we<32;){if(pe===0)break e;pe--,ye+=de[ae++]<>>16^65535)){se.msg="invalid stored block lengths",Y.mode=30;break}if(Y.length=65535&ye,we=ye=0,Y.mode=15,te===6)break e;case 15:Y.mode=16;case 16:if(_e=Y.length){if(pe<_e&&(_e=pe),be<_e&&(_e=be),_e===0)break e;o.arraySet(ie,de,ae,_e,le),pe-=_e,ae+=_e,be-=_e,le+=_e,Y.length-=_e;break}Y.mode=12;break;case 17:for(;we<14;){if(pe===0)break e;pe--,ye+=de[ae++]<>>=5,we-=5,Y.ndist=1+(31&ye),ye>>>=5,we-=5,Y.ncode=4+(15&ye),ye>>>=4,we-=4,286>>=3,we-=3}for(;Y.have<19;)Y.lens[qe[Y.have++]]=0;if(Y.lencode=Y.lendyn,Y.lenbits=7,ot={bits:Y.lenbits},Qe=u(0,Y.lens,0,19,Y.lencode,0,Y.work,ot),Y.lenbits=ot.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,We=65535&Ne,!((Fe=Ne>>>24)<=we);){if(pe===0)break e;pe--,ye+=de[ae++]<>>=Fe,we-=Fe,Y.lens[Y.have++]=We;else{if(We===16){for(rt=Fe+2;we>>=Fe,we-=Fe,Y.have===0){se.msg="invalid bit length repeat",Y.mode=30;break}he=Y.lens[Y.have-1],_e=3+(3&ye),ye>>>=2,we-=2}else if(We===17){for(rt=Fe+3;we>>=Fe)),ye>>>=3,we-=3}else{for(rt=Fe+7;we>>=Fe)),ye>>>=7,we-=7}if(Y.have+_e>Y.nlen+Y.ndist){se.msg="invalid bit length repeat",Y.mode=30;break}for(;_e--;)Y.lens[Y.have++]=he}}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,ot={bits:Y.lenbits},Qe=u(p,Y.lens,0,Y.nlen,Y.lencode,0,Y.work,ot),Y.lenbits=ot.bits,Qe){se.msg="invalid literal/lengths set",Y.mode=30;break}if(Y.distbits=6,Y.distcode=Y.distdyn,ot={bits:Y.distbits},Qe=u(f,Y.lens,Y.nlen,Y.ndist,Y.distcode,0,Y.work,ot),Y.distbits=ot.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<=pe&&258<=be){se.next_out=le,se.avail_out=be,se.next_in=ae,se.avail_in=pe,Y.hold=ye,Y.bits=we,d(se,Ze),le=se.next_out,ie=se.output,be=se.avail_out,ae=se.next_in,de=se.input,pe=se.avail_in,ye=Y.hold,we=Y.bits,Y.mode===12&&(Y.back=-1);break}for(Y.back=0;Ae=(Ne=Y.lencode[ye&(1<>>16&255,We=65535&Ne,!((Fe=Ne>>>24)<=we);){if(pe===0)break e;pe--,ye+=de[ae++]<>ht)])>>>16&255,We=65535&Ne,!(ht+(Fe=Ne>>>24)<=we);){if(pe===0)break e;pe--,ye+=de[ae++]<>>=ht,we-=ht,Y.back+=ht}if(ye>>>=Fe,we-=Fe,Y.back+=Fe,Y.length=We,Ae===0){Y.mode=26;break}if(32&Ae){Y.back=-1,Y.mode=12;break}if(64&Ae){se.msg="invalid literal/length code",Y.mode=30;break}Y.extra=15&Ae,Y.mode=22;case 22:if(Y.extra){for(rt=Y.extra;we>>=Y.extra,we-=Y.extra,Y.back+=Y.extra}Y.was=Y.length,Y.mode=23;case 23:for(;Ae=(Ne=Y.distcode[ye&(1<>>16&255,We=65535&Ne,!((Fe=Ne>>>24)<=we);){if(pe===0)break e;pe--,ye+=de[ae++]<>ht)])>>>16&255,We=65535&Ne,!(ht+(Fe=Ne>>>24)<=we);){if(pe===0)break e;pe--,ye+=de[ae++]<>>=ht,we-=ht,Y.back+=ht}if(ye>>>=Fe,we-=Fe,Y.back+=Fe,64&Ae){se.msg="invalid distance code",Y.mode=30;break}Y.offset=We,Y.extra=15&Ae,Y.mode=24;case 24:if(Y.extra){for(rt=Y.extra;we>>=Y.extra,we-=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(_e=Ze-be,Y.offset>_e){if((_e=Y.offset-_e)>Y.whave&&Y.sane){se.msg="invalid distance too far back",Y.mode=30;break}Ce=_e>Y.wnext?(_e-=Y.wnext,Y.wsize-_e):Y.wnext-_e,_e>Y.length&&(_e=Y.length),Te=Y.window}else Te=ie,Ce=le-Y.offset,_e=Y.length;for(be<_e&&(_e=be),be-=_e,Y.length-=_e;ie[le++]=Te[Ce++],--_e;);Y.length===0&&(Y.mode=21);break;case 26:if(be===0)break e;ie[le++]=Y.length,be--,Y.mode=21;break;case 27:if(Y.wrap){for(;we<32;){if(pe===0)break e;pe--,ye|=de[ae++]<$?(U=Ce[Te+w[te]],we[ke+w[te]]):(U=96,0),C=1<>le)+(A-=C)]=q<<24|U<<16|V|0,A!==0;);for(C=1<>=1;if(C!==0?(ye&=C-1,ye+=C):ye=0,te++,--Ze[se]==0){if(se===de)break;se=f[v+w[te]]}if(ie>>7)]}function ke(Ne,it){Ne.pending_buf[Ne.pending++]=255&it,Ne.pending_buf[Ne.pending++]=it>>>8&255}function Ze(Ne,it,qe){Ne.bi_valid>N-qe?(Ne.bi_buf|=it<>N-Ne.bi_valid,Ne.bi_valid+=qe-N):(Ne.bi_buf|=it<>>=1,qe<<=1,0<--it;);return qe>>>1}function Te(Ne,it,qe){var Xe,$e,Ke=new Array(w+1),ct=0;for(Xe=1;Xe<=w;Xe++)Ke[Xe]=ct=ct+qe[Xe-1]<<1;for($e=0;$e<=it;$e++){var Ue=Ne[2*$e+1];Ue!==0&&(Ne[2*$e]=Ce(Ke[Ue]++,Ue))}}function Fe(Ne){var it;for(it=0;it>1;1<=qe;qe--)ht(Ne,Ke,qe);for($e=Ve;qe=Ne.heap[1],Ne.heap[1]=Ne.heap[Ne.heap_len--],ht(Ne,Ke,1),Xe=Ne.heap[1],Ne.heap[--Ne.heap_max]=qe,Ne.heap[--Ne.heap_max]=Xe,Ke[2*$e]=Ke[2*qe]+Ke[2*Xe],Ne.depth[$e]=(Ne.depth[qe]>=Ne.depth[Xe]?Ne.depth[qe]:Ne.depth[Xe])+1,Ke[2*qe+1]=Ke[2*Xe+1]=$e,Ne.heap[1]=$e++,ht(Ne,Ke,1),2<=Ne.heap_len;);Ne.heap[--Ne.heap_max]=Ne.heap[1],function(Rt,$t){var ls,Qt,rs,as,ir,vt,Cs=$t.dyn_tree,or=$t.max_code,Ar=$t.stat_desc.static_tree,Wn=$t.stat_desc.has_stree,ai=$t.stat_desc.extra_bits,bo=$t.stat_desc.extra_base,Fa=$t.stat_desc.max_length,yn=0;for(as=0;as<=w;as++)Rt.bl_count[as]=0;for(Cs[2*Rt.heap[Rt.heap_max]+1]=0,ls=Rt.heap_max+1;ls>=7;$e<_;$e++)for(pe[$e]=Ke<<7,it=0;it<1<>>=1)if(1&Je&&Ue.dyn_ltree[2*Ve]!==0)return l;if(Ue.dyn_ltree[18]!==0||Ue.dyn_ltree[20]!==0||Ue.dyn_ltree[26]!==0)return i;for(Ve=32;Ve>>3,(Ke=Ne.static_len+3+7>>>3)<=$e&&($e=Ke)):$e=Ke=qe+5,qe+4<=$e&&it!==-1?rt(Ne,it,qe,Xe):Ne.strategy===4||Ke===$e?(Ze(Ne,2+(Xe?1:0),3),De(Ne,X,se)):(Ze(Ne,4+(Xe?1:0),3),function(Ue,Ve,Je,Rt){var $t;for(Ze(Ue,Ve-257,5),Ze(Ue,Je-1,5),Ze(Ue,Rt-4,4),$t=0;$t>>8&255,Ne.pending_buf[Ne.d_buf+2*Ne.last_lit+1]=255&it,Ne.pending_buf[Ne.l_buf+Ne.last_lit]=255&qe,Ne.last_lit++,it===0?Ne.dyn_ltree[2*qe]++:(Ne.matches++,it--,Ne.dyn_ltree[2*(Y[qe]+f+1)]++,Ne.dyn_dtree[2*we(it)]++),Ne.last_lit===Ne.lit_bufsize-1},a._tr_align=function(Ne){Ze(Ne,2,3),_e(Ne,A,X),function(it){it.bi_valid===16?(ke(it,it.bi_buf),it.bi_buf=0,it.bi_valid=0):8<=it.bi_valid&&(it.pending_buf[it.pending++]=255&it.bi_buf,it.bi_buf>>=8,it.bi_valid-=8)}(Ne)}},{"../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,p,f,v=1,_={},b=!1,j=l.document,w=Object.getPrototypeOf&&Object.getPrototypeOf(l);w=w&&w.setTimeout?w:l,d={}.toString.call(l.process)==="[object process]"?function(I){process.nextTick(function(){C(I)})}:function(){if(l.postMessage&&!l.importScripts){var I=!0,L=l.onmessage;return l.onmessage=function(){I=!1},l.postMessage("","*"),l.onmessage=L,I}}()?(f="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",A,!1):l.attachEvent("onmessage",A),function(I){l.postMessage(f+I,"*")}):l.MessageChannel?((p=new MessageChannel).port1.onmessage=function(I){C(I.data)},function(I){p.port2.postMessage(I)}):j&&"onreadystatechange"in j.createElement("script")?(u=j.documentElement,function(I){var L=j.createElement("script");L.onreadystatechange=function(){C(I),L.onreadystatechange=null,u.removeChild(L),L=null},u.appendChild(L)}):function(I){setTimeout(C,0,I)},w.setImmediate=function(I){typeof I!="function"&&(I=new Function(""+I));for(var L=new Array(arguments.length-1),R=0;R"u"?o===void 0?this:o:self)}).call(this,typeof f0<"u"?f0:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(nKe);var s8t=nKe.exports;const r8t=_o(s8t);function zme(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 n8t=()=>{const{isAdmin:t}=Gs(),[s,r]=S.useState(null),[n,a]=S.useState(null),[o,l]=S.useState("all"),[i,d]=S.useState(new Set),[u,p]=S.useState(!1),[f,v]=S.useState(!1),[_,b]=S.useState("images"),[j,w]=S.useState(null),{data:N=[],isLoading:C}=Ct({queryKey:["social-swag-2"],queryFn:async()=>{const{data:pe,error:be}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(be)throw be;return pe}}),{data:A=[]}=Ct({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:pe,error:be}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(be)throw be;return pe}}),{data:I=[]}=Ct({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:pe,error:be}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(be)throw be;return pe}}),{data:L=[]}=Ct({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:pe,error:be}=await G.from("social_accounts").select("id, platform").eq("is_active",!0);if(be)throw be;return pe||[]}}),R=L.length>0,$=S.useMemo(()=>o==="all"?null:I.find(pe=>pe.month===o)||null,[o,I]),q=S.useMemo(()=>[...new Set(N.map(be=>be.month))].sort((be,ye)=>ye.localeCompare(be)),[N]);S.useEffect(()=>{q.length>0&&o==="all"&&l(q[0])},[q,o]);const U=pe=>{try{const be=e_e(pe,"yyyy-MM",new Date);return ws(be,"MMMM yyyy")}catch{return pe}},V=S.useMemo(()=>o==="all"?N:N.filter(pe=>pe.month===o),[o,N]),X=S.useMemo(()=>{var pe;return o==="all"?null:((pe=A.find(be=>be.month===o))==null?void 0:pe.canva_link)||null},[o,A]),se=async pe=>{try{await navigator.clipboard.writeText(pe),fe.success("Caption copied to clipboard!")}catch{fe.error("Failed to copy caption")}},te=async(pe,be)=>{try{const we=await(await fetch(pe)).blob(),ke=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),Ze=navigator.canShare&&navigator.canShare({files:[new File([we],"test.jpg",{type:"image/jpeg"})]});if(ke&&Ze){const _e=new File([we],`social-swag-${be}.jpg`,{type:"image/jpeg"});await navigator.share({files:[_e],title:"Social Swag Image"}),fe.success("Image ready to save!")}else{const _e=window.URL.createObjectURL(we),Ce=document.createElement("a");Ce.href=_e,Ce.download=`social-swag-${be}.jpg`,document.body.appendChild(Ce),Ce.click(),document.body.removeChild(Ce),window.URL.revokeObjectURL(_e),fe.success("Image downloaded!")}}catch(ye){ye.name!=="AbortError"&&fe.error("Failed to download image")}},Y=pe=>{d(be=>{const ye=new Set(be);return ye.has(pe)?ye.delete(pe):ye.add(pe),ye})},de=()=>{d(new Set(V.map(pe=>pe.id)))},ie=()=>{d(new Set),p(!1)},ae=async()=>{const pe=V.filter(be=>i.has(be.id));if(pe.length===0){fe.error("No images selected");return}v(!0),fe.info(`Preparing ${pe.length} images for download...`);try{const be=new r8t,ye=[...pe].sort((Ce,Te)=>Ce.sort_order-Te.sort_order);for(let Ce=0;Ce{u?Y(pe.id):r(pe)};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(at,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(hn,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),e.jsxs(at,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(Jo,{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(Na,{defaultValue:"gallery",className:"space-y-6",children:[e.jsxs(va,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(ks,{value:"gallery",className:"gap-2",children:[e.jsx(Jo,{className:"h-4 w-4"}),"Gallery"]}),e.jsxs(ks,{value:"scheduled",className:"gap-2",children:[e.jsx(ld,{className:"h-4 w-4"}),"Scheduled"]})]}),e.jsxs(zs,{value:"gallery",className:"space-y-6",children:[t?R?e.jsx(Ee,{className:"border rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-muted text-2xl",children:"📸"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Ready to post!"}),e.jsx("p",{className:"text-muted-foreground",children:'Click any image and use "Create Post" to share directly to your connected accounts.'})]}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsx(vo,{to:"/social-connections",children:"Manage Accounts"})})]})})}):e.jsx(Ee,{className:"border-2 border-dashed border-primary/30 bg-gradient-to-r from-pink-500/5 via-purple-500/5 to-blue-500/5 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Hd,{className:"h-5 w-5 text-blue-600"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Wd,{className:"h-5 w-5 text-pink-600"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Post directly to social media"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your Facebook & Instagram accounts to post images with one click!"})]}),e.jsx(K,{asChild:!0,className:"gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600",children:e.jsxs(vo,{to:"/social-connections",children:[e.jsx(Ho,{className:"h-4 w-4"}),"Connect Accounts"]})})]})})}):e.jsx(Ee,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(Tn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Hd,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Wd,{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(at,{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(pe=>e.jsx("button",{onClick:()=>l(pe),className:Pt("px-4 py-2 rounded-full text-sm font-medium transition-all",o===pe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:U(pe)},pe))}),o!=="all"&&(X?e.jsxs("a",{href:X,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",U(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 ",U(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"),ie()},className:Pt("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(Jo,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{b("reels"),ie()},className:Pt("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(lu,{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(K,{variant:"outline",size:"sm",onClick:de,className:"gap-2",children:["Select All (",V.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,className:"gap-2",children:[e.jsx(Ur,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{size:"sm",onClick:ae,disabled:f,className:"gap-2",children:[e.jsx(xi,{className:"h-4 w-4"}),f?"Downloading...":`Download ${i.size} Selected`]}),e.jsx("span",{className:"text-xs text-muted-foreground hidden sm:inline",children:"Please ensure your browser allows downloads from the LevelUp Dashboard."})]})]}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[e.jsx(ua,{className:"h-4 w-4"}),"Select Images"]})})]}),C&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!C&&_==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(pe=>{const be=i.has(pe.id);return e.jsx(Ee,{className:Pt("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:()=>le(pe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:zme(pe.image_url,400,75),alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110",loading:"lazy",decoding:"async"}),pe.post_date&&!u&&e.jsx("div",{className:"absolute top-0 left-0 w-24 h-24 overflow-hidden pointer-events-none",children:e.jsx("div",{className:"absolute flex items-center justify-center text-white font-bold text-[10px] tracking-wider uppercase",style:{top:"20px",left:"-34px",width:"136px",transform:"rotate(-45deg)",backgroundColor:"#2d5052",padding:"5px 0",boxShadow:"0 2px 4px rgba(0,0,0,0.25)"},children:ws(new Date(pe.post_date+"T00:00:00"),"MMM d")})}),u&&e.jsx("div",{className:Pt("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",be?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:be&&e.jsx(ua,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},pe.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Jo,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!C&&_==="reels"&&e.jsx(e.Fragment,{children:$?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(Ee,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a($),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:zme($.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(at,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(lu,{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(lu,{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(vs,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(ys,{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:zme(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(on,{className:"h-4 w-4"}),ws(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(on,{className:"h-3.5 w-3.5"}),"Post on ",ws(new Date(s.post_date+"T00:00:00"),"MMMM d, yyyy")]})]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col gap-3 mt-6",children:[t&&e.jsxs(K,{onClick:()=>{w({imageUrl:s.image_url,imageId:s.id,caption:s.caption})},className:"w-full gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600 text-white",children:[e.jsx(ka,{className:"h-4 w-4"}),"Create Post"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(K,{variant:"outline",onClick:()=>se(s.caption),className:"flex-1 gap-2",children:[e.jsx(ni,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{variant:"outline",onClick:()=>te(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(xi,{className:"h-4 w-4"}),"Download"]})]})]})]})]})})})}),e.jsx(vs,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(ys,{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(lu,{className:"h-4 w-4"}),"Monthly Reel"]}),n.caption&&e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[n.caption&&e.jsxs(K,{onClick:()=>se(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(ni,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(K,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(sn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),e.jsx(e8t,{open:!!j,onOpenChange:pe=>!pe&&w(null),imageUrl:(j==null?void 0:j.imageUrl)||"",imageId:(j==null?void 0:j.imageId)||"",defaultCaption:(j==null?void 0:j.caption)||"",swagItemId:j==null?void 0:j.imageId})]}),e.jsx(zs,{value:"scheduled",children:e.jsx(t8t,{})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(Tn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Hd,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Wd,{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(at,{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(pe=>e.jsx("button",{onClick:()=>l(pe),className:Pt("px-4 py-2 rounded-full text-sm font-medium transition-all",o===pe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:U(pe)},pe))}),o!=="all"&&(X?e.jsxs("a",{href:X,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",U(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 ",U(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"),ie()},className:Pt("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(Jo,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{b("reels"),ie()},className:Pt("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(lu,{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(K,{variant:"outline",size:"sm",onClick:de,className:"gap-2",children:["Select All (",V.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,className:"gap-2",children:[e.jsx(Ur,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(K,{size:"sm",onClick:ae,disabled:f,className:"gap-2",children:[e.jsx(xi,{className:"h-4 w-4"}),f?"Downloading...":`Download ${i.size} Selected`]})]}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[e.jsx(ua,{className:"h-4 w-4"}),"Select Images"]})})]}),C&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!C&&_==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(pe=>{const be=i.has(pe.id);return e.jsx(Ee,{className:Pt("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:()=>le(pe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:pe.image_url,alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"}),u&&e.jsx("div",{className:Pt("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",be?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:be&&e.jsx(ua,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},pe.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Jo,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!C&&_==="reels"&&e.jsx(e.Fragment,{children:$?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(Ee,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a($),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:$.image_url,alt:"Reel preview",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs(at,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(lu,{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(lu,{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(vs,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(ys,{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(on,{className:"h-4 w-4"}),ws(new Date(s.created_at),"MMMM d, yyyy")]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[e.jsxs(K,{variant:"outline",onClick:()=>se(s.caption),className:"flex-1 gap-2",children:[e.jsx(ni,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{variant:"outline",onClick:()=>te(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(xi,{className:"h-4 w-4"}),"Download"]})]})]})]})})})}),e.jsx(vs,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(ys,{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(lu,{className:"h-4 w-4"}),"Monthly Reel"]}),n.caption&&e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[n.caption&&e.jsxs(K,{onClick:()=>se(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(ni,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(K,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(sn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},a8t=()=>{const{swagId:t}=Mo(),{user:s}=Gs(),{toast:r}=Ia(),n=ns(),{trackEngagement:a}=FL(),[o,l]=S.useState(""),{data:i,isLoading:d}=Ct({queryKey:["social-swag-detail",t],queryFn:async()=>{const{data:N,error:C}=await G.from("social_swag").select("*").eq("id",t).single();if(C)throw C;const{data:A}=await G.from("social_swag_links").select("*").eq("swag_id",t).order("sort_order");return{...N,links:A||[]}},enabled:!!t});S.useEffect(()=>{i&&a("social_swag",i.id,i.title,"view")},[i==null?void 0:i.id]);const{data:u=[]}=Ct({queryKey:["social-swag-likes",t],queryFn:async()=>{const{data:N,error:C}=await G.from("social_swag_likes").select("*").eq("swag_id",t);if(C)throw C;return N},enabled:!!t}),{data:p=[]}=Ct({queryKey:["social-swag-comments",t],queryFn:async()=>{const{data:N,error:C}=await G.from("social_swag_comments").select("*").eq("swag_id",t).order("created_at",{ascending:!1});if(C)throw C;const A=[...new Set(N.map(R=>R.user_id))],{data:I}=await G.from("profiles").select("id, name").in("id",A),L=new Map((I==null?void 0:I.map(R=>[R.id,R.name]))||[]);return N.map(R=>({...R,user_name:L.get(R.user_id)||"Unknown User"}))},enabled:!!t}),f=Ot({mutationFn:async N=>{const{error:C}=await G.from("social_swag_comments").insert({swag_id:t,user_id:s.id,content:N});if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),l(""),r({title:"Comment added!"})},onError:N=>{r({title:"Error adding comment",description:N.message,variant:"destructive"})}}),v=Ot({mutationFn:async N=>{const{error:C}=await G.from("social_swag_comments").delete().eq("id",N);if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),r({title:"Comment deleted"})}}),_=Ot({mutationFn:async()=>{const N=u.find(C=>C.user_id===(s==null?void 0:s.id));if(N){const{error:C}=await G.from("social_swag_likes").delete().eq("id",N.id);if(C)throw C}else{const{error:C}=await G.from("social_swag_likes").insert({swag_id:t,user_id:s.id});if(C)throw C}},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-likes",t]})}}),b=u.some(N=>N.user_id===(s==null?void 0:s.id)),j=N=>N.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),w=N=>{N.preventDefault(),!(!o.trim()||!s)&&f.mutate(o.trim())};return 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(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(vo,{to:"/social-swag",children:[e.jsx(Ua,{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(SM,{resourceType:"social_swag",resourceId:i.id,resourceTitle:i.title}),e.jsxs(K,{variant:b?"default":"outline",className:"gap-2 w-fit",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(pu,{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(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Lo,{className:"h-4 w-4"}),i.links.length===1?"Canva Link":"Canva Links"]}),e.jsx("div",{className:"grid gap-2",children:i.links.map(N=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{a("social_swag",i.id,i.title,"click_canva"),window.open(N.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:N.title}),e.jsx(sn,{className:"h-4 w-4 text-muted-foreground"})]},N.id))})]})}),e.jsx(Rl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(gc,{className:"h-5 w-5"}),"Comments (",p.length,")"]}),s?e.jsxs("form",{onSubmit:w,className:"flex gap-2",children:[e.jsx(Mr,{placeholder:"Add a comment...",value:o,onChange:N=>l(N.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!o.trim()||f.isPending,children:e.jsx(ka,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:p.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):p.map(N=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(gn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(xn,{className:"text-sm",children:j(N.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:N.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Cd(new Date(N.created_at),{addSuffix:!0})}),N.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>v.mutate(N.id),children:e.jsx(br,{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(Lo,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Item not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This item may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(vo,{to:"/social-swag",children:"Back to Social Swag"})})]})})},i8t=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=S.useState(!0),[i,d]=S.useState(!0),[u,p]=S.useState(!0),f=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(K,{variant:r==="all"?"secondary":"ghost",className:"w-full justify-start",onClick:()=>n("all"),children:[e.jsx(d5,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsxs(mf,{open:o,onOpenChange:l,children:[e.jsx(pf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",children:"Categories"}),o?e.jsx(Vo,{className:"h-4 w-4"}):e.jsx(Ha,{className:"h-4 w-4"})]})}),e.jsx(ff,{className:"space-y-1 pl-2",children:t.map(v=>e.jsxs(K,{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(mf,{open:i,onOpenChange:d,children:[e.jsx(pf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[e.jsx(zu,{className:"h-3 w-3"}),"Your Groups"]}),i?e.jsx(Vo,{className:"h-4 w-4"}):e.jsx(Ha,{className:"h-4 w-4"})]})}),e.jsx(ff,{className:"space-y-1 pl-2",children:s.map(v=>e.jsxs(K,{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(mf,{open:u,onOpenChange:p,children:[e.jsx(pf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"}),"Online Now",a.length>0&&e.jsx("span",{className:"ml-1 bg-green-500 text-white text-xs rounded-full px-1.5 py-0.5 min-w-[20px] text-center",children:a.length})]}),u?e.jsx(Vo,{className:"h-4 w-4"}):e.jsx(Ha,{className:"h-4 w-4"})]})}),e.jsx(ff,{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(gn,{className:"h-7 w-7",children:[e.jsx(Ea,{src:v.avatarUrl}),e.jsx(xn,{className:"text-xs",children:f(v.name)})]}),e.jsx(Gc,{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))})]})]})})})},o8t=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=S.useState(!1),i=u=>u.split(" ").map(p=>p[0]).join("").toUpperCase().slice(0,2),d=()=>{if(r==="all")return"All Posts";if(r.startsWith("group:")){const p=r.replace("group:",""),f=s.find(v=>v.id===p);return f?`🔒 ${f.name}`:"Private Group"}const u=t.find(p=>p.id===r);return u?`${u.icon||"📂"} ${u.name}`:"Category"};return e.jsxs("div",{className:"lg:hidden flex items-center gap-2 mb-4",children:[e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"flex-1 justify-between",children:[e.jsx("span",{className:"truncate",children:d()}),e.jsx(Vo,{className:"h-4 w-4 ml-2 shrink-0"})]})}),e.jsxs(Td,{className:"w-56 bg-background border",children:[e.jsxs(Ta,{onClick:()=>n("all"),children:[e.jsx(d5,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsx(S_,{}),e.jsx(jge,{className:"text-xs text-muted-foreground",children:"Categories"}),t.map(u=>e.jsxs(Ta,{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(S_,{}),e.jsxs(jge,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(zu,{className:"h-3 w-3"}),"Your Groups"]}),s.map(u=>e.jsxs(Ta,{onClick:()=>n(`group:${u.id}`),children:[e.jsx("span",{className:"mr-2",children:u.icon||"🔒"}),u.name]},u.id))]})]})]}),e.jsxs(gM,{open:o,onOpenChange:l,children:[e.jsx(r_e,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(hr,{className:"h-4 w-4"}),a.length>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-green-500 text-white text-xs rounded-full h-4 w-4 flex items-center justify-center",children:a.length})]})}),e.jsxs(rS,{children:[e.jsx(xM,{children:e.jsxs(yM,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(Bi,{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(gn,{className:"h-10 w-10",children:[e.jsx(Ea,{src:u.avatarUrl}),e.jsx(xn,{children:i(u.name)})]}),e.jsx(Gc,{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 Bme,vle="HoverCard",[aKe]=Ac(vle,[hy]),_le=hy(),[l8t,owe]=aKe(vle),iKe=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,d=_le(s),u=S.useRef(0),p=S.useRef(0),f=S.useRef(!1),v=S.useRef(!1),[_,b]=xu({prop:n,defaultProp:a??!1,onChange:o,caller:vle}),j=S.useCallback(()=>{clearTimeout(p.current),u.current=window.setTimeout(()=>b(!0),l)},[l,b]),w=S.useCallback(()=>{clearTimeout(u.current),!f.current&&!v.current&&(p.current=window.setTimeout(()=>b(!1),i))},[i,b]),N=S.useCallback(()=>b(!1),[b]);return S.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(p.current)},[]),e.jsx(l8t,{scope:s,open:_,onOpenChange:b,onOpen:j,onClose:w,onDismiss:N,hasSelectionRef:f,isPointerDownOnContentRef:v,children:e.jsx(mL,{...d,children:r})})};iKe.displayName=vle;var oKe="HoverCardTrigger",lKe=S.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=owe(oKe,r),o=_le(r);return e.jsx(oM,{asChild:!0,...o,children:e.jsx(Qr.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:Cr(t.onPointerEnter,Sae(a.onOpen)),onPointerLeave:Cr(t.onPointerLeave,Sae(a.onClose)),onFocus:Cr(t.onFocus,a.onOpen),onBlur:Cr(t.onBlur,a.onClose),onTouchStart:Cr(t.onTouchStart,l=>l.preventDefault())})})});lKe.displayName=oKe;var c8t="HoverCardPortal",[V1s,d8t]=aKe(c8t,{forceMount:void 0}),Nae="HoverCardContent",cKe=S.forwardRef((t,s)=>{const r=d8t(Nae,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=owe(Nae,t.__scopeHoverCard);return e.jsx(hd,{present:n||o.open,children:e.jsx(u8t,{"data-state":o.open?"open":"closed",...a,onPointerEnter:Cr(t.onPointerEnter,Sae(o.onOpen)),onPointerLeave:Cr(t.onPointerLeave,Sae(o.onClose)),ref:s})})});cKe.displayName=Nae;var u8t=S.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,d=owe(Nae,r),u=_le(r),p=S.useRef(null),f=Pa(s,p),[v,_]=S.useState(!1);return S.useEffect(()=>{if(v){const b=document.body;return Bme=b.style.userSelect||b.style.webkitUserSelect,b.style.userSelect="none",b.style.webkitUserSelect="none",()=>{b.style.userSelect=Bme,b.style.webkitUserSelect=Bme}}},[v]),S.useEffect(()=>{if(p.current){const b=()=>{_(!1),d.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var w;((w=document.getSelection())==null?void 0:w.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]),S.useEffect(()=>{p.current&&p8t(p.current).forEach(j=>j.setAttribute("tabindex","-1"))}),e.jsx(R_,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:Cr(o,b=>{b.preventDefault()}),onDismiss:d.onDismiss,children:e.jsx(pL,{...u,...i,onPointerDown:Cr(i.onPointerDown,b=>{b.currentTarget.contains(b.target)&&_(!0),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!0}),ref:f,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)"}})})}),h8t="HoverCardArrow",m8t=S.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=_le(r);return e.jsx(fL,{...a,...n,ref:s})});m8t.displayName=h8t;function Sae(t){return s=>s.pointerType==="touch"?void 0:t()}function p8t(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 f8t=iKe,g8t=lKe,dKe=cKe;const x8t=f8t,y8t=g8t,uKe=S.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(dKe,{ref:a,align:s,sideOffset:r,className:Pt("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));uKe.displayName=dKe.displayName;const v8t=[{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"}],_8t=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2),hKe=({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(x8t,{openDelay:200,closeDelay:100,children:[e.jsx(y8t,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:s})}),e.jsx(uKe,{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=v8t.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(gn,{className:"h-6 w-6",children:[e.jsx(Ea,{src:l.user_avatar||void 0}),e.jsx(xn,{className:"text-[10px]",children:_8t(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 b8t({images:t,initialIndex:s=0,open:r,onOpenChange:n}){const[a,o]=S.useState(s),[l,i]=S.useState(!1);S.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]);S.useEffect(()=>(window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)),[p]);const f=t[a];return e.jsx(vs,{open:r,onOpenChange:n,children:e.jsxs(ys,{className:"max-w-[95vw] max-h-[95vh] w-auto h-auto p-0 border-none bg-black/95 overflow-hidden",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 z-50 text-white hover:bg-white/20 h-10 w-10",onClick:()=>n(!1),children:e.jsx(Ur,{className:"h-6 w-6"})}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:d,children:e.jsx(zl,{className:"h-8 w-8"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:u,children:e.jsx(Ha,{className:"h-8 w-8"})})]}),t.length>1&&e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-50 text-white text-sm bg-black/50 px-3 py-1 rounded-full",children:[a+1," / ",t.length]}),(f==null?void 0:f.type)==="image"&&e.jsx(K,{variant:"ghost",size:"icon",className:"absolute top-2 left-2 z-50 text-white hover:bg-white/20 h-10 w-10",onClick:()=>i(!l),children:l?e.jsx(k5,{className:"h-5 w-5"}):e.jsx(c_,{className:"h-5 w-5"})}),e.jsx("div",{className:Pt("flex items-center justify-center w-full h-full min-h-[50vh] p-4",l?"cursor-zoom-out overflow-auto":"cursor-zoom-in"),onClick:()=>(f==null?void 0:f.type)==="image"&&i(!l),children:(f==null?void 0:f.type)==="video"?e.jsx("video",{src:f.url,controls:!0,autoPlay:!0,className:"max-w-full max-h-[85vh] object-contain",onClick:v=>v.stopPropagation()}):e.jsx("img",{src:f==null?void 0:f.url,alt:"",className:Pt("object-contain transition-transform duration-200",l?"max-w-none max-h-none scale-150":"max-w-full max-h-[85vh]")})}),t.length>1&&e.jsx("div",{className:"absolute bottom-12 left-1/2 -translate-x-1/2 z-50 flex gap-2 bg-black/50 p-2 rounded-lg max-w-[90vw] overflow-x-auto",children:t.map((v,_)=>e.jsx("button",{onClick:()=>{o(_),i(!1)},className:Pt("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 rR=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],w8t=({commentId:t,reactions:s,currentUserId:r})=>{var u,p;const n=ns(),[a,o]=S.useState(!1),l=s.find(f=>f.user_id===r),i=Ot({mutationFn:async f=>{l?l.reaction_type===f?await G.from("community_comment_reactions").delete().eq("id",l.id):await G.from("community_comment_reactions").update({reaction_type:f}).eq("id",l.id):await G.from("community_comment_reactions").insert({comment_id:t,user_id:r,reaction_type:f})},onSuccess:()=>{n.invalidateQueries({queryKey:["community-posts"]}),o(!1)}}),d={};return s.forEach(f=>{d[f.reaction_type]=(d[f.reaction_type]||0)+1}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.length>0&&e.jsx(hKe,{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(f=>{var v;return e.jsx("span",{className:"text-sm",children:(v=rR.find(_=>_.type===f))==null?void 0:v.emoji},f)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs(So,{open:a,onOpenChange:o,children:[e.jsx(Co,{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=rR.find(f=>f.type===l.reaction_type))==null?void 0:u.emoji," ",(p=rR.find(f=>f.type===l.reaction_type))==null?void 0:p.label]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Si,{className:"h-3 w-3"}),"Like"]})})}),e.jsx(ko,{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:rR.map(f=>e.jsx("button",{onClick:()=>i.mutate(f.type),className:"text-xl hover:scale-125 transition-transform p-1",title:f.label,children:f.emoji},f.type))})})]})]})};function lwe({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],p=i==="#";n.push(e.jsx(vo,{to:p?`/templates/${u}`:`/profile?user=${u}`,className:Pt("font-medium hover:underline",p?"text-white bg-[#2a4c64] px-1.5 py-0.5 rounded":"text-primary"),onClick:f=>f.stopPropagation(),children:p?d:`@${d}`},`mention-${l++}`))}else if(o[4]){const i=o[4],d=i.replace(/[.,;:!?)]+$/,""),u=i.slice(d.length);let p;try{const f=new URL(d);p=f.hostname+(f.pathname!=="/"?f.pathname.slice(0,20)+(f.pathname.length>20?"...":""):"")}catch{p=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:f=>f.stopPropagation(),children:p},`url-${l++}`)),u&&n.push(u)}a=o.index+o[0].length}return ae.jsx(S.Fragment,{children:i},d))})}function Cae({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 p=S.useRef(null),f=S.useRef(null),[v,_]=S.useState(!1),[b,j]=S.useState("user"),[w,N]=S.useState(""),[C,A]=S.useState(null),[I,L]=S.useState(0),[R,$]=S.useState({top:0,left:0,width:0}),q=S.useRef(new Map),U=S.useRef(new Map),V=we=>{if(d==="plain"){const Ce=[];return q.current.forEach((Fe,Ae)=>{we.includes(`@${Ae}`)&&Ce.push(Fe)}),[...new Set(Ce)]}const ke=/@\[([^\]]+)\]\(([^)]+)\)/g,Ze=[];let _e;for(;(_e=ke.exec(we))!==null;)Ze.push(_e[2]);return[...new Set(Ze)]},X=we=>{if(d==="plain"){const Ce=[];return U.current.forEach((Fe,Ae)=>{we.includes(`#${Ae}`)&&Ce.push(Fe)}),[...new Set(Ce)]}const ke=/#\[([^\]]+)\]\(([^)]+)\)/g,Ze=[];let _e;for(;(_e=ke.exec(we))!==null;)Ze.push(_e[2]);return[...new Set(Ze)]};S.useEffect(()=>{if(o){const we=V(t);o(we)}if(l){const we=X(t);l(we)}},[t,o,l,d]);const{data:se=[],isLoading:te}=Ct({queryKey:["mention-users",w],queryFn:async()=>{const we=G.from("profiles").select("id, name").limit(8),ke=w.length>=1?we.ilike("name",`%${w}%`):we.order("name"),{data:Ze,error:_e}=await ke;if(_e)throw _e;const Ce=Ze.map(Fe=>Fe.id),Te=await G9e(Ce);return Ze.map(Fe=>({id:Fe.id,name:Fe.name||"Unknown",avatar_url:Te.get(Fe.id)}))},enabled:v&&b==="user",staleTime:3e4}),{data:Y=[],isLoading:de}=Ct({queryKey:["mention-templates",w],queryFn:async()=>{let we=G.from("canva_templates").select("id, name, preview_image_url").lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(8);w.length>=1&&(we=we.ilike("name",`%${w}%`));const{data:ke,error:Ze}=await we;if(Ze)throw Ze;return ke||[]},enabled:v&&b==="template"&&u,staleTime:3e4}),ie=b==="user"?te:de,ae=b==="user"?se:Y,le=we=>we.split(" ").map(ke=>ke[0]).join("").toUpperCase().slice(0,2),pe=we=>{const ke=we.target.value,Ze=we.target.selectionStart;s(ke);const _e=ke.substring(0,Ze),Ce=_e.lastIndexOf("@"),Te=u?_e.lastIndexOf("#"):-1;let Fe=-1,Ae="user";if(Ce>Te?(Fe=Ce,Ae="user"):Te>Ce&&u&&(Fe=Te,Ae="template"),Fe!==-1){const We=_e.substring(Fe+1),ht=We.includes(" "),De=We.includes(` `);if(!ht&&!De&&We.length<=30){A(Fe),N(We),j(Ae),_(!0),L(0);return}}_(!1),A(null)},be=we=>{if(C===null)return;const ke=t.substring(0,C),Ze=t.substring(C+w.length+1),_e=b==="user"?"@":"#",Ce=d==="plain"?`${_e}${we.name} `:`${_e}[${we.name}](${we.id}) `;d==="plain"&&(b==="user"?q.current.set(we.name,we.id):U.current.set(we.name,we.id));const Te=ke+Ce+Ze;s(Te),_(!1),A(null),N(""),setTimeout(()=>{if(p.current){const Fe=ke.length+Ce.length;p.current.focus(),p.current.setSelectionRange(Fe,Fe)}},0)},ye=we=>{if(!(!v||ae.length===0))switch(we.key){case"ArrowDown":we.preventDefault(),L(ke=>(ke+1)%ae.length);break;case"ArrowUp":we.preventDefault(),L(ke=>(ke-1+ae.length)%ae.length);break;case"Enter":ae[I]&&(we.preventDefault(),be(ae[I]));break;case"Escape":we.preventDefault(),_(!1);break;case"Tab":ae[I]&&(we.preventDefault(),be(ae[I]));break}};return S.useEffect(()=>{const we=ke=>{f.current&&!f.current.contains(ke.target)&&p.current&&!p.current.contains(ke.target)&&_(!1)};return document.addEventListener("mousedown",we),()=>document.removeEventListener("mousedown",we)},[]),S.useEffect(()=>{if(!v)return;const we=()=>{const ke=p.current;if(!ke)return;const Ze=ke.getBoundingClientRect();$({top:Ze.bottom+4,left:Ze.left,width:Ze.width})};return we(),window.addEventListener("resize",we),window.addEventListener("scroll",we,!0),()=>{window.removeEventListener("resize",we),window.removeEventListener("scroll",we,!0)}},[v,t]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Mr,{ref:p,value:t,onChange:pe,onKeyDown:we=>{ye(we),we.defaultPrevented||i==null||i(we)},placeholder:r,className:Pt("resize-none",n),style:{minHeight:a}}),v&&wm.createPortal(e.jsxs("div",{ref:f,className:"fixed z-[1000] max-h-[220px] overflow-hidden rounded-lg border bg-popover shadow-lg",style:{top:R.top,left:R.left,width:R.width,maxWidth:"320px"},children:[e.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground border-b bg-muted/30",children:b==="user"?"👤 Mention a person":"📋 Link a template"}),ie?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Searching..."}):ae.length===0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:w.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:ae.map((we,ke)=>e.jsx("li",{className:Pt("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",ke===I?"bg-accent":"hover:bg-accent/50"),onClick:()=>be(we),onMouseEnter:()=>L(ke),children:b==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(gn,{className:"h-6 w-6",children:[e.jsx(Ea,{src:we.avatar_url}),e.jsx(xn,{className:"text-xs",children:le(we.name)})]}),e.jsx("span",{className:"text-sm font-medium truncate",children:we.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:we.preview_image_url?e.jsx("img",{src:we.preview_image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(Bl,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate",children:we.name})]})},we.id))})]}),document.body)]})}function j8t(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const DAe=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);function mKe({comment:t,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=ns(),[d,u]=S.useState(!1),[p,f]=S.useState(""),[v,_]=S.useState([]),b=Ot({mutationFn:async({content:C,parentCommentId:A})=>{const{data:I,error:L}=await G.from("community_comments").insert({post_id:s,user_id:r,content:C,parent_comment_id:A}).select("id").single();if(L)throw L;const R=v;if(R.length>0&&I){const $=R.filter(q=>q!==r).map(q=>({comment_id:I.id,mentioned_user_id:q,mentioned_by_user_id:r}));$.length>0&&await G.from("community_comment_mentions").insert($)}},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),f(""),_([]),u(!1)}}),j=Ot({mutationFn:async C=>{const{error:A}=await G.from("community_comments").delete().eq("id",C);if(A)throw A},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),w=()=>{p.trim()&&b.mutate({content:p,parentCommentId:t.id})};return e.jsxs("div",{className:l>0?"ml-8 border-l-2 border-muted pl-3":"",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(gn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ea,{src:t.user_avatar||void 0}),e.jsx(xn,{className:"text-xs",children:DAe(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(lwe,{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:Cd(new Date(t.created_at),{addSuffix:!0})}),e.jsx(w8t,{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(kP,{className:"h-3 w-3"}),"Reply"]}),(t.user_id===r||o)&&e.jsx("button",{onClick:()=>j.mutate(t.id),className:"hover:text-destructive",children:t.user_id!==r?"Remove":"Delete"})]}),d&&r&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(gn,{className:"h-6 w-6 shrink-0 mt-1",children:[e.jsx(Ea,{src:n||void 0}),e.jsx(xn,{className:"text-xs",children:DAe((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(Cae,{placeholder:`Reply to ${t.user_name}...`,value:p,onChange:f,onMentionsChange:_,mentionFormat:"plain",className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:w,disabled:!p.trim()||b.isPending,className:"h-8 px-2 mt-0.5",children:e.jsx(ka,{className:"h-3 w-3"})})]})]})]})]}),t.replies&&t.replies.length>0&&e.jsx("div",{className:"mt-2 space-y-2",children:t.replies.map(C=>e.jsx(mKe,{comment:C,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},C.id))})]})}const nR=[{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"}],k8t=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=Gs(),{avatarUrl:a}=W9e(t==null?void 0:t.id),{onlineUsers:o}=oqe(),{toast:l}=Ia(),i=ns(),d=S.useRef(null),[u,p]=S.useState("all"),[f,v]=S.useState(""),[_,b]=S.useState(""),[j,w]=S.useState(""),[N,C]=S.useState([]),[A,I]=S.useState([]),[L,R]=S.useState(""),[$,q]=S.useState(!1),[U,V]=S.useState(null),[X,se]=S.useState(""),[te,Y]=S.useState(new Set),[de,ie]=S.useState({}),[ae,le]=S.useState({}),[pe,be]=S.useState([]),[ye,we]=S.useState([]),[ke,Ze]=S.useState({open:!1,images:[],index:0});S.useEffect(()=>{if(u.startsWith("group:")){const Je=u.replace("group:","");w(Je),b("")}else u!=="all"?(b(u),w("")):(b(""),w(""))},[u]);const{data:_e=[]}=Ct({queryKey:["community-categories"],queryFn:async()=>{const{data:Je,error:Rt}=await G.from("community_categories").select("*").order("sort_order");if(Rt)throw Rt;return Je}}),{data:Ce=[]}=Ct({queryKey:["community-private-groups"],queryFn:async()=>{const{data:Je,error:Rt}=await G.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(Rt)throw Rt;return Je}}),Te=20,{data:Fe,isLoading:Ae,hasNextPage:We,fetchNextPage:ht,isFetchingNextPage:De}=dut({queryKey:["community-posts",u],initialPageParam:0,queryFn:async({pageParam:Je})=>{var ze;const Rt=Je*Te,$t=Rt+Te;let ls=G.from("community_posts").select("*").order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(Rt,$t);if(u.startsWith("group:")){const st=u.replace("group:","");ls=ls.eq("private_group_id",st)}else u==="all"||(ls=ls.eq("category_id",u).is("private_group_id",null));const{data:Qt,error:rs}=await ls;if(rs)throw rs;const as=((Qt==null?void 0:Qt.length)||0)>Te,ir=(Qt||[]).slice(0,Te);if(ir.length===0)return{posts:[],hasMore:!1,nextPage:Je+1};const vt=ir.map(st=>st.id),Cs=[...new Set(ir.filter(st=>st.category_id).map(st=>st.category_id))].filter(Boolean),[or,Ar,Wn,ai,bo]=await Promise.all([Cs.length?G.from("community_categories").select("*").in("id",Cs):Promise.resolve({data:[]}),G.from("community_post_media").select("*").in("post_id",vt).order("sort_order"),G.from("community_reactions").select("*").in("post_id",vt),G.from("community_comments").select("*").in("post_id",vt).order("created_at",{ascending:!0}),G.from("community_post_resources").select("*").in("post_id",vt)]),Fa=or==null?void 0:or.data,yn=Ar==null?void 0:Ar.data,na=Wn==null?void 0:Wn.data,Nn=ai==null?void 0:ai.data,ta=bo==null?void 0:bo.data,Kt=(Nn||[]).map(st=>st.id),[$r,es]=await Promise.all([Kt.length?G.from("community_comment_reactions").select("*").in("comment_id",Kt):Promise.resolve({data:[]}),(()=>{const st=(ta||[]).filter(Tt=>Tt.resource_type==="template").map(Tt=>Tt.resource_id);return st.length===0?Promise.resolve({data:[]}):G.from("canva_templates").select("id, name, preview_image_url").in("id",st)})()]),nn=($r==null?void 0:$r.data)||[],_a=(es==null?void 0:es.data)||[],aa=new Map(_a.map(st=>[st.id,{name:st.name,preview_image_url:st.preview_image_url}])),Pr=Array.from(new Set([...ir.map(st=>st.user_id),...(na||[]).map(st=>st.user_id),...(Nn||[]).map(st=>st.user_id),...nn.map(st=>st.user_id)])),[ii,nl]=await Promise.all([Pr.length?G.from("profiles").select("id, name").in("id",Pr):Promise.resolve({data:[]}),G9e(Pr)]),mi=new Map(((ze=ii==null?void 0:ii.data)==null?void 0:ze.map(st=>[st.id,st.name]))||[]),Vl=new Map((Fa||[]).map(st=>[st.id,st])),dt=st=>{const Tt=new Map,Nt=[];return st.forEach(Bt=>{Tt.set(Bt.id,{...Bt,user_name:mi.get(Bt.user_id)||"Unknown User",user_avatar:nl.get(Bt.user_id),reactions:nn.filter(Zt=>Zt.comment_id===Bt.id).map(Zt=>({...Zt,user_name:mi.get(Zt.user_id)||"Unknown User",user_avatar:nl.get(Zt.user_id)})),replies:[]})}),st.forEach(Bt=>{const Zt=Tt.get(Bt.id);if(Bt.parent_comment_id&&Tt.has(Bt.parent_comment_id)){const Ut=Tt.get(Bt.parent_comment_id);Ut.replies=Ut.replies||[],Ut.replies.push(Zt)}else Nt.push(Zt)}),Nt};return{posts:ir.map(st=>{const Tt=(ta||[]).filter(Nt=>Nt.post_id===st.id).map(Nt=>{let Bt="",Zt=null;if(Nt.resource_type==="template"){const Ut=aa.get(Nt.resource_id);Bt=(Ut==null?void 0:Ut.name)||"Unknown Template",Zt=(Ut==null?void 0:Ut.preview_image_url)||null}return{id:Nt.id,resource_type:Nt.resource_type,resource_id:Nt.resource_id,resource_name:Bt,resource_preview_url:Zt}});return{...st,user_name:mi.get(st.user_id)||"Unknown User",user_avatar:nl.get(st.user_id),category:st.category_id?Vl.get(st.category_id):null,media:(yn||[]).filter(Nt=>Nt.post_id===st.id),reactions:((na||[]).filter(Nt=>Nt.post_id===st.id)||[]).map(Nt=>({...Nt,user_name:mi.get(Nt.user_id)||"Unknown User",user_avatar:nl.get(Nt.user_id)})),comments:dt((Nn||[]).filter(Nt=>Nt.post_id===st.id)),resources:Tt}}),hasMore:as,nextPage:Je+1}},getNextPageParam:Je=>Je.hasMore?Je.nextPage:void 0}),Dt=S.useMemo(()=>(Fe==null?void 0:Fe.pages.flatMap(Je=>Je.posts))??[],[Fe]),he=Ot({mutationFn:async()=>{q(!0);const{data:Je,error:Rt}=await G.from("community_posts").insert({user_id:t.id,category_id:j?null:_||null,private_group_id:j||null,content:f,link_url:L||null}).select().single();if(Rt)throw Rt;for(let ls=0;ls0){const ls=pe.filter(Qt=>Qt!==t.id).map(Qt=>({post_id:Je.id,mentioned_user_id:Qt,mentioned_by_user_id:t.id}));ls.length>0&&await G.from("community_post_mentions").insert(ls)}const $t=j8t(f);if($t.length>0){const ls=$t.map(Qt=>({post_id:Je.id,resource_type:"template",resource_id:Qt}));await G.from("community_post_resources").insert(ls)}return Je},onSuccess:async Je=>{var Rt;i.invalidateQueries({queryKey:["community-posts"]}),v(""),be([]),we([]),b(""),w(""),C([]),I([]),R(""),l({title:"Post created!"});try{const $t=((Rt=t==null?void 0:t.user_metadata)==null?void 0:Rt.name)||"Someone",ls=f.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),Qt=ls.length>50?ls.substring(0,50)+"...":ls;await G.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${$t}: ${Qt}`,url:"/community"}})}catch($t){console.error("Failed to send push notification:",$t)}},onError:Je=>{l({title:"Error creating post",description:Je.message,variant:"destructive"})},onSettled:()=>q(!1)}),Qe=Ot({mutationFn:async({postId:Je,content:Rt})=>{const{error:$t}=await G.from("community_posts").update({content:Rt}).eq("id",Je);if($t)throw $t},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),V(null),se(""),l({title:"Post updated!"})}}),ot=Ot({mutationFn:async Je=>{const{error:Rt}=await G.from("community_posts").delete().eq("id",Je);if(Rt)throw Rt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),rt=Ot({mutationFn:async({postId:Je,isPinned:Rt})=>{const{error:$t}=await G.from("community_posts").update({is_pinned:!Rt,pinned_at:Rt?null:new Date().toISOString(),pinned_by:Rt?null:t==null?void 0:t.id}).eq("id",Je);if($t)throw $t},onSuccess:(Je,{isPinned:Rt})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:Rt?"Post unpinned":"Post pinned to top"})}}),Ne=Ot({mutationFn:async({postId:Je,reactionType:Rt})=>{var ls;const $t=(ls=Dt.find(Qt=>Qt.id===Je))==null?void 0:ls.reactions.find(Qt=>Qt.user_id===(t==null?void 0:t.id));$t?$t.reaction_type===Rt?await G.from("community_reactions").delete().eq("id",$t.id):await G.from("community_reactions").update({reaction_type:Rt}).eq("id",$t.id):await G.from("community_reactions").insert({post_id:Je,user_id:t.id,reaction_type:Rt})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),it=Ot({mutationFn:async({postId:Je,content:Rt})=>{const{data:$t,error:ls}=await G.from("community_comments").insert({post_id:Je,user_id:t.id,content:Rt}).select("id").single();if(ls)throw ls;const Qt=ae[Je]||[];if(Qt.length>0&&$t){const rs=Qt.filter(as=>as!==t.id).map(as=>({comment_id:$t.id,mentioned_user_id:as,mentioned_by_user_id:t.id}));rs.length>0&&await G.from("community_comment_mentions").insert(rs)}},onSuccess:(Je,{postId:Rt})=>{i.invalidateQueries({queryKey:["community-posts"]}),ie($t=>({...$t,[Rt]:""})),le($t=>({...$t,[Rt]:[]}))}});Ot({mutationFn:async Je=>{const{error:Rt}=await G.from("community_comments").delete().eq("id",Je);if(Rt)throw Rt},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const qe=Je=>{const Rt=Array.from(Je.target.files||[]);if(Rt.length+N.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}C($t=>[...$t,...Rt]),Rt.forEach($t=>{const ls=new FileReader;ls.onloadend=()=>{I(Qt=>[...Qt,ls.result])},ls.readAsDataURL($t)})},Xe=Je=>{C(Rt=>Rt.filter(($t,ls)=>ls!==Je)),I(Rt=>Rt.filter(($t,ls)=>ls!==Je))},$e=Je=>Je.split(" ").map(Rt=>Rt[0]).join("").toUpperCase().slice(0,2),Ke=Je=>{const Rt={};return Je.forEach($t=>{Rt[$t.reaction_type]=(Rt[$t.reaction_type]||0)+1}),Rt},ct=Je=>{var Rt;return(Rt=Je.find($t=>$t.user_id===(t==null?void 0:t.id)))==null?void 0:Rt.reaction_type},Ue=Je=>Je.reduce((Rt,$t)=>Rt+1+($t.replies?Ue($t.replies):0),0),Ve=Je=>{if(n)return!0;if(!s||!Je.private_group_id)return!1;const Rt=Ce.find($t=>$t.id===Je.private_group_id);return Rt!=null&&Rt.brokerage_id?r.some($t=>$t.id===Rt.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(i8t,{categories:_e,privateGroups:Ce,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsxs("div",{className:"flex-1 min-w-0 max-w-2xl mx-auto lg:mx-0 space-y-6",children:[e.jsxs("div",{className:"px-1",children:[e.jsx("h1",{className:"text-4xl lg:text-5xl font-bold text-foreground",children:"Community"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Connect and share with fellow agents"})]}),e.jsx(o8t,{categories:_e,privateGroups:Ce,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(gn,{className:"h-10 w-10",children:[e.jsx(Ea,{src:a||void 0}),e.jsx(xn,{children:t!=null&&t.email?$e(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(Cae,{placeholder:n?"What's on your mind? Use @ to mention someone, # to link a template":"What's on your mind? Use @ to mention someone",value:f,onChange:v,onMentionsChange:be,onTemplatesChange:we,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),A.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:A.map((Je,Rt)=>{var $t;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[($t=N[Rt])!=null&&$t.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(K,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>Xe(Rt),children:e.jsx(Ur,{className:"h-3 w-3"})})]},Rt)})}),L&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:L,onChange:Je=>R(Je.target.value),placeholder:"https://...",className:"flex-1"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>R(""),children:e.jsx(Ur,{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:qe,accept:"image/*,video/*",multiple:!0,className:"hidden"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var Je;return(Je=d.current)==null?void 0:Je.click()},children:[e.jsx(Jo,{className:"h-4 w-4 mr-1"}),"Photo"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var Je;return(Je=d.current)==null?void 0:Je.click()},children:[e.jsx(kn,{className:"h-4 w-4 mr-1"}),"Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>R("https://"),children:[e.jsx(Lo,{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:[Ce.length>0?e.jsxs(tr,{value:j||_||"none",onValueChange:Je=>{Je==="none"?(b(""),w("")):Je.startsWith("group:")?(w(Je.replace("group:","")),b("")):(b(Je),w(""))},children:[e.jsx(Js,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx(sr,{placeholder:"Select..."})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No category"}),_e.map(Je=>e.jsxs(At,{value:Je.id,children:[Je.icon," ",Je.name]},Je.id)),Ce.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"}),Ce.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(sr,{placeholder:"Category"})}),e.jsx(er,{children:_e.map(Je=>e.jsxs(At,{value:Je.id,children:[Je.icon," ",Je.name]},Je.id))})]}),e.jsxs(K,{size:"sm",onClick:()=>he.mutate(),disabled:!f.trim()||$,children:[e.jsx(ka,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),Ae?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((Je,Rt)=>e.jsx(Ee,{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"})]})]})})},Rt))}):Dt.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(gc,{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:[Dt.map(Je=>{var Rt,$t,ls,Qt;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex gap-3 min-w-0",children:[e.jsxs(gn,{className:"h-10 w-10",children:[e.jsx(Ea,{src:Je.user_avatar||void 0}),e.jsx(xn,{children:$e(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:Cd(new Date(Je.created_at),{addSuffix:!0})}),Je.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs(at,{variant:"secondary",className:"text-xs",children:[Je.category.icon," ",Je.category.name]})]})]})]})]}),(Je.user_id===(t==null?void 0:t.id)||Ve(Je))&&e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(ef,{className:"h-4 w-4"})})}),e.jsxs(Td,{align:"end",children:[Ve(Je)&&Je.private_group_id&&e.jsx(Ta,{onClick:()=>rt.mutate({postId:Je.id,isPinned:Je.is_pinned}),children:Je.is_pinned?e.jsxs(e.Fragment,{children:[e.jsx(vP,{className:"h-4 w-4 mr-2"}),"Unpin Post"]}):e.jsxs(e.Fragment,{children:[e.jsx(a_,{className:"h-4 w-4 mr-2"}),"Pin to Top"]})}),Je.user_id===(t==null?void 0:t.id)&&e.jsxs(Ta,{onClick:()=>{V(Je),se(Je.content)},children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ta,{className:"text-destructive",onClick:()=>ot.mutate(Je.id),children:[e.jsx(br,{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(a_,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Pinned"})]}),e.jsx("div",{className:"mb-3",children:e.jsx(lwe,{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((rs,as)=>{const ir=as===3&&Je.media.length>4,vt=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:()=>Ze({open:!0,images:Je.media.map(Cs=>({url:Cs.media_url,type:Cs.media_type==="video"?"video":"image"})),index:as}),children:[rs.media_type==="video"?e.jsx("video",{src:rs.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:rs.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"})})})}),ir&&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:["+",vt]})})]},rs.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:rs=>{rs.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(Lo,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:Je.link_url})]})})]}),Je.reactions.length>0&&e.jsx(hKe,{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(Ke(Je.reactions)).slice(0,3).map(([rs])=>{var as;return e.jsx("span",{className:"text-base",children:(as=nR.find(ir=>ir.type===rs))==null?void 0:as.emoji},rs)})}),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(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",children:[ct(Je.reactions)?e.jsx("span",{className:"mr-1",children:(Rt=nR.find(rs=>rs.type===ct(Je.reactions)))==null?void 0:Rt.emoji}):e.jsx(pu,{className:"h-4 w-4 mr-1"}),ct(Je.reactions)?($t=nR.find(rs=>rs.type===ct(Je.reactions)))==null?void 0:$t.label:"Like"]})}),e.jsx(ko,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:nR.map(rs=>e.jsx("button",{onClick:()=>Ne.mutate({postId:Je.id,reactionType:rs.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:rs.label,children:rs.emoji},rs.type))})})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>Y(rs=>{const as=new Set(rs);return as.has(Je.id)?as.delete(Je.id):as.add(Je.id),as}),children:[e.jsx(gc,{className:"h-4 w-4 mr-1"}),(()=>{const rs=Ue(Je.comments);return rs>0?`Comment (${rs})`:"Comment"})()]})]}),te.has(Je.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[Je.comments.map(rs=>e.jsx(mKe,{comment:rs,postId:Je.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:Ve(Je)},rs.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(gn,{className:"h-8 w-8",children:[e.jsx(Ea,{src:a||void 0}),e.jsx(xn,{className:"text-xs",children:$e(((ls=t.email)==null?void 0:ls.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(Cae,{placeholder:"Write a comment... (use @ to mention)",value:de[Je.id]||"",onChange:rs=>ie(as=>({...as,[Je.id]:rs})),onMentionsChange:rs=>le(as=>({...as,[Je.id]:rs})),mentionFormat:"plain",onKeyDown:rs=>{var as;rs.defaultPrevented||rs.key==="Enter"&&!rs.shiftKey&&((as=de[Je.id])!=null&&as.trim())&&(rs.preventDefault(),it.mutate({postId:Je.id,content:de[Je.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{var rs;(rs=de[Je.id])!=null&&rs.trim()&&it.mutate({postId:Je.id,content:de[Je.id]})},disabled:!((Qt=de[Je.id])!=null&&Qt.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx(ka,{className:"h-4 w-4"})})]})]})]})]})},Je.id)}),We&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(K,{variant:"outline",onClick:()=>ht(),disabled:De,children:De?"Loading…":"Load more posts"})})]}),e.jsx(vs,{open:!!U,onOpenChange:()=>V(null),children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Edit Post"})}),e.jsx(Mr,{value:X,onChange:Je=>se(Je.target.value),className:"min-h-[120px]"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>V(null),children:"Cancel"}),e.jsx(K,{onClick:()=>{U&&Qe.mutate({postId:U.id,content:X})},disabled:!X.trim(),children:"Save Changes"})]})]})}),e.jsx(b8t,{images:ke.images,initialIndex:ke.index,open:ke.open,onOpenChange:Je=>Ze(Rt=>({...Rt,open:Je}))})]})]})})},c4={open:{label:"Open",icon:Tn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:gc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:gi,color:"bg-green-500"},closed:{label:"Closed",icon:kc,color:"bg-muted-foreground"}},OAe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function N8t(){const{user:t}=Gs(),s=ns(),[r,n]=S.useState(null),[a,o]=S.useState(""),{data:l=[],isLoading:i}=Ct({queryKey:["support-tickets"],queryFn:async()=>{const{data:f,error:v}=await G.from("support_tickets").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(v)throw v;return f},enabled:!!t}),{data:d=[]}=Ct({queryKey:["ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:f,error:v}=await G.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(v)throw v;return f},enabled:!!r}),u=Ot({mutationFn:async f=>{if(!r||!t)throw new Error("Missing data");const{error:v}=await G.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:f,is_admin_reply:!1});if(v)throw v},onSuccess:()=>{s.invalidateQueries({queryKey:["ticket-replies",r==null?void 0:r.id]}),o(""),fe.success("Reply sent!")},onError:()=>{fe.error("Failed to send reply")}}),p=()=>{a.trim()&&u.mutate(a)};if(r){const f=c4[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(K,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(Ua,{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(at,{variant:"secondary",children:OAe[r.category]}),e.jsxs(at,{className:c4[r.status].color,children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),c4[r.status].label]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(yr,{children:["Created on ",ws(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Bi,{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:ws(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(Rl,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Mr,{placeholder:"Type your reply...",value:a,onChange:v=>o(v.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:p,disabled:!a.trim()||u.isPending,className:"self-end",children:e.jsx(ka,{className:"h-4 w-4"})})]})]})]})]})]})})}return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{className:"bg-gradient-to-br from-primary/10 via-primary/5 to-background border-primary/20",children:e.jsx(Oe,{className:"p-6 sm:p-8",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-6",children:[e.jsx("div",{className:"p-4 bg-primary/20 rounded-full",children:e.jsx(i0,{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(qge,{trigger:e.jsxs(K,{size:"lg",className:"gap-2",children:[e.jsx(Zs,{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(Zn,{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(qge,{trigger:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"New Ticket"]})})]}),i?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):l.length===0?e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"text-center py-12",children:[e.jsx(gc,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No tickets yet"}),e.jsx("p",{className:"text-muted-foreground",children:"You haven't submitted any support tickets. Use the button above to get started!"})]})}):e.jsx("div",{className:"space-y-3",children:l.map(f=>{const v=c4[f.status].icon;return e.jsx(Ee,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(f),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:f.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(at,{variant:"outline",className:"text-xs",children:OAe[f.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ws(new Date(f.created_at),"MMM d, yyyy")})]})]}),e.jsxs(at,{className:c4[f.status].color,children:[e.jsx(v,{className:"h-3 w-3 mr-1"}),c4[f.status].label]})]})})},f.id)})})]})})}function S8t({open:t,onOpenChange:s}){return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Ss,{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(on,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ns,{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 C8t({open:t,onOpenChange:s}){const{brokerageId:r}=Gs(),[n,a]=S.useState(""),[o,l]=S.useState([]),[i,d]=S.useState(!1),{data:u,isLoading:p}=Ct({queryKey:["brokerage-agents-for-onboarding",r],queryFn:async()=>{if(!r)return[];const{data:j,error:w}=await G.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name",{ascending:!0});if(w)throw w;return j},enabled:t&&!!r}),f=u==null?void 0:u.filter(j=>j.name.toLowerCase().includes(n.toLowerCase())||j.email.toLowerCase().includes(n.toLowerCase())),v=j=>{l(w=>w.includes(j)?w.filter(N=>N!==j):[...w,j])},_=async()=>{if(o.length===0){fe.error("Please select at least one agent");return}d(!0);try{const{data:j,error:w}=await G.functions.invoke("send-onboarding-link",{body:{agentIds:o}});if(w)throw w;fe.success(`Onboarding link sent to ${o.length} agent${o.length>1?"s":""}`),l([]),s(!1)}catch(j){console.error("Error sending onboarding link:",j),fe.error(j.message||"Failed to send onboarding link")}finally{d(!1)}},b=j=>{j||(l([]),a("")),s(j)};return e.jsx(vs,{open:t,onOpenChange:b,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Ss,{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(ka,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ns,{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(fn,{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:j=>a(j.target.value),className:"pl-10"})]}),p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):(f==null?void 0:f.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(hr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No agents found"})]}):e.jsx(Bi,{className:"h-[300px] border rounded-lg",children:e.jsx("div",{className:"p-2 space-y-1",children:f==null?void 0:f.map(j=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",onClick:()=>v(j.id),children:[e.jsx(zo,{checked:o.includes(j.id),onCheckedChange:()=>v(j.id)}),e.jsx(gn,{className:"h-8 w-8",children:e.jsx(xn,{className:"text-xs",children:j.name.split(" ").map(w=>w[0]).join("").toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:j.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:j.email})]})]},j.id))})}),o.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.length," agent",o.length>1?"s":""," selected"]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{onClick:_,disabled:o.length===0||i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ka,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function M8t(){const[t,s]=S.useState(!1),[r,n]=S.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"mb-8",children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(hr,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Agent Onboarding"}),e.jsx(yr,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Schedule Agent Onboarding"]}),e.jsxs(K,{variant:"outline",onClick:()=>n(!0),className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(S8t,{open:t,onOpenChange:s}),e.jsx(C8t,{open:r,onOpenChange:n})]})}function T8t({open:t,onOpenChange:s}){return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Ss,{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(Gx,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ns,{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 A8t(){const[t,s]=S.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"mb-8",children:[e.jsx(Lt,{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(Gx,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Launch or ReLaunch Meeting"}),e.jsx(yr,{children:"Schedule a private LevelUp information session for your brokerage. Have one of our staff host a meeting to help your team get the most out of all our trainings, tools, and resources."})]})]})}),e.jsx(Oe,{children:e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(Gx,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx(T8t,{open:t,onOpenChange:s})]})}function E8t(){const t=Dr(),[s,r]=S.useState(""),[n,a]=S.useState(null),{data:o,isLoading:l}=Ct({queryKey:["brokerage-resources-published"],queryFn:async()=>{const{data:j,error:w}=await G.from("brokerage_resources").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(w)throw w;return j}}),{data:i}=Ct({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:j,error:w}=await G.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(w)throw w;return j}}),{data:d}=Ct({queryKey:["brokerage-resource-pdfs-all"],queryFn:async()=>{const{data:j,error:w}=await G.from("brokerage_resource_pdfs").select("resource_id");if(w)throw w;return j}}),{data:u}=Ct({queryKey:["brokerage-resource-videos-all"],queryFn:async()=>{const{data:j,error:w}=await G.from("brokerage_resource_videos").select("resource_id");if(w)throw w;return j}}),{data:p}=Ct({queryKey:["brokerage-resource-links-all"],queryFn:async()=>{const{data:j,error:w}=await G.from("brokerage_resource_links").select("resource_id");if(w)throw w;return j}}),f=o==null?void 0:o.filter(j=>{var C;const w=j.title.toLowerCase().includes(s.toLowerCase())||((C=j.description)==null?void 0:C.toLowerCase().includes(s.toLowerCase())),N=!n||j.category_id===n;return w&&N}),v=i==null?void 0:i.filter(j=>o==null?void 0:o.some(w=>w.category_id===j.id)),_=j=>{const w=(d==null?void 0:d.filter(A=>A.resource_id===j).length)||0,N=(u==null?void 0:u.filter(A=>A.resource_id===j).length)||0,C=(p==null?void 0:p.filter(A=>A.resource_id===j).length)||0;return{pdfCount:w,videoCount:N,linkCount:C}},b=j=>{t(`/brokerage-resources/${j}`)};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(M8t,{}),e.jsx(A8t,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(fn,{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:j=>r(j.target.value),className:"pl-10"})]}),v&&v.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(at,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),v.map(j=>e.jsx(at,{variant:n===j.id?"default":"outline",className:"cursor-pointer",onClick:()=>a(j.id),children:j.name},j.id))]}),!l&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(f==null?void 0:f.length)||0," resource",(f==null?void 0:f.length)!==1?"s":""," available"]}),l?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[...Array(6)].map((j,w)=>e.jsxs(Ee,{children:[e.jsx(gs,{className:"h-40 w-full"}),e.jsx(Lt,{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"})]})]},w))}):(f==null?void 0:f.length)===0?e.jsxs(Ee,{className:"p-12 text-center",children:[e.jsx(th,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No resources found"}),e.jsx("p",{className:"text-muted-foreground",children:s||n?"Try adjusting your filters":"Check back later for new resources"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:f==null?void 0:f.map(j=>{const{pdfCount:w,videoCount:N,linkCount:C}=_(j.id),A=i==null?void 0:i.find(I=>I.id===j.category_id);return e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>b(j.id),children:[j.preview_image_url?e.jsx("img",{src:j.preview_image_url,alt:j.title,className:"w-full h-40 object-cover"}):e.jsx("div",{className:"w-full h-40 bg-muted flex items-center justify-center",children:e.jsx(th,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(zt,{className:"text-lg line-clamp-1",children:j.title}),A&&e.jsx(at,{variant:"secondary",className:"shrink-0 text-xs",children:A.name})]})}),e.jsxs(Oe,{children:[j.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:j.description}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[w>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-4 w-4"}),w]}),N>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(kn,{className:"h-4 w-4"}),N]}),C>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Lo,{className:"h-4 w-4"}),C]})]})]})]},j.id)})})]})})}const P8t=()=>{const{resourceId:t}=Mo(),{data:s,isLoading:r}=Ct({queryKey:["brokerage-resource-detail",t],queryFn:async()=>{const{data:a,error:o}=await G.from("brokerage_resources").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;const{data:l}=await G.from("brokerage_resource_pdfs").select("*").eq("resource_id",t).order("sort_order"),{data:i}=await G.from("brokerage_resource_videos").select("*").eq("resource_id",t).order("sort_order"),{data:d}=await G.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(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(vo,{to:"/brokerage-resources",children:[e.jsx(Ua,{className:"h-4 w-4"}),"Back to Resources"]})}),s.preview_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:s.preview_image_url,alt:s.title,className:"w-full max-h-[400px] object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),s.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:s.description}})]}),s.videos&&s.videos.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(kn,{className:"h-4 w-4"}),"Videos (",s.videos.length,")"]}),e.jsx("div",{className:"space-y-4",children:s.videos.map(a=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:a.title}),e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:a.video_url,className:"absolute top-0 left-0 w-full h-full rounded-lg border",allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})]},a.id))})]})}),s.pdfs&&s.pdfs.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(In,{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(In,{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(xi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})}),s.links&&s.links.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(sn,{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(sn,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"font-medium text-sm",children:a.title})]}),e.jsx(sn,{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(th,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Resource not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This resource may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(vo,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function I8t(){const{onlineUsers:t,totalOnline:s}=oqe();return e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Online Now"]}),e.jsxs(at,{variant:"secondary",className:"bg-green-100 text-green-700",children:[e.jsx(Gc,{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(Bi,{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(gn,{className:"h-9 w-9",children:[e.jsx(Ea,{src:r.avatarUrl,alt:r.name}),e.jsx(xn,{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 ",Cd(new Date(r.onlineSince),{addSuffix:!1})]})]})]},r.id)})})})})]})}const RAe={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:hr,path:"/admin/members",color:"bg-blue-500/10 text-blue-600"},{title:"Invite Codes",description:"Create and manage signup invite codes",icon:LP,path:"/admin/invite-codes",color:"bg-amber-500/10 text-amber-600"},{title:"Subscriptions",description:"Track and manage user subscriptions",icon:uf,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:sP,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:Vh,path:"/admin/discounts",color:"bg-red-500/10 text-red-600"},{title:"Referral Program",description:"Track brokerage referrals and discounts",icon:cd,path:"/admin/referrals",color:"bg-teal-500/10 text-teal-600"},{title:"Teams",description:"Manage agent teams across all brokerages",icon:hr,path:"/admin/members?tab=teams",color:"bg-violet-500/10 text-violet-600"},{title:"Prospector",description:"Send free trial invites and track conversions",icon:Hh,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:xc,path:"/admin/recruiting",color:"bg-gradient-to-br from-emerald-500/20 to-green-500/10 text-emerald-600"}]},content:{label:"Content",sections:[{title:"Manage Templates",description:"Upload and organize Canva templates",icon:Bl,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:sh,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:$g,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:hn,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:hn,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:I0,path:"/admin/newsletters",color:"bg-violet-500/10 text-violet-600"},{title:"Manage Events",description:"Create and publish events with Zoom integration",icon:ld,path:"/admin/events",color:"bg-green-500/10 text-green-600"},{title:"Additional Services",description:"Manage additional service offerings",icon:th,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:th,path:"/admin/brokerage-resources",color:"bg-slate-500/10 text-slate-600"},{title:"Agent Email Templates",description:"Manage curated email templates for agents",icon:_r,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:nN,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:Vp,path:"/admin/apps",color:"bg-purple-500/10 text-purple-600"},{title:"Email Templates",description:"Customize system email templates",icon:_r,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:zg,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:o5,path:"/admin/onboarding-checklist",color:"bg-emerald-500/10 text-emerald-600"},{title:"Marketplace",description:"Manage store categories, products, and orders",icon:Kx,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:io,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:Ki,path:"/admin/agent-points",color:"bg-amber-500/10 text-amber-600"},{title:"Integrations",description:"Connect Canva, Facebook & Instagram for platform-level features",icon:Ho,path:"/admin/integrations",color:"bg-blue-500/10 text-blue-600"},{title:"Agent Cards",description:"Manage digital business cards for agents",icon:hr,path:"/admin/agent-cards",color:"bg-gradient-to-br from-violet-500/20 to-purple-500/10 text-violet-600"},{title:"Notification Settings",description:"Test and manage push notifications",icon:zg,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:oo,path:"/admin/community",color:"bg-cyan-500/10 text-cyan-600"},{title:"Support Tickets",description:"View and respond to agent support requests",icon:p5,path:"/admin/support-tickets",color:"bg-rose-500/10 text-rose-600"},{title:"Wishlist",description:"Review and manage community feature requests",icon:s_,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:_r,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:Xo,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:Ou,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:sh,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:Si,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:Un,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:Bg,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:Ou,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:Jo,path:"/admin/beta/social-post-generator",color:"bg-gradient-to-br from-fuchsia-500/20 to-pink-500/10 text-fuchsia-600"},{title:"Postcard Direct Mail",description:"Upload monthly postcard designs and manage agent direct mail via Postalytics",icon:_r,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:t_,path:"/admin/beta/homereel",color:"bg-gradient-to-br from-violet-500/20 to-indigo-500/10 text-violet-600"}]}};function L8t(){const t=Dr();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(I8t,{})})]}),e.jsxs(Na,{defaultValue:"users",className:"w-full",children:[e.jsx(va,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1 overflow-x-auto",children:Object.entries(RAe).map(([s,r])=>e.jsx(ks,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(RAe).map(([s,r])=>e.jsx(zs,{value:s,className:"mt-6",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:r.sections.map(n=>e.jsxs(Ee,{className:"cursor-pointer hover:shadow-md transition-all hover:border-primary/50 group",onClick:()=>t(n.path),children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${n.color} mb-2 group-hover:scale-110 transition-transform`,children:e.jsx(n.icon,{className:"h-5 w-5"})}),e.jsx(zt,{className:"text-base",children:n.title})]}),e.jsx(Oe,{className:"pt-0",children:e.jsx(yr,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const An=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:Pt("w-full caption-bottom text-sm",t),...s})}));An.displayName="Table";const En=S.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:Pt("[&_tr]:border-b",t),...s}));En.displayName="TableHeader";const Pn=S.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:Pt("[&_tr:last-child]:border-0",t),...s}));Pn.displayName="TableBody";const D8t=S.forwardRef(({className:t,...s},r)=>e.jsx("tfoot",{ref:r,className:Pt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));D8t.displayName="TableFooter";const js=S.forwardRef(({className:t,...s},r)=>e.jsx("tr",{ref:r,className:Pt("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...s}));js.displayName="TableRow";const jt=S.forwardRef(({className:t,...s},r)=>e.jsx("th",{ref:r,className:Pt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));jt.displayName="TableHead";const lt=S.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:Pt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));lt.displayName="TableCell";const O8t=S.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:Pt("mt-4 text-sm text-muted-foreground",t),...s}));O8t.displayName="TableCaption";const R8t=()=>{const{isAdmin:t}=Gs(),s=Dr(),[r,n]=S.useState([]),[a,o]=S.useState(!0),[l,i]=S.useState(!1),[d,u]=S.useState(null);S.useEffect(()=>{if(!t){s("/dashboard");return}p()},[t]);const p=async()=>{try{const{data:j,error:w}=await G.from("app_tiles").select("*").order("name");if(w)throw w;n(j||[])}catch(j){console.error("Error loading apps:",j),fe.error("Failed to load apps")}finally{o(!1)}},f=async j=>{j.preventDefault();const w=new FormData(j.currentTarget),N={name:w.get("name"),description:w.get("description"),icon:w.get("icon"),app_id:w.get("app_id"),target_url:w.get("target_url"),required_tags:w.get("required_tags").split(",").map(C=>C.trim()).filter(Boolean)};try{if(d){const{error:C}=await G.from("app_tiles").update(N).eq("id",d.id);if(C)throw C;fe.success("App updated successfully")}else{const{error:C}=await G.from("app_tiles").insert([N]);if(C)throw C;fe.success("App created successfully")}i(!1),u(null),p()}catch(C){console.error("Error saving app:",C),fe.error("Failed to save app")}},v=async j=>{if(confirm("Are you sure you want to delete this app?"))try{const{error:w}=await G.from("app_tiles").delete().eq("id",j);if(w)throw w;fe.success("App deleted successfully"),p()}catch(w){console.error("Error deleting app:",w),fe.error("Failed to delete app")}},_=j=>{u(j),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(K,{variant:"ghost",size:"sm",onClick:()=>s("/dashboard"),children:[e.jsx(Ua,{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(vs,{open:l,onOpenChange:i,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{onClick:b,children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Add App"]})}),e.jsxs(ys,{className:"max-w-2xl",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{children:d?"Edit App":"Create New App"}),e.jsx(Kr,{children:"Configure the application tile settings"})]}),e.jsxs("form",{onSubmit:f,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(ve,{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(ve,{htmlFor:"description",children:"Description"}),e.jsx(Mr,{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(ve,{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(ve,{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(ve,{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(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{type:"submit",children:d?"Update":"Create"})]})]})]})]})]})})}),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Application Tiles"}),e.jsx(yr,{children:"Manage the apps that appear on the member dashboard"})]}),e.jsx(Oe,{children:r.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsxs(K,{onClick:b,children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create First App"]})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Icon"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"App ID"}),e.jsx(jt,{children:"Target URL"}),e.jsx(jt,{children:"Tags"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:r.map(j=>e.jsxs(js,{children:[e.jsx(lt,{className:"text-2xl",children:j.icon}),e.jsx(lt,{className:"font-medium",children:j.name}),e.jsx(lt,{className:"font-mono text-sm",children:j.app_id}),e.jsx(lt,{className:"text-sm text-muted-foreground max-w-xs truncate",children:j.target_url}),e.jsx(lt,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:j.required_tags.map(w=>e.jsx("span",{className:"text-xs bg-secondary text-secondary-foreground px-2 py-1 rounded",children:w},w))})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>_(j),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>v(j.id),children:e.jsx(br,{className:"h-4 w-4"})})]})})]},j.id))})]})})]})})]})};function _u({title:t,description:s,children:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(vo,{to:"/admin",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(Ua,{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 FAe=({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(at,{variant:"destructive",className:Pt("gap-1",s),children:[e.jsx(Th,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(at,{variant:"destructive",className:Pt("gap-1",s),children:[e.jsx(Tn,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(at,{className:Pt("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(at,{variant:"secondary",className:Pt("gap-1",s),children:[e.jsx(Tn,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},pKe=({open:t,onOpenChange:s,brokerages:r,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=Ia(),l=S.useRef(null),[i,d]=S.useState([]),[u,p]=S.useState(""),[f,v]=S.useState(!1),[_,b]=S.useState("upload"),[j,w]=S.useState(null),N=()=>{d([]),p(""),b("upload"),w(null),l.current&&(l.current.value="")},C=()=>{N(),s(!1)},A=q=>{const U=q.split(` `).map(Y=>Y.trim()).filter(Y=>Y);if(U.length===0)return[];const V=U[0].toLowerCase(),se=V.includes("first")||V.includes("last")||V.includes("email")||V.includes("name")||V.includes("phone")||V.includes("sms")||V.includes("consent")?U.slice(1):U,te=[];for(const Y of se){const ie=(Y.includes(" ")?Y.split(" "):Y.split(",")).map(ae=>ae.trim().replace(/^["']|["']$/g,""));if(ie.length>=2){let ae="",le="",pe="",be="",ye;if(ie.length===2){const Ze=ie[0].split(" ");ae=Ze[0]||"",le=Ze.slice(1).join(" ")||"",pe=ie[1]}else if(ie.length===3)ae=ie[0],le=ie[1],pe=ie[2];else if(ie.length===4)ae=ie[0],le=ie[1],pe=ie[2],be=ie[3];else if(ie.length>=5){ae=ie[0],le=ie[1],pe=ie[2],be=ie[3];const Ze=ie[4].toLowerCase();ye=Ze==="true"||Ze==="yes"||Ze==="1"||Ze==="y"}const ke=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(pe);te.push({firstName:ae.trim(),lastName:le.trim(),email:pe.trim().toLowerCase(),phone:be.trim()||void 0,smsConsent:ye,isValid:ke&&ae.trim().length>0,error:ke?ae.trim()?void 0:"Missing name":"Invalid email"})}}return te},I=q=>{var X;const U=(X=q.target.files)==null?void 0:X[0];if(!U)return;const V=new FileReader;V.onload=se=>{var de;const te=(de=se.target)==null?void 0:de.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")},V.readAsText(U)},L=async()=>{const q=i.filter(V=>V.isValid);if(q.length===0){o({title:"No valid users",description:"There are no valid users to import.",variant:"destructive"});return}const U=n||u||null;v(!0);try{const{data:{session:V}}=await G.auth.getSession(),X=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/bulk-create-users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${V==null?void 0:V.access_token}`},body:JSON.stringify({users:q.map(te=>({firstName:te.firstName,lastName:te.lastName,email:te.email,phone:te.phone,smsConsent:te.smsConsent})),brokerageId:U})}),se=await X.json();if(!X.ok)throw new Error(se.error||"Failed to import users");w(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(V){console.error("Import error:",V),o({title:"Import Failed",description:V.message||"Failed to import users",variant:"destructive"})}finally{v(!1)}},R=i.filter(q=>q.isValid).length,$=i.filter(q=>!q.isValid).length;return e.jsx(vs,{open:t,onOpenChange:C,children:e.jsxs(ys,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(C0,{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(Ya,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click to upload or drag and drop a CSV file"}),e.jsx(K,{onClick:()=>{var 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(ve,{children:"Assign to Brokerage (optional)"}),e.jsxs(tr,{value:u||"none",onValueChange:q=>p(q==="none"?"":q),children:[e.jsx(Js,{children:e.jsx(sr,{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(da,{className:"h-4 w-4 text-green-500"}),e.jsxs("span",{children:[R," valid"]})]}),$>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Qo,{className:"h-4 w-4"}),e.jsxs("span",{children:[$," invalid"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{className:"bg-muted/30",children:[e.jsx(jt,{children:"First Name"}),e.jsx(jt,{children:"Last Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Phone"}),e.jsx(jt,{children:"SMS"}),e.jsx(jt,{children:"Status"})]})}),e.jsx(Pn,{children:i.slice(0,100).map((q,U)=>e.jsxs(js,{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(at,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(at,{variant:"destructive",children:q.error||"Invalid"})})]},U))})]}),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"&&j&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(da,{className:"h-12 w-12 mx-auto text-green-500 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:[j.created," agent(s) created and invited"]}),j.failed>0&&e.jsxs("p",{className:"text-destructive mt-1",children:[j.failed," failed to create"]})]}),j.errors.length>0&&e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 max-h-40 overflow-auto",children:[e.jsx("p",{className:"font-medium text-destructive text-sm mb-2",children:"Errors:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[j.errors.slice(0,10).map((q,U)=>e.jsxs("li",{children:["• ",q]},U)),j.errors.length>10&&e.jsxs("li",{children:["...and ",j.errors.length-10," more"]})]})]})]}),e.jsxs(On,{children:[_==="upload"&&e.jsx(K,{variant:"outline",onClick:C,children:"Cancel"}),_==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:N,children:"Back"}),e.jsx(K,{onClick:L,disabled:f||R===0,children:f?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${R} Agent${R!==1?"s":""}`})]}),_==="result"&&e.jsx(K,{onClick:C,children:"Done"})]})]})})};function el({sortKey:t,currentSortKey:s,currentDirection:r,onSort:n,children:a,className:o,...l}){const i=s===t;return e.jsx(jt,{className:Pt("cursor-pointer select-none",o),...l,children:e.jsxs("button",{type:"button",className:"flex items-center gap-1 font-semibold hover:text-foreground transition-colors w-full text-left",onClick:()=>n(t),children:[a,i?r==="asc"?e.jsx(Vd,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(eh,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Hc,{className:"h-3.5 w-3.5 shrink-0 opacity-40"})]})})}function UL(t=null,s=null){const[r,n]=S.useState(t),[a,o]=S.useState(s),l=S.useCallback(d=>{r===d?a==="asc"?o("desc"):a==="desc"?(n(null),o(null)):o("asc"):(n(d),o("asc"))},[r,a]),i=S.useCallback((d,u)=>{if(!r||!a||!u[r])return d;const p=u[r];return[...d].sort((f,v)=>{const _=p(f),b=p(v);if(_==null&&b==null)return 0;if(_==null)return 1;if(b==null)return-1;let j;return typeof _=="string"&&typeof b=="string"?j=_.localeCompare(b,void 0,{sensitivity:"base"}):j=_-b,a==="asc"?j:-j})},[r,a]);return{sortKey:r,sortDirection:a,handleSort:l,sortData:i}}const F8t=[{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:Ki},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:Sd}];function fKe({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=S.useState("custom"),[l,i]=S.useState(""),[d,u]=S.useState(""),p=Qxt(),f=_=>{o(_.type),i(_.title),u(_.message)},v=async _=>{if(_.preventDefault(),!l.trim()){an({title:"Title required",description:"Please enter a celebration title",variant:"destructive"});return}try{await p.mutateAsync({user_id:r,celebration_type:a,title:l.trim(),message:d.trim()||void 0}),an({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),u(""),o("custom")}catch{an({title:"Error",description:"Failed to send celebration",variant:"destructive"})}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Sd,{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(ve,{className:"text-sm text-muted-foreground mb-2 block",children:"Quick presets:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:F8t.map((_,b)=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>f(_),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(ve,{htmlFor:"type",children:"Celebration Type"}),e.jsxs(tr,{value:a,onValueChange:_=>o(_),children:[e.jsx(Js,{children:e.jsx(sr,{})}),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(Ki,{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(Un,{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(Kc,{className:"h-4 w-4"})," Deal Closed"]})})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{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(ve,{htmlFor:"message",children:"Message (optional)"}),e.jsx(Mr,{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(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:p.isPending,children:[e.jsx(Sd,{className:"h-4 w-4 mr-2"}),p.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const $me={points_earned:{label:"Points Earned",icon:Ki,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:Un,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:Kc,color:"bg-green-500"},custom:{label:"Custom",icon:hn,color:"bg-purple-500"}};function z8t(){const[t,s]=S.useState(""),[r,n]=S.useState("all"),[a,o]=S.useState("all"),{data:l=[],isLoading:i}=Ct({queryKey:["admin-celebrations"],queryFn:async()=>{const{data:p,error:f}=await G.from("celebration_queue").select("*").order("created_at",{ascending:!1}).limit(500);if(f)throw f;const v=[...new Set([...p.map(j=>j.user_id),...p.map(j=>j.created_by).filter(Boolean)])],{data:_}=await G.from("profiles").select("id, name, email").in("id",v),b=new Map((_==null?void 0:_.map(j=>[j.id,j]))||[]);return p.map(j=>{var w,N,C;return{...j,user_name:((w=b.get(j.user_id))==null?void 0:w.name)||"Unknown",user_email:((N=b.get(j.user_id))==null?void 0:N.email)||"",creator_name:j.created_by?((C=b.get(j.created_by))==null?void 0:C.name)||"System":"Auto-triggered"}})}}),d=l.filter(p=>{var b,j;const f=((b=p.user_name)==null?void 0:b.toLowerCase().includes(t.toLowerCase()))||((j=p.user_email)==null?void 0:j.toLowerCase().includes(t.toLowerCase()))||p.title.toLowerCase().includes(t.toLowerCase()),v=r==="all"||p.celebration_type===r,_=a==="all"||a==="seen"&&p.seen_at||a==="unseen"&&!p.seen_at;return f&&v&&_}),u={total:l.length,seen:l.filter(p=>p.seen_at).length,unseen:l.filter(p=>!p.seen_at).length,byType:Object.keys($me).reduce((p,f)=>(p[f]=l.filter(v=>v.celebration_type===f).length,p),{})};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium",children:"Total Celebrations"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:u.total})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-green-600",children:"Seen"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:u.seen})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:u.unseen})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:u.byType.custom||0})})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Sd,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(yr,{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(fn,{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:p=>s(p.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:r,onValueChange:n,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{placeholder:"Filter by type"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Types"}),Object.entries($me).map(([p,f])=>e.jsx(At,{value:p,children:f.label},p))]})]}),e.jsxs(tr,{value:a,onValueChange:o,children:[e.jsx(Js,{className:"w-[140px]",children:e.jsx(sr,{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(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Points"}),e.jsx(jt,{children:"Created By"}),e.jsx(jt,{children:"Created"}),e.jsx(jt,{children:"Status"})]})}),e.jsx(Pn,{children:d.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):d.map(p=>{const f=$me[p.celebration_type],v=f.icon;return e.jsxs(js,{children:[e.jsx(lt,{children:e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(v,{className:"h-3 w-3"}),f.label]})}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:p.user_name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:p.user_email})]})}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:p.title}),p.message&&e.jsx("div",{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:p.message})]})}),e.jsx(lt,{children:p.points_amount?e.jsxs(at,{variant:"secondary",children:["+",p.points_amount]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:p.creator_name})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ws(new Date(p.created_at),"MMM d, yyyy h:mm a")})}),e.jsx(lt,{children:p.seen_at?e.jsx(at,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):e.jsx(at,{variant:"outline",className:"bg-orange-50 text-orange-700 border-orange-200",children:"Pending"})})]},p.id)})})]})}),d.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-right",children:["Showing ",d.length," of ",l.length," celebrations"]})]})]})]})}const B8t=()=>{const{user:t}=Gs(),{toast:s}=Ia(),[r,n]=S.useState([]),[a,o]=S.useState(!0),[l,i]=S.useState(!1),[d,u]=S.useState("all"),[p,f]=S.useState("all"),[v,_]=S.useState("new"),[b,j]=S.useState(new Set),w=S.useCallback(async()=>{try{o(!0);const{data:te,error:Y}=await G.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:de,error:ie}=await G.from("trial_email_exports").select("user_id");if(ie)throw ie;const ae=new Set((de||[]).map(pe=>pe.user_id)),le=(te||[]).map(pe=>({...pe,converted_from_trial_at:pe.converted_from_trial_at??null,already_exported:ae.has(pe.id)}));le.sort((pe,be)=>new Date(be.created_at).getTime()-new Date(pe.created_at).getTime()),n(le)}catch(te){console.error("Error loading trial users:",te),s({title:"Error",description:"Failed to load trial users",variant:"destructive"})}finally{o(!1)}},[s]);S.useEffect(()=>{w()},[w]);const N=te=>te.trial_started_at?"ghl":"stripe",C=te=>te.trial_expires_at?te.trial_expires_at:te.subscription_end_date?te.subscription_end_date:null,A=te=>te.converted_from_trial_at!==null,I=te=>{if(A(te))return!1;const Y=C(te);return Y?new Date(Y).getTime()<=Date.now():!1},L=r.filter(te=>!(d!=="all"&&N(te)!==d||p==="active"&&(I(te)||A(te))||p==="expired"&&!I(te)||p==="converted"&&!A(te)||v==="new"&&te.already_exported||v==="exported"&&!te.already_exported)),R=()=>{b.size===L.length?j(new Set):j(new Set(L.map(te=>te.id)))},$=te=>{const Y=new Set(b);Y.has(te)?Y.delete(te):Y.add(te),j(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",de=te.map(ye=>{const we=(ye.name||"").split(" "),ke=we[0]||"",Ze=we.slice(1).join(" ")||"",_e=N(ye)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Ce=A(ye)?"Converted":I(ye)?"Expired":"Active",Te=ye.created_at?new Date(ye.created_at).toLocaleDateString():"",Fe=C(ye)?new Date(C(ye)).toLocaleDateString():"";return`"${ke}","${Ze}","${ye.email}","${ye.phone||""}","${_e}","${Ce}","${Te}","${Fe}"`}),ie=[Y,...de].join(` `),ae=new Blob([ie],{type:"text/csv"}),le=URL.createObjectURL(ae),pe=document.createElement("a");pe.href=le,pe.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,pe.click(),URL.revokeObjectURL(le);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 G.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.`}),j(new Set),w()}catch(te){console.error("Export error:",te),s({title:"Error",description:"Failed to export",variant:"destructive"})}finally{i(!1)}},U=r.filter(te=>!te.already_exported).length,V=r.filter(te=>te.already_exported).length,X=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(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"Total"}),e.jsx(zt,{className:"text-2xl",children:r.length})]})}),e.jsx(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"New (Not Exported)"}),e.jsx(zt,{className:"text-2xl text-green-600",children:U})]})}),e.jsx(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"Active Trials"}),e.jsx(zt,{className:"text-2xl",children:se})]})}),e.jsx(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"Converted 🎉"}),e.jsx(zt,{className:"text-2xl text-primary",children:X})]})}),e.jsx(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"Already Exported"}),e.jsx(zt,{className:"text-2xl text-muted-foreground",children:V})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(tr,{value:v,onValueChange:te=>_(te),children:[e.jsx(Js,{className:"w-[160px]",children:e.jsx(sr,{})}),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(sr,{})}),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:p,onValueChange:te=>f(te),children:[e.jsx(Js,{className:"w-[160px]",children:e.jsx(sr,{})}),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(K,{onClick:q,disabled:l||b.size===0,children:[l?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Export Selected (",b.size,")"]})})]}),e.jsx("div",{className:"border rounded-lg",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"w-[40px]",children:e.jsx(zo,{checked:L.length>0&&b.size===L.length,onCheckedChange:R})}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Trial Type"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Signup Date"}),e.jsx(jt,{children:"Expires / Renews"}),e.jsx(jt,{children:"Exported"})]})}),e.jsx(Pn,{children:L.length===0?e.jsx(js,{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),de=A(te),ie=I(te),ae=C(te);return e.jsxs(js,{className:`hover:bg-muted/30 ${de?"bg-primary/5":""}`,children:[e.jsx(lt,{children:e.jsx(zo,{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,de&&e.jsx(Cc,{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(at,{variant:"outline",className:"gap-1",children:[e.jsx(uf,{className:"h-3 w-3"}),"Credit Card"]}):e.jsxs(at,{variant:"secondary",className:"gap-1",children:[e.jsx(_r,{className:"h-3 w-3"}),"Free (No CC)"]})}),e.jsx(lt,{children:de?e.jsxs(at,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[e.jsx(Cc,{className:"h-3 w-3"}),"Converted"]}):ie?e.jsx(at,{variant:"destructive",children:"Expired"}):e.jsx(at,{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:de&&ae?e.jsxs("span",{className:"text-muted-foreground",children:["Renews ",new Date(ae).toLocaleDateString()]}):ae?new Date(ae).toLocaleDateString():"—"}),e.jsx(lt,{children:te.already_exported?e.jsx(da,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(at,{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 · ",X," converted to paid"]})]})},$8t=()=>{const[t,s]=S.useState([]),[r,n]=S.useState(!0);return S.useEffect(()=>{(async()=>{const{data:o,error:l}=await G.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(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(br,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{children:"No deletion records yet"})]})}):e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-lg",children:"User Deletion History"})}),e.jsx(Oe,{children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Date"}),e.jsx(jt,{children:"User"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Brokerage"}),e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Deleted By"})]})}),e.jsx(Pn,{children:t.map(a=>e.jsxs(js,{children:[e.jsx(lt,{className:"whitespace-nowrap text-sm",children:ws(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(at,{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))})]})})]})},aS=t=>{const{user:s}=Gs(),r=ns(),n=Ct({queryKey:["teams",t],queryFn:async()=>{let f=G.from("teams").select("*").order("created_at",{ascending:!1});t&&(f=f.eq("brokerage_id",t));const{data:v,error:_}=await f;if(_)throw _;return v||[]},enabled:!!s}),a=f=>Ct({queryKey:["team-members",f],queryFn:async()=>{const{data:v,error:_}=await G.from("team_members").select("*").eq("team_id",f).order("role",{ascending:!0});if(_)throw _;const b=(v||[]).map(N=>N.user_id),{data:j}=await G.from("profiles").select("id, name, email, avatar_url").in("id",b),w=new Map((j||[]).map(N=>[N.id,N]));return(v||[]).map(N=>({...N,profile:w.get(N.user_id)||null}))},enabled:!!f}),o=Ot({mutationFn:async f=>{const v={name:f.name,created_by:s.id,description:f.description,contact_visibility:f.contact_visibility,lead_pond_enabled:f.lead_pond_enabled,shared_assets_enabled:f.shared_assets_enabled};f.brokerage_id&&(v.brokerage_id=f.brokerage_id);const{data:_,error:b}=await G.from("teams").insert(v).select().single();if(b)throw b;return _},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),fe.success("Team created!")},onError:f=>{fe.error("Failed to create team: "+f.message)}}),l=Ot({mutationFn:async({id:f,...v})=>{const{data:_,error:b}=await G.from("teams").update(v).eq("id",f).select().single();if(b)throw b;return _},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),fe.success("Team updated")},onError:f=>{fe.error("Failed to update team: "+f.message)}}),i=Ot({mutationFn:async f=>{const{error:v}=await G.from("teams").delete().eq("id",f);if(v)throw v},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),fe.success("Team deleted")},onError:f=>{fe.error("Failed to delete team: "+f.message)}}),d=Ot({mutationFn:async f=>{const{data:v,error:_}=await G.from("team_members").insert({team_id:f.team_id,user_id:f.user_id,role:f.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:(f,v)=>{r.invalidateQueries({queryKey:["team-members",v.team_id]}),fe.success("Member added to team")},onError:f=>{fe.error(f.message)}}),u=Ot({mutationFn:async f=>{const{error:v}=await G.from("team_members").delete().eq("id",f.member_id);if(v)throw v},onSuccess:(f,v)=>{r.invalidateQueries({queryKey:["team-members",v.team_id]}),fe.success("Member removed from team")},onError:f=>{fe.error("Failed to remove member: "+f.message)}}),p=Ot({mutationFn:async f=>{const{error:v}=await G.from("team_members").update({role:f.role}).eq("id",f.member_id);if(v)throw v},onSuccess:(f,v)=>{r.invalidateQueries({queryKey:["team-members",v.team_id]}),fe.success("Member role updated")},onError:f=>{fe.error("Failed to update role: "+f.message)}});return{teams:n.data||[],isLoading:n.isLoading,createTeam:o,updateTeam:l,deleteTeam:i,addMember:d,removeMember:u,updateMemberRole:p,useTeamMembers:a}},q8t=()=>{const{user:t}=Gs();return Ct({queryKey:["team-contacts",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.rpc("get_team_contacts",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},gKe=t=>{const{user:s}=Gs(),r=ns(),n=Ct({queryKey:["lead-pond",t],queryFn:async()=>{const{data:i,error:d}=await G.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),p=[...new Set(i.map(N=>N.added_by))],f=i.filter(N=>N.claimed_by).map(N=>N.claimed_by),v=[...new Set([...p,...f])],[_,b]=await Promise.all([G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",u),G.from("profiles").select("id, name, avatar_url").in("id",v)]),j=new Map((_.data||[]).map(N=>[N.id,N])),w=new Map((b.data||[]).map(N=>[N.id,N]));return i.map(N=>({...N,status:N.claimed_by?"claimed":"available",contact:j.get(N.contact_id)||null,contributor:w.get(N.added_by)||null,claimer:N.claimed_by&&w.get(N.claimed_by)||null}))},enabled:!!t&&!!s}),a=Ot({mutationFn:async i=>{const{data:d,error:u}=await G.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"]}),fe.success("Contact added to Lead Pond")},onError:i=>{fe.error(i.message)}}),o=Ot({mutationFn:async i=>{const{error:d}=await G.rpc("claim_lead_pond_contact",{_lead_pond_id:i});if(d)throw d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),fe.success("Lead claimed!")},onError:i=>{fe.error(i.message)}}),l=Ot({mutationFn:async i=>{const{error:d}=await G.rpc("return_lead_pond_contact",{_lead_pond_id:i});if(d)throw d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),fe.success("Lead returned to pond")},onError:i=>{fe.error(i.message)}});return{leadPondItems:n.data||[],isLoading:n.isLoading,addToLeadPond:a,claimLead:o,returnLead:l}},U8t=()=>{const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.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"]}),fe.success("Contact transferred successfully")},onError:s=>{fe.error(s.message||"Failed to transfer contact")}})};function xKe({open:t,onOpenChange:s,contactIds:r,contactNames:n=[],onComplete:a}){var L;const{user:o}=Gs(),{data:l}=Mf(),{useTeamMembers:i}=aS(),{data:d=[]}=i((l==null?void 0:l.teamId)||""),u=U8t(),[p,f]=S.useState(null),[v,_]=S.useState(""),[b,j]=S.useState(!1),w=d.filter(R=>R.user_id!==(o==null?void 0:o.id)),N=async()=>{if(p){j(!0);try{for(const R of r)await u.mutateAsync({contactId:R,toUserId:p,notes:v||void 0});s(!1),f(null),_(""),a==null||a()}catch{}finally{j(!1)}}},C=w.find(R=>R.user_id===p),A=r.length>1,I=n.length>0?A?`${n.length} contacts`:n[0]:A?`${r.length} contacts`:"this contact";return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(k0,{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(ve,{className:"text-sm font-medium mb-2 block",children:"Transfer to:"}),e.jsx("div",{className:"space-y-1 max-h-[240px] overflow-y-auto",children:w.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No other team members available"}):w.map(R=>{var $,q,U;return e.jsxs("button",{onClick:()=>f(R.user_id),className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${p===R.user_id?"bg-primary/10 border border-primary/30":"hover:bg-accent border border-transparent"}`,children:[e.jsxs(gn,{className:"h-8 w-8",children:[e.jsx(Ea,{src:(($=R.profile)==null?void 0:$.avatar_url)||""}),e.jsx(xn,{className:"text-xs",children:(((q=R.profile)==null?void 0:q.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:((U=R.profile)==null?void 0:U.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:R.role.replace("_"," ")})]})]},R.user_id)})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"transfer-notes",className:"text-sm font-medium",children:"Notes (optional)"}),e.jsx(Mr,{id:"transfer-notes",value:v,onChange:R=>_(R.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:N,disabled:!p||b,children:[b?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(k0,{className:"h-4 w-4 mr-2"}),"Transfer",C?` to ${(L=C.profile)==null?void 0:L.name}`:""]})]})]})})}const cwe=()=>{const t=Dr(),{data:s,isLoading:r}=q8t(),{data:n}=Mf(),[a,o]=S.useState(""),[l,i]=S.useState("all"),[d,u]=S.useState(null),[p,f]=S.useState(""),v=(n==null?void 0:n.role)==="team_leader",_=S.useMemo(()=>{if(!s)return[];const j=new Map;return s.forEach(w=>{j.has(w.owner_user_id)||j.set(w.owner_user_id,{id:w.owner_user_id,name:w.owner_name||"Unknown",avatar:w.owner_avatar_url})}),Array.from(j.values())},[s]),b=S.useMemo(()=>{if(!s)return[];let j=s;if(l!=="all"&&(j=j.filter(w=>w.owner_user_id===l)),a.trim()){const w=a.toLowerCase();j=j.filter(N=>{var C,A,I;return(N.first_name+" "+(N.last_name||"")).toLowerCase().includes(w)||((C=N.email)==null?void 0:C.toLowerCase().includes(w))||((A=N.phone)==null?void 0:A.includes(w))||((I=N.owner_name)==null?void 0:I.toLowerCase().includes(w))})}return j},[s,a,l]);return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(gs,{className:"h-10 w-full"}),e.jsx(gs,{className:"h-64 w-full"})]}):!s||s.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Team Contacts"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Team contact sharing is not enabled, or you're not on a team. Ask your manager about contact visibility settings."})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(fn,{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:j=>o(j.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:l,onValueChange:i,children:[e.jsx(Js,{className:"w-[200px]",children:e.jsx(sr,{placeholder:"Filter by agent"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Team Members"}),_.map(j=>e.jsx(At,{value:j.id,children:j.name},j.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(Ee,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(An,{className:"min-w-[800px]",children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Contact Info"}),e.jsx(jt,{children:"Address"}),e.jsx(jt,{children:"Lead Source"}),e.jsx(jt,{children:"Date Added"}),v&&e.jsx(jt,{className:"w-[80px]",children:"Actions"})]})}),e.jsx(Pn,{children:b.length===0?e.jsx(js,{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(j=>e.jsxs(js,{className:`hover:bg-accent/50 ${v?"cursor-pointer":""}`,onClick:v?()=>t(`/mission-control/contacts/${j.id}`):void 0,children:[e.jsx(lt,{className:"font-medium",children:e.jsxs("span",{className:v?"hover:text-primary hover:underline transition-colors":"",children:[j.first_name," ",j.last_name||""]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(gn,{className:"h-6 w-6",children:[e.jsx(Ea,{src:j.owner_avatar_url||""}),e.jsx(xn,{className:"text-[10px]",children:(j.owner_name||"?").charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:j.owner_name||"Unknown"})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[j.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(_r,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:j.email})]}),j.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Zn,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:j.phone})]}),!j.email&&!j.phone&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No contact info"})]})}),e.jsx(lt,{children:j.address?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(Ai,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:j.address})]}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(lt,{children:j.lead_source?e.jsx(at,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:j.lead_source}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ws(new Date(j.created_at),"MMM d, yyyy")})}),v&&e.jsx(lt,{children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:w=>{w.stopPropagation(),u(j.id),f(`${j.first_name} ${j.last_name||""}`.trim())},title:"Transfer to team member",children:e.jsx(k0,{className:"h-4 w-4"})})})]},j.id))})]})})}),e.jsx(xKe,{open:!!d,onOpenChange:j=>{j||u(null)},contactIds:d?[d]:[],contactNames:p?[p]:[],onComplete:()=>u(null)})]})},dwe=({teamId:t})=>{const{user:s}=Gs(),{leadPondItems:r,isLoading:n,claimLead:a,returnLead:o}=gKe(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(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Fg,{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,p,f,v,_,b,j;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=d.contact)==null?void 0:u.first_name," ",((p=d.contact)==null?void 0:p.last_name)||""]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 mt-1",children:[((f=d.contact)==null?void 0:f.email)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(_r,{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(Zn,{className:"h-3 w-3"})," ",d.contact.phone]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs(gn,{className:"h-4 w-4",children:[e.jsx(Ea,{src:((_=d.contributor)==null?void 0:_.avatar_url)||""}),e.jsx(xn,{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 ",((j=d.contributor)==null?void 0:j.name)||"Unknown"]})]})]}),e.jsxs(K,{size:"sm",onClick:()=>a.mutate(d.id),disabled:a.isPending,children:[e.jsx(nP,{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,p,f;return e.jsx(Ee,{className:"opacity-75",children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=d.contact)==null?void 0:u.first_name," ",((p=d.contact)==null?void 0:p.last_name)||""]}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs(at,{variant:"secondary",className:"text-xs",children:["Claimed by ",((f=d.claimer)==null?void 0:f.name)||"Unknown"]})})]}),d.claimed_by===(s==null?void 0:s.id)&&e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>o.mutate(d.id),disabled:o.isPending,children:[e.jsx(D0,{className:"mr-1 h-3 w-3"}),"Return"]})]})},d.id)})})]})]})},yKe=({teamId:t})=>{const{useTeamMembers:s}=aS(),{data:r=[]}=s(t),n=r.map(_=>_.user_id),a=new Map(r.map(_=>[_.user_id,_.profile])),{data:o=[],isLoading:l}=Ct({queryKey:["team-shared-presentations",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await G.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}=Ct({queryKey:["team-shared-open-houses",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await G.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:p}=Ct({queryKey:["team-shared-videos",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await G.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||p)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(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(Bg,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:o.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Presentations"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(Un,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:i.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Guest Books"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(kn,{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(Na,{defaultValue:"presentations",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsxs(ks,{value:"presentations",children:["Presentations (",o.length,")"]}),e.jsxs(ks,{value:"guest-books",children:["Guest Books (",i.length,")"]}),e.jsxs(ks,{value:"videos",children:["Videos (",u.length,")"]})]}),e.jsx(zs,{value:"presentations",className:"space-y-2",children:o.length===0?e.jsx(qme,{icon:e.jsx(Bg,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(_=>{const b=v(_.owner_user_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(gn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ea,{src:b.avatar}),e.jsx(xn,{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," · ",ws(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(at,{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(ya,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})}),e.jsx(zs,{value:"guest-books",className:"space-y-2",children:i.length===0?e.jsx(qme,{icon:e.jsx(Un,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(_=>{const b=v(_.agent_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(gn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ea,{src:b.avatar}),e.jsx(xn,{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," · ",ws(new Date(_.event_date),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[_.is_active?e.jsx(at,{className:"text-xs",children:"Active"}):e.jsx(at,{variant:"secondary",className:"text-xs",children:"Inactive"}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(hr,{className:"h-3 w-3"}),_.visitor_count||0]})]})]})},_.id)})}),e.jsx(zs,{value:"videos",className:"space-y-2",children:u.length===0?e.jsx(qme,{icon:e.jsx(kn,{className:"h-10 w-10"}),label:"No videos yet"}):u.map(_=>{const b=v(_.owner_user_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(gn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ea,{src:b.avatar}),e.jsx(xn,{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," · ",ws(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(at,{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(ya,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})})]})]})},qme=({icon:t,label:s})=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-8 text-center text-muted-foreground",children:[t,e.jsx("p",{className:"mt-2 text-sm",children:s})]})}),vKe=({team:t,brokerageAgents:s,onBack:r,onUpdate:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,onDeleteTeam:i,isUpdating:d,isAddingMember:u})=>{var $,q;const{useTeamMembers:p}=aS(),{data:f=[],isLoading:v}=p(t.id),[_,b]=S.useState(!1),[j,w]=S.useState(""),[N,C]=S.useState("team_member"),{data:A}=Ct({queryKey:["agents-on-other-teams",t.id],queryFn:async()=>{const{data:U}=await G.from("team_members").select("user_id, team_id, teams:team_id(name)").neq("team_id",t.id),V=new Map;return(U||[]).forEach(X=>{var se;V.set(X.user_id,((se=X.teams)==null?void 0:se.name)||"another team")}),V}}),I=new Set(f.map(U=>U.user_id)),L=s.filter(U=>!I.has(U.id)),R=async()=>{j&&(await a(j,N),w(""),C("team_member"),b(!1))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(K,{variant:"ghost",onClick:r,className:"mb-2",children:"← Back to Teams"}),e.jsxs(Na,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsx(ks,{value:"members",children:"Members"}),e.jsxs(ks,{value:"contacts",children:[e.jsx(tN,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(ks,{value:"lead-pond",children:[e.jsx(Fg,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(ks,{value:"shared-assets",children:[e.jsx(qh,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),e.jsx(ks,{value:"settings",children:"Settings"})]}),e.jsxs(zs,{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(vs,{open:_,onOpenChange:b,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(xc,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{children:"Agent"}),e.jsxs(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[j&&((($=L.find(U=>U.id===j))==null?void 0:$.name)||((q=L.find(U=>U.id===j))==null?void 0:q.email))||"Select an agent",e.jsx(df,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(ko,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search agents..."}),e.jsxs(kf,{children:[e.jsx(Nf,{children:"No agents found."}),e.jsx(Sf,{children:L.map(U=>{const V=A==null?void 0:A.get(U.id);return e.jsxs(Nm,{value:U.name||U.email||U.id,disabled:!!V,onSelect:()=>w(U.id),children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",j===U.id?"opacity-100":"opacity-0")}),U.name||U.email,V&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(on ",V,")"]})]},U.id)})})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Role"}),e.jsxs(tr,{value:N,onValueChange:C,children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"team_leader",children:"Team Leader"}),e.jsx(At,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{onClick:R,disabled:!j||u,children:u?"Adding...":"Add to Team"})]})]})]})]}),v?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(U=>e.jsx(gs,{className:"h-16 w-full"},U))}):f.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(hr,{className:"h-10 w-10 text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No members yet. Add agents to this team."})]})}):e.jsx("div",{className:"space-y-2",children:f.map(U=>{var V,X,se,te,Y;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(gn,{className:"h-10 w-10",children:[e.jsx(Ea,{src:((V=U.profile)==null?void 0:V.avatar_url)||""}),e.jsx(xn,{children:(((X=U.profile)==null?void 0:X.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((se=U.profile)==null?void 0:se.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(te=U.profile)==null?void 0:te.email})]}),U.role==="team_leader"?e.jsxs(at,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[e.jsx(Bh,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(at,{variant:"secondary",children:"Member"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(tr,{value:U.role,onValueChange:de=>l(U.id,de),children:[e.jsx(Js,{className:"w-[140px]",children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"team_leader",children:"Team Leader"}),e.jsx(At,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:e.jsx(RP,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Remove Member?"}),e.jsxs(Dl,{children:["Remove ",((Y=U.profile)==null?void 0:Y.name)||"this member"," from ",t.name,"?"]})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>o(U.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})]})]})},U.id)})})]}),e.jsx(zs,{value:"contacts",className:"space-y-4",children:e.jsx(cwe,{})}),t.lead_pond_enabled&&e.jsx(zs,{value:"lead-pond",className:"space-y-4",children:e.jsx(dwe,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx(zs,{value:"shared-assets",className:"space-y-4",children:e.jsx(yKe,{teamId:t.id})}),e.jsxs(zs,{value:"settings",className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{className:"text-lg",children:"Team Settings"}),e.jsx(yr,{children:"Configure how this team operates."})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Team Name"}),e.jsx(Re,{defaultValue:t.name,onBlur:U=>{U.target.value!==t.name&&n({name:U.target.value})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Mr,{defaultValue:t.description||"",onBlur:U=>{U.target.value!==(t.description||"")&&n({description:U.target.value||null})},rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Contact Visibility"}),e.jsxs(tr,{defaultValue:t.contact_visibility,onValueChange:U=>n({contact_visibility:U}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),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(ve,{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(Br,{checked:t.lead_pond_enabled,onCheckedChange:U=>n({lead_pond_enabled:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{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(Br,{checked:t.shared_assets_enabled,onCheckedChange:U=>n({shared_assets_enabled:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{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(Br,{checked:t.shared_videos_enabled??!1,onCheckedChange:U=>n({shared_videos_enabled:U})})]})]})]}),e.jsxs(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsxs(K,{variant:"destructive",size:"sm",children:[e.jsx(br,{className:"mr-2 h-4 w-4"}),"Delete Team"]})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Team?"}),e.jsxs(Dl,{children:['This will permanently delete "',t.name,'" and remove all team members. This cannot be undone.']})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>{i(),r()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},_Ke=({open:t,onOpenChange:s,onCreateTeam:r,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[d,u]=S.useState(1),[p,f]=S.useState(""),[v,_]=S.useState(""),[b,j]=S.useState(""),[w,N]=S.useState(""),[C,A]=S.useState([]),I=()=>{u(1),f(""),_(""),j(""),N(""),A([])},L=U=>{U||I(),s(U)},R=async()=>{const U=b&&b!=="none"?b:i||null;await r({name:p.trim(),description:v.trim()||void 0,brokerage_id:U,leaderId:w||void 0,memberIds:C.length>0?C:void 0}),I()},$=U=>{U!==w&&A(V=>V.includes(U)?V.filter(X=>X!==U):[...V,U])},q=a.filter(U=>U.id!==w);return e.jsx(vs,{open:t,onOpenChange:L,children:e.jsxs(ys,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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:Pt("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),e.jsx("div",{className:Pt("h-1.5 flex-1 rounded-full transition-colors",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(ve,{htmlFor:"team-name",children:"Team Name *"}),e.jsx(Re,{id:"team-name",value:p,onChange:U=>f(U.target.value),placeholder:"e.g., Downtown Squad",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"team-desc",children:"Description"}),e.jsx(Mr,{id:"team-desc",value:v,onChange:U=>_(U.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(ve,{children:"Brokerage"}),e.jsxs(tr,{value:b,onValueChange:j,children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"No brokerage (independent team)"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No brokerage (independent)"}),l.map(U=>e.jsx(At,{value:U.id,children:U.name},U.id))]})]})]})]}):e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Bh,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),e.jsxs(tr,{value:w,onValueChange:U=>{N(U),A(V=>V.filter(X=>X!==U))},children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a team leader (optional)"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No leader for now"}),a.map(U=>e.jsx(At,{value:U.id,children:U.name||U.email||"Unknown"},U.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(xc,{className:"h-3.5 w-3.5"}),"Initial Members",C.length>0&&e.jsxs(at,{variant:"secondary",className:"ml-1 text-xs",children:[C.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click agents to add them. You can always add more later."}),e.jsx("div",{className:"border rounded-lg max-h-[240px] overflow-y-auto divide-y",children:q.length===0?e.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:[e.jsx(hr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"No agents available"]}):q.map(U=>{const V=C.includes(U.id);return e.jsxs("button",{type:"button",className:Pt("w-full flex items-center gap-3 p-3 text-left transition-colors hover:bg-accent/50",V&&"bg-primary/5"),onClick:()=>$(U.id),children:[e.jsxs(gn,{className:"h-8 w-8",children:[e.jsx(Ea,{src:U.avatar_url||""}),e.jsx(xn,{className:"text-xs",children:(U.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:U.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:U.email})]}),e.jsx("div",{className:Pt("h-5 w-5 rounded-full border-2 flex items-center justify-center transition-colors shrink-0",V?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:V&&e.jsx(ua,{className:"h-3 w-3"})})]},U.id)})})]})]})}),e.jsx(On,{className:"gap-2 sm:gap-0",children:d===1?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>u(2),disabled:!p.trim(),children:["Next",e.jsx(Fi,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>u(1),children:[e.jsx(Ua,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(K,{onClick:R,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},V8t=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=aS(),[d,u]=S.useState(!1),[p,f]=S.useState(null),[v,_]=S.useState(""),{data:b}=Ct({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:L,error:R}=await G.from("brokerages").select("id, name").order("name");if(R)throw R;return L||[]}}),{data:j}=Ct({queryKey:["admin-team-member-info",t.map(L=>L.id).join(",")],queryFn:async()=>{var U;if(t.length===0)return{};const{data:L}=await G.from("team_members").select("team_id, user_id, role").in("team_id",t.map(V=>V.id));if(!L)return{};const R=L.filter(V=>V.role==="team_leader").map(V=>V.user_id);let $={};if(R.length>0){const{data:V}=await G.from("profiles").select("id, name").in("id",R);V&&($=Object.fromEntries(V.map(X=>[X.id,{name:X.name}])))}const q={};for(const V of t){const X=L.filter(te=>te.team_id===V.id),se=X.find(te=>te.role==="team_leader");q[V.id]={count:X.length,leaderName:se&&((U=$[se.user_id])==null?void 0:U.name)||null}}return q},enabled:t.length>0}),w=(p==null?void 0:p.brokerage_id)||null,{data:N}=Ct({queryKey:["brokerage-agents-for-teams",w],queryFn:async()=>{let L=G.from("profiles").select("id, name, email, avatar_url").order("name");w&&(L=L.eq("brokerage_id",w));const{data:R,error:$}=await L;if($)throw $;return R||[]},enabled:!!p}),C=Object.fromEntries((b||[]).map(L=>[L.id,L.name])),A=async L=>{const R=await r.mutateAsync({name:L.name,brokerage_id:L.brokerage_id||null,description:L.description});if(L.leaderId&&L.leaderId!=="none"&&await o.mutateAsync({team_id:R.id,user_id:L.leaderId,role:"team_leader"}),L.memberIds)for(const $ of L.memberIds)await o.mutateAsync({team_id:R.id,user_id:$,role:"team_member"});u(!1)};if(p)return e.jsx(vKe,{team:p,brokerageAgents:N||[],onBack:()=>f(null),onUpdate:L=>n.mutateAsync({id:p.id,...L}).then(R=>f(R)),onAddMember:(L,R)=>o.mutateAsync({team_id:p.id,user_id:L,role:R}),onRemoveMember:L=>l.mutateAsync({team_id:p.id,member_id:L}),onUpdateRole:(L,R)=>i.mutateAsync({team_id:p.id,member_id:L,role:R}),onDeleteTeam:()=>{a.mutate(p.id),f(null)},isUpdating:n.isPending,isAddingMember:o.isPending});const I=t.filter(L=>L.name.toLowerCase().includes(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(fn,{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(K,{size:"sm",onClick:()=>u(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(_Ke,{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(An,{children:[e.jsx(En,{children:e.jsxs(js,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"font-semibold",children:"Team Name"}),e.jsx(jt,{className:"font-semibold",children:"Brokerage"}),e.jsx(jt,{className:"font-semibold",children:"Leader"}),e.jsx(jt,{className:"font-semibold",children:"Members"}),e.jsx(jt,{className:"font-semibold",children:"Visibility"}),e.jsx(jt,{className:"w-[100px]"})]})}),e.jsx(Pn,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(L=>e.jsxs(js,{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(js,{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 R=j==null?void 0:j[L.id];return e.jsxs(js,{className:"hover:bg-muted/30",children:[e.jsxs(lt,{children:[e.jsx("button",{onClick:()=>f(L),className:"text-primary hover:underline font-medium",children:L.name}),L.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:L.description})]}),e.jsx(lt,{children:L.brokerage_id?e.jsx("span",{className:"text-sm",children:C[L.brokerage_id]||"—"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),e.jsx(lt,{children:R!=null&&R.leaderName?e.jsxs("span",{className:"text-sm flex items-center gap-1",children:[e.jsx(Bh,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),R.leaderName]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No leader"})}),e.jsx(lt,{children:e.jsxs(at,{variant:"secondary",className:"text-xs",children:[e.jsx(hr,{className:"h-3 w-3 mr-1"}),(R==null?void 0:R.count)??0]})}),e.jsx(lt,{children:e.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[e.jsx(rh,{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(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>f(L),title:"Edit team",children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>{confirm(`Delete team "${L.name}"? This cannot be undone.`)&&a.mutate(L.id)},title:"Delete team",children:e.jsx(br,{className:"h-3.5 w-3.5"})})]})})]},L.id)})})]})})]})},H8t=()=>{const t=Dr(),{user:s,isAdmin:r}=Gs(),{startImpersonation:n,isLoading:a}=M1e(),{toast:o}=Ia(),[l,i]=S.useState([]),[d,u]=S.useState([]),[p,f]=S.useState([]),[v,_]=S.useState({}),[b,j]=S.useState(!0),[w,N]=S.useState({}),[C,A]=S.useState(!1),[I,L]=S.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[R,$]=S.useState(!1),[q,U]=S.useState(""),[V,X]=S.useState(1),[se,te]=S.useState(50),[Y,de]=S.useState("all"),[ie,ae]=S.useState("all"),[le,pe]=S.useState("all"),[be,ye]=S.useState("all"),[we,ke]=S.useState(!1),[Ze,_e]=S.useState(!1),[Ce,Te]=S.useState(null),[Fe,Ae]=S.useState(null),[We,ht]=S.useState(!1),[De,Dt]=S.useState({name:"",email:"",brokerage_id:"",phone:""}),[he,Qe]=S.useState(null),[ot,rt]=S.useState(!1),[Ne,it]=S.useState(""),[qe,Xe]=S.useState(!1),[$e,Ke]=S.useState(!1),[ct,Ue]=S.useState(null),[Ve,Je]=S.useState(""),[Rt,$t]=S.useState(!1),[ls,Qt]=S.useState(!1),[rs,as]=S.useState(null),[ir,vt]=S.useState(!1),[Cs,or]=S.useState(!1),[Ar,Wn]=S.useState(null),[ai,bo]=S.useState(""),[Fa,yn]=S.useState(!1),[na,Nn]=S.useState({email:"",name:"",password:"",phone:""}),[ta,Kt]=S.useState(!1),[$r,es]=S.useState(!1),[nn,_a]=S.useState(""),[aa,Pr]=S.useState(!1),[ii,nl]=S.useState(!1),[mi,Vl]=S.useState(""),[dt,Se]=S.useState(new Set),[ze,st]=S.useState(!1),[Tt,Nt]=S.useState(!1),[Bt,Zt]=S.useState(null),[Ut,Xt]=S.useState(!1),[Is,xs]=S.useState(null),[pr,qr]=S.useState([]),[dr,Cn]=S.useState([]),[Mn,wn]=S.useState(!1),[ha,co]=S.useState({});S.useEffect(()=>{!s||!r||(Wa(),Wo())},[s,r]);const $o=async()=>{try{const{data:yt,error:Ts}=await G.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(Ts)throw Ts;const Ws={};for(const ln of yt??[])Ws[ln.brokerage_id]||(Ws[ln.brokerage_id]=[]),Ws[ln.brokerage_id].push(ln.user_id);_(Ws)}catch(yt){console.error("Error loading brokerage manager assignments:",yt)}},Wa=async()=>{try{j(!0);const{data:yt,error:Ts}=await G.functions.invoke("get-user-details");if(Ts)throw Ts;const Ws=yt.users||[];i(Ws),f(yt.brokerages||[]),await $o();const ln=Ws.filter(cn=>cn.roles.includes("assistant"));if(ln.length>0){const cn=ln.map(Fr=>Fr.id),{data:ea}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",cn);if(ea&&ea.length>0){const Fr=[...new Set(ea.map(qm=>qm.agent_id))],{data:to}=await G.from("profiles").select("id, name, email").in("id",Fr),Rf={};for(const qm of ea){const Hr=to==null?void 0:to.find(jy=>jy.id===qm.agent_id);Hr&&(Rf[qm.assistant_id]={agent_name:Hr.name||"",agent_email:Hr.email||""})}co(Rf)}}}catch(yt){console.error("Error loading members:",yt),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{j(!1)}},Wo=async()=>{try{const{data:yt,error:Ts}=await G.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(Ts)throw Ts;u(yt||[])}catch(yt){console.error("Error loading apps:",yt),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},Qi=async yt=>{if(!De.name.trim()||!De.email.trim()){o({title:"Error",description:"Name and email are required",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(De.email)){o({title:"Error",description:"Please enter a valid email address",variant:"destructive"});return}try{const{error:Ws}=await G.from("profiles").update({name:De.name.trim(),email:De.email.trim(),brokerage_id:De.brokerage_id||null,phone:De.phone.trim()||null}).eq("id",yt);if(Ws)throw Ws;o({title:"Success",description:"Member details updated successfully"}),Te(null),Wa()}catch(Ws){console.error("Error updating member:",Ws),o({title:"Error",description:Ws.message||"Failed to update member",variant:"destructive"})}},ba=async yt=>{try{const{data:{session:Ts}}=await G.auth.getSession(),Ws=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ts==null?void 0:Ts.access_token}`},body:JSON.stringify({userId:yt})}),ln=await Ws.json();if(!Ws.ok)throw new Error(ln.error||"Failed to resend welcome email");o({title:"Success",description:"Welcome email sent successfully"})}catch(Ts){console.error("Error resending welcome email:",Ts),o({title:"Error",description:Ts.message||"Failed to resend welcome email",variant:"destructive"})}},Ji=async(yt,Ts)=>{try{const{error:Ws}=await G.functions.invoke("send-password-reset",{body:{email:yt,redirectTo:window.location.origin}});if(Ws)throw Ws;o({title:"Password Reset Sent",description:`Password reset email sent to ${Ts}`})}catch(Ws){console.error("Error sending password reset:",Ws),o({title:"Error",description:Ws.message||"Failed to send password reset email",variant:"destructive"})}},yi=async(yt,Ts)=>{if(confirm(`Are you sure you want to delete ${Ts}? This action cannot be undone.`))try{const{data:{session:Ws}}=await G.auth.getSession(),ln=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ws==null?void 0:Ws.access_token}`},body:JSON.stringify({userId:yt})}),cn=await ln.json();if(!ln.ok)throw new Error(cn.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),Wa()}catch(Ws){console.error("Error deleting user:",Ws),o({title:"Error",description:Ws.message||"Failed to delete user",variant:"destructive"})}},sa=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 G.auth.getSession(),Ts=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)}),Ws=await Ts.json();if(!Ts.ok)throw new Error(Ws.error||"Failed to create user");if(I.role&&I.role!=="user"&&Ws.userId){const ln=I.role==="brokerage_manager"?I.brokerage_id:void 0;await eo(Ws.userId,I.role,"add",ln)}o({title:"Success",description:`User ${I.email} created successfully`}),L({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),$(!1),Wa()}catch(yt){console.error("Error creating user:",yt),o({title:"Error",description:yt.message||"Failed to create user",variant:"destructive"})}finally{A(!1)}},eo=async(yt,Ts,Ws,ln)=>{try{const{data:{session:cn}}=await G.auth.getSession(),ea={userId:yt,role:Ts,action:Ws};if(Ts==="brokerage_manager"){if(!ln){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}ea.brokerageId=ln}const Fr=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${cn==null?void 0:cn.access_token}`},body:JSON.stringify(ea)}),to=await Fr.json();if(!Fr.ok)throw new Error(to.error||"Failed to manage user role");o({title:"Success",description:`Role ${Ws==="add"?"added":"removed"} successfully`}),Wa()}catch(cn){console.error("Error managing user role:",cn),o({title:"Error",description:cn.message||"Failed to manage user role",variant:"destructive"})}},ac=(yt,Ts)=>Ts.length===0?!0:Ts.some(Ws=>yt.includes(Ws)),yc=async(yt,Ts,Ws)=>{const ln=`${yt}-${Ts.id}`;Qe(ln);try{if(Ws){const cn=l.find(Fr=>Fr.id===yt),ea=Ts.required_tags.filter(Fr=>cn==null?void 0:cn.tags.includes(Fr));for(const Fr of ea){const{error:to}=await G.from("user_tags").delete().eq("user_id",yt).eq("tag",Fr);if(to)throw to}o({title:"Access Removed",description:`Removed access to ${Ts.name}`})}else if(Ts.required_tags.length>0){const{error:cn}=await G.from("user_tags").insert({user_id:yt,tag:Ts.required_tags[0]});if(cn)throw cn;o({title:"Access Granted",description:`Granted access to ${Ts.name}`})}await Wa()}catch(cn){console.error("Error toggling access:",cn),o({title:"Error",description:cn.message||"Failed to update access",variant:"destructive"})}finally{Qe(null)}},Ad=async()=>{const yt=Ne.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(p.find(Ws=>Ws.name.toLowerCase()===yt.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}Xe(!0);try{const{error:Ws}=await G.from("brokerages").insert({name:yt});if(Ws)throw Ws;o({title:"Success",description:`Brokerage "${yt}" created successfully`}),it(""),rt(!1),Wa()}catch(Ws){console.error("Error creating brokerage:",Ws),o({title:"Error",description:Ws.message||"Failed to create brokerage",variant:"destructive"})}finally{Xe(!1)}},kp=yt=>{Ue(yt),Je(yt.name),Ke(!0)},vl=()=>{Ue(null),Je(""),Ke(!1)},wu=async()=>{if(!ct)return;const yt=Ve.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}$t(!0);try{const{error:Ts}=await G.from("brokerages").update({name:yt}).eq("id",ct.id);if(Ts)throw Ts;o({title:"Success",description:"Brokerage updated successfully"}),vl(),Wa()}catch(Ts){console.error("Error updating brokerage:",Ts),o({title:"Error",description:Ts.message||"Failed to update brokerage",variant:"destructive"})}finally{$t(!1)}},Xc=async(yt,Ts)=>{var Ws;if(!Ts||typeof Ts!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const ln={userId:yt,role:"brokerage_manager",action:"add",brokerageId:Ts};console.debug("[assignManagerToBrokerage] payload",ln);const{data:{session:cn}}=await G.auth.getSession(),ea=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${cn==null?void 0:cn.access_token}`},body:JSON.stringify(ln)}),Fr=await ea.json();if(!ea.ok&&!((Ws=Fr.error)!=null&&Ws.includes("duplicate")))throw new Error(Fr.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await Wa()}catch(ln){console.error("Error assigning manager:",ln),o({title:"Error",description:ln.message||"Failed to assign manager",variant:"destructive"})}},em=yt=>{as(yt),Qt(!0)},_l=async()=>{if(rs){vt(!0);try{const yt=l.filter(ln=>ln.brokerage_id===rs.id),{data:{session:Ts}}=await G.auth.getSession();for(const ln of yt){const cn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ts==null?void 0:Ts.access_token}`},body:JSON.stringify({userId:ln.id})});if(!cn.ok){const ea=await cn.json();console.error(`Failed to delete user ${ln.email}:`,ea.error)}}const{error:Ws}=await G.from("brokerages").delete().eq("id",rs.id);if(Ws)throw Ws;o({title:"Success",description:`Brokerage "${rs.name}" and ${yt.length} member(s) deleted`}),Qt(!1),as(null),Wa()}catch(yt){console.error("Error deleting brokerage:",yt),o({title:"Error",description:yt.message||"Failed to delete brokerage",variant:"destructive"})}finally{vt(!1)}}},Lf=yt=>{Wn(yt),bo(""),or(!0)},ex=()=>{Wn(null),bo(""),or(!1)},ov=async yt=>{try{const{error:Ts}=await G.from("profiles").update({brokerage_id:null}).eq("id",yt);if(Ts)throw Ts;o({title:"Success",description:"User removed from brokerage"}),Wa()}catch(Ts){console.error("Error removing user from brokerage:",Ts),o({title:"Error",description:Ts.message||"Failed to remove user",variant:"destructive"})}},lv=async(yt,Ts)=>{try{const{error:Ws}=await G.from("profiles").update({brokerage_id:Ts}).eq("id",yt);if(Ws)throw Ws;o({title:"Success",description:"User added to brokerage"}),Wa()}catch(Ws){console.error("Error adding user to brokerage:",Ws),o({title:"Error",description:Ws.message||"Failed to add user",variant:"destructive"})}},cv=async()=>{if(!Ar||!na.email||!na.name||!na.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}Kt(!0);try{const{data:{session:yt}}=await G.auth.getSession(),Ts=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({...na,brokerage_id:Ar.id,role:"user"})}),Ws=await Ts.json();if(!Ts.ok)throw new Error(Ws.error||"Failed to create agent");o({title:"Success",description:`Agent ${na.email} created successfully`}),Nn({email:"",name:"",password:"",phone:""}),yn(!1),Wa()}catch(yt){console.error("Error creating agent:",yt),o({title:"Error",description:yt.message||"Failed to create agent",variant:"destructive"})}finally{Kt(!1)}},$m=yt=>l.filter(Ts=>Ts.brokerage_id===yt),hh=yt=>{const Ts=$m(yt);if(!ai)return Ts;const Ws=ai.toLowerCase();return Ts.filter(ln=>ln.name.toLowerCase().includes(Ws)||ln.email.toLowerCase().includes(Ws))},Ed=yt=>l.filter(Ts=>Ts.brokerage_id!==yt),mh=l.filter(yt=>{var Ws;if(q){const ln=q.toLowerCase();if(!(yt.name.toLowerCase().includes(ln)||yt.email.toLowerCase().includes(ln)||((Ws=yt.brokerage_name)==null?void 0:Ws.toLowerCase().includes(ln))))return!1}if(Y==="claimed"&&!yt.claimed||Y==="unclaimed"&&yt.claimed||ie!=="all"&&!yt.roles.includes(ie))return!1;const Ts=yt.is_trial||yt.subscription_status==="trialing";return!(le==="trial"&&!Ts||le==="non-trial"&&Ts||be==="none"&&yt.brokerage_id||be!=="all"&&be!=="none"&&yt.brokerage_id!==be)}),{sortKey:md,sortDirection:Qc,handleSort:Pd,sortData:Np}=UL("created_at","desc"),Sp=Np(mh,{name:yt=>{var Ts;return((Ts=yt.name)==null?void 0:Ts.toLowerCase())||""},brokerage:yt=>{var Ts;return((Ts=yt.brokerage_name)==null?void 0:Ts.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}),tm=Sp.length,sm=se===0,Jc=sm?1:Math.ceil(tm/se),vy=sm?0:(V-1)*se,Df=sm?tm:vy+se,hl=Sp.slice(vy,Df),dv=yt=>{U(yt),X(1)},Of=yt=>{te(yt),X(1)},Uu=(yt,Ts)=>{yt(Ts),X(1)},sb=async(yt,Ts)=>{ke(!0);try{const Ws=l.find(Fr=>Fr.id===yt);if(!Ws)return;const ln=Ws.trial_expires_at?new Date(Ws.trial_expires_at):new Date,cn=new Date(ln.getTime()+Ts*24*60*60*1e3),{error:ea}=await G.from("profiles").update({trial_expires_at:cn.toISOString()}).eq("id",yt);if(ea)throw ea;o({title:"Trial Extended",description:`Trial extended by ${Ts} days`}),Wa()}catch(Ws){console.error("Error extending trial:",Ws),o({title:"Error",description:Ws.message||"Failed to extend trial",variant:"destructive"})}finally{ke(!1)}},hS=async yt=>{_e(!0);try{const{error:Ts}=await G.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",yt);if(Ts)throw Ts;o({title:"Account Converted",description:"User has been converted to a full account"}),Wa(),tx()}catch(Ts){console.error("Error converting trial:",Ts),o({title:"Error",description:Ts.message||"Failed to convert account",variant:"destructive"})}finally{_e(!1)}},_y=async yt=>{wn(!0);try{const{data:Ts}=await G.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",yt);if(Ts&&Ts.length>0){const ln=Ts.map(ea=>ea.assistant_id),{data:cn}=await G.from("profiles").select("id, name, email").in("id",ln);qr(Ts.map(ea=>{const Fr=cn==null?void 0:cn.find(to=>to.id===ea.assistant_id);return{id:ea.id,assistant_id:ea.assistant_id,assistant_name:(Fr==null?void 0:Fr.name)||"Unknown",assistant_email:(Fr==null?void 0:Fr.email)||"",permissions:ea.permissions||{}}}))}else qr([]);const{data:Ws}=await G.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",yt);if(Ws&&Ws.length>0){const ln=Ws.map(ea=>ea.agent_id),{data:cn}=await G.from("profiles").select("id, name, email").in("id",ln);Cn(Ws.map(ea=>{const Fr=cn==null?void 0:cn.find(to=>to.id===ea.agent_id);return{id:ea.id,agent_id:ea.agent_id,agent_name:(Fr==null?void 0:Fr.name)||"Unknown",agent_email:(Fr==null?void 0:Fr.email)||"",permissions:ea.permissions||{}}}))}else Cn([])}catch(Ts){console.error("Error loading assistant data:",Ts)}finally{wn(!1)}},wa=yt=>{Ae(yt),Dt({name:yt.name,email:yt.email,brokerage_id:yt.brokerage_id||"",phone:yt.phone||""}),ht(!0),_y(yt.id)},tx=()=>{Ae(null),ht(!1),Dt({name:"",email:"",brokerage_id:"",phone:""})},rb=async()=>{Fe&&(await Qi(Fe.id),tx())},mS=yt=>{Se(Ts=>{const Ws=new Set(Ts);return Ws.has(yt)?Ws.delete(yt):Ws.add(yt),Ws})},pS=()=>{if(dt.size===hl.length&&hl.every(yt=>dt.has(yt.id))){const yt=new Set(dt);hl.forEach(Ts=>yt.delete(Ts.id)),Se(yt)}else{const yt=new Set(dt);hl.forEach(Ts=>yt.add(Ts.id)),Se(yt)}},ph=()=>{Se(new Set)},by=async()=>{if(dt.size===0)return;st(!0);let yt=0,Ts=0;try{const{data:{session:Ws}}=await G.auth.getSession();for(const ln of dt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ws==null?void 0:Ws.access_token}`},body:JSON.stringify({userId:ln})})).ok?yt++:Ts++}catch{Ts++}o({title:"Bulk Email Complete",description:`Sent ${yt} emails${Ts>0?`, ${Ts} failed`:""}`}),ph()}catch(Ws){o({title:"Error",description:Ws.message||"Failed to send emails",variant:"destructive"})}finally{st(!1)}},wy=async()=>{if(dt.size===0)return;st(!0);let yt=0,Ts=0;try{const{data:{session:Ws}}=await G.auth.getSession();for(const ln of dt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-password-reset",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ws==null?void 0:Ws.access_token}`},body:JSON.stringify({userId:ln})})).ok?yt++:Ts++}catch{Ts++}o({title:"Bulk Password Reset Complete",description:`Sent ${yt} reset emails${Ts>0?`, ${Ts} failed`:""}`}),ph()}catch(Ws){o({title:"Error",description:Ws.message||"Failed to send password reset emails",variant:"destructive"})}finally{st(!1)}},nb=async()=>{if(dt.size===0)return;const yt=l.filter(cn=>dt.has(cn.id)).map(cn=>cn.name).slice(0,5).join(", "),Ts=dt.size>5?` and ${dt.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${dt.size} users (${yt}${Ts})? This action cannot be undone.`))return;st(!0);let Ws=0,ln=0;try{const{data:{session:cn}}=await G.auth.getSession();for(const ea of dt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${cn==null?void 0:cn.access_token}`},body:JSON.stringify({userId:ea})})).ok?Ws++:ln++}catch{ln++}o({title:"Bulk Delete Complete",description:`Deleted ${Ws} users${ln>0?`, ${ln} failed`:""}`}),ph(),Wa()}catch(cn){o({title:"Error",description:cn.message||"Failed to delete users",variant:"destructive"})}finally{st(!1)}},uv=async()=>{Nt(!0);try{const{data:{session:yt}}=await G.auth.getSession(),Ts=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(!Ts.ok){const ln=await Ts.json();throw new Error(ln.error||"Failed to sync phones")}const Ws=await Ts.json();o({title:"Phone Sync Complete",description:`Pulled ${Ws.summary.pulledFromGHL} from GHL, pushed ${Ws.summary.pushedToGHL} to GHL, ${Ws.summary.alreadySynced} already synced`}),Wa()}catch(yt){o({title:"Error",description:yt.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{Nt(!1)}},rm=async(yt,Ts)=>{Zt(yt);try{const{data:{session:Ws}}=await G.auth.getSession(),{data:ln}=await G.from("profiles").select("phone").eq("id",yt).single(),cn=(ln==null?void 0:ln.phone)||"",ea=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-tag-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ws==null?void 0:Ws.access_token}`},body:JSON.stringify({email:Ts,action:"update",phone:cn||void 0})});if(!ea.ok){const to=await ea.json();throw new Error(to.error||"Failed to sync with GHL")}const Fr=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(Ts)}`,{method:"GET",headers:{"Content-Type":"application/json"}});o({title:"Phone Synced",description:cn?`Phone ${cn} synced to GHL`:"Sync attempted - run bulk sync to pull phone from GHL"}),Wa()}catch(Ws){o({title:"Error",description:Ws.message||"Failed to sync phone",variant:"destructive"})}finally{Zt(null)}},sx=async yt=>{await n(yt)},ab=()=>{if(dt.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const yt=l.filter(to=>dt.has(to.id)),Ts=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],Ws=yt.map(to=>[to.name,to.email,to.phone||"",to.brokerage_name||"",to.roles.join("; "),to.claimed?"Claimed":"Unclaimed",new Date(to.created_at).toLocaleDateString()]),ln=[Ts.join(","),...Ws.map(to=>to.map(Rf=>`"${(Rf||"").replace(/"/g,'""')}"`).join(","))].join(` `),cn=new Blob([ln],{type:"text/csv"}),ea=URL.createObjectURL(cn),Fr=document.createElement("a");Fr.href=ea,Fr.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,Fr.click(),URL.revokeObjectURL(ea),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(_u,{title:"Member Management",description:"Manage users, roles, and permissions"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:uv,disabled:Tt,children:[Tt?e.jsx(As,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Zn,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:Tt?"Syncing...":"Sync Phones with GHL"}),e.jsx("span",{className:"sm:hidden",children:Tt?"Syncing...":"Sync GHL"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>es(!0),children:[e.jsx(C0,{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(vs,{open:R,onOpenChange:$,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(xc,{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(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{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(ve,{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(ve,{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(ve,{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(ve,{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(sr,{placeholder:I.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"None"}),p.map(yt=>e.jsx(At,{value:yt.id,children:yt.name},yt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(sr,{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(ve,{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(sr,{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(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),e.jsx(K,{onClick:sa,disabled:C,children:C?"Creating...":"Create User"})]})]})]})]})]}),e.jsxs(Na,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[e.jsxs(va,{children:[e.jsx(ks,{value:"members",children:"Members"}),e.jsx(ks,{value:"brokerages",children:"Brokerages"}),e.jsx(ks,{value:"teams",children:"Teams"}),e.jsx(ks,{value:"trials",children:"Trial Users"}),e.jsx(ks,{value:"access",children:"Access Matrix"}),e.jsx(ks,{value:"celebrations",children:"Celebrations"}),e.jsx(ks,{value:"deletions",children:"Deletion Log"})]}),e.jsxs(zs,{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(fn,{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=>dv(yt.target.value),className:"pl-10 h-9"})]}),e.jsxs(tr,{value:Y,onValueChange:yt=>Uu(de,yt),children:[e.jsx(Js,{className:"w-[130px] h-9",children:e.jsx(sr,{})}),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:ie,onValueChange:yt=>Uu(ae,yt),children:[e.jsx(Js,{className:"w-[130px] h-9",children:e.jsx(sr,{})}),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:le,onValueChange:yt=>Uu(pe,yt),children:[e.jsx(Js,{className:"w-[130px] h-9",children:e.jsx(sr,{})}),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=>Uu(ye,yt),children:[e.jsx(Js,{className:"w-[150px] h-9",children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Brokerages"}),e.jsx(At,{value:"none",children:"No Brokerage"}),p.map(yt=>e.jsx(At,{value:yt.id,children:yt.name},yt.id))]})]}),(q||Y!=="all"||ie!=="all"||le!=="all"||be!=="all")&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{U(""),de("all"),ae("all"),pe("all"),ye("all"),X(1)},children:[e.jsx(Ur,{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:sm?`Showing all ${tm} members`:`Showing ${vy+1}-${Math.min(Df,tm)} of ${tm} members`}),e.jsxs(tr,{value:se.toString(),onValueChange:yt=>Of(Number(yt)),children:[e.jsx(Js,{className:"h-9 w-[110px]",children:e.jsx(sr,{})}),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"})]})]})]})]}),dt.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(d0,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm font-medium",children:[dt.size," selected"]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:by,disabled:ze,children:[ze?e.jsx(As,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(_r,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Resend Invite"}),e.jsx("span",{className:"sm:hidden",children:"Invite"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:wy,disabled:ze,children:[ze?e.jsx(As,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Im,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Password Reset"}),e.jsx("span",{className:"sm:hidden",children:"Reset"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:ab,children:[e.jsx(xi,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Export"}),e.jsx("span",{className:"sm:hidden",children:"CSV"})]}),e.jsxs(K,{size:"sm",variant:"destructive",onClick:nb,disabled:ze,children:[ze?e.jsx(As,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(br,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"}),e.jsx("span",{className:"sm:hidden",children:"Del"})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:ph,disabled:ze,children:e.jsx(Ur,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"w-[50px]",children:e.jsx(zo,{checked:hl.length>0&&hl.every(yt=>dt.has(yt.id)),onCheckedChange:pS,"aria-label":"Select all on page"})}),e.jsx(el,{sortKey:"name",currentSortKey:md,currentDirection:Qc,onSort:Pd,children:"Name"}),e.jsx(el,{sortKey:"brokerage",currentSortKey:md,currentDirection:Qc,onSort:Pd,children:"Brokerage"}),e.jsx(el,{sortKey:"status",currentSortKey:md,currentDirection:Qc,onSort:Pd,children:"Status"}),e.jsx(el,{sortKey:"role",currentSortKey:md,currentDirection:Qc,onSort:Pd,children:"Role"}),e.jsx(el,{sortKey:"last_login",currentSortKey:md,currentDirection:Qc,onSort:Pd,children:"Last Login"}),e.jsx(el,{sortKey:"created_at",currentSortKey:md,currentDirection:Qc,onSort:Pd,children:"Member Since"}),e.jsx(jt,{className:"w-[100px]"})]})}),e.jsx(Pn,{children:hl.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):hl.map(yt=>e.jsxs(js,{className:`hover:bg-muted/30 ${dt.has(yt.id)?"bg-primary/5":""}`,children:[e.jsx(lt,{children:e.jsx(zo,{checked:dt.has(yt.id),onCheckedChange:()=>mS(yt.id),"aria-label":`Select ${yt.name}`})}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>wa(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 Ts=yt.is_trial&&yt.trial_expires_at||!yt.is_trial&&yt.subscription_status==="trialing"&&yt.subscription_end_date,Ws=yt.trial_expires_at||yt.subscription_end_date;if(Ts&&Ws){const ln=Math.ceil((new Date(Ws).getTime()-Date.now())/864e5),cn=ln<=0,ea=ln<=3;return e.jsx(at,{variant:"outline",className:Pt("w-fit",cn?"border-destructive text-destructive":ea?"border-amber-500 text-amber-600":"border-violet-300 text-violet-700 bg-violet-50"),children:cn?"Trial Expired":`Trial · ${ln}d left`})}return e.jsx(at,{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")&&ha[yt.id]&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",ha[yt.id].agent_name||ha[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(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",onClick:()=>{xs(yt),Xt(!0)},title:"Send celebration",children:e.jsx(Sd,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>wa(yt),title:"Edit member",children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>rm(yt.id,yt.email),disabled:Bt===yt.id,title:"Sync phone with GHL",children:Bt===yt.id?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(Zn,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ba(yt.id),title:"Resend welcome email",children:e.jsx(_r,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Ji(yt.email,yt.name),title:"Send password reset",children:e.jsx(rN,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>sx(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(As,{className:"h-4 w-4 animate-spin"}):e.jsx(f5,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>yi(yt.id,yt.name),title:"Delete user",children:e.jsx(br,{className:"h-4 w-4"})})]})})]},yt.id))})]})}),Jc>1&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Page ",V," of ",Jc]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>X(1),disabled:V===1,children:"First"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(yt=>Math.max(1,yt-1)),disabled:V===1,children:e.jsx(zl,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,Jc)},(yt,Ts)=>{let Ws;return Jc<=5||V<=3?Ws=Ts+1:V>=Jc-2?Ws=Jc-4+Ts:Ws=V-2+Ts,e.jsx(K,{variant:V===Ws?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>X(Ws),children:Ws},Ws)})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(yt=>Math.min(Jc,yt+1)),disabled:V===Jc,children:e.jsx(Ha,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>X(Jc),disabled:V===Jc,children:"Last"})]})]})]}),e.jsx(vs,{open:We,onOpenChange:ht,children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{htmlFor:"edit-name",children:"Name"}),e.jsx(Re,{id:"edit-name",value:De.name,onChange:yt=>Dt({...De,name:yt.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"edit-email",children:"Email"}),e.jsx(Re,{id:"edit-email",type:"email",value:De.email,onChange:yt=>Dt({...De,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(ve,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(Re,{id:"edit-phone",type:"tel",value:De.phone,onChange:yt=>Dt({...De,phone:yt.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs(tr,{value:De.brokerage_id||"none",onValueChange:yt=>Dt({...De,brokerage_id:yt==="none"?"":yt}),children:[e.jsx(Js,{id:"edit-brokerage",children:e.jsx(sr,{placeholder:"Select brokerage"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"None"}),p.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(at,{variant:"default",className:"gap-1",children:[e.jsx(rh,{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:()=>eo(Fe.id,yt,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(Ur,{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=>eo(Fe.id,yt,"add"),children:[e.jsx(Js,{className:"w-[200px]",children:e.jsx(sr,{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"})]}),(pr.length>0||dr.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(hr,{className:"h-4 w-4"}),"Assistant Relationships"]}),Mn?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(As,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs("div",{className:"space-y-3",children:[pr.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:"}),pr.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(at,{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(([,Ts])=>Ts).map(([Ts])=>e.jsx(at,{variant:"secondary",className:"text-[10px] capitalize",children:Ts},Ts))})]},yt.id))]}),dr.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:"}),dr.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(at,{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(([,Ts])=>Ts).map(([Ts])=>e.jsx(at,{variant:"secondary",className:"text-[10px] capitalize",children:Ts},Ts))})]},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 Ts=ac(Fe.tags,yt.required_tags),Ws=`${Fe.id}-${yt.id}`,ln=he===Ws,cn=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}),cn&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Available to all members"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:ln?e.jsx(As,{className:"h-4 w-4 animate-spin text-muted-foreground"}):cn?e.jsx(at,{variant:"secondary",className:"text-xs",children:"Always On"}):e.jsx(Br,{checked:Ts,onCheckedChange:()=>yc(Fe.id,yt,Ts)})})]},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(FAe,{expiresAt:Fe.trial_expires_at}),!Fe.trial_expires_at&&Fe.subscription_status==="trialing"&&Fe.subscription_end_date&&e.jsx(FAe,{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(K,{size:"sm",variant:"outline",onClick:()=>sb(Fe.id,7),disabled:we,children:[e.jsx(Q1,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>sb(Fe.id,14),disabled:we,children:[e.jsx(Q1,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>sb(Fe.id,30),disabled:we,children:[e.jsx(Q1,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(K,{size:"sm",variant:"default",onClick:()=>hS(Fe.id),disabled:Ze,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(l_,{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(On,{children:[e.jsx(K,{variant:"outline",onClick:tx,children:"Cancel"}),e.jsx(K,{onClick:rb,children:"Save Changes"})]})]})}),e.jsxs(zs,{value:"access",children:[d.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsx(K,{onClick:()=>t("/admin/apps"),children:"Configure Apps"})]})}):e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Member Access Matrix"}),e.jsx(yr,{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:[hl.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(Ts=>{const Ws=ac(yt.tags,Ts.required_tags),ln=`${yt.id}-${Ts.id}`,cn=he===ln;return e.jsx("td",{className:"p-4 text-center",children:e.jsx("div",{className:"flex items-center justify-center",children:cn?e.jsx(As,{className:"h-5 w-5 animate-spin text-muted-foreground"}):e.jsx(Br,{checked:Ws,onCheckedChange:()=>yc(yt.id,Ts,Ws),disabled:Ts.required_tags.length===0})})},Ts.id)})]},yt.id)),hl.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"})})]})]})}),Jc>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 ",vy+1,"-",Math.min(Df,tm)," of ",tm," • Page ",V," of ",Jc]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(yt=>Math.max(1,yt-1)),disabled:V===1,children:e.jsx(zl,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(yt=>Math.min(Jc,yt+1)),disabled:V===Jc,children:e.jsx(Ha,{className:"h-4 w-4"})})]})]})]})]}),e.jsx("div",{className:"mt-6",children:e.jsx(K,{variant:"outline",onClick:()=>t("/admin/apps"),children:"Manage Apps"})})]}),e.jsxs(zs,{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(fn,{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:nn,onChange:yt=>_a(yt.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[p.filter(yt=>yt.name.toLowerCase().includes(nn.toLowerCase())).length," of ",p.length," brokerages"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{const yt=[];for(const Fr of p){const to=v[Fr.id]??[];for(const Rf of to){const qm=l.find(Hr=>Hr.id===Rf);if(qm){const Hr=(qm.name||"").trim().split(/\s+/),jy=Hr[0]||"",ky=Hr.slice(1).join(" ")||"";yt.push({firstName:jy,lastName:ky,email:qm.email,brokerageName:Fr.name})}}}if(yt.length===0){o({title:"No managers found to export"});return}const Ws=[["First Name","Last Name","Email","Brokerage Name"].join(","),...yt.map(Fr=>[Fr.firstName,Fr.lastName,Fr.email,Fr.brokerageName].map(to=>`"${(to||"").replace(/"/g,'""')}"`).join(","))].join(` `),ln=new Blob([Ws],{type:"text/csv"}),cn=URL.createObjectURL(ln),ea=document.createElement("a");ea.href=cn,ea.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,ea.click(),URL.revokeObjectURL(cn),o({title:`Exported ${yt.length} managers`})},children:[e.jsx(xi,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(vs,{open:ot,onOpenChange:rt,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Aa,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(Re,{id:"brokerage-name",placeholder:"Enter brokerage name",value:Ne,onChange:yt=>it(yt.target.value),maxLength:100})]})}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>rt(!1),children:"Cancel"}),e.jsx(K,{onClick:Ad,disabled:qe,children:qe?"Creating...":"Create Brokerage"})]})]})]})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"font-semibold",children:"Brokerage Name"}),e.jsx(jt,{className:"font-semibold",children:"Manager(s)"}),e.jsx(jt,{className:"font-semibold",children:"Agents"}),e.jsx(jt,{className:"w-[150px]"})]})}),e.jsx(Pn,{children:(()=>{const yt=p.filter(Ts=>Ts.name.toLowerCase().includes(nn.toLowerCase()));return yt.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:nn?"No brokerages match your search":"No brokerages found"})}):yt.map(Ts=>{const Ws=l.filter(Fr=>Fr.brokerage_id===Ts.id),cn=(v[Ts.id]??[]).map(Fr=>l.find(to=>to.id===Fr)).filter(Boolean),ea=Ws.length;return e.jsxs(js,{className:"hover:bg-muted/30",children:[e.jsx(lt,{children:e.jsx("button",{onClick:()=>kp(Ts),className:"text-primary hover:underline font-medium",children:Ts.name})}),e.jsx(lt,{children:cn.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:cn.map(Fr=>e.jsx(at,{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:[ea," member",ea!==1?"s":""]}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"h-8",onClick:()=>Lf(Ts),children:[e.jsx(hr,{className:"h-4 w-4 mr-1"}),"Manage"]}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>kp(Ts),title:"Edit brokerage",children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>em(Ts),title:"Delete brokerage",children:e.jsx(br,{className:"h-4 w-4"})})]})})]},Ts.id)})})()})]})}),e.jsx(vs,{open:$e,onOpenChange:Ke,children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{children:"Edit Brokerage"}),e.jsx(Kr,{children:"Update brokerage details and manage managers"})]}),ct&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"edit-brokerage-name",children:"Brokerage Name"}),e.jsx(Re,{id:"edit-brokerage-name",value:Ve,onChange:yt=>Je(yt.target.value),maxLength:100})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{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 Ts=(v[ct.id]??[]).map(Ws=>l.find(ln=>ln.id===Ws)).filter(Boolean);return Ts.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):Ts.map(Ws=>e.jsxs(at,{variant:"default",className:"gap-1",children:[e.jsx(rh,{className:"h-3 w-3"}),Ws.name,e.jsx("button",{onClick:()=>eo(Ws.id,"brokerage_manager","remove",ct.id),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove manager from this brokerage",children:e.jsx(Ur,{className:"h-3 w-3"})})]},Ws.id))})()}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{className:"text-sm text-muted-foreground",children:"Assign manager from existing members:"}),e.jsxs(So,{open:aa,onOpenChange:Pr,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":aa,className:"w-full justify-between",children:["Search for a member...",e.jsx(fn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(ko,{className:"w-full p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search by name or email..."}),e.jsxs(kf,{className:"max-h-[200px]",children:[e.jsx(Nf,{children:"No members found."}),e.jsx(Sf,{children:(()=>{const yt=new Set(v[ct.id]??[]);return l.filter(Ts=>!yt.has(Ts.id)&&(r||Ts.brokerage_id===ct.id)).map(Ts=>e.jsxs(Nm,{value:`${Ts.name} ${Ts.email}`,onSelect:()=>{Xc(Ts.id,ct.id),Pr(!1)},children:[Ts.name," (",Ts.email,")"]},Ts.id))})()})]})]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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===ct.id).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(yt=>yt.brokerage_id===ct.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(at,{variant:"outline",className:"text-xs",children:"Manager"})]},yt.id))})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:vl,children:"Cancel"}),e.jsx(K,{onClick:wu,disabled:Rt,children:Rt?"Saving...":"Save Changes"})]})]})}),e.jsx(vs,{open:ls,onOpenChange:Qt,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(Kr,{children:['Are you sure you want to delete "',rs==null?void 0:rs.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 "',rs==null?void 0:rs.name,'"']}),e.jsxs("li",{children:["All ",l.filter(yt=>yt.brokerage_id===(rs==null?void 0:rs.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>Qt(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:_l,disabled:ir,children:ir?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(vs,{open:Cs,onOpenChange:or,children:e.jsxs(ys,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Aa,{className:"h-5 w-5"}),"Manage ",Ar==null?void 0:Ar.name]}),e.jsx(Kr,{children:"Add, remove, or manage users in this brokerage"})]}),Ar&&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(fn,{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:ai,onChange:yt=>bo(yt.target.value),className:"pl-10 h-9"})]}),e.jsxs(vs,{open:Fa,onOpenChange:yn,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(xc,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{children:"Add New Agent"}),e.jsxs(Kr,{children:["Create a new agent for ",Ar.name]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"agent-name",children:"Name"}),e.jsx(Re,{id:"agent-name",placeholder:"John Doe",value:na.name,onChange:yt=>Nn({...na,name:yt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"agent-email",children:"Email"}),e.jsx(Re,{id:"agent-email",type:"email",placeholder:"john@example.com",value:na.email,onChange:yt=>Nn({...na,email:yt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"agent-password",children:"Password"}),e.jsx(Re,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:na.password,onChange:yt=>Nn({...na,password:yt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"agent-phone",children:"Phone (optional)"}),e.jsx(Re,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:na.phone,onChange:yt=>Nn({...na,phone:yt.target.value})})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>yn(!1),children:"Cancel"}),e.jsx(K,{onClick:cv,disabled:ta,children:ta?"Creating...":"Create Agent"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Add existing user:"}),e.jsxs(So,{open:ii,onOpenChange:nl,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":ii,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(fn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(ko,{className:"w-[300px] p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search users...",value:mi,onValueChange:Vl}),e.jsxs(kf,{children:[e.jsx(Nf,{children:"No users found."}),e.jsx(Sf,{children:Ed(Ar.id).filter(yt=>mi===""||yt.name.toLowerCase().includes(mi.toLowerCase())||yt.email.toLowerCase().includes(mi.toLowerCase())).map(yt=>e.jsxs(Nm,{value:`${yt.name} ${yt.email}`,onSelect:()=>{lv(yt.id,Ar.id),nl(!1),Vl("")},children:[yt.name," (",yt.email,")"]},yt.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"font-semibold",children:"Name"}),e.jsx(jt,{className:"font-semibold",children:"Email"}),e.jsx(jt,{className:"font-semibold",children:"Status"}),e.jsx(jt,{className:"font-semibold",children:"Role"}),e.jsx(jt,{className:"w-[120px]"})]})}),e.jsx(Pn,{children:hh(Ar.id).length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:ai?"No matching members found":"No members in this brokerage"})}):hh(Ar.id).map(yt=>e.jsxs(js,{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(at,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):e.jsx(at,{variant:"secondary",children:"Pending"})}),e.jsx(lt,{children:yt.roles.includes("brokerage_manager")?e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(rh,{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(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ba(yt.id),title:"Resend welcome email",children:e.jsx(_r,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ov(yt.id),title:"Remove from brokerage",children:e.jsx(Ur,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>sx(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(As,{className:"h-4 w-4 animate-spin"}):e.jsx(f5,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>yi(yt.id,yt.name),title:"Delete user",children:e.jsx(br,{className:"h-4 w-4"})})]})})]},yt.id))})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[$m(Ar.id).length," total member",$m(Ar.id).length!==1?"s":""," •",$m(Ar.id).filter(yt=>yt.roles.includes("brokerage_manager")).length," manager",$m(Ar.id).filter(yt=>yt.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(On,{children:e.jsx(K,{variant:"outline",onClick:ex,children:"Close"})})]})})]}),e.jsx(zs,{value:"teams",children:e.jsx(V8t,{})}),e.jsx(zs,{value:"trials",children:e.jsx(B8t,{})}),e.jsx(zs,{value:"celebrations",children:e.jsx(z8t,{})}),e.jsx(zs,{value:"deletions",children:e.jsx($8t,{})})]})]}),e.jsx(pKe,{open:$r,onOpenChange:es,brokerages:p,onSuccess:Wa}),Is&&e.jsx(fKe,{open:Ut,onOpenChange:yt=>{Xt(yt),yt||xs(null)},userId:Is.id,userName:Is.name})]})},W8t=()=>{const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(!1),[l,i]=S.useState(""),[d,u]=S.useState(""),[p,f]=S.useState(""),[v,_]=S.useState("");S.useEffect(()=>{b()},[]);const b=async()=>{const{data:L,error:R}=await G.from("invite_codes").select("*").order("created_at",{ascending:!1});R?(fe.error("Failed to load invite codes"),console.error(R)):s(L||[]),n(!1)},j=async L=>{if(L.preventDefault(),!l.trim()){fe.error("Please enter a code");return}o(!0);const{error:R}=await G.from("invite_codes").insert({code:l.trim().toUpperCase(),description:d.trim()||null,max_uses:p?parseInt(p):null,trial_days:v?parseInt(v):null});R?R.code==="23505"?fe.error("This code already exists"):(fe.error("Failed to create invite code"),console.error(R)):(fe.success("Invite code created"),i(""),u(""),f(""),_(""),b()),o(!1)},w=async(L,R)=>{const{error:$}=await G.from("invite_codes").update({is_active:!R}).eq("id",L);$?fe.error("Failed to update code"):s(t.map(q=>q.id===L?{...q,is_active:!R}:q))},N=async L=>{const{error:R}=await G.from("invite_codes").delete().eq("id",L);R?fe.error("Failed to delete code"):(fe.success("Code deleted"),s(t.filter($=>$.id!==L)))},C="https://dashboard.relevelup.com",A=L=>{const R=`${C}/join?code=${L}`;navigator.clipboard.writeText(R),fe.success("Link copied to clipboard")},I=`${C}/join`;return e.jsx(Ms,{title:"Invite Codes",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"Invite Codes",description:"Manage signup invite codes"}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Create New Code"}),e.jsxs(yr,{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:j,className:"flex flex-wrap gap-4 items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(ve,{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(ve,{htmlFor:"maxUses",children:"Max Uses"}),e.jsx(Re,{id:"maxUses",type:"number",placeholder:"Unlimited",value:p,onChange:L=>f(L.target.value),className:"w-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(K,{type:"submit",disabled:a,children:[a?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Active Codes"})}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(As,{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(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Code"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Uses"}),e.jsx(jt,{children:"Trial"}),e.jsx(jt,{children:"Created"}),e.jsx(jt,{children:"Active"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(L=>e.jsxs(js,{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:ws(new Date(L.created_at),"MMM d, yyyy")}),e.jsx(lt,{children:e.jsx(Br,{checked:L.is_active,onCheckedChange:()=>w(L.id,L.is_active)})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>A(L.code),title:"Copy invite link",children:e.jsx(ni,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>N(L.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(br,{className:"h-4 w-4"})})]})})]},L.id))})]})})]})]})})},VL=async t=>{try{const{data:s,error:r}=await G.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}},CM=async t=>{try{const{data:s,error:r}=await G.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}}},G8t=async(t,s)=>await VL("new_templates")?CM({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}),K8t=async(t,s)=>CM({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),Z8t=async(t,s)=>await VL("new_events")?CM({title:"New Event",body:`New event: ${t}`,url:`/events/${s}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),Y8t=async(t,s)=>await VL("new_toolbox")?CM({title:"New Resource Kit",body:`New resource kit available: ${t}`,url:`/toolbox/${s}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),rye=async(t,s)=>await VL("new_social_swag")?CM({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}),X8t=async(t,s)=>await VL("new_newsletters")?CM({title:"New Newsletter",body:`New newsletter available: ${t}`,url:`/newsletters/${s}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),aR={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 Q8t(){const t=Dr(),s=ns(),[r,n]=S.useState(!1),[a,o]=S.useState(null),[l,i]=S.useState(aR),[d,u]=S.useState(null),[p,f]=S.useState(null),[v,_]=S.useState(!1),b=S.useRef(null),[j,w]=S.useState(!1),[N,C]=S.useState(null),[A,I]=S.useState(!1),[L,R]=S.useState(null),[$,q]=S.useState(null),[U,V]=S.useState(!0),[X,se]=S.useState(""),{data:te,isLoading:Y}=Ct({queryKey:["admin-events"],queryFn:async()=>{const{data:Ne,error:it}=await G.from("events").select("*").order("event_date",{ascending:!0});if(it)throw it;return Ne}}),{data:de}=Ct({queryKey:["event-registrations-count"],queryFn:async()=>{let Ne=[],it=0;const qe=1e3;for(;;){const{data:$e,error:Ke}=await G.from("event_registrations").select("event_id").range(it,it+qe-1);if(Ke)throw Ke;if(!$e||$e.length===0||(Ne=Ne.concat($e),$e.length{Xe[$e.event_id]=(Xe[$e.event_id]||0)+1}),Xe}}),{data:ie,isLoading:ae}=Ct({queryKey:["event-registrations-details",N==null?void 0:N.id],queryFn:async()=>{if(!N)return[];const{data:Ne,error:it}=await G.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(it)throw it;if(!Ne||Ne.length===0)return[];const qe=Ne.map(Ke=>Ke.user_id).filter(Boolean);let Xe=[];if(qe.length>0){const{data:Ke,error:ct}=await G.from("profiles").select("id, name, email").in("id",qe);if(ct)throw ct;Xe=Ke||[]}const $e=new Map((Xe==null?void 0:Xe.map(Ke=>[Ke.id,Ke]))||[]);return Ne.map(Ke=>({...Ke,profiles:Ke.user_id&&$e.get(Ke.user_id)||null}))},enabled:!!N}),{data:le,isLoading:pe}=Ct({queryKey:["event-attendees-details",N==null?void 0:N.id],queryFn:async()=>{if(!N)return[];const{data:Ne,error:it}=await G.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(it)throw it;if(!Ne||Ne.length===0)return[];const qe=Ne.map(Ue=>Ue.user_id).filter(Boolean);let Xe=[];if(qe.length>0){const{data:Ue,error:Ve}=await G.from("profiles").select("id, name, email").in("id",qe);if(Ve)throw Ve;Xe=Ue||[]}const{data:$e}=await G.from("agent_points").select("user_id").eq("event_id",N.id),Ke=new Set(($e==null?void 0:$e.map(Ue=>Ue.user_id))||[]),ct=new Map((Xe==null?void 0:Xe.map(Ue=>[Ue.id,Ue]))||[]);return Ne.map(Ue=>({...Ue,profiles:Ue.user_id&&ct.get(Ue.user_id)||null,points_awarded:Ue.user_id?Ke.has(Ue.user_id):!1}))},enabled:!!N}),be=Ne=>{C(Ne),w(!0)},ye=Ot({mutationFn:async Ne=>{const{data:{session:it}}=await G.auth.getSession();if(!it)throw new Error("Not authenticated");const qe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${it.access_token}`},body:JSON.stringify({event_id:Ne})}),Xe=await qe.json();if(!qe.ok)throw new Error(Xe.error||"Failed to sync");return Xe},onSuccess:Ne=>{s.invalidateQueries({queryKey:["event-registrations-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),fe.success(Ne.message)},onError:Ne=>{fe.error("Failed to sync: "+Ne.message)}}),we=Ot({mutationFn:async Ne=>{const{data:{session:it}}=await G.auth.getSession();if(!it)throw new Error("Not authenticated");const qe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${it.access_token}`},body:JSON.stringify({event_id:Ne})}),Xe=await qe.json();if(!qe.ok)throw new Error(Xe.error||"Failed to sync attendees");return Xe},onSuccess:Ne=>{s.invalidateQueries({queryKey:["event-attendees-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),Ne!=null&&Ne.message?fe.success(Ne.message):fe.success(`Synced ${Ne.synced||0} attendees. ${Ne.points_awarded||0} points awarded!`)},onError:Ne=>{fe.error("Failed to sync attendees: "+Ne.message)}}),ke=Ot({mutationFn:async({eventId:Ne,testMode:it})=>{const{data:{session:qe}}=await G.auth.getSession();if(!qe)throw new Error("Not authenticated");const Xe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-event-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${qe.access_token}`},body:JSON.stringify({event_id:Ne,test_mode:it})}),$e=await Xe.json();if(!Xe.ok)throw new Error($e.error||"Failed to send reminders");return $e},onSuccess:Ne=>{Ne.test?fe.success(Ne.message||"Test email sent!"):fe.success(Ne.message||`Reminder emails sent to ${Ne.sent} registrants!`)},onError:Ne=>{fe.error("Failed to send reminders: "+Ne.message)}}),{data:Ze}=Ct({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let Ne=[],it=0;const qe=1e3;for(;;){const{data:Xe,error:$e}=await G.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(it,it+qe-1);if($e)throw $e;if(!Xe||Xe.length===0||(Ne=[...Ne,...Xe],Xe.length{const{error:$e}=await G.from("event_attendees").update({user_id:it}).eq("id",Ne);if($e)throw $e;if(Xe&&qe){const{error:ct}=await G.from("zoom_email_aliases").upsert({user_id:it,zoom_email:qe.toLowerCase()},{onConflict:"zoom_email"});ct&&console.error("Failed to save alias:",ct)}const Ke=N==null?void 0:N.id;if(Ke){const{data:ct}=await G.from("user_roles").select("id").eq("user_id",it).eq("role","admin").single();if(!ct){const{data:Ue}=await G.from("agent_points").select("id").eq("user_id",it).eq("event_id",Ke).single();Ue||(await G.rpc("award_attendance_points",{p_user_id:it,p_event_id:Ke,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await G.rpc("check_and_award_badges",{p_user_id:it}))}}return{userId:it,zoomEmail:qe,shouldSaveAlias:Xe}},onSuccess:Ne=>{s.invalidateQueries({queryKey:["event-attendees-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let it="Attendee linked and points awarded!";Ne.shouldSaveAlias&&Ne.zoomEmail&&(it+=` Email "${Ne.zoomEmail}" will be auto-matched in the future.`),fe.success(it),I(!1),R(null),q(null),se("")},onError:Ne=>{fe.error("Failed to link attendee: "+Ne.message)}}),Ce=Ne=>{R(Ne),q(null),V(!0),se(""),I(!0)},Te=()=>{!L||!$||_e.mutate({attendeeId:L.id,userId:$,zoomEmail:L.zoom_email,shouldSaveAlias:U})},Fe=(Ze==null?void 0:Ze.filter(Ne=>{var qe,Xe;if(!X)return!0;const it=X.toLowerCase();return((qe=Ne.name)==null?void 0:qe.toLowerCase().includes(it))||((Xe=Ne.email)==null?void 0:Xe.toLowerCase().includes(it))}))||[],Ae=async Ne=>{const it=Ne.name.split(".").pop(),Xe=`${`${crypto.randomUUID()}.${it}`}`,{error:$e}=await G.storage.from("event-images").upload(Xe,Ne);if($e)throw $e;const{data:{publicUrl:Ke}}=G.storage.from("event-images").getPublicUrl(Xe);return Ke},We=Ne=>{var qe;const it=(qe=Ne.target.files)==null?void 0:qe[0];if(it){if(it.size>5*1024*1024){fe.error("Image must be less than 5MB");return}u(it),f(URL.createObjectURL(it))}},ht=()=>{u(null),f(null),i({...l,image_url:""}),b.current&&(b.current.value="")},De=Ot({mutationFn:async Ne=>{_(!0);let it=Ne.image_url;d&&(it=await Ae(d)||"");const qe=new Date(Ne.event_date),[Xe,$e]=Ne.event_time.split(":");qe.setHours(parseInt(Xe),parseInt($e));const Ke=[new Date(qe)];if(Ne.is_recurring&&Ne.recurrence_end_date){let Je=new Date(qe);for(;Ne.recurrence_pattern==="weekly"?Je=Ck(Je,1):Ne.recurrence_pattern==="biweekly"?Je=Ck(Je,2):Je=Wh(Je,1),!(Je>Ne.recurrence_end_date);)Ke.push(new Date(Je))}const ct=Ke.map(Je=>({title:Ne.title,description:Ne.description||null,image_url:it||null,video_url:Ne.video_url||null,event_date:Je.toISOString(),zoom_link:Ne.zoom_link,zoom_meeting_id:Ne.zoom_meeting_id||null,capacity:Ne.capacity?parseInt(Ne.capacity):null,is_published:Ne.is_published})),{data:Ue,error:Ve}=await G.from("events").insert(ct).select();if(Ve)throw Ve;return Ue&&Ue.length>0&&Z8t(Ne.title,Ue[0].id),Ke.length},onSuccess:Ne=>{s.invalidateQueries({queryKey:["admin-events"]}),fe.success(Ne>1?`${Ne} recurring events created successfully`:"Event created successfully"),n(!1),i(aR),u(null),f(null),_(!1)},onError:Ne=>{fe.error("Failed to create event: "+Ne.message),_(!1)}}),Dt=Ot({mutationFn:async({id:Ne,data:it})=>{_(!0);let qe=it.image_url;d&&(qe=await Ae(d)||"");const Xe=new Date(it.event_date),[$e,Ke]=it.event_time.split(":");Xe.setHours(parseInt($e),parseInt(Ke));const{error:ct}=await G.from("events").update({title:it.title,description:it.description||null,image_url:qe||null,video_url:it.video_url||null,event_date:Xe.toISOString(),zoom_link:it.zoom_link,zoom_meeting_id:it.zoom_meeting_id||null,capacity:it.capacity?parseInt(it.capacity):null,is_published:it.is_published}).eq("id",Ne);if(ct)throw ct},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),fe.success("Event updated successfully"),n(!1),o(null),i(aR),u(null),f(null),_(!1)},onError:Ne=>{fe.error("Failed to update event: "+Ne.message),_(!1)}}),he=Ot({mutationFn:async Ne=>{const{error:it}=await G.from("events").delete().eq("id",Ne);if(it)throw it},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),fe.success("Event deleted successfully")},onError:Ne=>{fe.error("Failed to delete event: "+Ne.message)}}),Qe=Ne=>{var qe;const it=new Date(Ne.event_date);o(Ne),i({title:Ne.title,description:Ne.description||"",image_url:Ne.image_url||"",video_url:Ne.video_url||"",event_date:it,event_time:ws(it,"HH:mm"),zoom_link:Ne.zoom_link,zoom_meeting_id:Ne.zoom_meeting_id||"",capacity:((qe=Ne.capacity)==null?void 0:qe.toString())||"",is_published:Ne.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),f(Ne.image_url||null),u(null),n(!0)},ot=Ne=>{if(Ne.preventDefault(),!l.event_date){fe.error("Please select a date");return}if(l.is_recurring&&!l.recurrence_end_date){fe.error("Please select an end date for recurring events");return}a?Dt.mutate({id:a.id,data:l}):De.mutate(l)},rt=()=>{n(!1),o(null),i(aR),u(null),f(null)};return e.jsx("div",{className:"min-h-screen bg-background p-6",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/dashboard"),children:e.jsx(Ua,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Event Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Create and manage upcoming events"})]})]}),e.jsxs(Ee,{className:"mb-6",children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"All Events"}),e.jsxs(vs,{open:r,onOpenChange:Ne=>!Ne&&rt(),children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Event"]})}),e.jsxs(ys,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:a?"Edit Event":"Create New Event"})}),e.jsxs("form",{onSubmit:ot,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:l.title,onChange:Ne=>i({...l,title:Ne.target.value}),placeholder:"Event title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Qg,{content:l.description,onChange:Ne=>i({...l,description:Ne}),placeholder:"Event description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Event Image"}),e.jsx("input",{type:"file",ref:b,accept:"image/*",onChange:We,className:"hidden"}),p?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:p,alt:"Event preview",className:"w-full h-32 object-cover rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:ht,children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs(K,{type:"button",variant:"outline",className:"w-full h-32 border-dashed flex flex-col gap-2",onClick:()=>{var Ne;return(Ne=b.current)==null?void 0:Ne.click()},children:[e.jsx(Ya,{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(ve,{children:"Date *"}),e.jsxs(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!l.event_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),l.event_date?ws(l.event_date,"PPP"):"Pick a date"]})}),e.jsx(ko,{className:"w-auto p-0",align:"start",children:e.jsx(yp,{mode:"single",selected:l.event_date,onSelect:Ne=>i({...l,event_date:Ne}),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"time",children:"Time *"}),e.jsx(Re,{id:"time",type:"time",value:l.event_time,onChange:Ne=>i({...l,event_time:Ne.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"zoom_link",children:"Zoom Link *"}),e.jsx(Re,{id:"zoom_link",value:l.zoom_link,onChange:Ne=>i({...l,zoom_link:Ne.target.value}),placeholder:"https://zoom.us/j/...",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"zoom_meeting_id",children:"Zoom Meeting ID (for API registration)"}),e.jsx(Re,{id:"zoom_meeting_id",value:l.zoom_meeting_id,onChange:Ne=>i({...l,zoom_meeting_id:Ne.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(ve,{htmlFor:"video_url",children:"Promo Video URL (optional)"}),e.jsx(Re,{id:"video_url",value:l.video_url,onChange:Ne=>i({...l,video_url:Ne.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(ve,{htmlFor:"capacity",children:"Capacity (optional)"}),e.jsx(Re,{id:"capacity",type:"number",value:l.capacity,onChange:Ne=>i({...l,capacity:Ne.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(jP,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{htmlFor:"is_recurring",children:"Recurring Event"})]}),e.jsx(Br,{id:"is_recurring",checked:l.is_recurring,onCheckedChange:Ne=>i({...l,is_recurring:Ne})})]}),l.is_recurring&&e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Frequency"}),e.jsxs(tr,{value:l.recurrence_pattern,onValueChange:Ne=>i({...l,recurrence_pattern:Ne}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),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(ve,{children:"Repeat Until"}),e.jsxs(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!l.recurrence_end_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?ws(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx(ko,{className:"w-auto p-0",align:"start",children:e.jsx(yp,{mode:"single",selected:l.recurrence_end_date,onSelect:Ne=>i({...l,recurrence_end_date:Ne}),disabled:Ne=>Ne<(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 Ne=1,it=new Date(l.event_date);for(;it=l.recurrence_pattern==="weekly"?Ck(it,1):l.recurrence_pattern==="biweekly"?Ck(it,2):Wh(it,1),!(it>l.recurrence_end_date);)Ne++;return Ne})()," events with the same Zoom link"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{htmlFor:"is_published",children:"Published"}),e.jsx(Br,{id:"is_published",checked:l.is_published,onCheckedChange:Ne=>i({...l,is_published:Ne})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:rt,className:"flex-1",children:"Cancel"}),e.jsx(K,{type:"submit",className:"flex-1",disabled:De.isPending||Dt.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(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Date & Time"}),e.jsx(jt,{children:"Registrations"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:te==null?void 0:te.map(Ne=>e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium",children:Ne.title}),e.jsx(lt,{children:ws(new Date(Ne.event_date),"PPP p")}),e.jsx(lt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>be(Ne),children:[e.jsx(hr,{className:"h-4 w-4"}),(de==null?void 0:de[Ne.id])||0,Ne.capacity&&` / ${Ne.capacity}`]})}),e.jsx(lt,{children:e.jsx("span",{className:Pt("px-2 py-1 rounded-full text-xs font-medium",Ne.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:Ne.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(Ne.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(sn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Qe(Ne),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this event?")&&he.mutate(Ne.id)},children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]})})]},Ne.id))})]})})]}),e.jsx(vs,{open:j,onOpenChange:w,children:e.jsxs(ys,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(hr,{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(K,{variant:"ghost",size:"sm",onClick:()=>ke.mutate({eventId:N.id,testMode:!0}),disabled:ke.isPending,children:[e.jsx(_r,{className:Pt("h-4 w-4 mr-2",ke.isPending&&"animate-spin")}),"Send Test to Me"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ke.mutate({eventId:N.id}),disabled:ke.isPending||!(ie!=null&&ie.length),children:[e.jsx(_r,{className:Pt("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(K,{variant:"outline",size:"sm",onClick:()=>ye.mutate(N.id),disabled:ye.isPending,children:[e.jsx(Po,{className:Pt("h-4 w-4 mr-2",ye.isPending&&"animate-spin")}),ye.isPending?"Syncing...":"Sync Registrations"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>we.mutate(N.id),disabled:we.isPending,children:[e.jsx(Ki,{className:Pt("h-4 w-4 mr-2",we.isPending&&"animate-spin")}),we.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),e.jsxs(Na,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(va,{className:"grid w-full grid-cols-2",children:[e.jsxs(ks,{value:"registrations",className:"gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Registrations (",(ie==null?void 0:ie.length)||0,")"]}),e.jsxs(ks,{value:"attendees",className:"gap-2",children:[e.jsx(da,{className:"h-4 w-4"}),"Attendees (",(le==null?void 0:le.length)||0,")"]})]}),e.jsx(zs,{value:"registrations",className:"mt-4",children:ae?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading registrations..."}):(ie==null?void 0:ie.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(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Registered"}),e.jsx(jt,{children:"Status"})]})}),e.jsx(Pn,{children:ie==null?void 0:ie.map(Ne=>{var $e,Ke;const it=(($e=Ne.profiles)==null?void 0:$e.name)||Ne.zoom_name||"Unknown",qe=((Ke=Ne.profiles)==null?void 0:Ke.email)||Ne.zoom_email||null,Xe=!Ne.user_id;return e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[it,Xe&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),e.jsx(lt,{children:qe?e.jsxs("a",{href:`mailto:${qe}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(_r,{className:"h-3 w-3"}),qe]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(lt,{className:"text-muted-foreground text-sm",children:ws(new Date(Ne.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(lt,{children:Ne.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"})})]},Ne.id)})})]})}),e.jsx(zs,{value:"attendees",className:"mt-4",children:pe?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading attendees..."}):(le==null?void 0:le.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No attendees recorded yet."}),(N==null?void 0:N.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Attendees & Award Points" after the event ends to import actual participants from Zoom.'})]}):e.jsxs(e.Fragment,{children:[(le==null?void 0:le.filter(Ne=>!Ne.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(Qo,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}),e.jsxs("h4",{className:"font-medium text-amber-800 dark:text-amber-200",children:["Unmatched Attendees (",le==null?void 0:le.filter(Ne=>!Ne.user_id).length,")"]})]}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300 mb-3",children:"These attendees couldn't be matched to a profile. Link them to award points."}),e.jsx("div",{className:"space-y-2",children:le==null?void 0:le.filter(Ne=>!Ne.user_id).map(Ne=>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:Ne.zoom_name||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Ne.zoom_email||"No email"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Ce(Ne),className:"gap-1",children:[e.jsx(Ho,{className:"h-3 w-3"}),"Link to Profile"]})]},Ne.id))})]}),e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Duration"}),e.jsx(jt,{children:"Points"})]})}),e.jsx(Pn,{children:le==null?void 0:le.filter(Ne=>Ne.user_id).map(Ne=>{var Xe,$e;const it=((Xe=Ne.profiles)==null?void 0:Xe.name)||Ne.zoom_name||"Unknown",qe=(($e=Ne.profiles)==null?void 0:$e.email)||Ne.zoom_email||null;return e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[it,Ne.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:qe?e.jsxs("a",{href:`mailto:${qe}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(_r,{className:"h-3 w-3"}),qe]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(lt,{children:Ne.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"}),Ne.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(lt,{children:Ne.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(Ki,{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"})})]},Ne.id)})})]})]})})]})]})}),e.jsx(vs,{open:A,onOpenChange:I,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Ho,{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(ve,{children:"Search for a profile"}),e.jsxs("div",{className:"relative",children:[e.jsx(fn,{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:X,onChange:Ne=>se(Ne.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(Ne=>e.jsxs("button",{type:"button",onClick:()=>q(Ne.id),className:Pt("w-full p-3 text-left hover:bg-muted/50 transition-colors",$===Ne.id&&"bg-primary/10 border-l-2 border-primary"),children:[e.jsx("p",{className:"text-sm font-medium",children:Ne.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Ne.email})]},Ne.id))})}),L.zoom_email&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(zo,{id:"save-alias",checked:U,onCheckedChange:Ne=>V(Ne)}),e.jsx("label",{htmlFor:"save-alias",className:"text-sm text-muted-foreground cursor-pointer",children:"Remember this email for future auto-matching"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsx(K,{onClick:Te,disabled:!$||_e.isPending,children:_e.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}function J8t({selectedKitIds:t,onChange:s}){const[r,n]=S.useState(""),[a,o]=S.useState(!1),{data:l=[]}=Ct({queryKey:["all-resource-kits-picker"],queryFn:async()=>{const{data:f,error:v}=await G.from("resource_kits").select("id, name, featured_image_url").eq("is_published",!0).order("name");if(v)throw v;return f}}),i=l.filter(f=>t.includes(f.id)),d=l.filter(f=>!t.includes(f.id)&&f.name.toLowerCase().includes(r.toLowerCase())),u=f=>{s([...t,f])},p=f=>{s(t.filter(v=>v!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(dl,{className:"h-4 w-4"}),"Linked Toolkits"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(f=>e.jsxs(at,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>p(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Ur,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(So,{open:a,onOpenChange:o,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(dl,{className:"h-3.5 w-3.5"}),"Add Toolkit"]})}),e.jsxs(ko,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(fn,{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:f=>n(f.target.value),className:"pl-7 h-8 text-sm"})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children: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(f=>e.jsxs("button",{type:"button",onClick:()=>{u(f.id),n("")},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[f.featured_image_url?e.jsx("img",{src:f.featured_image_url,alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(dl,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"truncate",children:f.name})]},f.id))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link toolkits that agents can download alongside this template."})]})}const eRt=()=>{const{user:t}=Gs(),{toast:s}=Ia(),r=ns(),[n,a]=Ec(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),[f,v]=S.useState(null),[_,b]=S.useState(0),[j,w]=S.useState(!1),[N,C]=S.useState(null),[A,I]=S.useState(""),[L,R]=S.useState([]),[$,q]=S.useState(""),[U,V]=S.useState(""),[X,se]=S.useState(!1),[te,Y]=S.useState(!1),{data:de=[]}=Ct({queryKey:["template-categories"],queryFn:async()=>{const{data:Qe,error:ot}=await G.from("template_categories").select("*").order("name");if(ot)throw ot;return Qe}}),{data:ie=[]}=Ct({queryKey:["template-types"],queryFn:async()=>{const{data:Qe,error:ot}=await G.from("template_types").select("*").order("name");if(ot)throw ot;return Qe}}),{data:ae=[],isLoading:le}=Ct({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:Qe,error:ot}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(ot)throw ot;const{data:rt,error:Ne}=await G.from("template_links").select("*").order("sort_order");if(Ne)throw Ne;const{data:it,error:qe}=await G.from("template_guides").select("*").order("sort_order");if(qe)throw qe;return Qe.map($e=>({...$e,links:(rt==null?void 0:rt.filter(Ke=>Ke.template_id===$e.id))||[],guides:(it==null?void 0:it.filter(Ke=>Ke.template_id===$e.id))||[]}))}});S.useEffect(()=>{const Qe=n.get("edit");if(Qe&&ae.length>0){const ot=ae.find(rt=>rt.id===Qe);ot&&(Ze(ot),a({},{replace:!0}))}},[ae,n]);const pe=Ot({mutationFn:async Qe=>{const{data:ot,error:rt}=await G.from("template_categories").insert({name:Qe}).select().single();if(rt)throw rt;return ot},onSuccess:Qe=>{r.invalidateQueries({queryKey:["template-categories"]}),p({...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=Ot({mutationFn:async Qe=>{const{data:ot,error:rt}=await G.from("template_types").insert({name:Qe}).select().single();if(rt)throw rt;return ot},onSuccess:Qe=>{r.invalidateQueries({queryKey:["template-types"]}),p({...u,type_id:Qe.id}),V(""),Y(!1),s({title:"Type added"})},onError:Qe=>{s({title:"Error adding type",description:Qe.message,variant:"destructive"})}}),ye=Ot({mutationFn:async Qe=>{var qe;let ot=Qe.existingImageUrl;if(Qe.image){const Xe=Qe.image.name.split(".").pop(),$e=`${Date.now()}-${Math.random().toString(36).substring(7)}.${Xe}`,{error:Ke}=await G.storage.from("template-previews").upload($e,Qe.image);if(Ke)throw Ke;const{data:ct}=G.storage.from("template-previews").getPublicUrl($e);ot=ct.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:ot,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 Ne=Qe.templateId;if(Ne){const{error:Xe}=await G.from("canva_templates").update(rt).eq("id",Ne);if(Xe)throw Xe;const{error:$e}=await G.from("template_links").delete().eq("template_id",Ne);if($e)throw $e;const Ke=((qe=Qe.existingGuides)==null?void 0:qe.map(Ve=>Ve.id).filter(Boolean))||[],ct=Qe.template.guides.map(Ve=>Ve.id).filter(Boolean),Ue=Ke.filter(Ve=>!ct.includes(Ve));Ue.length>0&&await G.from("template_guides").delete().in("id",Ue)}else{const{data:Xe,error:$e}=await G.from("canva_templates").insert(rt).select().single();if($e)throw $e;Ne=Xe.id,G8t(Qe.template.name,Xe.id)}const it=Qe.template.links.filter(Xe=>Xe.title.trim()&&Xe.canva_share_link.trim());if(it.length>0){const Xe=it.map((Ke,ct)=>({template_id:Ne,title:Ke.title.trim(),canva_share_link:Ke.canva_share_link.trim(),sort_order:ct})),{error:$e}=await G.from("template_links").insert(Xe);if($e)throw $e}for(let Xe=0;Xe0)){const{error:Xe}=await G.from("resource_kit_templates").insert(Qe.linkedKitIds.map($e=>({template_id:Ne,kit_id:$e})));if(Xe)throw Xe}},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"})}}),we=Ot({mutationFn:async Qe=>{const{error:ot}=await G.from("canva_templates").delete().eq("id",Qe);if(ot)throw ot},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=()=>{p({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),C(null),I(""),d(null),se(!1),Y(!1),q(""),V(""),v(null),b(0),w(!1),R([])},Ze=async Qe=>{var rt;d(Qe),p({name:Qe.name,description:Qe.description||"",category_id:Qe.category_id||"",type_id:Qe.type_id||"",publish_date:Qe.publish_date?new Date(Qe.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:Qe.links&&Qe.links.length>0?Qe.links.map(Ne=>({id:Ne.id,title:Ne.title,canva_share_link:Ne.canva_share_link,sort_order:Ne.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((rt=Qe.guides)==null?void 0:rt.map(Ne=>({id:Ne.id,name:Ne.name,file_url:Ne.file_url,file_type:Ne.file_type,file_size:Ne.file_size,sort_order:Ne.sort_order})))||[],video_url:Qe.video_url||""}),I(Qe.preview_image_url||""),v(null);const{data:ot}=await G.from("resource_kit_templates").select("kit_id").eq("template_id",Qe.id);R((ot||[]).map(Ne=>Ne.kit_id)),l(!0)},_e=Qe=>{var rt;const ot=(rt=Qe.target.files)==null?void 0:rt[0];ot&&(C(ot),I(URL.createObjectURL(ot)))},Ce=()=>{p({...u,links:[...u.links,{title:"",canva_share_link:"",sort_order:u.links.length}]})},Te=Qe=>{if(u.links.length<=1)return;const ot=u.links.filter((rt,Ne)=>Ne!==Qe);p({...u,links:ot})},Fe=(Qe,ot,rt)=>{const Ne=[...u.links];Ne[Qe]={...Ne[Qe],[ot]:rt},p({...u,links:Ne})},Ae=Qe=>{const ot=Qe.target.files;if(!ot)return;const rt=Array.from(ot).map((Ne,it)=>({name:Ne.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:Ne.type,file_size:Ne.size,sort_order:u.guides.length+it,file:Ne}));p({...u,guides:[...u.guides,...rt]}),Qe.target.value=""},We=Qe=>{const ot=u.guides.filter((rt,Ne)=>Ne!==Qe);p({...u,guides:ot})},ht=(Qe,ot)=>{const rt=[...u.guides];rt[Qe]={...rt[Qe],name:ot},p({...u,guides:rt})},De=async()=>{if(!f)return null;w(!0),b(0);try{const{data:Qe,error:ot}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.name||f.name}});if(ot)throw new Error(ot.message);const{videoId:rt,libraryId:Ne}=Qe,{data:it,error:qe}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:rt}});if(qe)throw new Error(qe.message);const Xe=new XMLHttpRequest;return await new Promise((Ke,ct)=>{Xe.upload.addEventListener("progress",Ue=>{if(Ue.lengthComputable){const Ve=Math.round(Ue.loaded/Ue.total*100);b(Ve)}}),Xe.addEventListener("load",()=>{Xe.status>=200&&Xe.status<300?Ke():ct(new Error(`Upload failed with status ${Xe.status}`))}),Xe.addEventListener("error",()=>ct(new Error("Upload failed"))),Xe.open("PUT",it.uploadUrl),Xe.setRequestHeader("AccessKey",it.apiKey),Xe.send(f)}),`https://player.mediadelivery.net/embed/${Ne}/${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{w(!1)}},Dt=Qe=>{var rt;const ot=(rt=Qe.target.files)==null?void 0:rt[0];ot&&v(ot),Qe.target.value=""},he=async Qe=>{if(Qe.preventDefault(),!u.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(u.links.filter(Ne=>Ne.title.trim()&&Ne.canva_share_link.trim()).length===0){s({title:"Please add at least one Canva link",variant:"destructive"});return}let rt=u.video_url;if(f){const Ne=await De();if(!Ne)return;rt=Ne}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(_u,{title:"Manage Templates",description:"Create and manage Canva templates"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ae.length})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:de.length})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ie.length})})]})]}),e.jsxs(vs,{open:o,onOpenChange:Qe=>{l(Qe),Qe||ke()},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Template"]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:i?"Edit Template":"Add New Template"})}),e.jsxs("form",{onSubmit:he,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Name *"}),e.jsx(Re,{id:"name",value:u.name,onChange:Qe=>p({...u,name:Qe.target.value}),placeholder:"Template name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Qg,{content:u.description,onChange:Qe=>p({...u,description:Qe}),placeholder:"Brief description of the template",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Canva Links *"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Ce,className:"gap-1",children:[e.jsx(Zs,{className:"h-3 w-3"}),"Add Link"]})]}),e.jsx("div",{className:"space-y-3",children:u.links.map((Qe,ot)=>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(ot,"title",rt.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(Re,{value:Qe.canva_share_link,onChange:rt=>Fe(ot,"canva_share_link",rt.target.value),placeholder:"https://www.canva.com/design/..."})]}),u.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>Te(ot),children:e.jsx(Ur,{className:"h-4 w-4"})})]},ot))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Category"}),X?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(K,{type:"button",size:"sm",onClick:()=>$.trim()&&pe.mutate($.trim()),disabled:pe.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{se(!1),q("")},children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:u.category_id,onValueChange:Qe=>p({...u,category_id:Qe}),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(sr,{placeholder:"Select category"})}),e.jsx(er,{children:de.map(Qe=>e.jsx(At,{value:Qe.id,children:Qe.name},Qe.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>se(!0),children:e.jsx(Zs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Template Type"}),te?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:U,onChange:Qe=>V(Qe.target.value),placeholder:"New type name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>U.trim()&&be.mutate(U.trim()),disabled:be.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Y(!1),V("")},children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:u.type_id,onValueChange:Qe=>p({...u,type_id:Qe}),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(sr,{placeholder:"Select type"})}),e.jsx(er,{children:ie.map(Qe=>e.jsx(At,{value:Qe.id,children:Qe.name},Qe.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>Y(!0),children:e.jsx(Zs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:u.publish_date,onChange:Qe=>p({...u,publish_date:Qe.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Templates are sorted by publish date (newest first) on the member page"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(K,{type:"button",size:"icon",variant:"destructive",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>{C(null),I("")},children:e.jsx(Ur,{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(Jo,{className:"h-8 w-8 text-muted-foreground/50"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Re,{type:"file",accept:"image/*",onChange:_e,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(ve,{children:"Video (Optional)"}),u.video_url&&!f?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/30",children:[e.jsx(kn,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:"Video uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>p({...u,video_url:""}),className:"text-destructive hover:text-destructive",children:"Remove"})]}),e.jsx("div",{className:"aspect-video max-w-md rounded-lg overflow-hidden border",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]}):j?e.jsxs("div",{className:"space-y-2 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(As,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm",children:["Uploading video... ",_,"%"]})]}),e.jsx(Ti,{value:_,className:"h-2"})]}):f?e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/30",children:[e.jsx(kn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:f.name}),e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(f.size/1024/1024).toFixed(1)," MB"]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>v(null),children:e.jsx(Ur,{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:Dt,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(kn,{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(ve,{children:"Guide Files (PDFs)"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Re,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:Ae,className:"hidden"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",asChild:!0,children:e.jsxs("span",{children:[e.jsx(Ya,{className:"h-3 w-3"}),"Add Files"]})})]})]}),u.guides.length>0?e.jsx("div",{className:"space-y-2",children:u.guides.map((Qe,ot)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(In,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(Re,{value:Qe.name,onChange:rt=>ht(ot,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(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>We(ot),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Qe.id||ot))}):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(J8t,{selectedKitIds:L,onChange:R}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{l(!1),ke()},children:"Cancel"}),e.jsx(K,{type:"submit",disabled:ye.isPending,children:ye.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:le?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):ae.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No templates yet. Add your first template!"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Preview"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Links"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:ae.map(Qe=>{var ot,rt,Ne,it,qe;return e.jsxs(js,{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(Jo,{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(at,{variant:"secondary",children:[((ot=Qe.links)==null?void 0:ot.length)||0," link",(((rt=Qe.links)==null?void 0:rt.length)||0)!==1?"s":""]}),(((Ne=Qe.guides)==null?void 0:Ne.length)||0)>0&&e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(In,{className:"h-3 w-3"}),(it=Qe.guides)==null?void 0:it.length," guide",(((qe=Qe.guides)==null?void 0:qe.length)||0)!==1?"s":""]})]})}),e.jsx(lt,{children:Qe.category?e.jsx(at,{variant:"secondary",children:Qe.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(lt,{children:Qe.type?e.jsx(at,{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(K,{size:"icon",variant:"ghost",onClick:()=>Ze(Qe),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&we.mutate(Qe.id)},children:e.jsx(br,{className:"h-4 w-4"})})]})})]},Qe.id)})})]})})})]})})};function bKe({selectedTemplateIds:t,onChange:s}){const[r,n]=S.useState(""),[a,o]=S.useState(!1),{data:l=[]}=Ct({queryKey:["all-canva-templates-picker"],queryFn:async()=>{const{data:f,error:v}=await G.from("canva_templates").select("id, name, preview_image_url").order("name");if(v)throw v;return f}}),i=l.filter(f=>t.includes(f.id)),d=l.filter(f=>!t.includes(f.id)&&f.name.toLowerCase().includes(r.toLowerCase())),u=f=>{s([...t,f])},p=f=>{s(t.filter(v=>v!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(aN,{className:"h-4 w-4"}),"Linked Templates"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(f=>e.jsxs(at,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>p(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Ur,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(So,{open:a,onOpenChange:o,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(aN,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs(ko,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(fn,{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:f=>n(f.target.value),className:"pl-7 h-8 text-sm"})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children: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(f=>e.jsxs("button",{type:"button",onClick:()=>{u(f.id),n("")},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[f.preview_image_url?e.jsx("img",{src:f.preview_image_url,alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(aN,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"truncate",children:f.name})]},f.id))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link templates that agents can use alongside this content."})]})}const tRt=[{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"}],sRt=()=>{const{user:t}=Gs(),[s,r]=Ec(),{toast:n}=Ia(),a=ns(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[f,v]=S.useState(null),[_,b]=S.useState(""),[j,w]=S.useState([]),[N,C]=S.useState([]),[A,I]=S.useState([]),[L,R]=S.useState([]),[$,q]=S.useState(""),[U,V]=S.useState(!1),[X,se]=S.useState(null),[te,Y]=S.useState(0),[de,ie]=S.useState(!1),[ae,le]=S.useState(null),{data:pe=[]}=Ct({queryKey:["academy-categories"],queryFn:async()=>{const{data:he,error:Qe}=await G.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(Qe)throw Qe;return he}}),{data:be=[],isLoading:ye}=Ct({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:he,error:Qe}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if(Qe)throw Qe;const{data:ot,error:rt}=await G.from("academy_resources").select("*").order("sort_order");if(rt)throw rt;return he.map(it=>({...it,resources:(ot==null?void 0:ot.filter(qe=>qe.video_id===it.id))||[]}))}});S.useEffect(()=>{const he=s.get("edit");if(he&&be.length>0){const Qe=be.find(ot=>ot.id===he);Qe&&(Te(Qe),r({},{replace:!0}))}},[be,s]);const we=Ot({mutationFn:async he=>{const{data:Qe,error:ot}=await G.from("academy_categories").insert({name:he,sort_order:pe.length}).select().single();if(ot)throw ot;return Qe},onSuccess:he=>{a.invalidateQueries({queryKey:["academy-categories"]}),p({...u,category_id:he.id}),q(""),V(!1),n({title:"Category added"})},onError:he=>{n({title:"Error adding category",description:he.message,variant:"destructive"})}}),ke=Ot({mutationFn:async he=>{let Qe=he.existingThumbnailUrl;if(he.thumbnail){const Ne=he.thumbnail.name.split(".").pop(),it=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${Ne}`,{error:qe}=await G.storage.from("academy-resources").upload(it,he.thumbnail);if(qe)throw qe;const{data:Xe}=G.storage.from("academy-resources").getPublicUrl(it);Qe=Xe.publicUrl}const ot={title:he.video.title,description:he.video.description||null,video_url:he.video.video_url,video_type:he.video.video_type,duration:he.video.duration||null,thumbnail_url:Qe,category_id:he.video.category_id||null,publish_date:he.video.publish_date?new Date(he.video.publish_date).toISOString():new Date().toISOString(),is_published:he.video.is_published,created_by:t==null?void 0:t.id};let rt=he.videoId;if(rt){const{error:Ne}=await G.from("academy_videos").update(ot).eq("id",rt);if(Ne)throw Ne}else{const{data:Ne,error:it}=await G.from("academy_videos").insert(ot).select().single();if(it)throw it;rt=Ne.id,K8t(he.video.title,Ne.id)}if(he.resourcesToDelete.length>0){const{error:Ne}=await G.from("academy_resources").delete().in("id",he.resourcesToDelete);if(Ne)throw Ne}for(let Ne=0;Ne0){const{error:Ne}=await G.from("academy_video_templates").insert(L.map(it=>({video_id:rt,template_id:it})));if(Ne)throw Ne}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Ce(),l(!1),n({title:i?"Video updated":"Video created"})},onError:he=>{n({title:"Error saving video",description:he.message,variant:"destructive"})}}),Ze=Ot({mutationFn:async he=>{const{error:Qe}=await G.from("academy_videos").delete().eq("id",he);if(Qe)throw Qe},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),n({title:"Video deleted"})},onError:he=>{n({title:"Error deleting video",description:he.message,variant:"destructive"})}}),_e=Ot({mutationFn:async({id:he,is_published:Qe})=>{const{error:ot}=await G.from("academy_videos").update({is_published:Qe}).eq("id",he);if(ot)throw ot},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:he=>{n({title:"Error updating video",description:he.message,variant:"destructive"})}}),Ce=()=>{p({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(""),w([]),C([]),I([]),d(null),R([]),q(""),se(null),Y(0),ie(!1),le(null)},Te=async he=>{d(he),p({title:he.title,description:he.description||"",video_url:he.video_url,video_type:he.video_type,duration:he.duration||"",category_id:he.category_id||"",publish_date:he.publish_date?new Date(he.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:he.is_published}),b(he.thumbnail_url||""),C(he.resources||[]),w([]),I([]);const{data:Qe}=await G.from("academy_video_templates").select("template_id").eq("video_id",he.id);R((Qe||[]).map(ot=>ot.template_id)),l(!0)},Fe=he=>{var ot;const Qe=(ot=he.target.files)==null?void 0:ot[0];Qe&&(v(Qe),b(URL.createObjectURL(Qe)))},Ae=he=>{const Qe=he.target.files;if(Qe){const ot=Array.from(Qe).map(rt=>({file:rt,title:rt.name.replace(/\.[^/.]+$/,"")}));w([...j,...ot])}he.target.value=""},We=he=>{w(j.filter((Qe,ot)=>ot!==he))},ht=he=>{I([...A,he]),C(N.filter(Qe=>Qe.id!==he))},De=async()=>{if(!X)return null;ie(!0),Y(0);try{const{data:he,error:Qe}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.title||X.name}});if(Qe)throw new Error(Qe.message);const{videoId:ot,libraryId:rt}=he;le(ot);const{data:Ne,error:it}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:ot}});if(it)throw new Error(it.message);const qe=new XMLHttpRequest;return await new Promise(($e,Ke)=>{qe.upload.addEventListener("progress",ct=>{if(ct.lengthComputable){const Ue=Math.round(ct.loaded/ct.total*100);Y(Ue)}}),qe.addEventListener("load",()=>{qe.status>=200&&qe.status<300?$e():Ke(new Error(`Upload failed with status ${qe.status}`))}),qe.addEventListener("error",()=>Ke(new Error("Upload failed"))),qe.open("PUT",Ne.uploadUrl),qe.setRequestHeader("AccessKey",Ne.apiKey),qe.send(X)}),`https://player.mediadelivery.net/embed/${rt}/${ot}`}catch(he){return console.error("Bunny upload error:",he),n({title:"Video upload failed",description:he instanceof Error?he.message:"Unknown error",variant:"destructive"}),null}finally{ie(!1)}},Dt=async he=>{if(he.preventDefault(),!u.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let Qe=u.video_url;if(u.video_type==="bunny_stream"&&X&&!i){const ot=await De();if(!ot)return;Qe=ot}else if(!u.video_url.trim()&&u.video_type!=="bunny_stream"){n({title:"Please enter a video URL",variant:"destructive"});return}else if(u.video_type==="bunny_stream"&&!X&&!u.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}ke.mutate({video:{...u,video_url:Qe},thumbnail:f,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:j,resourcesToDelete:A})};return e.jsx(Ms,{title:"Manage Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"Manage Academy",description:"Create and manage training videos and resources"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{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(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{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(he=>he.is_published).length})})]})]}),e.jsxs(vs,{open:o,onOpenChange:he=>{l(he),he||Ce()},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Video"]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:i?"Edit Video":"Add New Video"})}),e.jsxs("form",{onSubmit:Dt,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:u.title,onChange:he=>p({...u,title:he.target.value}),placeholder:"Video title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Qg,{content:u.description,onChange:he=>p({...u,description:he}),placeholder:"Brief description of the video",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Video Type"}),e.jsxs(tr,{value:u.video_type,onValueChange:he=>{p({...u,video_type:he,video_url:""}),se(null)},disabled:de,children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:tRt.map(he=>e.jsx(At,{value:he.value,children:he.label},he.value))})]})]}),u.video_type==="bunny_stream"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs(ve,{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:he=>{var ot;const Qe=(ot=he.target.files)==null?void 0:ot[0];Qe&&se(Qe)},disabled:de}),X&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(kn,{className:"h-4 w-4"}),X.name," (",(X.size/(1024*1024)).toFixed(1)," MB)"]}),de&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(As,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),e.jsx(Ti,{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(ve,{htmlFor:"video_url",children:"Video URL *"}),e.jsx(Re,{id:"video_url",value:u.video_url,onChange:he=>p({...u,video_url:he.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(ve,{htmlFor:"duration",children:"Duration"}),e.jsx(Re,{id:"duration",value:u.duration,onChange:he=>p({...u,duration:he.target.value}),placeholder:"e.g., 45:30"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:u.publish_date,onChange:he=>p({...u,publish_date:he.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Category"}),U?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:$,onChange:he=>q(he.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>$.trim()&&we.mutate($.trim()),disabled:we.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{V(!1),q("")},children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:u.category_id,onValueChange:he=>p({...u,category_id:he}),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(sr,{placeholder:"Select category"})}),e.jsx(er,{children:pe.map(he=>e.jsx(At,{value:he.id,children:he.name},he.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>V(!0),children:e.jsx(Zs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(ve,{children:"Resource Files"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{className:"cursor-pointer gap-1",children:[e.jsx(Ya,{className:"h-3 w-3"}),"Add Files",e.jsx("input",{type:"file",multiple:!0,accept:".pdf,.pptx,.ppt,.xlsx,.xls,.docx,.doc,.zip",onChange:Ae,className:"hidden"})]})})]}),(N.length>0||j.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[N.map(he=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:he.title}),e.jsx(at,{variant:"outline",className:"text-xs",children:he.file_type}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>ht(he.id),className:"text-destructive hover:text-destructive",children:e.jsx(Ur,{className:"h-4 w-4"})})]},he.id)),j.map((he,Qe)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:he.title,onChange:ot=>{const rt=[...j];rt[Qe].title=ot.target.value,w(rt)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(at,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>We(Qe),className:"text-destructive hover:text-destructive",children:e.jsx(Ur,{className:"h-4 w-4"})})]},Qe))]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: PDF, PowerPoint, Excel, Word, ZIP"})]}),e.jsx(bKe,{selectedTemplateIds:L,onChange:R}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"is_published",checked:u.is_published,onCheckedChange:he=>p({...u,is_published:he})}),e.jsx(ve,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(On,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:de,children:"Cancel"}),e.jsx(K,{type:"submit",disabled:ke.isPending||de,children:de?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):ke.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),e.jsx(Ee,{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(kn,{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(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{children:"Duration"}),e.jsx(jt,{children:"Resources"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-[120px]",children:"Actions"})]})}),e.jsx(Pn,{children:be.map(he=>e.jsxs(js,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[he.thumbnail_url?e.jsx("img",{src:he.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(kn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:he.title}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:he.video_type.replace("_"," ")})]})]})}),e.jsx(lt,{children:he.category?e.jsx(at,{variant:"outline",children:he.category.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(lt,{children:he.duration||"-"}),e.jsx(lt,{children:he.resources&&he.resources.length>0?e.jsxs(at,{variant:"secondary",children:[he.resources.length," file(s)"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(lt,{children:new Date(he.publish_date).toLocaleDateString()}),e.jsx(lt,{children:e.jsx(Br,{checked:he.is_published,onCheckedChange:Qe=>_e.mutate({id:he.id,is_published:Qe})})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Te(he),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Ze.mutate(he.id),className:"text-destructive hover:text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})]})})]},he.id))})]})})})]})})};function rRt(){var ke,Ze,_e;const t=ns(),[s,r]=Ec(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=S.useState(null),[f,v]=S.useState(""),[_,b]=S.useState([]),[j,w]=S.useState([]),[N,C]=S.useState([]),[A,I]=S.useState(null),{data:L,isLoading:R}=Ct({queryKey:["resource-kits"],queryFn:async()=>{const{data:Ce,error:Te}=await G.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(Te)throw Te;return Ce}}),{data:$}=Ct({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:Ce,error:Te}=await G.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(Te)throw Te;return Ce}}),{data:q}=Ct({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:Ce,error:Te}=await G.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(Te)throw Te;return Ce}});S.useEffect(()=>{const Ce=s.get("edit");if(Ce&&L&&L.length>0&&$&&q){const Te=L.find(Fe=>Fe.id===Ce);Te&&(V(Te),r({},{replace:!0}))}},[L,$,q,s]);const U=()=>{d({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),v(""),b([]),w([]),C([]),l(null)},V=async Ce=>{l(Ce),d({name:Ce.name,description:Ce.description||"",publish_date:Ce.publish_date.split("T")[0],is_published:Ce.is_published}),v(Ce.featured_image_url||"");const Te=($==null?void 0:$.filter(We=>We.kit_id===Ce.id))||[];b(Te.map(We=>({id:We.id,name:We.name,file_url:We.file_url,file_type:We.file_type,file_size:We.file_size,sort_order:We.sort_order})));const Fe=(q==null?void 0:q.filter(We=>We.kit_id===Ce.id))||[];w(Fe.map(We=>({id:We.id,title:We.title,canva_share_link:We.canva_share_link,sort_order:We.sort_order})));const{data:Ae}=await G.from("resource_kit_templates").select("template_id").eq("kit_id",Ce.id);C((Ae||[]).map(We=>We.template_id)),a(!0)},X=Ce=>{var Fe;const Te=(Fe=Ce.target.files)==null?void 0:Fe[0];Te&&(p(Te),v(URL.createObjectURL(Te)))},se=()=>{b([..._,{name:"",file_url:"",sort_order:_.length}])},te=Ce=>{b(_.filter((Te,Fe)=>Fe!==Ce))},Y=(Ce,Te,Fe)=>{const Ae=[..._];Ae[Ce]={...Ae[Ce],[Te]:Fe},b(Ae)},de=()=>{w([...j,{title:"",canva_share_link:"",sort_order:j.length}])},ie=Ce=>{w(j.filter((Te,Fe)=>Fe!==Ce))},ae=(Ce,Te,Fe)=>{const Ae=[...j];Ae[Ce]={...Ae[Ce],[Te]:Fe},w(Ae)},le=(Ce,Te)=>{var Ae;const Fe=(Ae=Te.target.files)==null?void 0:Ae[0];if(Fe){const We=[..._],ht=Fe.name.replace(/\.[^/.]+$/,"");We[Ce]={...We[Ce],file:Fe,file_type:Fe.type,file_size:Fe.size,name:We[Ce].name||ht},b(We)}},pe=Ot({mutationFn:async()=>{let Ce=(o==null?void 0:o.featured_image_url)||null;if(u){const ht=u.name.split(".").pop(),De=`${Date.now()}.${ht}`,{error:Dt}=await G.storage.from("resource-kits").upload(`featured/${De}`,u);if(Dt)throw Dt;const{data:he}=G.storage.from("resource-kits").getPublicUrl(`featured/${De}`);Ce=he.publicUrl}const Te={name:i.name,description:i.description||null,featured_image_url:Ce,publish_date:i.publish_date,is_published:i.is_published};let Fe;const Ae=!o,We=(o==null?void 0:o.is_published)||!1;if(o){const{error:ht}=await G.from("resource_kits").update(Te).eq("id",o.id);if(ht)throw ht;Fe=o.id;const De=($==null?void 0:$.filter(Ne=>Ne.kit_id===o.id).map(Ne=>Ne.id))||[],Dt=_.filter(Ne=>Ne.id).map(Ne=>Ne.id),he=De.filter(Ne=>!Dt.includes(Ne));he.length>0&&await G.from("resource_kit_files").delete().in("id",he);const Qe=(q==null?void 0:q.filter(Ne=>Ne.kit_id===o.id).map(Ne=>Ne.id))||[],ot=j.filter(Ne=>Ne.id).map(Ne=>Ne.id),rt=Qe.filter(Ne=>!ot.includes(Ne));rt.length>0&&await G.from("resource_kit_links").delete().in("id",rt)}else{const{data:ht,error:De}=await G.from("resource_kits").insert(Te).select().single();if(De)throw De;Fe=ht.id}for(let ht=0;ht<_.length;ht++){const De=_[ht];let Dt=De.file_url;if(De.file){const he=De.file.name.split(".").pop(),Qe=`${Date.now()}-${ht}.${he}`,{error:ot}=await G.storage.from("resource-kits").upload(`files/${Qe}`,De.file);if(ot)throw ot;const{data:rt}=G.storage.from("resource-kits").getPublicUrl(`files/${Qe}`);Dt=rt.publicUrl}De.id?await G.from("resource_kit_files").update({name:De.name,file_url:Dt,file_type:De.file_type,file_size:De.file_size,sort_order:ht}).eq("id",De.id):Dt&&De.name&&await G.from("resource_kit_files").insert({kit_id:Fe,name:De.name,file_url:Dt,file_type:De.file_type,file_size:De.file_size,sort_order:ht})}for(let ht=0;ht0){const{error:ht}=await G.from("resource_kit_templates").insert(N.map(De=>({kit_id:Fe,template_id:De})));if(ht)throw ht}return{kitId:Fe,kitName:i.name,isNewKit:Ae,wasPublished:We,isPublished:i.is_published}},onSuccess:Ce=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),t.invalidateQueries({queryKey:["resource-kit-links"]}),fe.success(o?"Resource kit updated":"Resource kit created"),Ce.isPublished&&(Ce.isNewKit||!Ce.wasPublished)&&Y8t(Ce.kitName,Ce.kitId),a(!1),U()},onError:Ce=>{fe.error("Failed to save resource kit: "+Ce.message)}}),be=Ot({mutationFn:async Ce=>{const{error:Te}=await G.from("resource_kits").delete().eq("id",Ce);if(Te)throw Te},onSuccess:()=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),fe.success("Resource kit deleted")},onError:Ce=>{fe.error("Failed to delete: "+Ce.message)}}),ye=Ce=>{if(Ce.preventDefault(),!i.name){fe.error("Please enter a name");return}pe.mutate()},we=Ce=>($==null?void 0:$.filter(Te=>Te.kit_id===Ce).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(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{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(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{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(Ce=>Ce.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{U(),a(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Resource Kit"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Files"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:R?e.jsx(js,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(L==null?void 0:L.length)===0?e.jsx(js,{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(Ce=>e.jsxs(js,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ce.featured_image_url?e.jsx("img",{src:Ce.featured_image_url,alt:Ce.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(dl,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ce.name}),Ce.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Ce.description})]})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),we(Ce.id)]})}),e.jsx(lt,{children:ws(new Date(Ce.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 ${Ce.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Ce.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const Te=($==null?void 0:$.filter(Ae=>Ae.kit_id===Ce.id))||[],Fe=(q==null?void 0:q.filter(Ae=>Ae.kit_id===Ce.id))||[];I({...Ce,files:Te,links:Fe})},children:e.jsx(ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>V(Ce),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&be.mutate(Ce.id)},children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]})})]},Ce.id))})]})})}),e.jsx(vs,{open:n,onOpenChange:a,children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{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(ve,{children:"Featured Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[f?e.jsx("img",{src:f,alt:"Preview",className:"w-24 h-24 rounded object-cover"}):e.jsx("div",{className:"w-24 h-24 rounded bg-muted flex items-center justify-center",children:e.jsx(dl,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Re,{type:"file",accept:"image/*",onChange:X})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Name *"}),e.jsx(Re,{id:"name",value:i.name,onChange:Ce=>d({...i,name:Ce.target.value}),placeholder:"Resource Kit Name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Qg,{content:i.description,onChange:Ce=>d({...i,description:Ce}),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(ve,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:i.publish_date,onChange:Ce=>d({...i,publish_date:Ce.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(Br,{checked:i.is_published,onCheckedChange:Ce=>d({...i,is_published:Ce})}),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(ve,{children:"Resource Files"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:se,children:[e.jsx(Zs,{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((Ce,Te)=>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 ",Te+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>te(Te),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsx(Re,{placeholder:"File name (e.g., Getting Started Guide)",value:Ce.name,onChange:Fe=>Y(Te,"name",Fe.target.value)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{type:"file",onChange:Fe=>le(Te,Fe),className:"flex-1"}),Ce.file_url&&!Ce.file&&e.jsx("a",{href:Ce.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline whitespace-nowrap",children:"Current file"}),Ce.file&&e.jsx("span",{className:"text-sm text-green-600 whitespace-nowrap",children:"New file selected"})]})]},Te))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ve,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:de,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Canva Link"]})]}),j.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No Canva links added yet. Click "Add Canva Link" to include templates.'}):e.jsx("div",{className:"space-y-3",children:j.map((Ce,Te)=>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 ",Te+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ie(Te),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsx(Re,{placeholder:"Link title (e.g., Social Media Post Template)",value:Ce.title,onChange:Fe=>ae(Te,"title",Fe.target.value)}),e.jsx(Re,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:Ce.canva_share_link,onChange:Fe=>ae(Te,"canva_share_link",Fe.target.value)})]},Te))})]}),e.jsx(bKe,{selectedTemplateIds:N,onChange:C}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:pe.isPending,children:pe.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(vs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsx(Ss,{children:e.jsx(Ns,{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,")"]}),((Ze=A==null?void 0:A.files)==null?void 0:Ze.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:(_e=A==null?void 0:A.files)==null?void 0:_e.map(Ce=>e.jsxs("a",{href:Ce.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(In,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ce.name})]},Ce.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(Ce=>e.jsxs("a",{href:Ce.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(Lo,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ce.title})]},Ce.id))})]})]})]})})]})})}const nRt=()=>{const{user:t}=Gs(),{toast:s}=Ia(),r=ns(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[u,p]=S.useState(null),[f,v]=S.useState(""),{data:_=[],isLoading:b}=Ct({queryKey:["social-swag-admin"],queryFn:async()=>{const{data:q,error:U}=await G.from("social_swag").select("*").order("publish_date",{ascending:!1});if(U)throw U;const{data:V,error:X}=await G.from("social_swag_links").select("*").order("sort_order");if(X)throw X;return q.map(te=>({...te,links:(V==null?void 0:V.filter(Y=>Y.swag_id===te.id))||[]}))}}),j=Ot({mutationFn:async q=>{let U=q.existingImageUrl;if(q.image){const de=q.image.name.split(".").pop(),ie=`${Date.now()}-${Math.random().toString(36).substring(7)}.${de}`,{error:ae}=await G.storage.from("template-previews").upload(ie,q.image);if(ae)throw ae;const{data:le}=G.storage.from("template-previews").getPublicUrl(ie);U=le.publicUrl}const V={title:q.item.title,description:q.item.description||null,preview_image_url:U,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 X=q.itemId;const se=!X,te=(o==null?void 0:o.is_published)||!1;if(X){const{error:de}=await G.from("social_swag").update(V).eq("id",X);if(de)throw de;await G.from("social_swag_links").delete().eq("swag_id",X)}else{const{data:de,error:ie}=await G.from("social_swag").insert(V).select().single();if(ie)throw ie;X=de.id}const Y=q.item.links.filter(de=>de.title.trim()&&de.canva_share_link.trim());if(Y.length>0){const de=Y.map((ae,le)=>({swag_id:X,title:ae.title.trim(),canva_share_link:ae.canva_share_link.trim(),sort_order:le})),{error:ie}=await G.from("social_swag_links").insert(de);if(ie)throw ie}return{itemId:X,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)&&rye(q.itemTitle,q.itemId),a(!1),N()},onError:q=>{s({title:"Error saving item",description:q.message,variant:"destructive"})}}),w=Ot({mutationFn:async q=>{const{error:U}=await G.from("social_swag").delete().eq("id",q);if(U)throw U},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}]}),p(null),v(""),l(null)},C=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(U=>({id:U.id,title:U.title,canva_share_link:U.canva_share_link,sort_order:U.sort_order})):[{title:"",canva_share_link:"",sort_order:0}]}),v(q.preview_image_url||""),a(!0)},A=q=>{var V;const U=(V=q.target.files)==null?void 0:V[0];U&&(p(U),v(URL.createObjectURL(U)))},I=()=>{d({...i,links:[...i.links,{title:"",canva_share_link:"",sort_order:i.links.length}]})},L=q=>{if(i.links.length<=1)return;const U=i.links.filter((V,X)=>X!==q);d({...i,links:U})},R=(q,U,V)=>{const X=[...i.links];X[q]={...X[q],[U]:V},d({...i,links:X})},$=q=>{if(q.preventDefault(),!i.title.trim()){s({title:"Title is required",variant:"destructive"});return}j.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Ms,{title:"Manage Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"Manage Social Swag",description:"Create and manage social media content"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{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(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{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(vs,{open:n,onOpenChange:q=>{a(q),q||N()},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Item"]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{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(ve,{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(ve,{children:"Description"}),e.jsx(Qg,{content:i.description,onChange:q=>d({...i,description:q}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(Br,{id:"is_published",checked:i.is_published,onCheckedChange:q=>d({...i,is_published:q})}),e.jsx(ve,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Preview Image"}),f?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:f,alt:"Preview",className:"w-full max-h-48 object-contain rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{p(null),v("")},children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(Jo,{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(ve,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:I,children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map((q,U)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["Link ",U+1]}),i.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>L(U),children:e.jsx(Ur,{className:"h-3 w-3"})})]}),e.jsx(Re,{placeholder:"Link title (e.g., Instagram Post)",value:q.title,onChange:V=>R(U,"title",V.target.value)}),e.jsx(Re,{placeholder:"Canva share link",value:q.canva_share_link,onChange:V=>R(U,"canva_share_link",V.target.value)})]})},U))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:j.isPending,children:j.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{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(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-16",children:"Preview"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Links"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:_.map(q=>{var U;return e.jsxs(js,{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(Jo,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(lt,{className:"font-medium",children:q.title}),e.jsxs(lt,{children:[((U=q.links)==null?void 0:U.length)||0," links"]}),e.jsx(lt,{children:new Date(q.publish_date).toLocaleDateString()}),e.jsx(lt,{children:e.jsx(at,{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(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/social-swag/${q.id}`,"_blank"),children:e.jsx(ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(q),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this item?")&&w.mutate(q.id)},children:e.jsx(br,{className:"h-4 w-4"})})]})})]},q.id)})})]})})})]})})};function aRt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const ble=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function MM(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function uwe(t){return"nodeType"in t}function zm(t){var s,r;return t?MM(t)?t:uwe(t)&&(s=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function hwe(t){const{Document:s}=zm(t);return t instanceof s}function HL(t){return MM(t)?!1:t instanceof zm(t).HTMLElement}function wKe(t){return t instanceof zm(t).SVGElement}function TM(t){return t?MM(t)?t.document:uwe(t)?hwe(t)?t:HL(t)||wKe(t)?t.ownerDocument:document:document:document}const ly=ble?S.useLayoutEffect:S.useEffect;function mwe(t){const s=S.useRef(t);return ly(()=>{s.current=t}),S.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a{t.current=setInterval(n,a)},[]),r=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,r]}function g6(t,s){s===void 0&&(s=[t]);const r=S.useRef(t);return ly(()=>{r.current!==t&&(r.current=t)},s),r}function WL(t,s){const r=S.useRef();return S.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function Mae(t){const s=mwe(t),r=S.useRef(null),n=S.useCallback(a=>{a!==r.current&&(s==null||s(a,r.current)),r.current=a},[]);return[r,n]}function nye(t){const s=S.useRef();return S.useEffect(()=>{s.current=t},[t]),s.current}let Ume={};function GL(t,s){return S.useMemo(()=>{if(s)return s;const r=Ume[t]==null?0:Ume[t]+1;return Ume[t]=r,t+"-"+r},[t,s])}function jKe(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 p=o[d];p!=null&&(o[d]=p+t*u)}return o},{...s})}}const O5=jKe(1),x6=jKe(-1);function oRt(t){return"clientX"in t&&"clientY"in t}function pwe(t){if(!t)return!1;const{KeyboardEvent:s}=zm(t.target);return s&&t instanceof s}function lRt(t){if(!t)return!1;const{TouchEvent:s}=zm(t.target);return s&&t instanceof s}function aye(t){if(lRt(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 oRt(t)?{x:t.clientX,y:t.clientY}:null}const C3=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[C3.Translate.toString(t),C3.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:r,easing:n}=t;return s+" "+r+"ms "+n}}}),zAe="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function cRt(t){return t.matches(zAe)?t:t.querySelector(zAe)}const dRt={display:"none"};function uRt(t){let{id:s,value:r}=t;return mt.createElement("div",{id:s,style:dRt},r)}function hRt(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 mt.createElement("div",{id:s,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function mRt(){const[t,s]=S.useState("");return{announce:S.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const kKe=S.createContext(null);function pRt(t){const s=S.useContext(kKe);S.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function fRt(){const[t]=S.useState(()=>new Set),s=S.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[S.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 gRt={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. `},xRt={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 yRt(t){let{announcements:s=xRt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=gRt}=t;const{announce:o,announcement:l}=mRt(),i=GL("DndLiveRegion"),[d,u]=S.useState(!1);if(S.useEffect(()=>{u(!0)},[]),pRt(S.useMemo(()=>({onDragStart(f){let{active:v}=f;o(s.onDragStart({active:v}))},onDragMove(f){let{active:v,over:_}=f;s.onDragMove&&o(s.onDragMove({active:v,over:_}))},onDragOver(f){let{active:v,over:_}=f;o(s.onDragOver({active:v,over:_}))},onDragEnd(f){let{active:v,over:_}=f;o(s.onDragEnd({active:v,over:_}))},onDragCancel(f){let{active:v,over:_}=f;o(s.onDragCancel({active:v,over:_}))}}),[o,s])),!d)return null;const p=mt.createElement(mt.Fragment,null,mt.createElement(uRt,{id:n,value:a.draggable}),mt.createElement(hRt,{id:i,announcement:l}));return r?wm.createPortal(p,r):p}var zd;(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"})(zd||(zd={}));function Tae(){}function iye(t,s){return S.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function NKe(){for(var t=arguments.length,s=new Array(t),r=0;r[...s].filter(n=>n!=null),[...s])}const Zg=Object.freeze({x:0,y:0});function SKe(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function CKe(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return r-n}function vRt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function BAe(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 MKe(t,s){if(!t||t.length===0)return null;const[r]=t;return r[s]}function $Ae(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 TKe=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=$Ae(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=SKe($Ae(d),a);o.push({id:i,data:{droppableContainer:l,value:u}})}}return o.sort(CKe)},_Rt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=BAe(s),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=BAe(d),p=a.reduce((v,_,b)=>v+SKe(u[b],_),0),f=Number((p/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:f}})}}return o.sort(CKe)};function bRt(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=bRt(i,s);d>0&&a.push({id:l,data:{droppableContainer:o,value:d}})}}return a.sort(vRt)};function jRt(t,s,r){return{...t,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function AKe(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:Zg}function kRt(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 NRt=kRt(1);function SRt(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 CRt(t,s,r){const n=SRt(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)),p=a?t.width/a:t.width,f=o?t.height/o:t.height;return{width:p,height:f,top:u,right:d+p,bottom:u+f,left:d}}const MRt={ignoreTransform:!1};function AM(t,s){s===void 0&&(s=MRt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:p}=zm(t).getComputedStyle(t);u&&(r=CRt(r,u,p))}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 qAe(t){return AM(t,{ignoreTransform:!0})}function TRt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function ARt(t,s){return s===void 0&&(s=zm(t).getComputedStyle(t)),s.position==="fixed"}function ERt(t,s){s===void 0&&(s=zm(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 wle(t,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(hwe(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!HL(a)||wKe(a)||r.includes(a))return r;const o=zm(t).getComputedStyle(a);return a!==t&&ERt(a,o)&&r.push(a),ARt(a,o)?r:n(a.parentNode)}return t?n(t):r}function EKe(t){const[s]=wle(t,1);return s??null}function Vme(t){return!ble||!t?null:MM(t)?t:uwe(t)?hwe(t)||t===TM(t).scrollingElement?window:HL(t)?t:null:null}function PKe(t){return MM(t)?t.scrollX:t.scrollLeft}function IKe(t){return MM(t)?t.scrollY:t.scrollTop}function oye(t){return{x:PKe(t),y:IKe(t)}}var cu;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(cu||(cu={}));function LKe(t){return!ble||!t?!1:t===document.scrollingElement}function DKe(t){const s={x:0,y:0},r=LKe(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 PRt={x:.2,y:.2};function IRt(t,s,r,n,a){let{top:o,left:l,right:i,bottom:d}=r;n===void 0&&(n=10),a===void 0&&(a=PRt);const{isTop:u,isBottom:p,isLeft:f,isRight:v}=DKe(t),_={x:0,y:0},b={x:0,y:0},j={height:s.height*a.y,width:s.width*a.x};return!u&&o<=s.top+j.height?(_.y=cu.Backward,b.y=n*Math.abs((s.top+j.height-o)/j.height)):!p&&d>=s.bottom-j.height&&(_.y=cu.Forward,b.y=n*Math.abs((s.bottom-j.height-d)/j.height)),!v&&i>=s.right-j.width?(_.x=cu.Forward,b.x=n*Math.abs((s.right-j.width-i)/j.width)):!f&&l<=s.left+j.width&&(_.x=cu.Backward,b.x=n*Math.abs((s.left+j.width-l)/j.width)),{direction:_,speed:b}}function LRt(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 OKe(t){return t.reduce((s,r)=>O5(s,oye(r)),Zg)}function DRt(t){return t.reduce((s,r)=>s+PKe(r),0)}function ORt(t){return t.reduce((s,r)=>s+IKe(r),0)}function RRt(t,s){if(s===void 0&&(s=AM),!t)return;const{top:r,left:n,bottom:a,right:o}=s(t);EKe(t)&&(a<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const FRt=[["x",["left","right"],DRt],["y",["top","bottom"],ORt]];class fwe{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=wle(r),a=OKe(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of FRt)for(const d of l)Object.defineProperty(this,d,{get:()=>{const u=i(n),p=a[o]-u;return this.rect[d]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class dI{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 zRt(t){const{EventTarget:s}=zm(t);return t instanceof s?t:TM(t)}function Hme(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 Yp;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Yp||(Yp={}));function UAe(t){t.preventDefault()}function BRt(t){t.stopPropagation()}var yo;(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"})(yo||(yo={}));const RKe={start:[yo.Space,yo.Enter],cancel:[yo.Esc],end:[yo.Space,yo.Enter,yo.Tab]},$Rt=(t,s)=>{let{currentCoordinates:r}=s;switch(t.code){case yo.Right:return{...r,x:r.x+25};case yo.Left:return{...r,x:r.x-25};case yo.Down:return{...r,y:r.y+25};case yo.Up:return{...r,y:r.y-25}}};class gwe{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 dI(TM(r)),this.windowListeners=new dI(zm(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Yp.Resize,this.handleCancel),this.windowListeners.add(Yp.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Yp.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&RRt(n),r(Zg)}handleKeyDown(s){if(pwe(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=RKe,coordinateGetter:l=$Rt,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,p=u?{x:u.left,y:u.top}:Zg;this.referenceCoordinates||(this.referenceCoordinates=p);const f=l(s,{active:r,context:n.current,currentCoordinates:p});if(f){const v=x6(f,p),_={x:0,y:0},{scrollableAncestors:b}=n.current;for(const j of b){const w=s.code,{isTop:N,isRight:C,isLeft:A,isBottom:I,maxScroll:L,minScroll:R}=DKe(j),$=LRt(j),q={x:Math.min(w===yo.Right?$.right-$.width/2:$.right,Math.max(w===yo.Right?$.left:$.left+$.width/2,f.x)),y:Math.min(w===yo.Down?$.bottom-$.height/2:$.bottom,Math.max(w===yo.Down?$.top:$.top+$.height/2,f.y))},U=w===yo.Right&&!C||w===yo.Left&&!A,V=w===yo.Down&&!I||w===yo.Up&&!N;if(U&&q.x!==f.x){const X=j.scrollLeft+v.x,se=w===yo.Right&&X<=L.x||w===yo.Left&&X>=R.x;if(se&&!v.y){j.scrollTo({left:X,behavior:i});return}se?_.x=j.scrollLeft-X:_.x=w===yo.Right?j.scrollLeft-L.x:j.scrollLeft-R.x,_.x&&j.scrollBy({left:-_.x,behavior:i});break}else if(V&&q.y!==f.y){const X=j.scrollTop+v.y,se=w===yo.Down&&X<=L.y||w===yo.Up&&X>=R.y;if(se&&!v.x){j.scrollTo({top:X,behavior:i});return}se?_.y=j.scrollTop-X:_.y=w===yo.Down?j.scrollTop-L.y:j.scrollTop-R.y,_.y&&j.scrollBy({top:-_.y,behavior:i});break}}this.handleMove(s,O5(x6(f,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()}}gwe.activators=[{eventName:"onKeyDown",handler:(t,s,r)=>{let{keyboardCodes:n=RKe,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 VAe(t){return!!(t&&"distance"in t)}function HAe(t){return!!(t&&"delay"in t)}class xwe{constructor(s,r,n){var a;n===void 0&&(n=zRt(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=TM(l),this.documentListeners=new dI(this.document),this.listeners=new dI(n),this.windowListeners=new dI(zm(l)),this.initialCoordinates=(a=aye(o))!=null?a:Zg,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(Yp.Resize,this.handleCancel),this.windowListeners.add(Yp.DragStart,UAe),this.windowListeners.add(Yp.VisibilityChange,this.handleCancel),this.windowListeners.add(Yp.ContextMenu,UAe),this.documentListeners.add(Yp.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(HAe(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(VAe(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(Yp.Click,BRt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Yp.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=aye(s))!=null?r:Zg,u=x6(a,d);if(!n&&i){if(VAe(i)){if(i.tolerance!=null&&Hme(u,i.tolerance))return this.handleCancel();if(Hme(u,i.distance))return this.handleStart()}if(HAe(i)&&Hme(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===yo.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const qRt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class jle extends xwe{constructor(s){const{event:r}=s,n=TM(r.target);super(s,qRt,n)}}jle.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 URt={move:{name:"mousemove"},end:{name:"mouseup"}};var lye;(function(t){t[t.RightClick=2]="RightClick"})(lye||(lye={}));class VRt extends xwe{constructor(s){super(s,URt,TM(s.event.target))}}VRt.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return r.button===lye.RightClick?!1:(n==null||n({event:r}),!0)}}];const Wme={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class HRt extends xwe{constructor(s){super(s,Wme)}static setup(){return window.addEventListener(Wme.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Wme.move.name,s)};function s(){}}}HRt.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 uI;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(uI||(uI={}));var Aae;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Aae||(Aae={}));function WRt(t){let{acceleration:s,activator:r=uI.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=Aae.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:p,delta:f,threshold:v}=t;const _=KRt({delta:f,disabled:!o}),[b,j]=iRt(),w=S.useRef({x:0,y:0}),N=S.useRef({x:0,y:0}),C=S.useMemo(()=>{switch(r){case uI.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case uI.DraggableRect:return a}},[r,a,d]),A=S.useRef(null),I=S.useCallback(()=>{const R=A.current;if(!R)return;const $=w.current.x*N.current.x,q=w.current.y*N.current.y;R.scrollBy($,q)},[]),L=S.useMemo(()=>i===Aae.TreeOrder?[...u].reverse():u,[i,u]);S.useEffect(()=>{if(!o||!u.length||!C){j();return}for(const R of L){if((n==null?void 0:n(R))===!1)continue;const $=u.indexOf(R),q=p[$];if(!q)continue;const{direction:U,speed:V}=IRt(R,q,C,s,v);for(const X of["x","y"])_[X][U[X]]||(V[X]=0,U[X]=0);if(V.x>0||V.y>0){j(),A.current=R,b(I,l),w.current=V,N.current=U;return}}w.current={x:0,y:0},N.current={x:0,y:0},j()},[s,I,n,j,o,l,JSON.stringify(C),JSON.stringify(_),b,u,L,p,JSON.stringify(v)])}const GRt={x:{[cu.Backward]:!1,[cu.Forward]:!1},y:{[cu.Backward]:!1,[cu.Forward]:!1}};function KRt(t){let{delta:s,disabled:r}=t;const n=nye(s);return WL(a=>{if(r||!n||!a)return GRt;const o={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[cu.Backward]:a.x[cu.Backward]||o.x===-1,[cu.Forward]:a.x[cu.Forward]||o.x===1},y:{[cu.Backward]:a.y[cu.Backward]||o.y===-1,[cu.Forward]:a.y[cu.Forward]||o.y===1}}},[r,s,n])}function ZRt(t,s){const r=s!=null?t.get(s):void 0,n=r?r.node.current:null;return WL(a=>{var o;return s==null?null:(o=n??a)!=null?o:null},[n,s])}function YRt(t,s){return S.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 y6;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(y6||(y6={}));var cye;(function(t){t.Optimized="optimized"})(cye||(cye={}));const WAe=new Map;function XRt(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=S.useState(null),{frequency:i,measure:d,strategy:u}=a,p=S.useRef(t),f=w(),v=g6(f),_=S.useCallback(function(N){N===void 0&&(N=[]),!v.current&&l(C=>C===null?N:C.concat(N.filter(A=>!C.includes(A))))},[v]),b=S.useRef(null),j=WL(N=>{if(f&&!r)return WAe;if(!N||N===WAe||p.current!==t||o!=null){const C=new Map;for(let A of t){if(!A)continue;if(o&&o.length>0&&!o.includes(A.id)&&A.rect.current){C.set(A.id,A.rect.current);continue}const I=A.node.current,L=I?new fwe(d(I),I):null;A.rect.current=L,L&&C.set(A.id,L)}return C}return N},[t,o,r,f,d]);return S.useEffect(()=>{p.current=t},[t]),S.useEffect(()=>{f||_()},[r,f]),S.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),S.useEffect(()=>{f||typeof i!="number"||b.current!==null||(b.current=setTimeout(()=>{_(),b.current=null},i))},[i,f,_,...n]),{droppableRects:j,measureDroppableContainers:_,measuringScheduled:o!=null};function w(){switch(u){case y6.Always:return!1;case y6.BeforeDragging:return r;default:return!r}}}function FKe(t,s){return WL(r=>t?r||(typeof s=="function"?s(t):t):null,[s,t])}function QRt(t,s){return FKe(t,s)}function JRt(t){let{callback:s,disabled:r}=t;const n=mwe(s),a=S.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,r]);return S.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function kle(t){let{callback:s,disabled:r}=t;const n=mwe(s),a=S.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[r]);return S.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function eFt(t){return new fwe(AM(t),t)}function GAe(t,s,r){s===void 0&&(s=eFt);const[n,a]=S.useState(null);function o(){a(d=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=d??r)!=null?u:null}const p=s(t);return JSON.stringify(d)===JSON.stringify(p)?d:p})}const l=JRt({callback(d){if(t)for(const u of d){const{type:p,target:f}=u;if(p==="childList"&&f instanceof HTMLElement&&f.contains(t)){o();break}}}}),i=kle({callback:o});return ly(()=>{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 tFt(t){const s=FKe(t);return AKe(t,s)}const KAe=[];function sFt(t){const s=S.useRef(t),r=WL(n=>t?n&&n!==KAe&&t&&s.current&&t.parentNode===s.current.parentNode?n:wle(t):KAe,[t]);return S.useEffect(()=>{s.current=t},[t]),r}function rFt(t){const[s,r]=S.useState(null),n=S.useRef(t),a=S.useCallback(o=>{const l=Vme(o.target);l&&r(i=>i?(i.set(l,oye(l)),new Map(i)):null)},[]);return S.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(d=>{const u=Vme(d);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,oye(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=Vme(d);u==null||u.removeEventListener("scroll",a)})}},[a,t]),S.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>O5(o,l),Zg):OKe(t):Zg,[t,s])}function ZAe(t,s){s===void 0&&(s=[]);const r=S.useRef(null);return S.useEffect(()=>{r.current=null},s),S.useEffect(()=>{const n=t!==Zg;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?x6(t,r.current):Zg}function nFt(t){S.useEffect(()=>{if(!ble)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 aFt(t,s){return S.useMemo(()=>t.reduce((r,n)=>{let{eventName:a,handler:o}=n;return r[a]=l=>{o(l,s)},r},{}),[t,s])}function zKe(t){return S.useMemo(()=>t?TRt(t):null,[t])}const YAe=[];function iFt(t,s){s===void 0&&(s=AM);const[r]=t,n=zKe(r?zm(r):null),[a,o]=S.useState(YAe);function l(){o(()=>t.length?t.map(d=>LKe(d)?n:new fwe(s(d),d)):YAe)}const i=kle({callback:l});return ly(()=>{i==null||i.disconnect(),l(),t.forEach(d=>i==null?void 0:i.observe(d))},[t]),a}function oFt(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return HL(s)?s:t}function lFt(t){let{measure:s}=t;const[r,n]=S.useState(null),a=S.useCallback(u=>{for(const{target:p}of u)if(HL(p)){n(f=>{const v=s(p);return f?{...f,width:v.width,height:v.height}:v});break}},[s]),o=kle({callback:a}),l=S.useCallback(u=>{const p=oFt(u);o==null||o.disconnect(),p&&(o==null||o.observe(p)),n(p?s(p):null)},[s,o]),[i,d]=Mae(l);return S.useMemo(()=>({nodeRef:i,rect:r,setRef:d}),[r,i,d])}const cFt=[{sensor:jle,options:{}},{sensor:gwe,options:{}}],dFt={current:{}},bre={draggable:{measure:qAe},droppable:{measure:qAe,strategy:y6.WhileDragging,frequency:cye.Optimized},dragOverlay:{measure:AM}};class hI 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 uFt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new hI,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Tae},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:bre,measureDroppableContainers:Tae,windowRect:null,measuringScheduled:!1},hFt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Tae,draggableNodes:new Map,over:null,measureDroppableContainers:Tae},Nle=S.createContext(hFt),BKe=S.createContext(uFt);function mFt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new hI}}}function pFt(t,s){switch(s.type){case zd.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case zd.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 zd.DragEnd:case zd.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case zd.RegisterDroppable:{const{element:r}=s,{id:n}=r,a=new hI(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case zd.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 hI(t.droppable.containers);return l.set(r,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:l}}}case zd.UnregisterDroppable:{const{id:r,key:n}=s,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const o=new hI(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function fFt(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=S.useContext(Nle),o=nye(n),l=nye(r==null?void 0:r.id);return S.useEffect(()=>{if(!s&&!n&&o&&l!=null){if(!pwe(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 p of[d.current,u.current]){if(!p)continue;const f=cRt(p);if(f){f.focus();break}}})}},[n,s,a,l,o]),null}function gFt(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function xFt(t){return S.useMemo(()=>({draggable:{...bre.draggable,...t==null?void 0:t.draggable},droppable:{...bre.droppable,...t==null?void 0:t.droppable},dragOverlay:{...bre.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 yFt(t){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=t;const o=S.useRef(!1),{x:l,y:i}=typeof a=="boolean"?{x:a,y:a}:a;ly(()=>{if(!l&&!i||!s){o.current=!1;return}if(o.current||!n)return;const u=s==null?void 0:s.node.current;if(!u||u.isConnected===!1)return;const p=r(u),f=AKe(p,n);if(l||(f.x=0),i||(f.y=0),o.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const v=EKe(u);v&&v.scrollBy({top:f.y,left:f.x})}},[s,l,i,n,r])}const $Ke=S.createContext({...Zg,scaleX:1,scaleY:1});var m1;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(m1||(m1={}));const qKe=S.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:d=!0,children:u,sensors:p=cFt,collisionDetection:f=wRt,measuring:v,modifiers:_,...b}=s;const j=S.useReducer(pFt,void 0,mFt),[w,N]=j,[C,A]=fRt(),[I,L]=S.useState(m1.Uninitialized),R=I===m1.Initialized,{draggable:{active:$,nodes:q,translate:U},droppable:{containers:V}}=w,X=$!=null?q.get($):null,se=S.useRef({initial:null,translated:null}),te=S.useMemo(()=>{var Fa;return $!=null?{id:$,data:(Fa=X==null?void 0:X.data)!=null?Fa:dFt,rect:se}:null},[$,X]),Y=S.useRef(null),[de,ie]=S.useState(null),[ae,le]=S.useState(null),pe=g6(b,Object.values(b)),be=GL("DndDescribedBy",l),ye=S.useMemo(()=>V.getEnabled(),[V]),we=xFt(v),{droppableRects:ke,measureDroppableContainers:Ze,measuringScheduled:_e}=XRt(ye,{dragging:R,dependencies:[U.x,U.y],config:we.droppable}),Ce=ZRt(q,$),Te=S.useMemo(()=>ae?aye(ae):null,[ae]),Fe=bo(),Ae=QRt(Ce,we.draggable.measure);yFt({activeNode:$!=null?q.get($):null,config:Fe.layoutShiftCompensation,initialRect:Ae,measure:we.draggable.measure});const We=GAe(Ce,we.draggable.measure,Ae),ht=GAe(Ce?Ce.parentElement:null),De=S.useRef({activatorEvent:null,active:null,activeNode:Ce,collisionRect:null,collisions:null,droppableRects:ke,draggableNodes:q,draggingNode:null,draggingNodeRect:null,droppableContainers:V,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Dt=V.getNodeFor((r=De.current.over)==null?void 0:r.id),he=lFt({measure:we.dragOverlay.measure}),Qe=(n=he.nodeRef.current)!=null?n:Ce,ot=R?(a=he.rect)!=null?a:We:null,rt=!!(he.nodeRef.current&&he.rect),Ne=tFt(rt?null:We),it=zKe(Qe?zm(Qe):null),qe=sFt(R?Dt??Ce:null),Xe=iFt(qe),$e=gFt(_,{transform:{x:U.x-Ne.x,y:U.y-Ne.y,scaleX:1,scaleY:1},activatorEvent:ae,active:te,activeNodeRect:We,containerNodeRect:ht,draggingNodeRect:ot,over:De.current.over,overlayNodeRect:he.rect,scrollableAncestors:qe,scrollableAncestorRects:Xe,windowRect:it}),Ke=Te?O5(Te,U):null,ct=rFt(qe),Ue=ZAe(ct),Ve=ZAe(ct,[We]),Je=O5($e,Ue),Rt=ot?NRt(ot,$e):null,$t=te&&Rt?f({active:te,collisionRect:Rt,droppableRects:ke,droppableContainers:ye,pointerCoordinates:Ke}):null,ls=MKe($t,"id"),[Qt,rs]=S.useState(null),as=rt?$e:O5($e,Ve),ir=jRt(as,(o=Qt==null?void 0:Qt.rect)!=null?o:null,We),vt=S.useRef(null),Cs=S.useCallback((Fa,yn)=>{let{sensor:na,options:Nn}=yn;if(Y.current==null)return;const ta=q.get(Y.current);if(!ta)return;const Kt=Fa.nativeEvent,$r=new na({active:Y.current,activeNode:ta,event:Kt,options:Nn,context:De,onAbort(nn){if(!q.get(nn))return;const{onDragAbort:aa}=pe.current,Pr={id:nn};aa==null||aa(Pr),C({type:"onDragAbort",event:Pr})},onPending(nn,_a,aa,Pr){if(!q.get(nn))return;const{onDragPending:nl}=pe.current,mi={id:nn,constraint:_a,initialCoordinates:aa,offset:Pr};nl==null||nl(mi),C({type:"onDragPending",event:mi})},onStart(nn){const _a=Y.current;if(_a==null)return;const aa=q.get(_a);if(!aa)return;const{onDragStart:Pr}=pe.current,ii={activatorEvent:Kt,active:{id:_a,data:aa.data,rect:se}};wm.unstable_batchedUpdates(()=>{Pr==null||Pr(ii),L(m1.Initializing),N({type:zd.DragStart,initialCoordinates:nn,active:_a}),C({type:"onDragStart",event:ii}),ie(vt.current),le(Kt)})},onMove(nn){N({type:zd.DragMove,coordinates:nn})},onEnd:es(zd.DragEnd),onCancel:es(zd.DragCancel)});vt.current=$r;function es(nn){return async function(){const{active:aa,collisions:Pr,over:ii,scrollAdjustedTranslate:nl}=De.current;let mi=null;if(aa&&nl){const{cancelDrop:Vl}=pe.current;mi={activatorEvent:Kt,active:aa,collisions:Pr,delta:nl,over:ii},nn===zd.DragEnd&&typeof Vl=="function"&&await Promise.resolve(Vl(mi))&&(nn=zd.DragCancel)}Y.current=null,wm.unstable_batchedUpdates(()=>{N({type:nn}),L(m1.Uninitialized),rs(null),ie(null),le(null),vt.current=null;const Vl=nn===zd.DragEnd?"onDragEnd":"onDragCancel";if(mi){const dt=pe.current[Vl];dt==null||dt(mi),C({type:Vl,event:mi})}})}}},[q]),or=S.useCallback((Fa,yn)=>(na,Nn)=>{const ta=na.nativeEvent,Kt=q.get(Nn);if(Y.current!==null||!Kt||ta.dndKit||ta.defaultPrevented)return;const $r={active:Kt};Fa(na,yn.options,$r)===!0&&(ta.dndKit={capturedBy:yn.sensor},Y.current=Nn,Cs(na,yn))},[q,Cs]),Ar=YRt(p,or);nFt(p),ly(()=>{We&&I===m1.Initializing&&L(m1.Initialized)},[We,I]),S.useEffect(()=>{const{onDragMove:Fa}=pe.current,{active:yn,activatorEvent:na,collisions:Nn,over:ta}=De.current;if(!yn||!na)return;const Kt={active:yn,activatorEvent:na,collisions:Nn,delta:{x:Je.x,y:Je.y},over:ta};wm.unstable_batchedUpdates(()=>{Fa==null||Fa(Kt),C({type:"onDragMove",event:Kt})})},[Je.x,Je.y]),S.useEffect(()=>{const{active:Fa,activatorEvent:yn,collisions:na,droppableContainers:Nn,scrollAdjustedTranslate:ta}=De.current;if(!Fa||Y.current==null||!yn||!ta)return;const{onDragOver:Kt}=pe.current,$r=Nn.get(ls),es=$r&&$r.rect.current?{id:$r.id,rect:$r.rect.current,data:$r.data,disabled:$r.disabled}:null,nn={active:Fa,activatorEvent:yn,collisions:na,delta:{x:ta.x,y:ta.y},over:es};wm.unstable_batchedUpdates(()=>{rs(es),Kt==null||Kt(nn),C({type:"onDragOver",event:nn})})},[ls]),ly(()=>{De.current={activatorEvent:ae,active:te,activeNode:Ce,collisionRect:Rt,collisions:$t,droppableRects:ke,draggableNodes:q,draggingNode:Qe,draggingNodeRect:ot,droppableContainers:V,over:Qt,scrollableAncestors:qe,scrollAdjustedTranslate:Je},se.current={initial:ot,translated:Rt}},[te,Ce,$t,Rt,q,Qe,ot,ke,V,Qt,qe,Je]),WRt({...Fe,delta:U,draggingRect:Rt,pointerCoordinates:Ke,scrollableAncestors:qe,scrollableAncestorRects:Xe});const Wn=S.useMemo(()=>({active:te,activeNode:Ce,activeNodeRect:We,activatorEvent:ae,collisions:$t,containerNodeRect:ht,dragOverlay:he,draggableNodes:q,droppableContainers:V,droppableRects:ke,over:Qt,measureDroppableContainers:Ze,scrollableAncestors:qe,scrollableAncestorRects:Xe,measuringConfiguration:we,measuringScheduled:_e,windowRect:it}),[te,Ce,We,ae,$t,ht,he,q,V,ke,Qt,Ze,qe,Xe,we,_e,it]),ai=S.useMemo(()=>({activatorEvent:ae,activators:Ar,active:te,activeNodeRect:We,ariaDescribedById:{draggable:be},dispatch:N,draggableNodes:q,over:Qt,measureDroppableContainers:Ze}),[ae,Ar,te,We,N,be,q,Qt,Ze]);return mt.createElement(kKe.Provider,{value:A},mt.createElement(Nle.Provider,{value:ai},mt.createElement(BKe.Provider,{value:Wn},mt.createElement($Ke.Provider,{value:ir},u)),mt.createElement(fFt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),mt.createElement(yRt,{...i,hiddenTextDescribedById:be}));function bo(){const Fa=(de==null?void 0:de.autoScrollEnabled)===!1,yn=typeof d=="object"?d.enabled===!1:d===!1,na=R&&!Fa&&!yn;return typeof d=="object"?{...d,enabled:na}:{enabled:na}}}),vFt=S.createContext(null),XAe="button",_Ft="Draggable";function bFt(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=GL(_Ft),{activators:l,activatorEvent:i,active:d,activeNodeRect:u,ariaDescribedById:p,draggableNodes:f,over:v}=S.useContext(Nle),{role:_=XAe,roleDescription:b="draggable",tabIndex:j=0}=a??{},w=(d==null?void 0:d.id)===s,N=S.useContext(w?$Ke:vFt),[C,A]=Mae(),[I,L]=Mae(),R=aFt(l,s),$=g6(r);ly(()=>(f.set(s,{id:s,key:o,node:C,activatorNode:I,data:$}),()=>{const U=f.get(s);U&&U.key===o&&f.delete(s)}),[f,s]);const q=S.useMemo(()=>({role:_,tabIndex:j,"aria-disabled":n,"aria-pressed":w&&_===XAe?!0:void 0,"aria-roledescription":b,"aria-describedby":p.draggable}),[n,_,j,w,b,p.draggable]);return{active:d,activatorEvent:i,activeNodeRect:u,attributes:q,isDragging:w,listeners:n?void 0:R,node:C,over:v,setNodeRef:A,setActivatorNodeRef:L,transform:N}}function wFt(){return S.useContext(BKe)}const jFt="Droppable",kFt={timeout:25};function NFt(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=GL(jFt),{active:l,dispatch:i,over:d,measureDroppableContainers:u}=S.useContext(Nle),p=S.useRef({disabled:r}),f=S.useRef(!1),v=S.useRef(null),_=S.useRef(null),{disabled:b,updateMeasurementsFor:j,timeout:w}={...kFt,...a},N=g6(j??n),C=S.useCallback(()=>{if(!f.current){f.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{u(Array.isArray(N.current)?N.current:[N.current]),_.current=null},w)},[w]),A=kle({callback:C,disabled:b||!l}),I=S.useCallback((q,U)=>{A&&(U&&(A.unobserve(U),f.current=!1),q&&A.observe(q))},[A]),[L,R]=Mae(I),$=g6(s);return S.useEffect(()=>{!A||!L.current||(A.disconnect(),f.current=!1,A.observe(L.current))},[L,A]),S.useEffect(()=>(i({type:zd.RegisterDroppable,element:{id:n,key:o,disabled:r,node:L,rect:v,data:$}}),()=>i({type:zd.UnregisterDroppable,key:o,id:n})),[n]),S.useEffect(()=>{r!==p.current.disabled&&(i({type:zd.SetDroppableDisabled,id:n,key:o,disabled:r}),p.current.disabled=r)},[n,o,r,i]),{active:l,rect:v,isOver:(d==null?void 0:d.id)===n,node:L,over:d,setNodeRef:R}}function ywe(t,s,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function SFt(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function iR(t){return t!==null&&t>=0}function CFt(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=TFt(r,l,a);if(l===a){const u=r[o];return u?{x:aa&&l<=o?{x:-i.width-d,y:0,...oR}:l=o?{x:i.width+d,y:0,...oR}:{x:0,y:0,...oR}};function TFt(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=ywe(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}},UKe="Sortable",VKe=mt.createContext({activeIndex:-1,containerId:UKe,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Sle,disabled:{draggable:!1,droppable:!1}});function HKe(t){let{children:s,id:r,items:n,strategy:a=Sle,disabled:o=!1}=t;const{active:l,dragOverlay:i,droppableRects:d,over:u,measureDroppableContainers:p}=wFt(),f=GL(UKe,r),v=i.rect!==null,_=S.useMemo(()=>n.map(R=>typeof R=="object"&&"id"in R?R.id:R),[n]),b=l!=null,j=l?_.indexOf(l.id):-1,w=u?_.indexOf(u.id):-1,N=S.useRef(_),C=!CFt(_,N.current),A=w!==-1&&j===-1||C,I=MFt(o);ly(()=>{C&&b&&p(_)},[C,_,b,p]),S.useEffect(()=>{N.current=_},[_]);const L=S.useMemo(()=>({activeIndex:j,containerId:f,disabled:I,disableTransforms:A,items:_,overIndex:w,useDragOverlay:v,sortedRects:SFt(_,d),strategy:a}),[j,f,I.draggable,I.droppable,A,_,w,d,v,a]);return mt.createElement(VKe.Provider,{value:L},s)}const AFt=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return ywe(r,n,a).indexOf(s)},EFt=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},PFt={duration:200,easing:"ease"},WKe="transform",IFt=C3.Transition.toString({property:WKe,duration:0,easing:"linear"}),LFt={roleDescription:"sortable"};function DFt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=S.useState(null),i=S.useRef(r);return ly(()=>{if(!s&&r!==i.current&&n.current){const d=a.current;if(d){const u=AM(n.current,{ignoreTransform:!0}),p={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(p.x||p.y)&&l(p)}}r!==i.current&&(i.current=r)},[s,r,n,a]),S.useEffect(()=>{o&&l(null)},[o]),o}function GKe(t){let{animateLayoutChanges:s=EFt,attributes:r,disabled:n,data:a,getNewIndex:o=AFt,id:l,strategy:i,resizeObserverConfig:d,transition:u=PFt}=t;const{items:p,containerId:f,activeIndex:v,disabled:_,disableTransforms:b,sortedRects:j,overIndex:w,useDragOverlay:N,strategy:C}=S.useContext(VKe),A=OFt(n,_),I=p.indexOf(l),L=S.useMemo(()=>({sortable:{containerId:f,index:I,items:p},...a}),[f,a,I,p]),R=S.useMemo(()=>p.slice(p.indexOf(l)),[p,l]),{rect:$,node:q,isOver:U,setNodeRef:V}=NFt({id:l,data:L,disabled:A.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...d}}),{active:X,activatorEvent:se,activeNodeRect:te,attributes:Y,setNodeRef:de,listeners:ie,isDragging:ae,over:le,setActivatorNodeRef:pe,transform:be}=bFt({id:l,data:L,attributes:{...LFt,...r},disabled:A.draggable}),ye=aRt(V,de),we=!!X,ke=we&&!b&&iR(v)&&iR(w),Ze=!N&&ae,_e=Ze&&ke?be:null,Te=ke?_e??(i??C)({rects:j,activeNodeRect:te,activeIndex:v,overIndex:w,index:I}):null,Fe=iR(v)&&iR(w)?o({id:l,items:p,activeIndex:v,overIndex:w}):I,Ae=X==null?void 0:X.id,We=S.useRef({activeId:Ae,items:p,newIndex:Fe,containerId:f}),ht=p!==We.current.items,De=s({active:X,containerId:f,isDragging:ae,isSorting:we,id:l,index:I,items:p,newIndex:We.current.newIndex,previousItems:We.current.items,previousContainerId:We.current.containerId,transition:u,wasDragging:We.current.activeId!=null}),Dt=DFt({disabled:!De,index:I,node:q,rect:$});return S.useEffect(()=>{we&&We.current.newIndex!==Fe&&(We.current.newIndex=Fe),f!==We.current.containerId&&(We.current.containerId=f),p!==We.current.items&&(We.current.items=p)},[we,Fe,f,p]),S.useEffect(()=>{if(Ae===We.current.activeId)return;if(Ae!=null&&We.current.activeId==null){We.current.activeId=Ae;return}const Qe=setTimeout(()=>{We.current.activeId=Ae},50);return()=>clearTimeout(Qe)},[Ae]),{active:X,activeIndex:v,attributes:Y,data:L,rect:$,index:I,newIndex:Fe,items:p,isOver:U,isSorting:we,isDragging:ae,listeners:ie,node:q,overIndex:w,over:le,setNodeRef:ye,setActivatorNodeRef:pe,setDroppableNodeRef:V,setDraggableNodeRef:de,transform:Dt??Te,transition:he()};function he(){if(Dt||ht&&We.current.newIndex===I)return IFt;if(!(Ze&&!pwe(se)||!u)&&(we||De))return C3.Transition.toString({...u,property:WKe})}}function OFt(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 Eae(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 RFt=[yo.Down,yo.Right,yo.Up,yo.Left],FFt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(RFt.includes(t.code)){if(t.preventDefault(),!r||!n)return;const d=[];o.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const v=a.get(f.id);if(v)switch(t.code){case yo.Down:n.topv.top&&d.push(f);break;case yo.Left:n.left>v.left&&d.push(f);break;case yo.Right:n.left1&&(p=u[1].id),p!=null){const f=o.get(r.id),v=o.get(p),_=v?a.get(v.id):null,b=v==null?void 0:v.node.current;if(b&&_&&f&&v){const w=wle(b).some((R,$)=>i[$]!==R),N=KKe(f,v),C=zFt(f,v),A=w||!N?{x:0,y:0}:{x:C?n.width-_.width:0,y:C?n.height-_.height:0},I={x:_.left,y:_.top};return A.x&&A.y?I:x6(I,A)}}}};function KKe(t,s){return!Eae(t)||!Eae(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function zFt(t,s){return!Eae(t)||!Eae(s)||!KKe(t,s)?!1:t.data.current.sortable.indexs(t),children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"destructive",size:"icon",className:"h-7 w-7",onClick:()=>r(t),children:e.jsx(br,{className:"h-3.5 w-3.5"})})]}),t.post_date&&e.jsx("div",{className:"absolute bottom-2 left-2",children:e.jsxs(at,{className:"bg-primary/90 text-primary-foreground text-[10px] gap-1 backdrop-blur-sm px-1.5 py-0.5",children:[e.jsx(on,{className:"h-2.5 w-2.5"}),ws(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(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:Pt("w-full h-7 text-[11px] gap-1 justify-start font-normal",!t.post_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"h-3 w-3"}),t.post_date?ws(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs(ko,{className:"w-auto p-0",align:"start",children:[e.jsx(yp,{mode:"single",selected:t.post_date?new Date(t.post_date+"T00:00:00"):void 0,onSelect:f=>n(t.id,f?ws(f,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"}),t.post_date&&e.jsx("div",{className:"p-2 border-t",children:e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>n(t.id,null),children:"Clear date"})})]})]})]})]})})}const $Ft=()=>{const t=ns(),[s,r]=S.useState("all"),[n,a]=S.useState(!1),[o,l]=S.useState(ws(new Date,"yyyy-MM")),[i,d]=S.useState([]),[u,p]=S.useState(!1),[f,v]=S.useState(null),[_,b]=S.useState(null),[j,w]=S.useState(""),[N,C]=S.useState(null),[A,I]=S.useState(!1),[L,R]=S.useState(!1),[$,q]=S.useState(ws(new Date,"yyyy-MM")),[U,V]=S.useState(null),[X,se]=S.useState(""),[te,Y]=S.useState(""),[de,ie]=S.useState(""),[ae,le]=S.useState(!1),pe=NKe(iye(jle,{activationConstraint:{distance:5}}),iye(gwe,{coordinateGetter:FFt})),{data:be=[],isLoading:ye}=Ct({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:Ke,error:ct}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(ct)throw ct;return Ke}}),{data:we=[]}=Ct({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:Ke,error:ct}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(ct)throw ct;return Ke}}),{data:ke=[]}=Ct({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:Ke,error:ct}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(ct)throw ct;return Ke}}),Ze=[...new Set(be.map(Ke=>Ke.month))].sort((Ke,ct)=>ct.localeCompare(Ke)),_e=s==="all"?be:be.filter(Ke=>Ke.month===s),Ce=Ke=>{const ct=e_e(Ke,"yyyy-MM",new Date);return ws(ct,"MMMM yyyy")},Te=Ke=>{b(Ke),w(Ke.caption),C(Ke.post_date)},Fe=async()=>{if(_){I(!0);try{const{error:Ke}=await G.from("social_swag_2").update({caption:j,post_date:N}).eq("id",_.id);if(Ke)throw Ke;fe.success("Image updated"),b(null),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})}catch{fe.error("Failed to update image")}finally{I(!1)}}},Ae=async Ke=>{const{active:ct,over:Ue}=Ke;if(!Ue||ct.id===Ue.id)return;const Ve=_e,Je=Ve.findIndex(ls=>ls.id===ct.id),Rt=Ve.findIndex(ls=>ls.id===Ue.id);if(Je===-1||Rt===-1)return;const $t=ywe(Ve,Je,Rt);t.setQueryData(["admin-social-swag-2"],ls=>{if(!ls)return ls;const Qt={};return $t.forEach((rs,as)=>{Qt[rs.id]=as}),ls.map(rs=>Qt[rs.id]!==void 0?{...rs,sort_order:Qt[rs.id]}:rs).sort((rs,as)=>rs.month!==as.month?as.month.localeCompare(rs.month):rs.sort_order-as.sort_order)});try{await Promise.all($t.map((ls,Qt)=>G.from("social_swag_2").update({sort_order:Qt}).eq("id",ls.id)))}catch{fe.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},We=Ke=>{const Ue=Array.from(Ke.target.files||[]).sort((Ve,Je)=>Ve.name.localeCompare(Je.name,void 0,{numeric:!0,sensitivity:"base"})).slice(0,16-i.length).map(Ve=>({file:Ve,preview:URL.createObjectURL(Ve),caption:""}));d(Ve=>[...Ve,...Ue].slice(0,16))},ht=Ke=>{d(ct=>{const Ue=[...ct];return URL.revokeObjectURL(Ue[Ke].preview),Ue.splice(Ke,1),Ue})},De=(Ke,ct)=>{d(Ue=>{const Ve=[...Ue];return Ve[Ke]={...Ve[Ke],caption:ct},Ve})},Dt=async()=>{var ct;if(i.length===0){fe.error("Please add at least one image");return}if(i.filter(Ue=>!Ue.caption.trim()).length>0){fe.error("Please add captions to all images");return}p(!0);try{const{data:Ue}=await G.from("social_swag_2").select("sort_order").eq("month",o).order("sort_order",{ascending:!1}).limit(1),Ve=(((ct=Ue==null?void 0:Ue[0])==null?void 0:ct.sort_order)??-1)+1;for(let Je=0;Je{const ct=Ke.image_url.split("/social-swag-2/");ct[1]&&await G.storage.from("social-swag-2").remove([ct[1]]);const{error:Ue}=await G.from("social_swag_2").delete().eq("id",Ke.id);if(Ue)throw Ue},onSuccess:()=>{fe.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>fe.error("Failed to delete image")}),Qe=Ot({mutationFn:async({id:Ke,postDate:ct})=>{const{error:Ue}=await G.from("social_swag_2").update({post_date:ct}).eq("id",Ke);if(Ue)throw Ue},onSuccess:()=>{fe.success("Post date updated"),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})},onError:()=>fe.error("Failed to update post date")}),ot=Ot({mutationFn:async({month:Ke,link:ct})=>{const{error:Ue}=await G.from("social_swag_2_months").upsert({month:Ke,canva_link:ct||null},{onConflict:"month"});if(Ue)throw Ue},onSuccess:()=>{fe.success("Canva link updated"),v(null),t.invalidateQueries({queryKey:["admin-social-swag-2-months"]})},onError:()=>fe.error("Failed to update Canva link")}),rt=Ke=>{var ct;return((ct=we.find(Ue=>Ue.month===Ke))==null?void 0:ct.canva_link)||""},Ne=Ke=>ke.find(ct=>ct.month===Ke)||null,it=Ke=>{var Ue;const ct=(Ue=Ke.target.files)==null?void 0:Ue[0];ct&&(V(ct),se(URL.createObjectURL(ct)))},qe=()=>{X&&URL.revokeObjectURL(X),V(null),se(""),Y(""),ie("")},Xe=async()=>{if(!U){fe.error("Please select an image");return}le(!0);try{const Ke=U.name.split(".").pop(),ct=`reels/${$}-${Date.now()}.${Ke}`,{error:Ue}=await G.storage.from("social-swag-2").upload(ct,U);if(Ue)throw Ue;const{data:{publicUrl:Ve}}=G.storage.from("social-swag-2").getPublicUrl(ct),{error:Je}=await G.from("social_swag_2_reels").upsert({month:$,image_url:Ve,canva_link:de||null,caption:te||null},{onConflict:"month"});if(Je)throw Je;fe.success("Reel uploaded successfully!"),rye(`${Ce($)} Reel`,"social-swag-2"),qe(),R(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(Ke){console.error("Reel upload error:",Ke),fe.error("Failed to upload reel")}finally{le(!1)}},$e=Ot({mutationFn:async Ke=>{const ct=Ke.image_url.split("/social-swag-2/");ct[1]&&await G.storage.from("social-swag-2").remove([ct[1]]);const{error:Ue}=await G.from("social_swag_2_reels").delete().eq("id",Ke.id);if(Ue)throw Ue},onSuccess:()=>{fe.success("Reel deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})},onError:()=>fe.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(vs,{open:n,onOpenChange:a,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Upload Images"]})}),e.jsxs(ys,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Upload Social Swag Images"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Month"}),e.jsx(Re,{type:"month",value:o,onChange:Ke=>l(Ke.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{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:We,className:"hidden",id:"swag-upload",disabled:i.length>=16}),e.jsxs("label",{htmlFor:"swag-upload",className:"cursor-pointer",children:[e.jsx(Ya,{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((Ke,ct)=>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:Ke.preview,alt:`Upload ${ct+1}`,className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>ht(ct),children:e.jsx(Ur,{className:"h-3 w-3"})})]}),e.jsx(Mr,{placeholder:"Caption...",value:Ke.caption,onChange:Ue=>De(ct,Ue.target.value),className:"text-xs h-20"})]},ct))}),e.jsx(K,{onClick:Dt,disabled:u||i.length===0,className:"w-full gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ya,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),e.jsxs(vs,{open:L,onOpenChange:Ke=>{R(Ke),Ke||qe()},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(lu,{className:"h-4 w-4"}),"Upload Reel"]})}),e.jsxs(ys,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Upload Monthly Reel"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Month"}),e.jsx(Re,{type:"month",value:$,onChange:Ke=>q(Ke.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Reel Preview Image"}),X?e.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:X,alt:"Reel preview",className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{URL.revokeObjectURL(X),V(null),se("")},children:e.jsx(Ur,{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:it,className:"hidden",id:"reel-upload"}),e.jsxs("label",{htmlFor:"reel-upload",className:"cursor-pointer",children:[e.jsx(lu,{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(ve,{children:"Canva Download Link"}),e.jsx(Re,{value:de,onChange:Ke=>ie(Ke.target.value),placeholder:"https://www.canva.com/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Caption"}),e.jsx(Mr,{value:te,onChange:Ke=>Y(Ke.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(K,{onClick:Xe,disabled:ae||!U,className:"w-full gap-2",children:ae?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ya,{className:"h-4 w-4"}),"Upload Reel"]})})]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:be.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:Ze.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Months"})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Na,{value:s,onValueChange:r,children:e.jsxs(va,{children:[e.jsx(ks,{value:"all",children:"All"}),Ze.map(Ke=>e.jsx(ks,{value:Ke,children:Ce(Ke)},Ke))]})}),s!=="all"&&e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Lo,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(ve,{className:"text-sm text-muted-foreground",children:["Canva Edit Link for ",Ce(s)]}),(f==null?void 0:f.month)===s?e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(Re,{value:f.link,onChange:Ke=>v({...f,link:Ke.target.value}),placeholder:"https://www.canva.com/..."}),e.jsx(K,{size:"sm",onClick:()=>ot.mutate(f),children:"Save"}),e.jsx(K,{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(K,{size:"sm",variant:"outline",onClick:()=>v({month:s,link:rt(s)}),children:"Edit"})]})]})]})})}),s!=="all"&&e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(lu,{className:"h-4 w-4 text-muted-foreground mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(ve,{className:"text-sm text-muted-foreground",children:["Reel for ",Ce(s)]}),(()=>{const Ke=Ne(s);return Ke?e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("img",{src:Ke.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:Ke.caption||"No caption"}),Ke.canva_link&&e.jsx("a",{href:Ke.canva_link,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-xs",children:"View Canva Link"})]}),e.jsx(K,{variant:"destructive",size:"sm",onClick:()=>$e.mutate(Ke),children:e.jsx(br,{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..."}):_e.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Jo,{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(qKe,{sensors:pe,collisionDetection:TKe,onDragEnd:Ae,children:e.jsx(HKe,{items:_e.map(Ke=>Ke.id),strategy:Sle,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:_e.map(Ke=>e.jsx(BFt,{item:Ke,onEdit:Te,onDelete:ct=>he.mutate(ct),onDateChange:(ct,Ue)=>Qe.mutate({id:ct,postDate:Ue})},Ke.id))})})})]}),e.jsx(vs,{open:!!_,onOpenChange:Ke=>{Ke||b(null)},children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(Ns,{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(ve,{children:"Caption"}),e.jsx(Mr,{value:j,onChange:Ke=>w(Ke.target.value),placeholder:"Enter caption...",className:"h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Post Date"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("flex-1 justify-start gap-2 font-normal",!N&&"text-muted-foreground"),children:[e.jsx(on,{className:"h-4 w-4"}),N?ws(new Date(N+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx(ko,{className:"w-auto p-0",align:"start",children:e.jsx(yp,{mode:"single",selected:N?new Date(N+"T00:00:00"):void 0,onSelect:Ke=>C(Ke?ws(Ke,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),N&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(null),children:"Cancel"}),e.jsx(K,{onClick:Fe,disabled:A,className:"gap-2",children:A?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},qFt=()=>{const{toast:t}=Ia(),s=ns(),[r,n]=S.useState("categories"),[a,o]=S.useState(!1),[l,i]=S.useState(null),[d,u]=S.useState({name:"",description:"",icon:""}),[p,f]=S.useState(!1),[v,_]=S.useState(null),[b,j]=S.useState({name:"",description:"",icon:""}),[w,N]=S.useState(!1),[C,A]=S.useState(null),[I,L]=S.useState(""),{data:R=[],isLoading:$}=Ct({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:Ae,error:We}=await G.from("community_categories").select("*").order("sort_order");if(We)throw We;return Ae}}),{data:q=[],isLoading:U}=Ct({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:Ae,error:We}=await G.from("community_private_groups").select("*").order("sort_order");if(We)throw We;return Ae}}),{data:V=[]}=Ct({queryKey:["admin-group-members",C==null?void 0:C.id],queryFn:async()=>{if(!C)return[];const{data:Ae,error:We}=await G.from("community_private_group_members").select("*").eq("group_id",C.id);if(We)throw We;return Ae},enabled:!!C}),{data:X=[]}=Ct({queryKey:["admin-all-profiles"],queryFn:async()=>{let We=[],ht=0,De=!0;for(;De;){const{data:Dt,error:he}=await G.from("profiles").select("id, name, email, brokerage_id").order("name").range(ht,ht+1e3-1);if(he)throw he;Dt&&Dt.length>0?(We=[...We,...Dt],ht+=1e3,De=Dt.length===1e3):De=!1}return We}}),{data:se=[]}=Ct({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:Ae,error:We}=await G.from("brokerages").select("*").order("name");if(We)throw We;return Ae}}),te=Ot({mutationFn:async Ae=>{if(Ae.id){const{error:We}=await G.from("community_categories").update({name:Ae.name,description:Ae.description||null,icon:Ae.icon||null}).eq("id",Ae.id);if(We)throw We}else{const We=Math.max(...R.map(De=>De.sort_order),0),{error:ht}=await G.from("community_categories").insert({name:Ae.name,description:Ae.description||null,icon:Ae.icon||null,sort_order:We+1});if(ht)throw ht}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),u({name:"",description:"",icon:""}),t({title:l?"Category updated!":"Category created!"})},onError:Ae=>{t({title:"Error",description:Ae.message,variant:"destructive"})}}),Y=Ot({mutationFn:async Ae=>{const{error:We}=await G.from("community_categories").delete().eq("id",Ae);if(We)throw We},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),t({title:"Category deleted"})}}),de=Ot({mutationFn:async({id:Ae,direction:We})=>{const ht=R.findIndex(De=>De.id===Ae);if(We==="up"&&ht>0){const De=R[ht-1],Dt=R[ht];await G.from("community_categories").update({sort_order:Dt.sort_order}).eq("id",De.id),await G.from("community_categories").update({sort_order:De.sort_order}).eq("id",Dt.id)}else if(We==="down"&&hts.invalidateQueries({queryKey:["admin-community-categories"]})}),ie=Ot({mutationFn:async Ae=>{if(Ae.id){const{error:We}=await G.from("community_private_groups").update({name:Ae.name,description:Ae.description||null,icon:Ae.icon||null}).eq("id",Ae.id);if(We)throw We}else{const We=Math.max(...q.map(De=>De.sort_order),0),{error:ht}=await G.from("community_private_groups").insert({name:Ae.name,description:Ae.description||null,icon:Ae.icon||null,sort_order:We+1});if(ht)throw ht}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),f(!1),_(null),j({name:"",description:"",icon:""}),t({title:v?"Private group updated!":"Private group created!"})},onError:Ae=>{t({title:"Error",description:Ae.message,variant:"destructive"})}}),ae=Ot({mutationFn:async Ae=>{const{error:We}=await G.from("community_private_groups").delete().eq("id",Ae);if(We)throw We},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),t({title:"Private group deleted"})}}),le=Ot({mutationFn:async({id:Ae,direction:We})=>{const ht=q.findIndex(De=>De.id===Ae);if(We==="up"&&ht>0){const De=q[ht-1],Dt=q[ht];await G.from("community_private_groups").update({sort_order:Dt.sort_order}).eq("id",De.id),await G.from("community_private_groups").update({sort_order:De.sort_order}).eq("id",Dt.id)}else if(We==="down"&&hts.invalidateQueries({queryKey:["admin-private-groups"]})}),pe=Ot({mutationFn:async({groupId:Ae,userId:We,isMember:ht})=>{if(ht){const{error:De}=await G.from("community_private_group_members").delete().eq("group_id",Ae).eq("user_id",We);if(De)throw De}else{const{error:De}=await G.from("community_private_group_members").insert({group_id:Ae,user_id:We});if(De)throw De}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",C==null?void 0:C.id]})}}),be=Ot({mutationFn:async({groupId:Ae,brokerageId:We,isMember:ht})=>{if(ht){const{error:De}=await G.from("community_private_group_members").delete().eq("group_id",Ae).eq("brokerage_id",We);if(De)throw De}else{const{error:De}=await G.from("community_private_group_members").insert({group_id:Ae,brokerage_id:We});if(De)throw De}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",C==null?void 0:C.id]})}}),ye=Ae=>{i(Ae),u({name:Ae.name,description:Ae.description||"",icon:Ae.icon||""}),o(!0)},we=()=>{i(null),u({name:"",description:"",icon:""}),o(!0)},ke=Ae=>{_(Ae),j({name:Ae.name,description:Ae.description||"",icon:Ae.icon||""}),f(!0)},Ze=()=>{_(null),j({name:"",description:"",icon:""}),f(!0)},_e=Ae=>{A(Ae),L(""),N(!0)},Ce=Ae=>V.some(We=>We.user_id===Ae),Te=Ae=>V.some(We=>We.brokerage_id===Ae),Fe=X.filter(Ae=>Ae.name.toLowerCase().includes(I.toLowerCase())||Ae.email.toLowerCase().includes(I.toLowerCase()));return e.jsx(Ms,{title:"Community Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),e.jsxs(Na,{value:r,onValueChange:n,children:[e.jsxs(va,{children:[e.jsx(ks,{value:"categories",children:"Public Categories"}),e.jsxs(ks,{value:"private-groups",children:[e.jsx(zu,{className:"h-4 w-4 mr-1"}),"Private Groups"]})]}),e.jsxs(zs,{value:"categories",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Categories visible to all community members"}),e.jsxs(K,{onClick:we,children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-[50px]",children:"Order"}),e.jsx(jt,{className:"w-[80px]",children:"Icon"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Pn,{children:$?e.jsx(js,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):R.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):R.map((Ae,We)=>e.jsxs(js,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:We===0,onClick:()=>de.mutate({id:Ae.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:We===R.length-1,onClick:()=>de.mutate({id:Ae.id,direction:"down"}),children:"↓"})]})}),e.jsx(lt,{className:"text-2xl",children:Ae.icon||"📁"}),e.jsx(lt,{className:"font-medium",children:Ae.name}),e.jsx(lt,{className:"text-muted-foreground",children:Ae.description||"—"}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ye(Ae),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this category? Posts will be uncategorized.")&&Y.mutate(Ae.id)},children:e.jsx(br,{className:"h-4 w-4"})})]})})]},Ae.id))})]})})})]}),e.jsxs(zs,{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(Aa,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),e.jsxs(K,{onClick:Ze,children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-[50px]",children:"Order"}),e.jsx(jt,{className:"w-[80px]",children:"Icon"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{className:"w-[120px]",children:"Members"}),e.jsx(jt,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(Pn,{children:U?e.jsx(js,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):q.length===0?e.jsx(js,{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((Ae,We)=>e.jsxs(js,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:We===0,onClick:()=>le.mutate({id:Ae.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:We===q.length-1,onClick:()=>le.mutate({id:Ae.id,direction:"down"}),children:"↓"})]})}),e.jsx(lt,{className:"text-2xl",children:Ae.icon||"🔒"}),e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Ae.name,Ae.brokerage_id?e.jsxs(at,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(Aa,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):e.jsxs(at,{variant:"secondary",className:"text-xs",children:[e.jsx(zu,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(lt,{className:"text-muted-foreground",children:Ae.description||"—"}),e.jsx(lt,{children:e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>_e(Ae),children:[e.jsx(hr,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1",children:[!Ae.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ke(Ae),children:e.jsx(Ra,{className:"h-4 w-4"})}),!Ae.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this private group? All posts in this group will be deleted.")&&ae.mutate(Ae.id)},children:e.jsx(br,{className:"h-4 w-4"})}),Ae.brokerage_id&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},Ae.id))})]})})})]})]}),e.jsx(vs,{open:a,onOpenChange:o,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{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:Ae=>u(We=>({...We,icon:Ae.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:Ae=>u(We=>({...We,name:Ae.target.value})),placeholder:"Category name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Mr,{value:d.description,onChange:Ae=>u(We=>({...We,description:Ae.target.value})),placeholder:"Brief description of this category",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>te.mutate({...d,id:l==null?void 0:l.id}),disabled:!d.name.trim(),children:l?"Save Changes":"Create Category"})]})]})]})}),e.jsx(vs,{open:p,onOpenChange:f,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{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:Ae=>j(We=>({...We,icon:Ae.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:Ae=>j(We=>({...We,name:Ae.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(Mr,{value:b.description,onChange:Ae=>j(We=>({...We,description:Ae.target.value})),placeholder:"Brief description of this private group",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>f(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>ie.mutate({...b,id:v==null?void 0:v.id}),disabled:!b.name.trim(),children:v?"Save Changes":"Create Private Group"})]})]})]})}),e.jsx(vs,{open:w,onOpenChange:N,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsx(Ss,{children:e.jsxs(Ns,{children:["Manage Members: ",C==null?void 0:C.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Na,{defaultValue:"brokerages",children:[e.jsxs(va,{className:"w-full",children:[e.jsx(ks,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),e.jsx(ks,{value:"users",className:"flex-1",children:"Individual Users"})]}),e.jsxs(zs,{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(Bi,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[se.map(Ae=>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(zo,{checked:Te(Ae.id),onCheckedChange:()=>{C&&be.mutate({groupId:C.id,brokerageId:Ae.id,isMember:Te(Ae.id)})}}),e.jsx("span",{className:"font-medium",children:Ae.name})]}),e.jsxs(at,{variant:"secondary",children:[X.filter(We=>We.brokerage_id===Ae.id).length," agents"]})]},Ae.id)),se.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No brokerages found"})]})})]}),e.jsxs(zs,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(fn,{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:Ae=>L(Ae.target.value),className:"pl-9"})]}),e.jsx(Bi,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Fe.map(Ae=>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(zo,{checked:Ce(Ae.id),onCheckedChange:()=>{C&&pe.mutate({groupId:C.id,userId:Ae.id,isMember:Ce(Ae.id)})}}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ae.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:Ae.email})]})]})},Ae.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(K,{onClick:()=>N(!1),children:"Done"})})]})]})})]})})},QAe=t=>{switch(t){case"academy_video":return e.jsx(ul,{className:"h-3 w-3"});case"template":return e.jsx(In,{className:"h-3 w-3"});case"toolbox":return e.jsx(dl,{className:"h-3 w-3"});case"newsletter":return e.jsx(I0,{className:"h-3 w-3"});case"social_swag":return e.jsx(hn,{className:"h-3 w-3"});default:return e.jsx(sn,{className:"h-3 w-3"})}},UFt=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}},VFt=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}},HFt=()=>{const{toast:t}=Ia(),[s,r]=S.useState([]),[n,a]=S.useState([]),[o,l]=S.useState([]),[i,d]=S.useState(!0),[u,p]=S.useState(""),[f,v]=S.useState(null),[_,b]=S.useState([]),[j,w]=S.useState([]);S.useEffect(()=>{N()},[]);const N=async()=>{try{d(!0);const{data:V,error:X}=await G.from("activity_logs").select(` id, user_id, app_name, launched_at, profiles ( name, email, brokerages ( name ) ) `).order("launched_at",{ascending:!1}).limit(5e3);if(X)throw X;const{data:se,error:te}=await G.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:de}=await G.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",Y),ie=new Map((de==null?void 0:de.map(ye=>[ye.id,ye]))||[]),ae=(V==null?void 0:V.map(ye=>{var we,ke,Ze,_e;return{id:ye.id,user_id:ye.user_id,app_name:ye.app_name,launched_at:ye.launched_at,user_name:((we=ye.profiles)==null?void 0:we.name)||"Unknown",user_email:((ke=ye.profiles)==null?void 0:ke.email)||"Unknown",brokerage_name:((_e=(Ze=ye.profiles)==null?void 0:Ze.brokerages)==null?void 0:_e.name)||null}}))||[],le=(se==null?void 0:se.map(ye=>{var ke;const we=ie.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:(we==null?void 0:we.name)||"Unknown",user_email:(we==null?void 0:we.email)||"Unknown",brokerage_name:((ke=we==null?void 0:we.brokerages)==null?void 0:ke.name)||null}}))||[];r(ae),a(le);const pe=new Map;ae.forEach(ye=>{if(!pe.has(ye.user_id))pe.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 we=pe.get(ye.user_id);we.total_app_launches++,new Date(ye.launched_at)>new Date(we.last_activity_at)&&(we.last_activity_type="app",we.last_activity_name=ye.app_name,we.last_activity_at=ye.launched_at)}}),le.forEach(ye=>{if(!pe.has(ye.user_id))pe.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 we=pe.get(ye.user_id);we.total_content_views++,new Date(ye.created_at)>new Date(we.last_activity_at)&&(we.last_activity_type=ye.resource_type,we.last_activity_name=ye.resource_title,we.last_activity_at=ye.created_at)}});const be=Array.from(pe.values()).sort((ye,we)=>new Date(we.last_activity_at).getTime()-new Date(ye.last_activity_at).getTime());l(be)}catch(V){console.error("Error loading activity:",V),t({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{d(!1)}},C=V=>{v({id:V.user_id,name:V.user_name,email:V.user_email});const X=s.filter(te=>te.user_id===V.user_id),se=n.filter(te=>te.user_id===V.user_id);b(X),w(se)},A=()=>{v(null),b([]),w([])},{sortKey:I,sortDirection:L,handleSort:R,sortData:$}=UL("last_activity_at","desc"),q=o.filter(V=>{var se;if(!u)return!0;const X=u.toLowerCase();return V.user_name.toLowerCase().includes(X)||V.user_email.toLowerCase().includes(X)||((se=V.brokerage_name)==null?void 0:se.toLowerCase().includes(X))}),U=$(q,{user:V=>{var X;return((X=V.user_name)==null?void 0:X.toLowerCase())||""},brokerage:V=>{var X;return((X=V.brokerage_name)==null?void 0:X.toLowerCase())||""},last_activity_at:V=>new Date(V.last_activity_at).getTime(),apps:V=>V.total_app_launches,content:V=>V.total_content_views});return i?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"User Activity"}),e.jsx(yr,{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(fn,{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:V=>p(V.target.value),className:"pl-9"})]})}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(el,{sortKey:"user",currentSortKey:I,currentDirection:L,onSort:R,children:"User"}),e.jsx(el,{sortKey:"brokerage",currentSortKey:I,currentDirection:L,onSort:R,children:"Brokerage"}),e.jsx(jt,{children:"Last Activity"}),e.jsx(el,{sortKey:"last_activity_at",currentSortKey:I,currentDirection:L,onSort:R,children:"Last Active"}),e.jsx(el,{sortKey:"apps",currentSortKey:I,currentDirection:L,onSort:R,className:"text-right",children:"Apps"}),e.jsx(el,{sortKey:"content",currentSortKey:I,currentDirection:L,onSort:R,className:"text-right",children:"Content"})]})}),e.jsx(Pn,{children:U.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):U.map(V=>e.jsxs(js,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>C(V),children:[e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:V.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:V.user_email})]})}),e.jsx(lt,{children:V.brokerage_name?e.jsx(at,{variant:"outline",children:V.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:V.last_activity_type==="app"?e.jsxs(at,{variant:"secondary",children:[e.jsx(sn,{className:"h-3 w-3 mr-1"}),V.last_activity_name]}):e.jsxs(at,{variant:"outline",className:"flex items-center gap-1",children:[QAe(V.last_activity_type),e.jsx("span",{className:"max-w-32 truncate",children:V.last_activity_name})]})})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:Cd(new Date(V.last_activity_at),{addSuffix:!0})}),e.jsx(lt,{className:"text-right",children:e.jsx(at,{variant:"outline",children:V.total_app_launches})}),e.jsx(lt,{className:"text-right",children:e.jsx(at,{variant:"outline",children:V.total_content_views})})]},V.user_id))})]})})]})]}),e.jsx(vs,{open:!!f,onOpenChange:V=>!V&&A(),children:e.jsxs(ys,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{children:[f==null?void 0:f.name,"'s Activity"]}),e.jsx(Kr,{children:f==null?void 0:f.email})]}),e.jsxs(Na,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(va,{className:"grid w-full grid-cols-2",children:[e.jsxs(ks,{value:"content",children:["Content (",j.length,")"]}),e.jsxs(ks,{value:"apps",children:["App Launches (",_.length,")"]})]}),e.jsx(zs,{value:"content",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Resource"}),e.jsx(jt,{children:"Action"}),e.jsx(jt,{children:"Time"})]})}),e.jsx(Pn,{children:j.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):j.map(V=>e.jsxs(js,{children:[e.jsx(lt,{children:e.jsxs(at,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[QAe(V.resource_type),UFt(V.resource_type)]})}),e.jsx(lt,{className:"max-w-48",children:e.jsx("span",{className:"truncate block",children:V.resource_title})}),e.jsx(lt,{children:e.jsx(at,{variant:"secondary",children:VFt(V.action_type)})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:Cd(new Date(V.created_at),{addSuffix:!0})})]},V.id))})]})})}),e.jsx(zs,{value:"apps",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"App"}),e.jsx(jt,{children:"Time"})]})}),e.jsx(Pn,{children:_.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):_.map(V=>e.jsxs(js,{children:[e.jsx(lt,{children:e.jsx(at,{variant:"secondary",children:V.app_name})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:Cd(new Date(V.launched_at),{addSuffix:!0})})]},V.id))})]})})})]})]})})]})},WFt=()=>{const{toast:t}=Ia(),[s,r]=S.useState({totalUsers:0,activeUsers:0,pendingUsers:0,totalBrokerages:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0,uniqueActiveThisWeek:0}),[n,a]=S.useState(!0);S.useEffect(()=>{o()},[]);const o=async()=>{try{a(!0);const{count:l}=await G.from("profiles").select("*",{count:"exact",head:!0}),{count:i}=await G.from("profiles").select("*",{count:"exact",head:!0}).not("last_login","is",null),d=(l||0)-(i||0),{count:u}=await G.from("brokerages").select("*",{count:"exact",head:!0}),{count:p}=await G.from("activity_logs").select("*",{count:"exact",head:!0}),f=new Date;f.setDate(f.getDate()-7);const{count:v}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",f.toISOString()),_=new Date;_.setMonth(_.getMonth()-1);const{count:b}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",_.toISOString()),{data:j}=await G.from("activity_logs").select("user_id").gte("launched_at",f.toISOString()),w=new Set(j==null?void 0:j.map(N=>N.user_id)).size;r({totalUsers:l||0,activeUsers:i||0,pendingUsers:d,totalBrokerages:u||0,totalLaunches:p||0,launchesThisWeek:v||0,launchesThisMonth:b||0,uniqueActiveThisWeek:w})}catch(l){console.error("Error loading analytics:",l),t({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{a(!1)}};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(hr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalUsers}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.activeUsers," active, ",s.pendingUsers," pending"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(gi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.activeUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.totalUsers>0?`${Math.round(s.activeUsers/s.totalUsers*100)}% of total`:"0% of total"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(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(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(Aa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalBrokerages}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total brokerages"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(Am,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(Am,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(Am,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisMonth}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(Cc,{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"})]})]})]})},JAe={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},eEe={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 ZKe({brokerageOnly:t=!1,brokerageId:s}){const[r,n]=S.useState([]),[a,o]=S.useState(!0),[l,i]=S.useState(""),[d,u]=S.useState("all");S.useEffect(()=>{p()},[s]);const p=async()=>{o(!0);try{let R=[];if(t&&s){const{data:Y}=await G.from("profiles").select("id").eq("brokerage_id",s);if(R=(Y==null?void 0:Y.map(de=>de.id))||[],R.length===0){n([]),o(!1);return}}let $=G.from("resource_shares").select("*").order("created_at",{ascending:!1});t&&R.length>0&&($=$.or(`sender_id.in.(${R.join(",")}),recipient_id.in.(${R.join(",")})`));const{data:q,error:U}=await $;if(U)throw U;const V=new Set;q==null||q.forEach(Y=>{V.add(Y.sender_id),V.add(Y.recipient_id)});const{data:X}=await G.from("profiles").select("id, name, email").in("id",Array.from(V)),se=new Map((X==null?void 0:X.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(R){console.error("Error loading shares:",R)}finally{o(!1)}},{sortKey:f,sortDirection:v,handleSort:_,sortData:b}=UL("created_at","desc"),j=r.filter(R=>{var U,V;const $=l===""||R.resource_title.toLowerCase().includes(l.toLowerCase())||((U=R.sender)==null?void 0:U.name.toLowerCase().includes(l.toLowerCase()))||((V=R.recipient)==null?void 0:V.name.toLowerCase().includes(l.toLowerCase())),q=d==="all"||R.resource_type===d;return $&&q}),w=b(j,{resource:R=>{var $;return(($=R.resource_title)==null?void 0:$.toLowerCase())||""},type:R=>R.resource_type,sender:R=>{var $,q;return((q=($=R.sender)==null?void 0:$.name)==null?void 0:q.toLowerCase())||""},recipient:R=>{var $,q;return((q=($=R.recipient)==null?void 0:$.name)==null?void 0:q.toLowerCase())||""},status:R=>R.is_read?1:0,created_at:R=>new Date(R.created_at).getTime()}),N=r.length,C=new Set(r.map(R=>R.sender_id)).size,A=new Set(r.map(R=>R.recipient_id)).size,I=r.length>0?Math.round(r.filter(R=>R.is_read).length/r.length*100):0,L=r.reduce((R,$)=>(R[$.resource_type]=(R[$.resource_type]||0)+1,R),{});return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((R,$)=>e.jsxs(Ee,{children:[e.jsx(Lt,{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(Ee,{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(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Shares"}),e.jsx(cd,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:N})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active Sharers"}),e.jsx(hr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:C})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(Cc,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:A})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(In,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[I,"%"]})})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(([R,$])=>e.jsxs(at,{variant:"secondary",className:eEe[R],children:[JAe[R],": ",$]},R)),Object.keys(L).length===0&&e.jsx("span",{className:"text-muted-foreground text-sm",children:"No shares yet"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Share History"}),e.jsxs(yr,{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(fn,{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:R=>i(R.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:d,onValueChange:u,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{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(Bi,{className:"h-[400px]",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(el,{sortKey:"resource",currentSortKey:f,currentDirection:v,onSort:_,children:"Resource"}),e.jsx(el,{sortKey:"type",currentSortKey:f,currentDirection:v,onSort:_,children:"Type"}),e.jsx(el,{sortKey:"sender",currentSortKey:f,currentDirection:v,onSort:_,children:"Sender"}),e.jsx(el,{sortKey:"recipient",currentSortKey:f,currentDirection:v,onSort:_,children:"Recipient"}),e.jsx(el,{sortKey:"status",currentSortKey:f,currentDirection:v,onSort:_,children:"Status"}),e.jsx(el,{sortKey:"created_at",currentSortKey:f,currentDirection:v,onSort:_,children:"Date"})]})}),e.jsx(Pn,{children:w.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):w.map(R=>{var $,q;return e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium max-w-[200px] truncate",children:R.resource_title}),e.jsx(lt,{children:e.jsx(at,{variant:"secondary",className:eEe[R.resource_type],children:JAe[R.resource_type]})}),e.jsx(lt,{children:(($=R.sender)==null?void 0:$.name)||"Unknown"}),e.jsx(lt,{children:((q=R.recipient)==null?void 0:q.name)||"Unknown"}),e.jsx(lt,{children:e.jsx(at,{variant:R.is_read?"default":"outline",children:R.is_read?"Read":"Unread"})}),e.jsx(lt,{className:"text-muted-foreground",children:ws(new Date(R.created_at),"MMM d, yyyy")})]},R.id)})})]})})]})]})]})}const Gme={academy_video:{label:"Academy Videos",icon:kn,color:"bg-purple-100 text-purple-800",actionLabel:"Watched",actionIcon:ya},template:{label:"Templates",icon:l0,color:"bg-blue-100 text-blue-800",actionLabel:"Accessed",actionIcon:jm},toolbox:{label:"Toolkit",icon:$g,color:"bg-amber-100 text-amber-800",actionLabel:"Downloaded",actionIcon:xi},newsletter:{label:"Newsletters",icon:_r,color:"bg-emerald-100 text-emerald-800",actionLabel:"Clicked",actionIcon:jm},social_swag:{label:"Social Swag",icon:Bl,color:"bg-pink-100 text-pink-800",actionLabel:"Accessed",actionIcon:jm},event:{label:"Events",icon:on,color:"bg-cyan-100 text-cyan-800",actionLabel:"Registered",actionIcon:jm}};function tEe(t){return t.resource_type==="toolbox"?t.total_downloads:t.total_clicks}function GFt(t,s){return t==="toolbox"?s.downloads:s.clicks}function KFt(){var R;const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(null),l=S.useRef(null),{sortKey:i,sortDirection:d,handleSort:u,sortData:p}=UL("total_views","desc");S.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:$,error:q}=await G.rpc("get_admin_content_engagement");if(q)throw q;s($||[])}catch($){console.error("Error loading content engagement:",$)}finally{n(!1)}},v=$=>{o(q=>{const U=q===$?null:$;return requestAnimationFrame(()=>{var V;(V=l.current)==null||V.scrollIntoView({behavior:"smooth",block:"start"})}),U})};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(Ee,{children:[e.jsx(Lt,{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(Ee,{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),j=t.reduce(($,q)=>$+q.total_downloads,0),w=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,$),{}),C=a?t.filter($=>$.resource_type===a):t,A=p(C,{asset:$=>{var q;return((q=$.resource_title)==null?void 0:q.toLowerCase())||""},type:$=>$.resource_type,views:$=>$.total_views,actions:$=>tEe($),unique_users:$=>$.unique_users,last_activity:$=>$.last_engaged_at?new Date($.last_engaged_at).getTime():0}),I=a?Gme[a]||{label:a,icon:ya,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(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Views"}),e.jsx(ya,{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(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(jm,{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(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Downloads"}),e.jsx(xi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PDF downloads"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Assets Tracked"}),e.jsx(Cc,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:w}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique content items"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(jm,{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+j)/_*100):0,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Of views → actions"})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{className:"text-sm font-medium",children:"Engagement by Content Type"}),e.jsx(yr,{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 U=Gme[$]||{label:$,icon:ya,color:"bg-muted text-muted-foreground",actionIcon:jm},V=U.icon,X=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 ${X?"ring-2 ring-primary border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsx("div",{className:`p-2 rounded-md ${U.color}`,children:e.jsx(V,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:U.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(ya,{className:"h-3 w-3"})," ",q.views]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(U.actionIcon,{className:"h-3 w-3"})," ",GFt($,q)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"})," ",q.uniqueUsers]})]})]}),e.jsxs(at,{variant:"secondary",className:"text-[10px]",children:[q.assets," items"]})]},$)})})})]}),e.jsx("div",{ref:l,children:e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{className:"text-sm font-medium flex items-center gap-2",children:I&&L?e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"h-4 w-4"}),I.label," — Top Performers"]}):"Top Content by Engagement"}),e.jsx(yr,{children:a?`${C.length} ${((R=I==null?void 0:I.label)==null?void 0:R.toLowerCase())||"items"} ranked by total interactions`:"All tracked assets ranked by total interactions"})]}),a&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>o(null),className:"gap-1",children:[e.jsx(Ua,{className:"h-3.5 w-3.5"}),"Show All"]})]})}),e.jsx(Oe,{children:C.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No engagement data yet. As users view and click content, stats will appear here."}):e.jsx(Bi,{className:"h-[400px]",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-[40px]",children:"#"}),e.jsx(el,{sortKey:"asset",currentSortKey:i,currentDirection:d,onSort:u,children:"Asset"}),!a&&e.jsx(el,{sortKey:"type",currentSortKey:i,currentDirection:d,onSort:u,children:"Type"}),e.jsx(el,{sortKey:"views",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:"Views"}),e.jsx(el,{sortKey:"actions",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:I?I.actionLabel:"Actions"}),e.jsx(el,{sortKey:"unique_users",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:"Unique Users"}),e.jsx(el,{sortKey:"last_activity",currentSortKey:i,currentDirection:d,onSort:u,children:"Last Activity"})]})}),e.jsx(Pn,{children:A.map(($,q)=>{const U=Gme[$.resource_type]||{label:$.resource_type,color:"bg-muted text-muted-foreground"};return e.jsxs(js,{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(at,{className:`text-[10px] ${U.color}`,children:U.label})}),e.jsx(lt,{className:"text-right font-medium",children:$.total_views}),e.jsx(lt,{className:"text-right font-medium",children:tEe($)}),e.jsx(lt,{className:"text-right",children:$.unique_users}),e.jsx(lt,{className:"text-xs text-muted-foreground",children:$.last_engaged_at?Cd(new Date($.last_engaged_at),{addSuffix:!0}):"—"})]},`${$.resource_type}-${$.resource_id}`)})})]})})})]})})]})}const ZFt=()=>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(Na,{defaultValue:"analytics",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsx(ks,{value:"analytics",children:"Analytics"}),e.jsx(ks,{value:"content",children:"Content"}),e.jsx(ks,{value:"activity",children:"Activity"}),e.jsx(ks,{value:"shares",children:"Shares"})]}),e.jsx(zs,{value:"analytics",className:"space-y-4",children:e.jsx(WFt,{})}),e.jsx(zs,{value:"content",className:"space-y-4",children:e.jsx(KFt,{})}),e.jsx(zs,{value:"activity",className:"space-y-4",children:e.jsx(HFt,{})}),e.jsx(zs,{value:"shares",className:"space-y-4",children:e.jsx(ZKe,{})})]})]})});function YFt(){const t=ns(),[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),[i,d]=S.useState(null),[u,p]=S.useState(""),[f,v]=S.useState([]),[_,b]=S.useState([]),[j,w]=S.useState([]),[N,C]=S.useState(!1),[A,I]=S.useState(null),[L,R]=S.useState(""),{data:$,isLoading:q}=Ct({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:De,error:Dt}=await G.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(Dt)throw Dt;return De}}),{data:U}=Ct({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:De,error:Dt}=await G.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(Dt)throw Dt;return De}}),{data:V}=Ct({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:De,error:Dt}=await G.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(Dt)throw Dt;return De}}),{data:X}=Ct({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:De,error:Dt}=await G.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(Dt)throw Dt;return De}}),{data:se,isLoading:te}=Ct({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:De,error:Dt}=await G.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(Dt)throw Dt;return De}}),Y=()=>{l({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),d(null),p(""),v([]),b([]),w([]),a(null),R("")},de=De=>{a(De),l({title:De.title,description:De.description||"",publish_date:De.publish_date.split("T")[0],is_published:De.is_published,category_id:De.category_id||""}),p(De.preview_image_url||""),R("");const Dt=(U==null?void 0:U.filter(ot=>ot.resource_id===De.id))||[];v(Dt.map(ot=>({id:ot.id,name:ot.name,file_url:ot.file_url,file_size:ot.file_size,sort_order:ot.sort_order})));const he=(V==null?void 0:V.filter(ot=>ot.resource_id===De.id))||[];b(he.map(ot=>({id:ot.id,title:ot.title,video_url:ot.video_url,sort_order:ot.sort_order})));const Qe=(X==null?void 0:X.filter(ot=>ot.resource_id===De.id))||[];w(Qe.map(ot=>({id:ot.id,title:ot.title,canva_share_link:ot.canva_share_link,sort_order:ot.sort_order}))),r(!0)},ie=De=>{var he;const Dt=(he=De.target.files)==null?void 0:he[0];Dt&&(d(Dt),p(URL.createObjectURL(Dt)))},ae=()=>{v([...f,{name:"",file_url:"",sort_order:f.length}])},le=De=>{v(f.filter((Dt,he)=>he!==De))},pe=(De,Dt,he)=>{const Qe=[...f];if(Dt==="file"&&he instanceof File){const ot=he.name.replace(/\.[^/.]+$/,"");Qe[De]={...Qe[De],file:he,file_size:he.size,name:Qe[De].name||ot}}else Qe[De]={...Qe[De],[Dt]:he};v(Qe)},be=()=>{b([..._,{title:"",video_url:"",sort_order:_.length}])},ye=De=>{b(_.filter((Dt,he)=>he!==De))},we=(De,Dt,he)=>{const Qe=[..._];Dt==="file"&&he instanceof File?Qe[De]={...Qe[De],file:he}:Qe[De]={...Qe[De],[Dt]:he},b(Qe)},ke=()=>{w([...j,{title:"",canva_share_link:"",sort_order:j.length}])},Ze=De=>{w(j.filter((Dt,he)=>he!==De))},_e=(De,Dt,he)=>{const Qe=[...j];Qe[De]={...Qe[De],[Dt]:he},w(Qe)},Ce=async(De,Dt)=>{try{const he=await G.functions.invoke("bunny-upload",{body:{action:"create",title:De.name}});if(he.error)throw he.error;const{videoId:Qe,uploadUrl:ot,libraryId:rt}=he.data,Ne=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Qe,libraryId:rt}});if(Ne.error)throw Ne.error;const{uploadUrl:it,apiKey:qe}=Ne.data,Xe=new XMLHttpRequest;return Xe.open("PUT",it,!0),Xe.setRequestHeader("AccessKey",qe),Xe.upload.onprogress=$e=>{if($e.lengthComputable){const Ke=Math.round($e.loaded/$e.total*100),ct=[..._];ct[Dt]={...ct[Dt],uploadProgress:Ke},b(ct)}},await new Promise(($e,Ke)=>{Xe.onload=()=>Xe.status>=200&&Xe.status<300?$e():Ke(new Error("Upload failed")),Xe.onerror=()=>Ke(new Error("Upload failed")),Xe.send(De)}),`https://iframe.mediadelivery.net/embed/${rt}/${Qe}`}catch(he){throw console.error("Bunny upload error:",he),he}},Te=Ot({mutationFn:async De=>{const{data:Dt,error:he}=await G.from("brokerage_resource_categories").insert({name:De,sort_order:(se==null?void 0:se.length)||0}).select().single();if(he)throw he;return Dt},onSuccess:De=>{t.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:De.id}),R(""),fe.success("Category created")},onError:De=>{fe.error("Failed to create category: "+De.message)}}),Fe=Ot({mutationFn:async()=>{C(!0);let De=(n==null?void 0:n.preview_image_url)||null;if(i){const Qe=i.name.split(".").pop(),ot=`${Date.now()}.${Qe}`,{error:rt}=await G.storage.from("brokerage-resources").upload(`previews/${ot}`,i);if(rt)throw rt;const{data:Ne}=G.storage.from("brokerage-resources").getPublicUrl(`previews/${ot}`);De=Ne.publicUrl}const Dt={title:o.title,description:o.description||null,preview_image_url:De,publish_date:o.publish_date,is_published:o.is_published,category_id:o.category_id||null};let he;if(n){const{error:Qe}=await G.from("brokerage_resources").update(Dt).eq("id",n.id);if(Qe)throw Qe;he=n.id;const ot=(U==null?void 0:U.filter(Ue=>Ue.resource_id===n.id).map(Ue=>Ue.id))||[],rt=f.filter(Ue=>Ue.id).map(Ue=>Ue.id),Ne=ot.filter(Ue=>!rt.includes(Ue));Ne.length>0&&await G.from("brokerage_resource_pdfs").delete().in("id",Ne);const it=(V==null?void 0:V.filter(Ue=>Ue.resource_id===n.id).map(Ue=>Ue.id))||[],qe=_.filter(Ue=>Ue.id).map(Ue=>Ue.id),Xe=it.filter(Ue=>!qe.includes(Ue));Xe.length>0&&await G.from("brokerage_resource_videos").delete().in("id",Xe);const $e=(X==null?void 0:X.filter(Ue=>Ue.resource_id===n.id).map(Ue=>Ue.id))||[],Ke=j.filter(Ue=>Ue.id).map(Ue=>Ue.id),ct=$e.filter(Ue=>!Ke.includes(Ue));ct.length>0&&await G.from("brokerage_resource_links").delete().in("id",ct)}else{const{data:Qe,error:ot}=await G.from("brokerage_resources").insert(Dt).select().single();if(ot)throw ot;he=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"]}),fe.success(n?"Resource updated":"Resource created"),r(!1),Y(),C(!1)},onError:De=>{fe.error("Failed to save resource: "+De.message),C(!1)}}),Ae=Ot({mutationFn:async De=>{const{error:Dt}=await G.from("brokerage_resources").delete().eq("id",De);if(Dt)throw Dt},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),fe.success("Resource deleted")},onError:De=>{fe.error("Failed to delete: "+De.message)}}),We=De=>{if(De.preventDefault(),!o.title){fe.error("Please enter a title");return}Fe.mutate()},ht=De=>{const Dt=(U==null?void 0:U.filter(ot=>ot.resource_id===De).length)||0,he=(V==null?void 0:V.filter(ot=>ot.resource_id===De).length)||0,Qe=(X==null?void 0:X.filter(ot=>ot.resource_id===De).length)||0;return{pdfCount:Dt,videoCount:he,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(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:($==null?void 0:$.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{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(De=>De.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{Y(),r(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{children:"Content"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:q?e.jsx(js,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):($==null?void 0:$.length)===0?e.jsx(js,{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(De=>{const{pdfCount:Dt,videoCount:he,linkCount:Qe}=ht(De.id),ot=se==null?void 0:se.find(rt=>rt.id===De.category_id);return e.jsxs(js,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[De.preview_image_url?e.jsx("img",{src:De.preview_image_url,alt:De.title,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(th,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:De.title}),De.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:De.description})]})]})}),e.jsx(lt,{children:ot?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:ot.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(In,{className:"h-3.5 w-3.5"}),Dt]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(kn,{className:"h-3.5 w-3.5"}),he]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Lo,{className:"h-3.5 w-3.5"}),Qe]})]})}),e.jsx(lt,{children:ws(new Date(De.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 ${De.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:De.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const rt=(U==null?void 0:U.filter(qe=>qe.resource_id===De.id))||[],Ne=(V==null?void 0:V.filter(qe=>qe.resource_id===De.id))||[],it=(X==null?void 0:X.filter(qe=>qe.resource_id===De.id))||[];I({...De,pdfs:rt,videos:Ne,links:it})},children:e.jsx(ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>de(De),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&Ae.mutate(De.id)},children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]})})]},De.id)})})]})})}),e.jsx(vs,{open:s,onOpenChange:r,children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:n?"Edit Brokerage Resource":"Add Brokerage Resource"})}),e.jsxs("form",{onSubmit:We,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[u?e.jsx("img",{src:u,alt:"Preview",className:"w-24 h-24 rounded object-cover"}):e.jsx("div",{className:"w-24 h-24 rounded bg-muted flex items-center justify-center",children:e.jsx(th,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Re,{type:"file",accept:"image/*",onChange:ie})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:o.title,onChange:De=>l({...o,title:De.target.value}),placeholder:"Resource Title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(Vh,{className:"h-4 w-4"}),"Category"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:o.category_id,onValueChange:De=>l({...o,category_id:De}),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(sr,{placeholder:"Select a category"})}),e.jsx(er,{children:se==null?void 0:se.map(De=>e.jsx(At,{value:De.id,children:De.name},De.id))})]}),o.category_id&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>l({...o,category_id:""}),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Or create new category...",value:L,onChange:De=>R(De.target.value),className:"flex-1"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",disabled:!L.trim()||Te.isPending,onClick:()=>Te.mutate(L.trim()),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Qg,{content:o.description,onChange:De=>l({...o,description:De}),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(ve,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:o.publish_date,onChange:De=>l({...o,publish_date:De.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(Br,{checked:o.is_published,onCheckedChange:De=>l({...o,is_published:De})}),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(ve,{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-4 w-4"}),"PDF Documents (",f.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ae,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add PDF"]})]}),f.map((De,Dt)=>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:De.name,onChange:he=>pe(Dt,"name",he.target.value),className:"flex-1"}),e.jsx(Re,{type:"file",accept:".pdf",onChange:he=>{var ot;const Qe=(ot=he.target.files)==null?void 0:ot[0];Qe&&pe(Dt,"file",Qe)},className:"flex-1"}),De.file_url&&!De.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>le(Dt),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Dt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(kn,{className:"h-4 w-4"}),"Videos (",_.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:be,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),_.map((De,Dt)=>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:De.title,onChange:he=>we(Dt,"title",he.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>ye(Dt),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsx(Re,{type:"file",accept:"video/*",onChange:he=>{var ot;const Qe=(ot=he.target.files)==null?void 0:ot[0];Qe&&we(Dt,"file",Qe)}}),De.uploadProgress!==void 0&&De.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:`${De.uploadProgress}%`}})}),De.video_url&&!De.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Video uploaded"})]},Dt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(Lo,{className:"h-4 w-4"}),"Canva Links (",j.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ke,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),j.map((De,Dt)=>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:De.title,onChange:he=>_e(Dt,"title",he.target.value),className:"flex-1"}),e.jsx(Re,{placeholder:"Canva Share Link",value:De.canva_share_link,onChange:he=>_e(Dt,"canva_share_link",he.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>Ze(Dt),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Dt))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:Fe.isPending||N,children:Fe.isPending||N?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(vs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{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(In,{className:"h-4 w-4"}),"PDF Documents (",A.pdfs.length,")"]}),e.jsx("div",{className:"space-y-1",children:A.pdfs.map(De=>e.jsx("a",{href:De.file_url,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:De.name},De.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(kn,{className:"h-4 w-4"}),"Videos (",A.videos.length,")"]}),e.jsx("div",{className:"space-y-2",children:A.videos.map(De=>e.jsx("div",{className:"p-2 border rounded",children:e.jsx("p",{className:"font-medium text-sm",children:De.title})},De.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(Lo,{className:"h-4 w-4"}),"Canva Links (",A.links.length,")"]}),e.jsx("div",{className:"space-y-1",children:A.links.map(De=>e.jsx("a",{href:De.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:De.title},De.id))})]})]})]})})]})})}const YKe=[{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 XFt(){const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(!1),[l,i]=S.useState(!1),[d,u]=S.useState(null),[p,f]=S.useState(!1),[v,_]=S.useState(!1),[b,j]=S.useState(""),[w,N]=S.useState(""),[C,A]=S.useState(""),[I,L]=S.useState(""),[R,$]=S.useState("Learn More"),[q,U]=S.useState("top"),[V,X]=S.useState(""),[se,te]=S.useState(!0),[Y,de]=S.useState(""),[ie,ae]=S.useState("");S.useEffect(()=>{le()},[]);const le=async()=>{try{const{data:Te,error:Fe}=await G.from("dashboard_banners").select("*").order("placement").order("sort_order");if(Fe)throw Fe;s(Te||[])}catch(Te){fe.error("Failed to load banners: "+Te.message)}finally{n(!1)}},pe=()=>{j(""),N(""),A(""),L(""),$("Learn More"),U("top"),X(""),te(!0),de(""),ae(""),u(null)},be=Te=>{u(Te),j(Te.title),N(Te.description||""),A(Te.image_url),L(Te.link_url||""),$(Te.link_text||"Learn More"),U(Te.placement),X(Te.section_after||""),te(Te.is_active),de(Te.start_date?ws(new Date(Te.start_date),"yyyy-MM-dd'T'HH:mm"):""),ae(Te.end_date?ws(new Date(Te.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},ye=async Te=>{var Ae;const Fe=(Ae=Te.target.files)==null?void 0:Ae[0];if(Fe){f(!0);try{const We=Fe.name.split(".").pop(),ht=`${Date.now()}.${We}`,{error:De}=await G.storage.from("banner-images").upload(ht,Fe);if(De)throw De;const{data:{publicUrl:Dt}}=G.storage.from("banner-images").getPublicUrl(ht);A(Dt),fe.success("Image uploaded successfully")}catch(We){fe.error("Failed to upload image: "+We.message)}finally{f(!1)}}},we=async()=>{if(!b.trim()||!C){fe.error("Please fill in required fields (title and image)");return}_(!0);try{const Te={title:b.trim(),description:w.trim()||null,image_url:C,link_url:I.trim()||null,link_text:R.trim()||"Learn More",placement:q,section_after:q==="between"?V:null,is_active:se,start_date:Y?new Date(Y).toISOString():null,end_date:ie?new Date(ie).toISOString():null};if(d){const{error:Fe}=await G.from("dashboard_banners").update(Te).eq("id",d.id);if(Fe)throw Fe;fe.success("Banner updated successfully")}else{const Fe=t.filter(We=>We.placement===q).length,{error:Ae}=await G.from("dashboard_banners").insert({...Te,sort_order:Fe});if(Ae)throw Ae;fe.success("Banner created successfully")}o(!1),pe(),le()}catch(Te){fe.error("Failed to save banner: "+Te.message)}finally{_(!1)}},ke=async()=>{if(d)try{const{error:Te}=await G.from("dashboard_banners").delete().eq("id",d.id);if(Te)throw Te;fe.success("Banner deleted successfully"),i(!1),u(null),le()}catch(Te){fe.error("Failed to delete banner: "+Te.message)}},Ze=async Te=>{try{const{error:Fe}=await G.from("dashboard_banners").update({is_active:!Te.is_active}).eq("id",Te.id);if(Fe)throw Fe;fe.success(Te.is_active?"Banner deactivated":"Banner activated"),le()}catch(Fe){fe.error("Failed to update banner: "+Fe.message)}},_e=t.filter(Te=>Te.placement==="top"),Ce=t.filter(Te=>Te.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(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Jo,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(yr,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(vs,{open:a&&q==="top",onOpenChange:Te=>{Te||pe(),o(Te),Te&&U("top")},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{onClick:()=>{pe(),U("top")},children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Add Hero Banner"]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{children:[d?"Edit":"Create"," Banner"]}),e.jsx(Kr,{children:"Configure the banner's content and display settings"})]}),e.jsx(sEe,{title:b,setTitle:j,description:w,setDescription:N,imageUrl:C,linkUrl:I,setLinkUrl:L,linkText:R,setLinkText:$,placement:q,setPlacement:U,sectionAfter:V,setSectionAfter:X,isActive:se,setIsActive:te,startDate:Y,setStartDate:de,endDate:ie,setEndDate:ae,handleImageUpload:ye,uploading:p,showPlacementOptions:!1}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),pe()},children:"Cancel"}),e.jsx(K,{onClick:we,disabled:v,children:v?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{children:_e.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:_e.map(Te=>e.jsx(rEe,{banner:Te,onEdit:()=>be(Te),onDelete:()=>{u(Te),i(!0)},onToggleActive:()=>Ze(Te)},Te.id))})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Jo,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(yr,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(vs,{open:a&&q==="between",onOpenChange:Te=>{Te||pe(),o(Te),Te&&U("between")},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{onClick:()=>{pe(),U("between")},children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Add Section Banner"]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{children:[d?"Edit":"Create"," Section Banner"]}),e.jsx(Kr,{children:"Configure where this banner appears between sections"})]}),e.jsx(sEe,{title:b,setTitle:j,description:w,setDescription:N,imageUrl:C,linkUrl:I,setLinkUrl:L,linkText:R,setLinkText:$,placement:q,setPlacement:U,sectionAfter:V,setSectionAfter:X,isActive:se,setIsActive:te,startDate:Y,setStartDate:de,endDate:ie,setEndDate:ae,handleImageUpload:ye,uploading:p,showPlacementOptions:!0}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),pe()},children:"Cancel"}),e.jsx(K,{onClick:we,disabled:v,children:v?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{children:Ce.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:Ce.map(Te=>e.jsx(rEe,{banner:Te,onEdit:()=>be(Te),onDelete:()=>{u(Te),i(!0)},onToggleActive:()=>Ze(Te),showSection:!0},Te.id))})})]})]}),e.jsx(vs,{open:l,onOpenChange:i,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:ke,children:"Delete"})]})]})})]})}function sEe({title:t,setTitle:s,description:r,setDescription:n,imageUrl:a,linkUrl:o,setLinkUrl:l,linkText:i,setLinkText:d,placement:u,setPlacement:p,sectionAfter:f,setSectionAfter:v,isActive:_,setIsActive:b,startDate:j,setStartDate:w,endDate:N,setEndDate:C,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(ve,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",placeholder:"Banner headline...",value:t,onChange:R=>s(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Mr,{id:"description",placeholder:"Optional banner description...",value:r,onChange:R=>n(R.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(ve,{htmlFor:"linkUrl",children:"Link URL (optional)"}),e.jsx(Re,{id:"linkUrl",placeholder:"https://...",value:o,onChange:R=>l(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"linkText",children:"Button Text"}),e.jsx(Re,{id:"linkText",placeholder:"Learn More",value:i,onChange:R=>d(R.target.value)})]})]}),L&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Placement"}),e.jsxs(tr,{value:f,onValueChange:v,children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select section placement..."})}),e.jsx(er,{children:YKe.map(R=>e.jsx(At,{value:R.value,children:R.label},R.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"startDate",className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Start Date (optional)"]}),e.jsx(Re,{id:"startDate",type:"datetime-local",value:j,onChange:R=>w(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"endDate",className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"End Date (optional)"]}),e.jsx(Re,{id:"endDate",type:"datetime-local",value:N,onChange:R=>C(R.target.value)})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"isActive",checked:_,onCheckedChange:b}),e.jsx(ve,{htmlFor:"isActive",children:"Active"})]})})]})}function rEe({banner:t,onEdit:s,onDelete:r,onToggleActive:n,showSection:a=!1}){var l;const o=(l=YKe.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(Fu,{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(at,{variant:"secondary",children:"Inactive"}),t.start_date&&new Date(t.start_date)>new Date&&e.jsx(at,{variant:"outline",children:"Scheduled"})]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:t.description}),a&&o&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t.link_url&&e.jsx("a",{href:t.link_url,target:"_blank",rel:"noopener noreferrer",children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(sn,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:n,children:t.is_active?e.jsx(ya,{className:"h-4 w-4"}):e.jsx(Em,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:s,children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]})]})}const lR={open:{label:"Open",icon:Tn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:gc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:gi,color:"bg-green-500"},closed:{label:"Closed",icon:kc,color:"bg-muted-foreground"}},nEe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function QFt(){var R,$;const{user:t}=Gs(),s=ns(),[r,n]=S.useState(null),[a,o]=S.useState(""),[l,i]=S.useState("all"),[d,u]=S.useState("all"),[p,f]=S.useState(!1),{data:v=[],isLoading:_}=Ct({queryKey:["admin-support-tickets",l,d],queryFn:async()=>{let q=G.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:U,error:V}=await q;if(V)throw V;return U}}),{data:b=[]}=Ct({queryKey:["admin-users-notifications"],queryFn:async()=>{const{data:q,error:U}=await G.from("user_roles").select("user_id").eq("role","admin");if(U)throw U;const V=q.map(ie=>ie.user_id),{data:X,error:se}=await G.from("profiles").select("id, name, email").in("id",V);if(se)throw se;const{data:te,error:Y}=await G.from("support_notification_settings").select("user_id, receive_notifications");if(Y)throw Y;const de=new Map((te==null?void 0:te.map(ie=>[ie.user_id,ie.receive_notifications]))||[]);return X.map(ie=>({...ie,receives_notifications:de.get(ie.id)||!1}))}}),{data:j=[]}=Ct({queryKey:["admin-ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:q,error:U}=await G.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(U)throw U;return q},enabled:!!r}),w=Ot({mutationFn:async({userId:q,enabled:U})=>{const{data:V}=await G.from("support_notification_settings").select("id").eq("user_id",q).maybeSingle();if(V){const{error:X}=await G.from("support_notification_settings").update({receive_notifications:U}).eq("user_id",q);if(X)throw X}else{const{error:X}=await G.from("support_notification_settings").insert({user_id:q,receive_notifications:U});if(X)throw X}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users-notifications"]}),fe.success("Notification settings updated")},onError:()=>{fe.error("Failed to update settings")}}),N=Ot({mutationFn:async({ticketId:q,status:U})=>{const{error:V}=await G.from("support_tickets").update({status:U}).eq("id",q);if(V)throw V},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),r&&n({...r,status:r.status}),fe.success("Status updated")},onError:()=>{fe.error("Failed to update status")}}),C=Ot({mutationFn:async({ticketId:q,assignedTo:U})=>{const{error:V}=await G.from("support_tickets").update({assigned_to:U}).eq("id",q);if(V)throw V},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),fe.success("Ticket assigned")},onError:()=>{fe.error("Failed to assign ticket")}}),A=Ot({mutationFn:async q=>{var V,X;if(!r||!t)throw new Error("Missing data");const{error:U}=await G.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:q,is_admin_reply:!0});if(U)throw U;try{await G.functions.invoke("support-reply-notify",{body:{ticketId:r.id,ticketSubject:r.subject,replyContent:q,userEmail:(V=r.profiles)==null?void 0:V.email,userName:(X=r.profiles)==null?void 0:X.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(""),fe.success("Reply sent!")},onError:()=>{fe.error("Failed to send reply")}}),I=()=>{a.trim()&&A.mutate(a)};S.useEffect(()=>{const q=G.channel("admin-tickets").on("postgres_changes",{event:"*",schema:"public",table:"support_tickets"},()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]})}).subscribe();return()=>{G.removeChannel(q)}},[s]);const L=v.filter(q=>q.status==="open").length;return r?(lR[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(K,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(Ua,{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(at,{variant:"secondary",children:nEe[r.category]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["from ",((R=r.profiles)==null?void 0:R.name)||"Unknown"," (",($=r.profiles)==null?void 0:$.email,")"]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{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(sr,{})}),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(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm",children:"Assigned To"})}),e.jsx(Oe,{children:e.jsxs(tr,{value:r.assigned_to||"unassigned",onValueChange:q=>{const U=q==="unassigned"?null:q;C.mutate({ticketId:r.id,assignedTo:U}),n({...r,assigned_to:U})},children:[e.jsx(Js,{children:e.jsx(sr,{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(Ee,{children:[e.jsx(Lt,{children:e.jsxs(yr,{children:["Created on ",ws(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Bi,{className:"h-[300px] pr-4",children:j.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:j.map(q=>{var U,V;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?`${((U=q.profiles)==null?void 0:U.name)||"Admin"} (Support)`:((V=q.profiles)==null?void 0:V.name)||"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ws(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(Rl,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Mr,{placeholder:"Type your reply...",value:a,onChange:q=>o(q.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:I,disabled:!a.trim()||A.isPending,className:"self-end",children:e.jsx(ka,{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(at,{variant:"destructive",className:"ml-2",children:[L," open"]})]})]}),e.jsxs(vs,{open:p,onOpenChange:f,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx($l,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(Xi,{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(cf,{className:"h-4 w-4 text-primary"}):e.jsx(X1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Br,{checked:q.receives_notifications,onCheckedChange:U=>w.mutate({userId:q.id,enabled:U})})]})]},q.id))})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[e.jsx(Na,{value:l,onValueChange:i,className:"w-auto",children:e.jsxs(va,{children:[e.jsx(ks,{value:"all",children:"All"}),e.jsx(ks,{value:"open",children:"Open"}),e.jsx(ks,{value:"in_progress",children:"In Progress"}),e.jsx(ks,{value:"resolved",children:"Resolved"}),e.jsx(ks,{value:"closed",children:"Closed"})]})}),e.jsxs(tr,{value:d,onValueChange:u,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{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(Ee,{children:e.jsxs(Oe,{className:"text-center py-12",children:[e.jsx(gc,{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 V,X;const U=lR[q.status].icon;return e.jsx(Ee,{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(at,{variant:"outline",className:"text-xs",children:nEe[q.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(V=q.profiles)==null?void 0:V.name," • ",ws(new Date(q.created_at),"MMM d, yyyy")]}),q.assigned_to&&e.jsxs(at,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Xi,{className:"h-3 w-3"}),((X=b.find(se=>se.id===q.assigned_to))==null?void 0:X.name)||"Assigned"]})]})]}),e.jsxs(at,{className:lR[q.status].color,children:[e.jsx(U,{className:"h-3 w-3 mr-1"}),lR[q.status].label]})]})})},q.id)})})})]})]})})}const JFt=qu.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 ezt({content:t,onChange:s,variables:r}){const n=AWe({extensions:[OWe,WWe.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),GWe.configure({types:["heading","paragraph"]}),KWe,JFt],content:t,onUpdate:({editor:l})=>{s(l.getHTML())}});S.useEffect(()=>{n&&t!==n.getHTML()&&n.commands.setContent(t)},[t,n]);const a=l=>{n&&n.chain().focus().insertContent(`{{${l.key}}}`).run()},o=()=>{if(!n)return;const l=n.getAttributes("link").href,i=window.prompt("URL",l);if(i!==null){if(i===""){n.chain().focus().extendMarkRange("link").unsetLink().run();return}n.chain().focus().extendMarkRange("link").setLink({href:i}).run()}};return n?e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBold().run(),className:n.isActive("bold")?"bg-muted":"",children:e.jsx(a5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleItalic().run(),className:n.isActive("italic")?"bg-muted":"",children:e.jsx(h5,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBulletList().run(),className:n.isActive("bulletList")?"bg-muted":"",children:e.jsx(Uh,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleOrderedList().run(),className:n.isActive("orderedList")?"bg-muted":"",children:e.jsx(A0,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("left").run(),className:n.isActive({textAlign:"left"})?"bg-muted":"",children:e.jsx(s5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("center").run(),className:n.isActive({textAlign:"center"})?"bg-muted":"",children:e.jsx(t5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("right").run(),className:n.isActive({textAlign:"right"})?"bg-muted":"",children:e.jsx(r5,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:o,className:n.isActive("link")?"bg-muted":"",children:e.jsx(Lo,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleCodeBlock().run(),className:n.isActive("codeBlock")?"bg-muted":"",children:e.jsx(Jk,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().undo().run(),disabled:!n.can().undo(),children:e.jsx(j5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().redo().run(),disabled:!n.can().redo(),children:e.jsx(b5,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),r.length>0&&e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(FP,{className:"h-4 w-4"}),"Insert Variable"]})}),e.jsx(Td,{align:"end",className:"w-64",children:r.map(l=>e.jsxs(Ta,{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(MWe,{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(at,{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 tzt(){const t=ns(),[s,r]=S.useState(null),[n,a]=S.useState(null),[o,l]=S.useState(""),[i,d]=S.useState(""),[u,p]=S.useState(""),[f,v]=S.useState(!0),[_,b]=S.useState("visual"),{data:j,isLoading:w}=Ct({queryKey:["email-templates"],queryFn:async()=>{const{data:L,error:R}=await G.from("email_templates").select("*").order("name");if(R)throw R;return L.map($=>({...$,available_variables:$.available_variables||[]}))}}),N=Ot({mutationFn:async L=>{const{error:R}=await G.from("email_templates").update({subject:L.subject,body_html:L.body_html,description:L.description,is_active:L.is_active}).eq("id",L.id);if(R)throw R},onSuccess:()=>{t.invalidateQueries({queryKey:["email-templates"]}),fe.success("Email template updated successfully"),r(null)},onError:L=>{fe.error("Failed to update template: "+L.message)}}),C=L=>{r(L),l(L.subject),d(L.body_html),p(L.description||""),v(L.is_active),b("visual")},A=()=>{s&&N.mutate({id:s.id,subject:o,body_html:i,description:u,is_active:f})},I=(L,R)=>{let $=L;return R.forEach(q=>{const U=`{{${q.key}}}`,V=`[${q.label}]`;$=$.replace(new RegExp(U.replace(/[{}]/g,"\\$&"),"g"),V)}),$};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(K,{variant:"ghost",onClick:()=>r(null),children:[e.jsx(Ua,{className:"h-4 w-4 mr-2"}),"Back to Templates"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(K,{variant:"outline",onClick:()=>a(s),children:[e.jsx(ya,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{onClick:A,disabled:N.isPending,children:[e.jsx(Bu,{className:"h-4 w-4 mr-2"}),N.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(_r,{className:"h-5 w-5"}),s.name]}),e.jsxs(yr,{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(ve,{htmlFor:"active-toggle",children:"Active"}),e.jsx(Br,{id:"active-toggle",checked:f,onCheckedChange:v})]})]})}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Mr,{id:"description",value:u,onChange:L=>p(L.target.value),placeholder:"Brief description of when this email is sent",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(ve,{children:"Email Body"}),e.jsx(Na,{value:_,onValueChange:L=>b(L),children:e.jsxs(va,{className:"h-8",children:[e.jsxs(ks,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(iN,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(ks,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(Jk,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),_==="visual"?e.jsx(ezt,{content:i,onChange:d,variables:s.available_variables}):e.jsx(Mr,{value:i,onChange:L=>d(L.target.value),className:"font-mono text-sm min-h-[400px]",placeholder:"HTML email body"})]})]})]})]}),e.jsx(vs,{open:!!n,onOpenChange:()=>a(null),children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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"})]}),w?e.jsx("div",{className:"grid gap-4",children:[...Array(4)].map((L,R)=>e.jsx(Ee,{children:e.jsxs(Lt,{children:[e.jsx(gs,{className:"h-5 w-48"}),e.jsx(gs,{className:"h-4 w-96"})]})},R))}):e.jsx("div",{className:"grid gap-4",children:j==null?void 0:j.map(L=>e.jsxs(Ee,{className:"hover:shadow-md transition-shadow",children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(zt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(_r,{className:"h-5 w-5 text-muted-foreground"}),L.name,!L.is_active&&e.jsx(at,{variant:"secondary",children:"Inactive"})]}),e.jsx(yr,{children:L.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>a(L),children:[e.jsx(ya,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{size:"sm",onClick:()=>C(L),children:[e.jsx(Oc,{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(R=>e.jsx(at,{variant:"outline",className:"font-mono text-xs",children:`{{${R.key}}}`},R.key))})]})]})})]},L.id))}),e.jsx(vs,{open:!!n&&!s,onOpenChange:()=>a(null),children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{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 szt(){const t=ns(),[s,r]=S.useState("templates"),[n,a]=S.useState(null),[o,l]=S.useState(null),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[f,v]=S.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[_,b]=S.useState({name:"",description:"",icon:"📧"}),{data:j=[]}=Ct({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:V,error:X}=await G.from("email_template_categories").select("*").order("sort_order");if(X)throw X;return V}}),{data:w=[],isLoading:N}=Ct({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:V,error:X}=await G.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(X)throw X;return V}}),C=Ot({mutationFn:async V=>{const X={title:V.title,subject:V.subject,body:V.body,description:V.description||null,tone:V.tone||null,category_id:V.category_id||null,is_active:V.is_active};if(V.id){const{error:se}=await G.from("agent_email_templates").update(X).eq("id",V.id);if(se)throw se}else{const{error:se}=await G.from("agent_email_templates").insert(X);if(se)throw se}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),d(!1),fe.success(n?"Template updated":"Template created")},onError:()=>fe.error("Failed to save template")}),A=Ot({mutationFn:async V=>{const{error:X}=await G.from("agent_email_templates").delete().eq("id",V);if(X)throw X},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),fe.success("Template deleted")}}),I=Ot({mutationFn:async V=>{const X={name:V.name,description:V.description||null,icon:V.icon};if(V.id){const{error:se}=await G.from("email_template_categories").update(X).eq("id",V.id);if(se)throw se}else{const se=j.length>0?Math.max(...j.map(Y=>Y.sort_order))+1:0,{error:te}=await G.from("email_template_categories").insert({...X,sort_order:se});if(te)throw te}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),p(!1),fe.success(o?"Category updated":"Category created")},onError:()=>fe.error("Failed to save category")}),L=Ot({mutationFn:async V=>{const{error:X}=await G.from("email_template_categories").delete().eq("id",V);if(X)throw X},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),fe.success("Category deleted")}}),R=()=>{a(null),v({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),d(!0)},$=V=>{a(V),v({title:V.title,subject:V.subject,body:V.body,description:V.description||"",tone:V.tone||"",category_id:V.category_id||"",is_active:V.is_active}),d(!0)},q=()=>{l(null),b({name:"",description:"",icon:"📧"}),p(!0)},U=V=>{l(V),b({name:V.name,description:V.description||"",icon:V.icon}),p(!0)};return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(_u,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),e.jsxs(Na,{value:s,onValueChange:r,children:[e.jsxs(va,{children:[e.jsxs(ks,{value:"templates",className:"gap-2",children:[e.jsx(_r,{className:"h-4 w-4"})," Templates"]}),e.jsxs(ks,{value:"categories",className:"gap-2",children:[e.jsx(qh,{className:"h-4 w-4"})," Categories"]})]}),e.jsxs(zs,{value:"templates",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:R,className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"})," Add Template"]})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Template"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Category"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Tone"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:N?e.jsx(js,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:e.jsx(As,{className:"h-6 w-6 animate-spin mx-auto"})})}):w.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):w.map(V=>e.jsxs(js,{children:[e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:V.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:V.subject})]})}),e.jsx(lt,{className:"hidden md:table-cell",children:V.category?e.jsxs(at,{variant:"outline",className:"gap-1",children:[V.category.icon," ",V.category.name]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(lt,{className:"hidden md:table-cell",children:V.tone?e.jsx(at,{variant:"secondary",children:V.tone}):"—"}),e.jsx(lt,{children:e.jsx(at,{variant:V.is_active?"default":"secondary",children:V.is_active?"Active":"Inactive"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$(V),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&A.mutate(V.id)},children:e.jsx(br,{className:"h-4 w-4"})})]})})]},V.id))})]})})})]}),e.jsxs(zs,{value:"categories",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:q,className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"})," Add Category"]})}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:j.map(V=>e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:V.icon})," ",V.name]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>U(V),children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{confirm("Delete this category?")&&L.mutate(V.id)},children:e.jsx(br,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:V.description||"No description"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[w.filter(X=>X.category_id===V.id).length," templates"]})]})]},V.id))})]})]}),e.jsx(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{className:"sm:max-w-[700px] max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{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(ve,{children:"Title"}),e.jsx(Re,{value:f.title,onChange:V=>v(X=>({...X,title:V.target.value})),placeholder:"e.g. Quick Check-in"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Category"}),e.jsxs(tr,{value:f.category_id,onValueChange:V=>v(X=>({...X,category_id:V})),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select category"})}),e.jsx(er,{children:j.map(V=>e.jsxs(At,{value:V.id,children:[V.icon," ",V.name]},V.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Subject Line"}),e.jsx(Re,{value:f.subject,onChange:V=>v(X=>({...X,subject:V.target.value})),placeholder:"e.g. Hey {{first_name}}, just checking in!"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{first_name}}",", ","{{last_name}}",", ","{{full_name}}"," for merge variables"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Email Body"}),e.jsx(Mr,{value:f.body,onChange:V=>v(X=>({...X,body:V.target.value})),rows:12,placeholder:"Write your email template...",className:"resize-y"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Description (internal)"}),e.jsx(Re,{value:f.description,onChange:V=>v(X=>({...X,description:V.target.value})),placeholder:"Short description for admin reference"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Tone"}),e.jsx(Re,{value:f.tone,onChange:V=>v(X=>({...X,tone:V.target.value})),placeholder:"e.g. Warm & Casual"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:f.is_active,onCheckedChange:V=>v(X=>({...X,is_active:V}))}),e.jsx(ve,{children:"Active"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>C.mutate({...f,id:n==null?void 0:n.id}),disabled:C.isPending||!f.title||!f.subject||!f.body,children:[C.isPending&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),n?"Save Changes":"Create Template"]})]})]})}),e.jsx(vs,{open:u,onOpenChange:p,children:e.jsxs(ys,{className:"sm:max-w-[450px]",children:[e.jsx(Ss,{children:e.jsx(Ns,{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(ve,{children:"Icon"}),e.jsx(Re,{value:_.icon,onChange:V=>b(X=>({...X,icon:V.target.value})),className:"text-center text-lg"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Name"}),e.jsx(Re,{value:_.name,onChange:V=>b(X=>({...X,name:V.target.value})),placeholder:"e.g. Check-in & Stay in Touch"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Description"}),e.jsx(Re,{value:_.description,onChange:V=>b(X=>({...X,description:V.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>I.mutate({..._,id:o==null?void 0:o.id}),disabled:I.isPending||!_.name,children:[I.isPending&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const rzt=({brokerageId:t})=>{var mi,Vl;const{toast:s}=Ia(),[r,n]=S.useState([]),[a,o]=S.useState(!0),[l,i]=S.useState(""),[d,u]=S.useState("all"),[p,f]=S.useState(new Set),[v,_]=S.useState(!1),[b,j]=S.useState({}),[w,N]=S.useState(!1),[C,A]=S.useState(!1),[I,L]=S.useState({email:"",name:"",password:"",phone:""}),[R,$]=S.useState(!1),[q,U]=S.useState(null),[V,X]=S.useState(!1),[se,te]=S.useState(!1),[Y,de]=S.useState(!1),[ie,ae]=S.useState(""),[le,pe]=S.useState(!1),[be,ye]=S.useState([]),[we,ke]=S.useState(!1),[Ze,_e]=S.useState(!1),[Ce,Te]=S.useState(null),[Fe,Ae]=S.useState({name:"",phone:"",email:""}),[We,ht]=S.useState(!1),[De,Dt]=S.useState(!1),[he,Qe]=S.useState(null),[ot,rt]=S.useState("asc"),[Ne,it]=S.useState(!1),[qe,Xe]=S.useState(null),[$e,Ke]=S.useState(!1),[ct,Ue]=S.useState(null),[Ve,Je]=S.useState(""),[Rt,$t]=S.useState(!1),[ls,Qt]=S.useState(null);S.useEffect(()=>{as(),rs()},[t]);const rs=async()=>{try{const{data:dt,error:Se}=await G.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if(Se)throw Se;ye((dt==null?void 0:dt.map(ze=>ze.user_id))||[])}catch(dt){console.error("Error loading brokerage managers:",dt)}},as=async()=>{try{o(!0);const{data:dt,error:Se}=await G.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if(Se)throw Se;const ze=dt.agents||[];if(n(ze),ze.length>0){const st=ze.map(Nt=>Nt.id),{data:Tt}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",st);if(Tt&&Tt.length>0){const Nt=Tt.map(Ut=>Ut.assistant_id),{data:Bt}=await G.from("profiles").select("id, name, email").in("id",Nt),Zt={};for(const Ut of Tt){const Xt=Bt==null?void 0:Bt.find(Is=>Is.id===Ut.assistant_id);Xt&&(Zt[Ut.agent_id]={name:Xt.name||"",email:Xt.email||""})}j(Zt)}else j({})}}catch(dt){console.error("Error loading agents:",dt),s({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{o(!1)}},ir=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:dt}}=await G.auth.getSession(),Se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${dt==null?void 0:dt.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),as()}catch(dt){console.error("Error creating agent:",dt),s({title:"Error",description:dt.message||"Failed to create agent",variant:"destructive"})}finally{A(!1)}},vt=async dt=>{try{const{data:{session:Se}}=await G.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:dt})}),st=await ze.json();if(!ze.ok)throw new Error(st.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"})}},Cs=async(dt,Se)=>{try{const{error:ze}=await G.functions.invoke("send-password-reset",{body:{email:dt,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"})}},or=dt=>{U(dt),$(!0)},Ar=dt=>{Te(dt),Ae({name:dt.name,phone:dt.phone||"",email:dt.email}),_e(!0)},Wn=async()=>{if(!Ce)return;if(!Fe.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const dt=Fe.email.trim().toLowerCase()!==Ce.email.toLowerCase();ht(!0);try{if(dt){if(!Fe.email.trim())throw new Error("Email is required");Dt(!0);const{data:{session:ze}}=await G.auth.getSession(),st=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:Ce.id,newEmail:Fe.email.trim(),brokerageId:t})}),Tt=await st.json();if(Dt(!1),!st.ok)throw new Error(Tt.error||"Failed to update email")}const{error:Se}=await G.from("profiles").update({name:Fe.name.trim(),phone:Fe.phone.trim()||null}).eq("id",Ce.id);if(Se)throw Se;s({title:"Success",description:"Agent profile updated successfully"}),_e(!1),Te(null),as()}catch(Se){console.error("Error updating agent:",Se),s({title:"Error",description:Se.message||"Failed to update agent",variant:"destructive"})}finally{ht(!1),Dt(!1)}},ai=async()=>{if(!ie){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}pe(!0);try{const{data:{session:dt}}=await G.auth.getSession(),Se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${dt==null?void 0:dt.access_token}`},body:JSON.stringify({userId:ie,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"}),de(!1),ae(""),rs()}catch(dt){console.error("Error adding brokerage manager:",dt),s({title:"Error",description:dt.message||"Failed to add brokerage manager",variant:"destructive"})}finally{pe(!1)}},bo=async dt=>{try{const{data:{session:Se}}=await G.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:dt,role:"brokerage_manager",action:"remove",brokerageId:t})}),st=await ze.json();if(!ze.ok)throw new Error(st.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),rs()}catch(Se){console.error("Error removing brokerage manager:",Se),s({title:"Error",description:Se.message||"Failed to remove brokerage manager",variant:"destructive"})}},Fa=dt=>be.includes(dt),yn=dt=>{Ue(dt),Je(""),Ke(!0)},na=async()=>{if(!(!ct||!Ve)){if(Ve.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}$t(!0);try{const{data:{session:dt}}=await G.auth.getSession(),Se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${dt==null?void 0:dt.access_token}`},body:JSON.stringify({agentId:ct.id,brokerageId:t,action:"set_password",newPassword:Ve})}),ze=await Se.json();if(!Se.ok)throw new Error(ze.error||"Failed to set password");s({title:"Success",description:`Password set for ${ct.name}`}),Ke(!1),Ue(null),Je("")}catch(dt){console.error("Error setting password:",dt),s({title:"Error",description:dt.message||"Failed to set password",variant:"destructive"})}finally{$t(!1)}}},Nn=async dt=>{Qt(dt.id);try{const{data:{session:Se}}=await G.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:dt.id,brokerageId:t,action:"claim_account"})}),st=await ze.json();if(!ze.ok)throw new Error(st.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${dt.name}`}),as()}catch(Se){console.error("Error claiming account:",Se),s({title:"Error",description:Se.message||"Failed to claim account",variant:"destructive"})}finally{Qt(null)}},ta=async()=>{if(q){X(!0);try{const{data:{session:dt}}=await G.auth.getSession(),Se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/remove-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${dt==null?void 0:dt.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),U(null),as()}catch(dt){console.error("Error removing agent:",dt),s({title:"Error",description:dt.message||"Failed to remove agent",variant:"destructive"})}finally{X(!1)}}},Kt=dt=>{const Se=dt.trim().split(" ");return Se.length>1?Se[Se.length-1].toLowerCase():dt.toLowerCase()},$r=dt=>{he===dt?rt(ot==="asc"?"desc":"asc"):(Qe(dt),rt("asc"))},es=dt=>he!==dt?e.jsx(Hc,{className:"ml-1 h-4 w-4"}):ot==="asc"?e.jsx(Vd,{className:"ml-1 h-4 w-4"}):e.jsx(eh,{className:"ml-1 h-4 w-4"}),nn=r.filter(dt=>{if(d==="active"&&!dt.claimed||d==="pending"&&dt.claimed)return!1;if(!l)return!0;const Se=l.toLowerCase();return dt.name.toLowerCase().includes(Se)||dt.email.toLowerCase().includes(Se)}),_a=[...nn].sort((dt,Se)=>{if(!he)return 0;let ze=0;return he==="name"?ze=Kt(dt.name).localeCompare(Kt(Se.name)):he==="status"&&(ze=dt.claimed===Se.claimed?0:dt.claimed?-1:1),ot==="asc"?ze:-ze});nn.filter(dt=>dt.claimed&&!Fa(dt.id));const aa=dt=>{f(Se=>{const ze=new Set(Se);return ze.has(dt)?ze.delete(dt):ze.add(dt),ze})},Pr=()=>{p.size===_a.length?f(new Set):f(new Set(_a.map(dt=>dt.id)))},ii=()=>{f(new Set)},nl=async()=>{const dt=Array.from(p);if(dt.length===0)return;_(!0);let Se=0,ze=0;try{const{data:{session:st}}=await G.auth.getSession();for(const Tt of dt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${st==null?void 0:st.access_token}`},body:JSON.stringify({userId:Tt})})).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"}),ii()}catch(st){console.error("Error bulk sending welcome emails:",st),s({title:"Error",description:st.message||"Failed to send welcome emails",variant:"destructive"})}finally{_(!1)}};return a?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Agents"}),e.jsx(yr,{children:"Manage your brokerage's agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>de(!0),children:[e.jsx(rh,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(K,{variant:"outline",onClick:()=>te(!0),children:[e.jsx(C0,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(K,{onClick:()=>N(!0),children:[e.jsx(xc,{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(fn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search agents...",value:l,onChange:dt=>i(dt.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:d,onValueChange:dt=>u(dt),children:[e.jsx(Js,{className:"w-[160px]",children:e.jsx(sr,{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"})]})]})]}),p.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:[p.size," agent",p.size>1?"s":""," selected"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:nl,disabled:v,children:[e.jsx(_r,{className:"mr-2 h-4 w-4"}),v?"Sending...":"Resend Welcome Email"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:ii,children:"Clear"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-[40px]",children:e.jsx(zo,{checked:_a.length>0&&p.size===_a.length,onCheckedChange:Pr,"aria-label":"Select all"})}),e.jsx(jt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>$r("name"),children:["Name (Last)",es("name")]})}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>$r("status"),children:["Status",es("status")]})}),e.jsx(jt,{children:"Actions"})]})}),e.jsx(Pn,{children:_a.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):_a.map(dt=>e.jsxs(js,{children:[e.jsx(lt,{children:e.jsx(zo,{checked:p.has(dt.id),onCheckedChange:()=>aa(dt.id),"aria-label":`Select ${dt.name}`})}),e.jsx(lt,{className:"font-medium",children:dt.name}),e.jsx(lt,{children:dt.email}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[dt.claimed?e.jsx(at,{variant:"default",children:"Active"}):e.jsx(at,{variant:"secondary",children:"Pending"}),Fa(dt.id)&&e.jsxs(at,{variant:"outline",className:"border-primary text-primary",children:[e.jsx(AP,{className:"mr-1 h-3 w-3"}),"Manager"]}),b[dt.id]&&e.jsxs(at,{variant:"outline",className:"text-xs",children:[e.jsx(hr,{className:"mr-1 h-3 w-3"}),"Asst: ",b[dt.id].name||b[dt.id].email]})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{Xe(dt),it(!0)},title:"Send celebration",className:"text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",children:e.jsx(Sd,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Ar(dt),title:"Edit agent",children:e.jsx(Ra,{className:"h-4 w-4"})}),!dt.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>vt(dt.id),title:"Resend welcome email",children:e.jsx(_r,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Nn(dt),title:"Claim account for agent",disabled:ls===dt.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:e.jsx(l_,{className:"h-4 w-4"})})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>yn(dt),title:"Set password",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",children:e.jsx(zu,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Cs(dt.email,dt.name),title:"Send password reset email",children:e.jsx(rN,{className:"h-4 w-4"})}),Fa(dt.id)&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>bo(dt.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:e.jsx(rh,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>or(dt),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(br,{className:"h-4 w-4"})})]})})]},dt.id))})]})})]})]}),e.jsx(vs,{open:w,onOpenChange:N,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",value:I.name,onChange:dt=>L({...I,name:dt.target.value}),placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:I.email,onChange:dt=>L({...I,email:dt.target.value}),placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(Re,{id:"phone",type:"tel",value:I.phone,onChange:dt=>L({...I,phone:dt.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"password",children:"Temporary Password"}),e.jsx(Re,{id:"password",type:"password",value:I.password,onChange:dt=>L({...I,password:dt.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>N(!1),children:"Cancel"}),e.jsx(K,{onClick:ir,disabled:C,children:C?"Creating...":"Create Agent"})]})]})}),e.jsx(vs,{open:R,onOpenChange:$,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:ta,disabled:V,children:V?"Removing...":"Remove Agent"})]})]})}),e.jsx(pKe,{open:se,onOpenChange:te,fixedBrokerageId:t,onSuccess:as}),e.jsx(vs,{open:Y,onOpenChange:de,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{children:"Select Agent"}),e.jsxs(So,{open:we,onOpenChange:ke,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":we,className:"w-full justify-between",children:[ie?((mi=r.find(dt=>dt.id===ie))==null?void 0:mi.name)+" ("+((Vl=r.find(dt=>dt.id===ie))==null?void 0:Vl.email)+")":"Select an agent to promote...",e.jsx(df,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(ko,{className:"w-full p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search by name or email..."}),e.jsxs(kf,{className:"max-h-[200px]",children:[e.jsx(Nf,{children:"No eligible agents found."}),e.jsx(Sf,{children:r.filter(dt=>!Fa(dt.id)).map(dt=>e.jsxs(Nm,{value:`${dt.name} ${dt.email}`,onSelect:()=>{ae(dt.id),ke(!1)},children:[e.jsx(ua,{className:`mr-2 h-4 w-4 ${ie===dt.id?"opacity-100":"opacity-0"}`}),dt.name," (",dt.email,")"]},dt.id))})]})]})})]}),r.filter(dt=>!Fa(dt.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>de(!1),children:"Cancel"}),e.jsx(K,{onClick:ai,disabled:le||!ie,children:le?"Adding...":"Add as Manager"})]})]})}),e.jsx(vs,{open:Ze,onOpenChange:_e,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{children:"Edit Agent"}),e.jsxs(Kr,{children:["Update profile information for ",Ce==null?void 0:Ce.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"edit-name",children:"Name"}),e.jsx(Re,{id:"edit-name",value:Fe.name,onChange:dt=>Ae({...Fe,name:dt.target.value}),placeholder:"Agent name"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"edit-email",children:"Email"}),e.jsx(Re,{id:"edit-email",type:"email",value:Fe.email,onChange:dt=>Ae({...Fe,email:dt.target.value}),placeholder:"agent@example.com"}),Fe.email.trim().toLowerCase()!==(Ce==null?void 0:Ce.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(ve,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(Re,{id:"edit-phone",type:"tel",value:Fe.phone,onChange:dt=>Ae({...Fe,phone:dt.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>_e(!1),children:"Cancel"}),e.jsx(K,{onClick:Wn,disabled:We||De,children:De?"Updating email...":We?"Saving...":"Save Changes"})]})]})}),qe&&e.jsx(fKe,{open:Ne,onOpenChange:dt=>{it(dt),dt||Xe(null)},userId:qe.id,userName:qe.name}),e.jsx(vs,{open:$e,onOpenChange:Ke,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{children:"Set Password"}),e.jsxs(Kr,{children:["Set a new password for ",ct==null?void 0:ct.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(ve,{htmlFor:"new-password",children:"New Password"}),e.jsx(Re,{id:"new-password",type:"password",value:Ve,onChange:dt=>Je(dt.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(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>Ke(!1),children:"Cancel"}),e.jsx(K,{onClick:na,disabled:Rt||!Ve||Ve.length<6,children:Rt?"Setting...":"Set Password"})]})]})})]})},nzt={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},azt={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},izt=t=>{switch(t){case"academy_video":return e.jsx(kn,{className:"h-4 w-4"});case"template":return e.jsx(In,{className:"h-4 w-4"});case"toolbox":return e.jsx(In,{className:"h-4 w-4"});case"newsletter":return e.jsx(I0,{className:"h-4 w-4"});case"social_swag":return e.jsx(hn,{className:"h-4 w-4"});case"event":return e.jsx(on,{className:"h-4 w-4"});default:return e.jsx(sn,{className:"h-4 w-4"})}},ozt=({brokerageId:t})=>{const{toast:s}=Ia(),[r,n]=S.useState([]),[a,o]=S.useState([]),[l,i]=S.useState([]),[d,u]=S.useState(!0),[p,f]=S.useState(null);S.useEffect(()=>{v()},[t]);const v=async()=>{try{u(!0);const{data:j,error:w}=await G.from("profiles").select("id, name, email").eq("brokerage_id",t);if(w)throw w;const N=j.map(X=>X.id),C=new Map(j.map(X=>[X.id,X]));if(N.length===0){n([]),o([]),i([]);return}const{data:A,error:I}=await G.from("activity_logs").select("*").in("user_id",N).order("launched_at",{ascending:!1});if(I)throw I;const L=A.map(X=>{var se,te;return{id:X.id,user_id:X.user_id,app_name:X.app_name,launched_at:X.launched_at,user_name:((se=C.get(X.user_id))==null?void 0:se.name)||"Unknown",user_email:((te=C.get(X.user_id))==null?void 0:te.email)||"Unknown"}});n(L);const{data:R,error:$}=await G.from("content_engagement_logs").select("*").in("user_id",N).order("created_at",{ascending:!1});if($)throw $;const q=(R||[]).map(X=>{var se,te;return{id:X.id,user_id:X.user_id,resource_type:X.resource_type,resource_id:X.resource_id,resource_title:X.resource_title,action_type:X.action_type,created_at:X.created_at,user_name:((se=C.get(X.user_id))==null?void 0:se.name)||"Unknown",user_email:((te=C.get(X.user_id))==null?void 0:te.email)||"Unknown"}});o(q);const U=new Map;j.forEach(X=>{U.set(X.id,{user_id:X.id,user_name:X.name,user_email:X.email,app_launches:0,content_views:0,last_activity:""})}),L.forEach(X=>{const se=U.get(X.user_id);se&&(se.app_launches++,(!se.last_activity||new Date(X.launched_at)>new Date(se.last_activity))&&(se.last_activity=X.launched_at))}),q.forEach(X=>{const se=U.get(X.user_id);se&&(se.content_views++,(!se.last_activity||new Date(X.created_at)>new Date(se.last_activity))&&(se.last_activity=X.created_at))});const V=Array.from(U.values()).filter(X=>X.app_launches>0||X.content_views>0).sort((X,se)=>new Date(se.last_activity).getTime()-new Date(X.last_activity).getTime());i(V)}catch(j){console.error("Error loading activity:",j),s({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{u(!1)}},_=j=>r.filter(w=>w.user_id===j),b=j=>a.filter(w=>w.user_id===j);return d?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Agent Activity"}),e.jsx(yr,{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(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Agent"}),e.jsx(jt,{className:"text-center",children:"App Launches"}),e.jsx(jt,{className:"text-center",children:"Content Views"}),e.jsx(jt,{children:"Last Active"})]})}),e.jsx(Pn,{children:l.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(j=>e.jsxs(js,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>f({id:j.user_id,name:j.user_name,email:j.user_email}),children:[e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:j.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:j.user_email})]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(ul,{className:"h-3 w-3"}),j.app_launches]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(at,{variant:"secondary",className:"gap-1",children:[e.jsx(In,{className:"h-3 w-3"}),j.content_views]})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:j.last_activity&&Cd(new Date(j.last_activity),{addSuffix:!0})})]},j.user_id))})]})})})]}),e.jsx(vs,{open:!!p,onOpenChange:j=>!j&&f(null),children:e.jsxs(ys,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{children:[p==null?void 0:p.name,"'s Activity"]}),e.jsx(Kr,{children:p==null?void 0:p.email})]}),e.jsxs(Na,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(va,{className:"grid w-full grid-cols-2",children:[e.jsx(ks,{value:"content",children:"Content Engagement"}),e.jsx(ks,{value:"apps",children:"App Launches"})]}),e.jsx(zs,{value:"content",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Resource"}),e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Action"}),e.jsx(jt,{children:"Time"})]})}),e.jsx(Pn,{children:p&&b(p.id).length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):p&&b(p.id).map(j=>e.jsxs(js,{children:[e.jsx(lt,{className:"max-w-[200px] truncate font-medium",children:j.resource_title}),e.jsx(lt,{children:e.jsxs(at,{variant:"outline",className:"gap-1",children:[izt(j.resource_type),nzt[j.resource_type]||j.resource_type]})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:azt[j.action_type]||j.action_type})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:Cd(new Date(j.created_at),{addSuffix:!0})})]},j.id))})]})})}),e.jsx(zs,{value:"apps",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"App"}),e.jsx(jt,{children:"Time"})]})}),e.jsx(Pn,{children:p&&_(p.id).length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):p&&_(p.id).map(j=>e.jsxs(js,{children:[e.jsx(lt,{children:e.jsx(at,{variant:"outline",children:j.app_name})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:Cd(new Date(j.launched_at),{addSuffix:!0})})]},j.id))})]})})})]})]})})]})},lzt=({brokerageId:t})=>{const{toast:s}=Ia(),[r,n]=S.useState({totalAgents:0,activeAgents:0,pendingAgents:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0}),[a,o]=S.useState(!0);S.useEffect(()=>{l()},[t]);const l=async()=>{try{o(!0);const{data:i,error:d}=await G.from("profiles").select("id").eq("brokerage_id",t);if(d)throw d;const u=i.map(L=>L.id),p=u.length;if(u.length===0){o(!1);return}const{data:f,error:v}=await G.from("profiles").select("id, email").in("id",u);if(v)throw v;const{count:_}=await G.from("profiles").select("*",{count:"exact",head:!0}).eq("brokerage_id",t).not("last_login","is",null),b=_||0,j=p-b,{count:w}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u),N=new Date;N.setDate(N.getDate()-7);const{count:C}=await G.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 G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",A.toISOString());n({totalAgents:p,activeAgents:b,pendingAgents:j,totalLaunches:w||0,launchesThisWeek:C||0,launchesThisMonth:I||0})}catch(i){console.error("Error loading analytics:",i),s({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{o(!1)}};return a?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Agents"}),e.jsx(hr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalAgents}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.activeAgents," active, ",r.pendingAgents," pending"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(gi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.activeAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.totalAgents>0?`${Math.round(r.activeAgents/r.totalAgents*100)}% of total`:"0% of total"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(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(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(Am,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"This Week"}),e.jsx(Am,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"This Month"}),e.jsx(Am,{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"})]})]})]})},czt=({brokerageId:t})=>{const[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState({description:"",maxUses:""});S.useEffect(()=>{f()},[t]);const f=async()=>{try{const{data:N,error:C}=await G.from("invite_codes").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(C)throw C;r(N||[])}catch(N){console.error("Error loading invite codes:",N),fe.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:C}=await G.from("invite_codes").insert({code:N,description:u.description||null,max_uses:u.maxUses?parseInt(u.maxUses):null,brokerage_id:t,is_active:!0});if(C)throw C;fe.success("Invite link created!"),d(!1),p({description:"",maxUses:""}),f()}catch(N){console.error("Error creating invite code:",N),fe.error("Failed to create invite link")}finally{l(!1)}},b=async N=>{try{const{error:C}=await G.from("invite_codes").delete().eq("id",N);if(C)throw C;fe.success("Invite link deleted"),r(s.filter(A=>A.id!==N))}catch(C){console.error("Error deleting invite code:",C),fe.error("Failed to delete invite link")}},j=async(N,C)=>{try{const{error:A}=await G.from("invite_codes").update({is_active:!C}).eq("id",N);if(A)throw A;r(s.map(I=>I.id===N?{...I,is_active:!C}:I)),fe.success(`Invite link ${C?"deactivated":"activated"}`)}catch(A){console.error("Error toggling invite code:",A),fe.error("Failed to update invite link")}},w=N=>{const C=`${window.location.origin}/join?code=${N}`;navigator.clipboard.writeText(C),fe.success("Link copied to clipboard!")};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Lo,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(yr,{children:"Create shareable links for agents to join your brokerage"})]}),e.jsxs(vs,{open:i,onOpenChange:d,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Link"]})}),e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{htmlFor:"description",children:"Description (optional)"}),e.jsx(Re,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:u.description,onChange:N=>p({...u,description:N.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"maxUses",children:"Max Uses (optional)"}),e.jsx(Re,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:u.maxUses,onChange:N=>p({...u,maxUses:N.target.value})})]}),e.jsx(K,{onClick:_,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(As,{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(Lo,{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(at,{variant:N.is_active?"default":"secondary",children:N.is_active?"Active":"Inactive"})]}),N.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:N.description}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[N.uses_count," uses",N.max_uses&&` / ${N.max_uses} max`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(N.code),title:"Copy link",children:e.jsx(ni,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>j(N.id,N.is_active),title:N.is_active?"Deactivate":"Activate",children:N.is_active?"Disable":"Enable"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(N.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(br,{className:"h-4 w-4"})})]})]},N.id))})})]})},dzt=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,d]=S.useState(""),[u,p]=S.useState([]),[f,v]=S.useState(""),[_,b]=S.useState(!1),j=I=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I),w=()=>{const I=i.trim().toLowerCase();if(I&&j(I)&&!u.includes(I)){if(u.length>=10){fe.error("Maximum 10 emails per invite");return}p([...u,I]),d("")}else I&&!j(I)?fe.error("Please enter a valid email address"):u.includes(I)&&fe.error("Email already added")},N=I=>{p(u.filter(L=>L!==I))},C=I=>{(I.key==="Enter"||I.key===",")&&(I.preventDefault(),w())},A=async()=>{if(u.length===0){fe.error("Please add at least one email address");return}b(!0);try{const{data:I,error:L}=await G.functions.invoke("send-referral-invite",{body:{emails:u,personalMessage:f.trim()||void 0,referralCode:r,brokerageId:n,senderName:a,brokerageName:o}});if(L)throw L;I.successCount===I.totalCount?fe.success(`${I.successCount} invite${I.successCount>1?"s":""} sent successfully!`):fe.warning(`${I.successCount} of ${I.totalCount} invites sent. Some failed.`),p([]),v(""),s(!1),l==null||l()}catch(I){console.error("Error sending invites:",I),fe.error("Failed to send invites. Please try again.")}finally{b(!1)}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-[550px]",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(_r,{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(io,{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(ve,{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:C,onBlur:w}),e.jsx(K,{type:"button",variant:"secondary",onClick:w,children:"Add"})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:u.map(I=>e.jsxs(at,{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(Ur,{className:"h-3 w-3"})})]},I))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"message",children:"Personal Message (optional)"}),e.jsx(Mr,{id:"message",placeholder:"Add a personal note that will appear at the top of the email...",value:f,onChange:I=>v(I.target.value),rows:3,maxLength:500}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[f.length,"/500 characters"]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),"What they'll receive:"]}),e.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Beautiful branded email from you"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Your personal message (if added)"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Key LevelUp features for brokerages"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Direct signup link with your referral code"]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick: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(ka,{className:"h-4 w-4 mr-2"}),"Send ",u.length>0&&`(${u.length})`," Invite",u.length!==1?"s":""]})})]})]})})},uzt=({brokerageId:t,refreshTrigger:s})=>{const[r,n]=S.useState([]),[a,o]=S.useState(!0);S.useEffect(()=>{l()},[t,s]);const l=async()=>{try{const{data:d,error:u}=await G.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(at,{className:"bg-green-100 text-green-800 gap-1",children:[e.jsx(gi,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(at,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx(kc,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(at,{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(_r,{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 ",ws(new Date(d.sent_at),"MMM d, yyyy")]})]}),i(d.status)]},d.id))]})},hzt=()=>{const{brokerageId:t,user:s}=Gs(),[r,n]=S.useState(null),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState([]),[p,f]=S.useState(!0),[v,_]=S.useState(!1),[b,j]=S.useState(0);S.useEffect(()=>{t&&w()},[t]);const w=async()=>{try{const[R,$]=await Promise.all([G.from("brokerages").select("name").eq("id",t).single(),s?G.from("profiles").select("name").eq("id",s.id).single():Promise.resolve({data:null})]);R.data&&o(R.data.name),$.data&&i($.data.name||"A LevelUp Member");const{data:q}=await G.from("referral_codes").select("code").eq("brokerage_id",t).single();if(q)n(q.code);else{const V=`REF${t==null?void 0:t.slice(0,8).toUpperCase()}`;await G.from("referral_codes").insert({brokerage_id:t,code:V}),n(V)}const{data:U}=await G.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(U||[])}catch(R){console.error("Error fetching referral data:",R)}finally{f(!1)}},N=()=>{const R=`https://dashboard.relevelup.com/?ref=${r}`;navigator.clipboard.writeText(R),fe.success("Referral link copied to clipboard!")},C=d.filter(R=>R.status==="qualified").length,A=d.filter(R=>R.status==="pending").length,I=C*25,L=Math.max(0,Math.ceil((299-I)/25));return p?null:e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-primary/10 via-primary/5 to-background border-b",children:e.jsxs("div",{className:"px-6 py-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"bg-primary/20 rounded-full p-2",children:e.jsx(io,{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(gi,{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(hn,{className:"h-5 w-5"}),e.jsx("span",{className:"font-bold",children:"FREE Membership Unlocked!"})]})]})})]})}),e.jsxs(Oe,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(K,{onClick:()=>_(!0),className:"w-full",size:"lg",children:[e.jsx(_r,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),e.jsxs(K,{onClick:N,variant:"outline",className:"w-full",size:"lg",children:[e.jsx(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(Kc,{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(hr,{className:"h-5 w-5 mx-auto text-primary mb-1"}),e.jsx("p",{className:"text-2xl font-bold",children:C}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified Referrals"})]}),e.jsxs("div",{className:"text-center p-4 bg-amber-50 dark:bg-amber-950/20 rounded-lg border border-amber-200 dark:border-amber-900",children:[e.jsx(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(uzt,{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(R=>{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:(($=R.referred_brokerage)==null?void 0:$.name)||((q=R.referred_user)==null?void 0:q.email)||"Pending setup"}),e.jsxs(at,{variant:R.status==="qualified"?"default":R.status==="pending"?"secondary":"destructive",className:R.status==="qualified"?"bg-green-600":"",children:[R.status==="qualified"&&e.jsx(gi,{className:"h-3 w-3 mr-1"}),R.status]})]},R.id)})]})]})]}),e.jsx(dzt,{open:v,onOpenChange:_,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>j(R=>R+1)})]})},mzt=({brokerageId:t})=>{const s=Dr(),{teams:r,isLoading:n}=aS(t),{data:a,isLoading:o}=Ct({queryKey:["team-aggregate-stats",t,r.map(p=>p.id)],queryFn:async()=>{if(r.length===0)return[];const p=r.map(R=>R.id),{data:f}=await G.from("team_members").select("team_id, user_id, role").in("team_id",p);if(!f||f.length===0)return r.map(R=>({team_id:R.id,team_name:R.name,member_count:0,leader_name:null,leader_avatar:null,total_contacts:0,total_deals:0,total_videos:0}));const v=f.map(R=>R.user_id),_=f.filter(R=>R.role==="team_leader").map(R=>R.user_id),{data:b}=await G.from("profiles").select("id, name, avatar_url").in("id",_),j=new Map((b||[]).map(R=>[R.id,R])),{data:w}=await G.from("innercircle_contacts").select("owner_user_id").in("owner_user_id",v),{data:N}=await G.from("deal_pipeline").select("owner_user_id").in("owner_user_id",v),{data:C}=await G.from("agent_videos").select("owner_user_id").in("owner_user_id",v).eq("is_deleted",!1),A=new Map;(w||[]).forEach(R=>{A.set(R.owner_user_id,(A.get(R.owner_user_id)||0)+1)});const I=new Map;(N||[]).forEach(R=>{I.set(R.owner_user_id,(I.get(R.owner_user_id)||0)+1)});const L=new Map;return(C||[]).forEach(R=>{L.set(R.owner_user_id,(L.get(R.owner_user_id)||0)+1)}),r.map(R=>{const $=f.filter(Y=>Y.team_id===R.id),q=$.find(Y=>Y.role==="team_leader"),U=q?j.get(q.user_id):null,V=$.map(Y=>Y.user_id),X=V.reduce((Y,de)=>Y+(A.get(de)||0),0),se=V.reduce((Y,de)=>Y+(I.get(de)||0),0),te=V.reduce((Y,de)=>Y+(L.get(de)||0),0);return{team_id:R.id,team_name:R.name,member_count:$.length,leader_name:(U==null?void 0:U.name)||null,leader_avatar:(U==null?void 0:U.avatar_url)||null,total_contacts:X,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(p=>e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(gs,{className:"h-5 w-32"})}),e.jsx(Oe,{children:e.jsx(gs,{className:"h-24 w-full"})})]},p))});if(r.length===0)return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create teams to organize your agents and track their performance."}),e.jsx(K,{onClick:()=>s("/brokerage/teams"),children:"Manage Teams"})]})});const i=(a||[]).reduce((p,f)=>p+f.member_count,0),d=(a||[]).reduce((p,f)=>p+f.total_contacts,0),u=(a||[]).reduce((p,f)=>p+f.total_deals,0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 grid-cols-2 md:grid-cols-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"})," Teams"]}),e.jsx("p",{className:"text-2xl font-bold",children:r.length})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"})," Total Members"]}),e.jsx("p",{className:"text-2xl font-bold",children:i})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(tN,{className:"h-4 w-4"})," Total Contacts"]}),e.jsx("p",{className:"text-2xl font-bold",children:d.toLocaleString()})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(th,{className:"h-4 w-4"})," Total Deals"]}),e.jsx("p",{className:"text-2xl font-bold",children:u.toLocaleString()})]})})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:(a||[]).map(p=>e.jsxs(Ee,{className:"hover:shadow-md transition-shadow",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-lg",children:p.team_name}),e.jsxs(at,{variant:"secondary",children:[p.member_count," members"]})]}),p.leader_name&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs(gn,{className:"h-6 w-6",children:[e.jsx(Ea,{src:p.leader_avatar||""}),e.jsx(xn,{className:"text-xs",children:p.leader_name.charAt(0).toUpperCase()})]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Bh,{className:"h-3 w-3 text-amber-500"}),p.leader_name]})]})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_contacts.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Contacts"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_deals.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Deals"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_videos.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]},p.team_id))}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{variant:"outline",onClick:()=>s("/brokerage/teams"),children:"Manage Teams →"})})]})},pzt=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=Gs(),i=Dr(),{toast:d}=Ia(),[u,p]=S.useState(""),[f,v]=S.useState(!0),_=o||(a.length>0?a[0].id:r);S.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:j,error:w}=await G.from("brokerages").select("name").eq("id",_).single();if(w)throw w;p(j.name)}catch(j){console.error("Error loading brokerage info:",j),d({title:"Error",description:"Failed to load brokerage information",variant:"destructive"})}finally{v(!1)}};return f?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(Aa,{className:"mr-2 h-4 w-4"}),e.jsx(sr,{placeholder:"Select brokerage"})]}),e.jsx(er,{children:a.map(j=>e.jsx(At,{value:j.id,children:j.name},j.id))})]})]}),e.jsxs(Na,{defaultValue:"agents",className:"space-y-4",children:[e.jsxs(va,{className:"grid w-full grid-cols-4 md:grid-cols-8",children:[e.jsx(ks,{value:"agents",children:"Agents"}),e.jsx(ks,{value:"teams",children:"Teams"}),e.jsx(ks,{value:"invite",children:"Invite Links"}),e.jsx(ks,{value:"referrals",children:"Referrals"}),e.jsx(ks,{value:"leaderboard",children:"Leaderboard"}),e.jsx(ks,{value:"activity",children:"Activity"}),e.jsx(ks,{value:"analytics",children:"Analytics"}),e.jsx(ks,{value:"shares",children:"Shares"})]}),e.jsx(zs,{value:"agents",className:"space-y-4",children:e.jsx(rzt,{brokerageId:_})}),e.jsx(zs,{value:"teams",className:"space-y-4",children:e.jsx(mzt,{brokerageId:_})}),e.jsx(zs,{value:"invite",className:"space-y-4",children:e.jsx(czt,{brokerageId:_})}),e.jsx(zs,{value:"referrals",className:"space-y-4",children:e.jsx(hzt,{})}),e.jsx(zs,{value:"leaderboard",className:"space-y-4",children:e.jsx(IGe,{brokerageId:_,title:`${u} Event Leaderboard`,showUserStats:!1})}),e.jsx(zs,{value:"activity",className:"space-y-4",children:e.jsx(ozt,{brokerageId:_})}),e.jsx(zs,{value:"analytics",className:"space-y-4",children:e.jsx(lzt,{brokerageId:_})}),e.jsx(zs,{value:"shares",className:"space-y-4",children:e.jsx(ZKe,{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(Aa,{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 fzt({brokerageId:t,canManage:s}){const{user:r}=Gs(),[n,a]=S.useState([]),[o,l]=S.useState(!0),[i,d]=S.useState(!1),[u,p]=S.useState(null),[f,v]=S.useState(null),[_,b]=S.useState(!1),[j,w]=S.useState(""),[N,C]=S.useState(""),[A,I]=S.useState(!1),L=async()=>{try{const{data:V,error:X}=await G.from("brokerage_announcements").select("*").eq("brokerage_id",t).order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1});if(X)throw X;const se=V;if(se&&se.length>0){const te=[...new Set(se.map(ae=>ae.created_by))],{data:Y}=await G.from("profiles").select("id, name, avatar_url").in("id",te),de=new Map((Y==null?void 0:Y.map(ae=>[ae.id,ae]))||[]),ie=se.map(ae=>({...ae,author:de.get(ae.created_by)||{name:"Unknown",avatar_url:null}}));a(ie)}else a([])}catch(V){console.error("Error fetching announcements:",V)}finally{l(!1)}};S.useEffect(()=>{L()},[t]);const R=()=>{w(""),C(""),I(!1),p(null)},$=V=>{V?(p(V),w(V.title),C(V.content),I(V.is_pinned)):R(),d(!0)},q=async()=>{if(!j.trim()||!N.trim()){fe.error("Please fill in all fields");return}b(!0);try{if(u){const{error:V}=await G.from("brokerage_announcements").update({title:j.trim(),content:N.trim(),is_pinned:A,pinned_at:A?new Date().toISOString():null}).eq("id",u.id);if(V)throw V;fe.success("Announcement updated")}else{const{error:V}=await G.from("brokerage_announcements").insert({brokerage_id:t,created_by:r==null?void 0:r.id,title:j.trim(),content:N.trim(),is_pinned:A,pinned_at:A?new Date().toISOString():null});if(V)throw V;fe.success("Announcement created")}d(!1),R(),L()}catch(V){console.error("Error saving announcement:",V),fe.error("Failed to save announcement")}finally{b(!1)}},U=async()=>{if(f)try{const{error:V}=await G.from("brokerage_announcements").delete().eq("id",f);if(V)throw V;fe.success("Announcement deleted"),L()}catch(V){console.error("Error deleting announcement:",V),fe.error("Failed to delete announcement")}finally{v(null)}};return o?e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(zg,{className:"h-5 w-5"}),"Announcements"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"animate-pulse space-y-3",children:e.jsx("div",{className:"h-20 bg-muted rounded"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(zg,{className:"h-5 w-5 text-primary"}),"Announcements"]}),s&&e.jsxs(K,{size:"sm",onClick:()=>$(),className:"gap-1",children:[e.jsx(Zs,{className:"h-4 w-4"}),"New"]})]}),e.jsx(Oe,{children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No announcements yet"}):e.jsx("div",{className:"space-y-4",children:n.map(V=>{var X,se,te,Y;return e.jsx("div",{className:`p-4 rounded-lg border ${V.is_pinned?"bg-primary/5 border-primary/20":"bg-muted/30"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[V.is_pinned&&e.jsx(a_,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold truncate",children:V.title})]}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:V.content}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-muted-foreground",children:[e.jsxs(gn,{className:"h-5 w-5",children:[e.jsx(Ea,{src:((X=V.author)==null?void 0:X.avatar_url)||void 0}),e.jsx(xn,{className:"text-[10px]",children:((te=(se=V.author)==null?void 0:se.name)==null?void 0:te.charAt(0))||"?"})]}),e.jsx("span",{children:(Y=V.author)==null?void 0:Y.name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:ws(new Date(V.created_at),"MMM d, yyyy")})]})]}),s&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>$(V),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>v(V.id),children:e.jsx(br,{className:"h-4 w-4"})})]})]})},V.id)})})})]}),e.jsx(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{children:u?"Edit Announcement":"New Announcement"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title"}),e.jsx(Re,{id:"title",value:j,onChange:V=>w(V.target.value),placeholder:"Announcement title..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"content",children:"Content"}),e.jsx(Mr,{id:"content",value:N,onChange:V=>C(V.target.value),placeholder:"Write your announcement...",rows:4})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"pinned",checked:A,onCheckedChange:I}),e.jsxs(ve,{htmlFor:"pinned",className:"flex items-center gap-1 cursor-pointer",children:[e.jsx(a_,{className:"h-4 w-4"}),"Pin to top"]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{onClick:q,disabled:_,children:_?"Saving...":u?"Update":"Create"})]})]})]})}),e.jsx(nc,{open:!!f,onOpenChange:()=>v(null),children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Announcement"}),e.jsx(Dl,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:U,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function gzt({brokerageId:t}){const[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(""),[i,d]=S.useState(new Set);S.useEffect(()=>{(async()=>{try{const{data:f,error:v}=await G.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(f||[]),f&&f.length>0){const _=f.map(j=>j.id),{data:b}=await G.from("agent_assistant_assignments").select("agent_id").in("agent_id",_);b&&d(new Set(b.map(j=>j.agent_id)))}}catch(f){console.error("Error fetching agents:",f)}finally{a(!1)}})()},[t]);const u=s.filter(p=>{var f,v;return p.name.toLowerCase().includes(o.toLowerCase())||p.email.toLowerCase().includes(o.toLowerCase())||((f=p.title)==null?void 0:f.toLowerCase().includes(o.toLowerCase()))||((v=p.areas_served)==null?void 0:v.toLowerCase().includes(o.toLowerCase()))});return n?e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Agent Roster"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[1,2,3,4].map(p=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-48 bg-muted rounded-lg"})},p))})})]}):e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(hr,{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(fn,{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:p=>l(p.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(p=>e.jsx(xzt,{agent:p,hasAssistant:i.has(p.id)},p.id))})})]})}function xzt({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(gn,{className:"h-20 w-20 mb-3 ring-2 ring-background shadow-md",children:[e.jsx(Ea,{src:t.avatar_url||void 0,alt:t.name}),e.jsx(xn,{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(at,{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(Ai,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:t.areas_served})]}),t.years_experience&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center",children:[t.years_experience," ",t.years_experience===1?"year":"years"," experience"]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.phone&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:`tel:${t.phone}`,title:`Call ${t.name}`,children:e.jsx(Zn,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:`mailto:${t.email}`,title:`Email ${t.name}`,children:e.jsx(_r,{className:"h-4 w-4"})})}),t.linkedin_url&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:t.linkedin_url,target:"_blank",rel:"noopener noreferrer",title:"LinkedIn",children:e.jsx(Lm,{className:"h-4 w-4"})})}),t.instagram_url&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:t.instagram_url,target:"_blank",rel:"noopener noreferrer",title:"Instagram",children:e.jsx(Wd,{className:"h-4 w-4"})})})]})]})}function yzt({brokerageId:t}){const[s,r]=S.useState([]),[n,a]=S.useState(!0);if(S.useEffect(()=>{(async()=>{try{const{data:d,error:u}=await G.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 p=d.map(j=>j.id),{data:f,error:v}=await G.from("agent_attendance_stats").select("user_id, total_points").in("user_id",p).order("total_points",{ascending:!1});if(v)throw v;const _=new Map(d.map(j=>[j.id,j])),b=(f||[]).filter(j=>j.total_points>0).map(j=>{const w=_.get(j.user_id);return{user_id:j.user_id,total_points:j.total_points,name:(w==null?void 0:w.name)||"Unknown",avatar_url:(w==null?void 0:w.avatar_url)||null}});r(b)}catch(d){console.error("Error fetching leaderboard:",d)}finally{a(!1)}})()},[t]),n)return e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Ki,{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(E0,{className:Pt("h-5 w-5",o(i))}):e.jsx("span",{className:"w-5 text-center text-sm text-muted-foreground",children:i});return e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Ki,{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(f=>f[0]).join("").toUpperCase().slice(0,2),p=d+1;return e.jsxs("div",{className:Pt("flex items-center gap-3 p-2 rounded-lg",p<=3&&"bg-muted/50"),children:[e.jsx("div",{className:"w-6 flex justify-center",children:l(p)}),e.jsxs(gn,{className:"h-8 w-8",children:[e.jsx(Ea,{src:i.avatar_url||void 0}),e.jsx(xn,{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 vzt({brokerageId:t}){const s=Dr(),[r,n]=S.useState([]),[a,o]=S.useState(!0);S.useEffect(()=>{(async()=>{try{const{data:d,error:u}=await G.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 p=d.map(j=>j.id),f=new Map(d.map(j=>[j.id,j])),{data:v,error:_}=await G.from("listings").select(` id, slug, property_address, city, price, property_type, agent_id, listing_photos(photo_url) `).in("agent_id",p).eq("status","active").order("created_at",{ascending:!1}).limit(6);if(_)throw _;const b=(v||[]).map(j=>({id:j.id,slug:j.slug,property_address:j.property_address,city:j.city,price:j.price,property_type:j.property_type,agent_id:j.agent_id,agent:f.get(j.agent_id)||null,photos:j.listing_photos||[]}));n(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(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Un,{className:"h-5 w-5"}),"Brokerage Listings"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[1,2].map(i=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-32 bg-muted rounded-lg"})},i))})})]}):e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Un,{className:"h-5 w-5 text-primary"}),"Brokerage Listings"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>s("/mission-control/listings"),className:"gap-1",children:[e.jsx(Zs,{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(Un,{className:"h-10 w-10 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No active listings from your brokerage yet"}),e.jsxs(K,{size:"sm",onClick:()=>s("/mission-control/listings/new"),className:"gap-1",children:[e.jsx(Zs,{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(Un,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("span",{className:"text-[10px] font-medium bg-primary text-primary-foreground px-1.5 py-0.5 rounded uppercase",children:i.property_type.replace("_"," ")})})]}),e.jsxs("div",{className:"p-2.5",children:[e.jsx("p",{className:"font-semibold text-sm text-primary",children:l(i.price)}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:i.property_address||"Address not available"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.city}),i.agent&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-1.5 truncate",children:["Listed by ",i.agent.name]})]})]},i.id))}),r.length>0&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full mt-3",onClick:()=>s("/mission-control/listings"),children:["View All Listings",e.jsx(sn,{className:"h-3 w-3 ml-1"})]})]})]})}function _zt(){const{user:t,isAdmin:s,isBrokerageManager:r}=Gs(),n=Dr(),[a,o]=S.useState(!0),[l,i]=S.useState(null),[d,u]=S.useState(""),[p,f]=S.useState(0),[v,_]=S.useState(!1),[b,j]=S.useState(!1);return S.useEffect(()=>{(async()=>{if(t)try{const{data:N}=await G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(N!=null&&N.brokerage_id)){o(!1);return}i(N.brokerage_id);const{data:C}=await G.from("brokerages").select("name").eq("id",N.brokerage_id).maybeSingle();C&&u(C.name);const{count:A}=await G.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",N.brokerage_id);if(f(A||0),s)_(!0),j(!0);else if(r){const{data:I}=await G.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",N.brokerage_id).maybeSingle();_(!!I),j(!!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(hr,{className:"h-5 w-5 text-primary"}),e.jsxs("span",{className:"font-medium",children:[p," ",p===1?"Agent":"Agents"]})]}),b&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>n("/brokerage-content"),children:[e.jsx(Ou,{className:"h-4 w-4 mr-2"}),"Brokerage Content"]}),e.jsxs(K,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[e.jsx(Un,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})]}),e.jsx(fzt,{brokerageId:l,canManage:v}),e.jsx(gzt,{brokerageId:l}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx(yzt,{brokerageId:l}),e.jsx(vzt,{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(Aa,{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 bzt(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 wzt(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 aEe={video:{icon:ul,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:In,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:Ho,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:on,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:Bl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function jzt({item:t,canManage:s}){const[r,n]=S.useState(!1),[a,o]=S.useState(null),l=c5t(),i=Dr(),d=aEe[t.content_type]||aEe.link,u=d.icon,p=S.useMemo(()=>t.thumbnail_url?t.thumbnail_url:t.content_type==="graphic"&&t.file_url?t.file_url:t.content_type==="video"?bzt(t.url):null,[t]);S.useEffect(()=>{p||!t.url||t.content_type!=="video"||!wzt(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,p]);const f=p||a,v=()=>{i(`/brokerage-content/${t.id}`)},_=async()=>{try{await l.mutateAsync(t.id),fe.success("Content deleted")}catch{fe.error("Failed to delete")}n(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"group overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30 cursor-pointer",onClick:v,children:[f?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:f,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/30 flex items-center justify-center",children:e.jsx(u,{className:"h-12 w-12 text-muted-foreground/30"})}),e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs(at,{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(at,{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:["📅 ",ws(new Date(t.event_date),"MMM d, yyyy · h:mm a")]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Added ",ws(new Date(t.created_at),"MMM d, yyyy")]})]}),s&&e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,onClick:b=>b.stopPropagation(),children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Jp,{className:"h-4 w-4"})})}),e.jsx(Td,{align:"end",children:e.jsxs(Ta,{onClick:b=>{b.stopPropagation(),n(!0)},className:"text-destructive",children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]})})]}),e.jsx(nc,{open:r,onOpenChange:n,children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Content"}),e.jsxs(Dl,{children:['Are you sure you want to delete "',t.title,'"? This cannot be undone.']})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:_,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function kzt(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 iEe=[{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 Nzt({brokerageId:t,categories:s}){var we;const{user:r}=Gs(),[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(""),[u,p]=S.useState("📁"),[f,v]=S.useState(!1);S.useRef(null);const[_,b]=S.useState("video"),[j,w]=S.useState(""),[N,C]=S.useState(""),[A,I]=S.useState(""),[L,R]=S.useState(""),[$,q]=S.useState(""),[U,V]=S.useState(""),[X,se]=S.useState(""),te=l5t(),Y=d5t(t),de=u5t(),ie=h5t(t),ae=()=>{b("video"),w(""),C(""),I(""),R(""),q(""),V(""),se("")},le=async(ke,Ze)=>{var Ce;const _e=(Ce=ke.target.files)==null?void 0:Ce[0];if(_e){v(!0);try{const Te=_e.name.split(".").pop(),Fe=`${t}/${Date.now()}-${Math.random().toString(36).slice(2)}.${Te}`,{error:Ae}=await G.storage.from("brokerage-content").upload(Fe,_e);if(Ae)throw Ae;const{data:{publicUrl:We}}=G.storage.from("brokerage-content").getPublicUrl(Fe);Ze==="file"?(R(We),_==="graphic"&&!$&&q(We)):q(We),fe.success("File uploaded")}catch(Te){fe.error(Te.message||"Upload failed")}finally{v(!1)}}},pe=async()=>{if(!j.trim()){fe.error("Title is required");return}if(r)try{await te.mutateAsync({brokerage_id:t,category_id:X||null,content_type:_,title:j.trim(),description:N.trim()||null,url:A.trim()||null,file_url:L.trim()||null,thumbnail_url:$.trim()||null,event_date:U?new Date(U).toISOString():null,created_by:r.id}),fe.success("Content added!"),ae(),a(!1)}catch(ke){fe.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(""),p("📁"),fe.success("Category created")}catch(ke){fe.error(ke.message||"Failed to create category")}},ye=async()=>{try{await ie.mutateAsync(),fe.success("Default categories created")}catch{fe.error("Failed to create defaults")}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(vs,{open:n,onOpenChange:a,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Content"]})}),e.jsxs(ys,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{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(ve,{children:"Content Type"}),e.jsxs(tr,{value:_,onValueChange:b,children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:iEe.map(ke=>e.jsx(At,{value:ke.value,children:ke.label},ke.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(we=iEe.find(ke=>ke.value===_))==null?void 0:we.hint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Category"}),e.jsxs(tr,{value:X,onValueChange:se,children:[e.jsx(Js,{children:e.jsx(sr,{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(ve,{children:"Title *"}),e.jsx(Re,{value:j,onChange:ke=>w(ke.target.value),placeholder:"Content title"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Description"}),e.jsx(Mr,{value:N,onChange:ke=>C(ke.target.value),placeholder:"Brief description...",rows:2})]}),["video","link","graphic","event"].includes(_)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:_==="video"?"Video URL":_==="graphic"?"Canva / Image URL":_==="event"?"Event Link (Zoom, etc.)":"URL"}),e.jsx(Re,{value:A,onChange:ke=>{const Ze=ke.target.value;if(I(Ze),_==="video"&&!$){const _e=kzt(Ze);_e&&q(_e)}},placeholder:"https://..."})]}),["pdf","graphic"].includes(_)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{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=>le(ke,"file"),disabled:f}),f&&e.jsx(As,{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(ve,{children:"Thumbnail Image (optional)"}),e.jsx(Re,{type:"file",accept:"image/*",onChange:ke=>le(ke,"thumbnail"),disabled:f}),$&&e.jsxs("div",{className:"relative w-20 h-20 rounded overflow-hidden",children:[e.jsx("img",{src:$,className:"w-full h-full object-cover",alt:"thumb"}),e.jsx("button",{onClick:()=>q(""),className:"absolute top-0 right-0 bg-background/80 rounded-bl p-0.5",children:e.jsx(Ur,{className:"h-3 w-3"})})]})]}),_==="event"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Event Date & Time"}),e.jsx(Re,{type:"datetime-local",value:U,onChange:ke=>V(ke.target.value)})]}),e.jsxs(K,{onClick:pe,disabled:te.isPending||!j.trim(),className:"w-full",children:[te.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Content"]})]})]})]}),e.jsxs(vs,{open:o,onOpenChange:l,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",children:[e.jsx($l,{className:"h-4 w-4 mr-2"}),"Categories"]})}),e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Manage Categories"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[s.length===0&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No categories yet"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ye,disabled:ie.isPending,children:[ie.isPending?e.jsx(As,{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(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:async()=>{await de.mutateAsync(ke.id),fe.success("Category deleted")},children:e.jsx(Ur,{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=>p(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(K,{size:"sm",onClick:be,disabled:!i.trim(),children:"Add"})]})]})]})]})]})}function Szt(){const{user:t,isAdmin:s,isBrokerageManager:r}=Gs(),[n,a]=S.useState(!0),[o,l]=S.useState(null),[i,d]=S.useState(""),[u,p]=S.useState(!1),[f,v]=S.useState(null),[_,b]=S.useState("");S.useEffect(()=>{(async()=>{if(t)try{const{data:I}=await G.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 G.from("brokerages").select("name").eq("id",I.brokerage_id).maybeSingle();if(L&&d(L.name),s)p(!0);else if(r){const{data:R}=await G.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",I.brokerage_id).maybeSingle();p(!!R)}}catch(I){console.error("Error fetching brokerage info:",I)}finally{a(!1)}})()},[t,s,r]);const{data:j=[]}=a5t(o),{data:w=[],isLoading:N}=i5t(o,f),C=S.useMemo(()=>{if(!_.trim())return w;const A=_.toLowerCase();return w.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)})},[w,_]);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(Nzt,{brokerageId:o,categories:j}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(fn,{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(K,{variant:f===null?"default":"outline",size:"sm",onClick:()=>v(null),children:"All"}),j.map(A=>e.jsxs(K,{variant:f===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"})}):C.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(qh,{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:C.map(A=>e.jsx(jzt,{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(Aa,{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 oEe={video:{icon:ul,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:In,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:Ho,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:on,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:Bl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function Czt(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 Mzt(t){try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function Tzt(t){try{return new URL(t).hostname.includes("vimeo.com")}catch{return!1}}function Azt(t){try{const s=t.match(/vimeo\.com\/(\d+)/);if(s)return`https://player.vimeo.com/video/${s[1]}`}catch{}return null}function Ezt(){const{contentId:t}=Mo(),{data:s,isLoading:r}=Ct({queryKey:["brokerage-content-detail",t],queryFn:async()=>{const{data:u,error:p}=await G.from("brokerage_content").select(` *, category:brokerage_content_categories(*) `).eq("id",t).single();if(p)throw p;return u},enabled:!!t});if(r)return e.jsx(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(Aa,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Content not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This content may have been removed."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(vo,{to:"/brokerage-content",children:"Back to Content"})})]})});const n=oEe[s.content_type]||oEe.link,a=n.icon,o=s.url||s.file_url,l=o&&Mzt(o)?Czt(o):null,i=o&&Tzt(o)?Azt(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(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(vo,{to:"/brokerage-content",children:[e.jsx(Ua,{className:"h-4 w-4"}),"Back to Content"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(at,{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(at,{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 ",ws(new Date(s.created_at),"MMMM d, yyyy")]})]}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),d&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"relative w-full bg-black",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src: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(Ee,{className:"overflow-hidden",children:e.jsx("img",{src:s.file_url,alt:s.title,className:"w-full max-h-[600px] object-contain bg-muted"})}),!d&&s.content_type!=="graphic"&&s.thumbnail_url&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("img",{src:s.thumbnail_url,alt:s.title,className:"w-full max-h-[400px] object-cover"})}),s.description&&e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})})}),s.content_type==="event"&&s.event_date&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(on,{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:ws(new Date(s.event_date),"EEEE, MMMM d, yyyy · h:mm a")})]})]})}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.file_url&&e.jsx(K,{asChild:!0,size:"lg",children:e.jsxs("a",{href:s.file_url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),s.content_type==="pdf"?"Download Document":"Download File"]})}),s.url&&e.jsx(K,{variant:s.file_url?"outline":"default",asChild:!0,size:"lg",children:e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{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 Pzt(){const t=Dr(),[s,r]=S.useState(""),[n,a]=S.useState("grid"),{data:o,isLoading:l}=Ct({queryKey:["newsletters"],queryFn:async()=>{const{data:A,error:I}=await G.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(I)throw I;return A}}),{data:i}=Ct({queryKey:["newsletter-likes-all"],queryFn:async()=>{const{data:A}=await G.from("newsletter_likes").select("newsletter_id");return A||[]}}),{data:d}=Ct({queryKey:["newsletter-comments-all"],queryFn:async()=>{const{data:A}=await G.from("newsletter_comments").select("newsletter_id");return A||[]}}),{data:u}=Ct({queryKey:["newsletter-resource-counts"],queryFn:async()=>{const[A,I,L,R]=await Promise.all([G.from("newsletter_canva_links").select("newsletter_id"),G.from("newsletter_pdfs").select("newsletter_id"),G.from("newsletter_videos").select("newsletter_id"),G.from("newsletter_drive_links").select("newsletter_id")]);return{canva:A.data||[],pdfs:I.data||[],videos:L.data||[],drives:R.data||[]}}}),p=A=>(i==null?void 0:i.filter(I=>I.newsletter_id===A).length)||0,f=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},j=A=>{var I;return((I=u==null?void 0:u.drives)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},w=A=>v(A)+_(A)+b(A)+j(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()))}),C=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(fn,{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(K,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(mp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Uh,{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(Ee,{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(In,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No newsletters match your search":"No newsletters available yet"}),s&&e.jsx(K,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&N&&N.length>0&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-3",children:N.map(A=>{const I=w(A.id),L=v(A.id),R=_(A.id),$=b(A.id);return n==="grid"?e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer border-border/50",onClick:()=>C(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(In,{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(on,{className:"h-3 w-3"}),ws(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(at,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Bl,{className:"h-3 w-3"})," ",L," Template",L>1?"s":""]}),R>0&&e.jsxs(at,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(xi,{className:"h-3 w-3"})," ",R," PDF",R>1?"s":""]}),$>0&&e.jsxs(at,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(ul,{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(pu,{className:"h-3 w-3"})," ",p(A.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gc,{className:"h-3 w-3"})," ",f(A.id)]})]})]})]},A.id):e.jsx(Ee,{className:"group overflow-hidden hover:shadow-md transition-all duration-200 cursor-pointer border-border/50",onClick:()=>C(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(In,{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(on,{className:"h-3 w-3"}),ws(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(pu,{className:"h-3 w-3"})," ",p(A.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gc,{className:"h-3 w-3"})," ",f(A.id)]})]})]})]})},A.id)})})]})})}function Izt({rows:t}){if(!t||t.length===0)return null;const s=t.filter(r=>r.columns.some(n=>n.title||n.description||n.image_url));return s.length===0?null:e.jsx("div",{className:"space-y-6",children:s.map((r,n)=>{const a=r.columns.filter(o=>o.title||o.description||o.image_url);return a.length===0?null:e.jsx("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${a.length}, minmax(0, 1fr))`},children:a.map((o,l)=>e.jsxs(Ee,{className:"overflow-hidden border-border/50",children:[o.image_url&&e.jsx("img",{src:o.image_url,alt:o.title||"",className:"w-full h-40 object-cover"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[o.title&&e.jsx("h4",{className:"font-semibold text-foreground",children:o.title}),o.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:o.description})]})]},l))},n)})})}function Lzt(){const{id:t}=Mo(),s=Dr(),{user:r}=Gs(),{toast:n}=Ia(),a=ns(),{trackEngagement:o}=FL(),[l,i]=S.useState(""),{data:d,isLoading:u}=Ct({queryKey:["newsletter",t],queryFn:async()=>{const{data:L,error:R}=await G.from("newsletter_content").select("*").eq("id",t).single();if(R)throw R;return L},enabled:!!t});S.useEffect(()=>{d&&o("newsletter",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:p}=Ct({queryKey:["newsletter-drives",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_drive_links").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:f}=Ct({queryKey:["newsletter-pdfs",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_pdfs").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:v}=Ct({queryKey:["newsletter-videos",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_videos").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:_}=Ct({queryKey:["newsletter-canva-links",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_canva_links").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:b}=Ct({queryKey:["newsletter-likes",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_likes").select("*").eq("newsletter_id",t);return L||[]},enabled:!!t}),{data:j}=Ct({queryKey:["newsletter-comments",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_comments").select("*, profiles:user_id(name)").eq("newsletter_id",t).order("created_at",{ascending:!1});return L||[]},enabled:!!t}),w=b==null?void 0:b.some(L=>L.user_id===(r==null?void 0:r.id)),N=Ot({mutationFn:async()=>{w?await G.from("newsletter_likes").delete().eq("newsletter_id",t).eq("user_id",r==null?void 0:r.id):await G.from("newsletter_likes").insert({newsletter_id:t,user_id:r==null?void 0:r.id})},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-likes",t]})}}),C=Ot({mutationFn:async L=>{const{error:R}=await G.from("newsletter_comments").insert({newsletter_id:t,user_id:r==null?void 0:r.id,content:L});if(R)throw R},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),i(""),n({title:"Comment added"})}}),A=Ot({mutationFn:async L=>{const{error:R}=await G.from("newsletter_comments").delete().eq("id",L);if(R)throw R},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),n({title:"Comment deleted"})}}),I=L=>{if(L.includes("player.mediadelivery.net")||L.includes("iframe.mediadelivery.net")){const R=L.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(R)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://iframe.mediadelivery.net/embed/${R[1]}/${R[2]}?autoplay=false`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}if(L.includes("youtube.com")||L.includes("youtu.be")){const R=L.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([^&\s]+)/);if(R)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${R[1]}`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}return e.jsxs("a",{href:L,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(ul,{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(K,{variant:"ghost",onClick:()=>s("/newsletters"),className:"mb-4",children:[e.jsx(Ua,{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:ws(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(Izt,{rows:d.content_blocks||[]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(SM,{resourceType:"newsletter",resourceId:d.id,resourceTitle:d.title}),e.jsxs(K,{variant:w?"default":"outline",size:"sm",onClick:()=>N.mutate(),children:[e.jsx(Si,{className:`h-4 w-4 mr-1 ${w?"fill-current":""}`}),(b==null?void 0:b.length)||0," ",(b==null?void 0:b.length)===1?"Like":"Likes"]})]}),_&&_.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(Bl,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:L.title}),e.jsx(sn,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},L.id))})]}),p&&p.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-lg",children:"Google Drive Files"})}),e.jsx(Oe,{className:"space-y-2",children:p.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(sn,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:L.title})]},L.id))})]}),f&&f.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-lg",children:"PDF Downloads"})}),e.jsx(Oe,{className:"space-y-2",children:f.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(In,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-medium flex-1",children:L.name}),e.jsx(xi,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]}),v&&v.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"text-lg",children:["Comments (",(j==null?void 0:j.length)||0,")"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Mr,{placeholder:"Write a comment...",value:l,onChange:L=>i(L.target.value),className:"flex-1"}),e.jsx(K,{onClick:()=>l.trim()&&C.mutate(l),disabled:!l.trim()||C.isPending,children:e.jsx(ka,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-4",children:j==null?void 0:j.map(L=>{var R,$,q;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(gn,{className:"h-8 w-8",children:e.jsx(xn,{children:(($=(R=L.profiles)==null?void 0:R.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:ws(new Date(L.created_at),"MMM d, yyyy")}),L.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>A.mutate(L.id),children:e.jsx(br,{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(K,{variant:"link",onClick:()=>s("/newsletters"),children:"Back to Newsletters"})]})})}function Dzt({rows:t,onChange:s}){const[r,n]=S.useState(null),a=()=>{s([...t,{columns:[{title:"",description:""},{title:"",description:""},{title:"",description:""}]}])},o=u=>{s(t.filter((p,f)=>f!==u))},l=(u,p,f,v)=>{const _=[...t];_[u]={..._[u],columns:_[u].columns.map((b,j)=>j===p?{...b,[f]:v}:b)},s(_)},i=async(u,p,f)=>{var b;const v=(b=f.target.files)==null?void 0:b[0];if(!v)return;const _=`${u}-${p}`;n(_);try{const j=`content-blocks/${Date.now()}-${v.name}`,{error:w}=await G.storage.from("newsletter-content").upload(j,v);if(!w){const{data:N}=G.storage.from("newsletter-content").getPublicUrl(j);l(u,p,"image_url",N.publicUrl)}}finally{n(null)}},d=(u,p)=>{l(u,p,"image_url","")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-base font-medium",children:"Content Blocks (3-Column Rows)"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:a,children:[e.jsx(Zs,{className:"mr-1 h-3 w-3"})," Add Row"]})]}),t.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No content block rows yet. Add a row to create a 3-column layout."}),t.map((u,p)=>e.jsxs(Ee,{className:"relative",children:[e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>o(p),children:e.jsx(Ur,{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(Fu,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Row ",p+1]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:u.columns.map((f,v)=>{const _=`${p}-${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]}),f.image_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:f.image_url,alt:"",className:"w-full h-20 object-cover rounded"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(p,v),children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{children:[e.jsx(Re,{type:"file",accept:"image/*",className:"hidden",id:`block-img-${_}`,onChange:b=>i(p,v,b)}),e.jsx(K,{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(Jo,{className:"h-3 w-3 mr-1"})," Image"]})})})]}),e.jsx(Re,{placeholder:"Title",value:f.title,onChange:b=>l(p,v,"title",b.target.value),className:"h-8 text-sm"}),e.jsx(Mr,{placeholder:"Description",value:f.description,onChange:b=>l(p,v,"description",b.target.value),className:"text-sm min-h-[60px] resize-none"})]},v)})})]})]},p))]})}function Ozt(){const{toast:t}=Ia(),s=ns(),[r,n]=S.useState(!1),[a,o]=S.useState(null),[l,i]=S.useState({title:"",description:"",publish_date:ws(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[d,u]=S.useState(null),[p,f]=S.useState(null),[v,_]=S.useState([]),[b,j]=S.useState([]),[w,N]=S.useState([]),[C,A]=S.useState([]),[I,L]=S.useState([]),[R,$]=S.useState([]),[q,U]=S.useState(!1),{data:V,isLoading:X}=Ct({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:_e,error:Ce}=await G.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Ce)throw Ce;return _e}}),se=Ot({mutationFn:async _e=>{const{data:Ce,error:Te}=await G.from("newsletter_content").insert({title:_e.title,description:_e.description||null,preview_image_url:_e.preview_image_url,publish_date:_e.publish_date,is_published:_e.is_published,content_blocks:_e.content_blocks}).select().single();if(Te)throw Te;return Ce},onSuccess:async _e=>{await de(_e.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),_e.is_published&&X8t(_e.title,_e.id),le()},onError:_e=>{t({title:"Error creating newsletter",description:_e.message,variant:"destructive"})}}),te=Ot({mutationFn:async _e=>{const{error:Ce}=await G.from("newsletter_content").update({title:_e.title,description:_e.description||null,preview_image_url:_e.preview_image_url,publish_date:_e.publish_date,is_published:_e.is_published,content_blocks:_e.content_blocks}).eq("id",_e.id);if(Ce)throw Ce;return _e.id},onSuccess:async _e=>{await de(_e),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter updated successfully"}),le()},onError:_e=>{t({title:"Error updating newsletter",description:_e.message,variant:"destructive"})}}),Y=Ot({mutationFn:async _e=>{const{error:Ce}=await G.from("newsletter_content").delete().eq("id",_e);if(Ce)throw Ce},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter deleted successfully"})},onError:_e=>{t({title:"Error deleting newsletter",description:_e.message,variant:"destructive"})}}),de=async _e=>{await G.from("newsletter_drive_links").delete().eq("newsletter_id",_e),await G.from("newsletter_pdfs").delete().eq("newsletter_id",_e),await G.from("newsletter_videos").delete().eq("newsletter_id",_e),await G.from("newsletter_canva_links").delete().eq("newsletter_id",_e);for(const Ce of R){const Te=`${_e}/${Date.now()}-${Ce.file.name}`,{error:Fe}=await G.storage.from("newsletter-content").upload(Te,Ce.file);if(!Fe){const{data:Ae}=G.storage.from("newsletter-content").getPublicUrl(Te);b.push({name:Ce.name,file_url:Ae.publicUrl,file_size:Ce.file.size,sort_order:b.length})}}v.length>0&&await G.from("newsletter_drive_links").insert(v.map((Ce,Te)=>({newsletter_id:_e,title:Ce.title,drive_url:Ce.drive_url,sort_order:Te}))),b.length>0&&await G.from("newsletter_pdfs").insert(b.map((Ce,Te)=>({newsletter_id:_e,name:Ce.name,file_url:Ce.file_url,file_size:Ce.file_size||null,sort_order:Te}))),w.length>0&&await G.from("newsletter_videos").insert(w.map((Ce,Te)=>({newsletter_id:_e,title:Ce.title,video_url:Ce.video_url,sort_order:Te}))),C.length>0&&await G.from("newsletter_canva_links").insert(C.map((Ce,Te)=>({newsletter_id:_e,title:Ce.title,canva_share_link:Ce.canva_share_link,sort_order:Te})))},ie=async _e=>{o(_e),i({title:_e.title,description:_e.description||"",publish_date:ws(new Date(_e.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:_e.is_published}),f(_e.preview_image_url),L(_e.content_blocks||[]);const[Ce,Te,Fe,Ae]=await Promise.all([G.from("newsletter_drive_links").select("*").eq("newsletter_id",_e.id).order("sort_order"),G.from("newsletter_pdfs").select("*").eq("newsletter_id",_e.id).order("sort_order"),G.from("newsletter_videos").select("*").eq("newsletter_id",_e.id).order("sort_order"),G.from("newsletter_canva_links").select("*").eq("newsletter_id",_e.id).order("sort_order")]);_(Ce.data||[]),j(Te.data||[]),N(Fe.data||[]),A(Ae.data||[]),$([]),n(!0)},ae=async _e=>{const[Ce,Te,Fe,Ae]=await Promise.all([G.from("newsletter_drive_links").select("*").eq("newsletter_id",_e.id).order("sort_order"),G.from("newsletter_pdfs").select("*").eq("newsletter_id",_e.id).order("sort_order"),G.from("newsletter_videos").select("*").eq("newsletter_id",_e.id).order("sort_order"),G.from("newsletter_canva_links").select("*").eq("newsletter_id",_e.id).order("sort_order")]);o(null),i({title:`${_e.title} (Copy)`,description:_e.description||"",publish_date:ws(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),f(_e.preview_image_url),L(_e.content_blocks||[]),_((Ce.data||[]).map(({id:We,...ht})=>ht)),j((Te.data||[]).map(({id:We,...ht})=>ht)),N((Fe.data||[]).map(({id:We,...ht})=>ht)),A((Ae.data||[]).map(({id:We,...ht})=>ht)),$([]),n(!0)},le=()=>{n(!1),o(null),i({title:"",description:"",publish_date:ws(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),u(null),f(null),_([]),j([]),N([]),A([]),L([]),$([])},pe=async _e=>{var Te;const Ce=(Te=_e.target.files)==null?void 0:Te[0];Ce&&(u(Ce),f(URL.createObjectURL(Ce)))},be=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}U(!0);let _e=p;if(d){const Ce=`previews/${Date.now()}-${d.name}`,{error:Te}=await G.storage.from("newsletter-content").upload(Ce,d);if(!Te){const{data:Fe}=G.storage.from("newsletter-content").getPublicUrl(Ce);_e=Fe.publicUrl}}a?te.mutate({id:a.id,...l,preview_image_url:_e,content_blocks:I}):se.mutate({...l,preview_image_url:_e,content_blocks:I}),U(!1)},ye=()=>_([...v,{title:"",drive_url:"",sort_order:v.length}]),we=()=>N([...w,{title:"",video_url:"",sort_order:w.length}]),ke=()=>A([...C,{title:"",canva_share_link:"",sort_order:C.length}]),Ze=_e=>{const Ce=_e.target.files;if(!Ce)return;const Te=Array.from(Ce).map(Fe=>({file:Fe,name:Fe.name.replace(/\.[^/.]+$/,"")}));$([...R,...Te])};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(_u,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources"}),e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.filter(_e=>_e.is_published).length)||0})})]})]}),e.jsxs(vs,{open:r,onOpenChange:_e=>!_e&&le(),children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"})," Add Newsletter"]})}),e.jsxs(ys,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{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(ve,{children:"Title *"}),e.jsx(Re,{value:l.title,onChange:_e=>i({...l,title:_e.target.value}),placeholder:"Newsletter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Publish Date"}),e.jsx(Re,{type:"datetime-local",value:l.publish_date,onChange:_e=>i({...l,publish_date:_e.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Qg,{content:l.description,onChange:_e=>i({...l,description:_e}),placeholder:"Newsletter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[p&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:p,alt:"Preview",className:"h-20 w-32 object-cover rounded-md"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute -top-2 -right-2 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{u(null),f(null)},children:e.jsx(Ur,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(Re,{type:"file",accept:"image/*",onChange:pe,className:"hidden",id:"preview-upload"}),e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("label",{htmlFor:"preview-upload",className:"cursor-pointer",children:[e.jsx(Ya,{className:"mr-2 h-4 w-4"})," Upload Image"]})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:l.is_published,onCheckedChange:_e=>i({...l,is_published:_e})}),e.jsx(ve,{children:"Published"})]}),e.jsx(Dzt,{rows:I,onChange:L}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-base font-medium",children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ke,children:[e.jsx(Zs,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),C.map((_e,Ce)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Re,{placeholder:"Link title",value:_e.title,onChange:Te=>{const Fe=[...C];Fe[Ce].title=Te.target.value,A(Fe)},className:"w-1/3"}),e.jsx(Re,{placeholder:"Canva share link",value:_e.canva_share_link,onChange:Te=>{const Fe=[...C];Fe[Ce].canva_share_link=Te.target.value,A(Fe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>A(C.filter((Te,Fe)=>Fe!==Ce)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Ce))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-base font-medium",children:"Google Drive Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ye,children:[e.jsx(Zs,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),v.map((_e,Ce)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Re,{placeholder:"Link title",value:_e.title,onChange:Te=>{const Fe=[...v];Fe[Ce].title=Te.target.value,_(Fe)},className:"w-1/3"}),e.jsx(Re,{placeholder:"Google Drive URL",value:_e.drive_url,onChange:Te=>{const Fe=[...v];Fe[Ce].drive_url=Te.target.value,_(Fe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>_(v.filter((Te,Fe)=>Fe!==Ce)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Ce))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-base font-medium",children:"PDF Files"}),e.jsxs("div",{children:[e.jsx(Re,{type:"file",accept:".pdf",multiple:!0,onChange:Ze,className:"hidden",id:"pdf-upload"}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{htmlFor:"pdf-upload",className:"cursor-pointer",children:[e.jsx(Ya,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),b.map((_e,Ce)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:_e.name}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>j(b.filter((Te,Fe)=>Fe!==Ce)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},`existing-${Ce}`)),R.map((_e,Ce)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:_e.name,onChange:Te=>{const Fe=[...R];Fe[Ce].name=Te.target.value,$(Fe)},className:"flex-1 h-8",placeholder:"PDF name"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"(new)"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>$(R.filter((Te,Fe)=>Fe!==Ce)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},`pending-${Ce}`))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-base font-medium",children:"Video Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:we,children:[e.jsx(Zs,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),w.map((_e,Ce)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Re,{placeholder:"Video title",value:_e.title,onChange:Te=>{const Fe=[...w];Fe[Ce].title=Te.target.value,N(Fe)},className:"w-1/3"}),e.jsx(Re,{placeholder:"Video URL",value:_e.video_url,onChange:Te=>{const Fe=[...w];Fe[Ce].video_url=Te.target.value,N(Fe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>N(w.filter((Te,Fe)=>Fe!==Ce)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Ce))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:le,children:"Cancel"}),e.jsx(K,{onClick:be,disabled:q||se.isPending||te.isPending,children:q?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:X?e.jsx(js,{children:e.jsx(lt,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(V==null?void 0:V.length)===0?e.jsx(js,{children:e.jsx(lt,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No newsletters yet. Create your first one!"})}):V==null?void 0:V.map(_e=>e.jsxs(js,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[_e.preview_image_url?e.jsx("img",{src:_e.preview_image_url,alt:_e.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(In,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:_e.title}),_e.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:_e.description.replace(/<[^>]*>/g,"")})]})]})}),e.jsx(lt,{children:ws(new Date(_e.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 ${_e.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:_e.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ie(_e),title:"Edit",children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ae(_e),title:"Duplicate",children:e.jsx(ni,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",title:"Delete",onClick:()=>{confirm("Are you sure you want to delete this newsletter?")&&Y.mutate(_e.id)},children:e.jsx(br,{className:"h-4 w-4"})})]})})]},_e.id))})]})})})]})})}const lEe={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 Rzt(){const{user:t}=Gs(),{toast:s}=Ia(),r=Dr(),n=ns(),[a,o]=S.useState(""),[l,i]=S.useState("popular"),[d,u]=S.useState(!1),[p,f]=S.useState(""),[v,_]=S.useState(""),[b,j]=S.useState(!1),{data:w=[],isLoading:N}=Ct({queryKey:["wishlist-items",l,b],queryFn:async()=>{let R=G.from("wishlist_items").select("*");b&&t&&(R=R.eq("user_id",t.id)),l==="latest"?R=R.order("created_at",{ascending:!1}):l==="popular"?R=R.order("vote_count",{ascending:!1}):l==="trending"&&(R=R.order("vote_count",{ascending:!1}));const{data:$,error:q}=await R;if(q)throw q;const U=[...new Set(($==null?void 0:$.map(ie=>ie.user_id))||[])],{data:V}=await G.from("profiles").select("id, name").in("id",U),X=new Map((V==null?void 0:V.map(ie=>[ie.id,ie]))||[]);let se=[];if(t){const{data:ie}=await G.from("wishlist_votes").select("item_id").eq("user_id",t.id);se=(ie==null?void 0:ie.map(ae=>ae.item_id))||[]}const te=($==null?void 0:$.map(ie=>ie.id))||[],{data:Y}=await G.from("wishlist_comments").select("item_id").in("item_id",te),de=new Map;return Y==null||Y.forEach(ie=>{de.set(ie.item_id,(de.get(ie.item_id)||0)+1)}),$==null?void 0:$.map(ie=>{const ae=X.get(ie.user_id),le=(ae==null?void 0:ae.name)||"Unknown";return{...ie,user_name:le,user_initials:le.split(" ").map(pe=>pe[0]).join("").toUpperCase().slice(0,2),has_voted:se.includes(ie.id),comment_count:de.get(ie.id)||0}})}}),C=Ot({mutationFn:async({title:R,description:$})=>{const{error:q}=await G.from("wishlist_items").insert({user_id:t.id,title:R,description:$});if(q)throw q},onSuccess:()=>{n.invalidateQueries({queryKey:["wishlist-items"]}),u(!1),f(""),_(""),s({title:"Idea submitted!",description:"Your idea has been added to the wishlist."})},onError:R=>{s({title:"Error",description:R.message,variant:"destructive"})}}),A=Ot({mutationFn:async({itemId:R,hasVoted:$})=>{if($){const{error:q}=await G.from("wishlist_votes").delete().eq("item_id",R).eq("user_id",t.id);if(q)throw q;return{itemId:R,wasAdded:!1}}else{const{error:q}=await G.from("wishlist_votes").insert({item_id:R,user_id:t.id});if(q)throw q;return{itemId:R,wasAdded:!0}}},onSuccess:async R=>{if(n.invalidateQueries({queryKey:["wishlist-items"]}),R!=null&&R.wasAdded){const $=w.find(U=>U.id===R.itemId),q=(($==null?void 0:$.vote_count)||0)+1;G.functions.invoke("wishlist-notify",{body:{itemId:R.itemId,voteCount:q}}).catch(console.error)}},onError:R=>{s({title:"Error",description:R.message,variant:"destructive"})}}),I=w.filter(R=>R.title.toLowerCase().includes(a.toLowerCase())||R.description.toLowerCase().includes(a.toLowerCase())),L=()=>{if(!p.trim()||!v.trim()){s({title:"Error",description:"Please fill in both title and description.",variant:"destructive"});return}C.mutate({title:p.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(s_,{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(vs,{open:d,onOpenChange:u,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Idea"]})}),e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{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(ve,{htmlFor:"title",children:"Title"}),e.jsx(Re,{id:"title",placeholder:"Give your idea a clear title...",value:p,onChange:R=>f(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Mr,{id:"description",placeholder:"Describe your idea in detail. What problem does it solve? How would it help agents?",value:v,onChange:R=>_(R.target.value),rows:4})]}),e.jsx(K,{onClick:L,className:"w-full",disabled:C.isPending,children:C.isPending?e.jsxs(e.Fragment,{children:[e.jsx(As,{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(fn,{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:R=>o(R.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Na,{value:l,onValueChange:R=>i(R),children:e.jsxs(va,{children:[e.jsx(ks,{value:"popular",children:"Most Popular"}),e.jsx(ks,{value:"latest",children:"Latest"}),e.jsx(ks,{value:"trending",children:"Trending"})]})})})]}),e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsx(K,{variant:b?"default":"outline",size:"sm",onClick:()=>j(!b),children:b?"Show All Ideas":"My Ideas"})}),N?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(As,{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(s_,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No ideas yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Be the first to submit an idea!"}),e.jsxs(K,{onClick:()=>u(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Idea"]})]}):e.jsx("div",{className:"space-y-3",children:I.map(R=>e.jsx("div",{className:"bg-card border rounded-lg p-4 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>r(`/wishlist/${R.id}`),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:$=>{$.stopPropagation(),A.mutate({itemId:R.id,hasVoted:R.has_voted||!1})},className:Pt("flex flex-col items-center justify-center min-w-[50px] py-2 px-3 rounded-lg border transition-colors",R.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(Vd,{className:Pt("h-4 w-4",R.has_voted&&"fill-current")}),e.jsx("span",{className:"text-sm font-semibold",children:R.vote_count})]}),e.jsx(gn,{className:"h-10 w-10 bg-primary/20",children:e.jsx(xn,{className:"bg-primary/20 text-primary text-sm font-medium",children:R.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:R.title}),e.jsx(at,{className:Pt("text-xs",lEe[R.status].color),children:lEe[R.status].label})]}),e.jsx("p",{className:"text-muted-foreground text-sm line-clamp-2",children:R.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:R.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(R.created_at).toLocaleDateString()})]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(oo,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:R.comment_count})]})]})},R.id))})]})})}const cEe={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 Fzt(){const{itemId:t}=Mo(),s=Dr(),{user:r}=Gs(),{toast:n}=Ia(),a=ns(),[o,l]=S.useState(""),{data:i=!1}=Ct({queryKey:["user-is-admin",r==null?void 0:r.id],queryFn:async()=>{if(!r)return!1;const{data:w,error:N}=await G.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!N&&!!w},enabled:!!r}),{data:d,isLoading:u}=Ct({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:w,error:N}=await G.from("wishlist_items").select("*").eq("id",t).single();if(N)throw N;const{data:C}=await G.from("profiles").select("name").eq("id",w.user_id).single();let A=!1;if(r){const{data:I}=await G.from("wishlist_votes").select("id").eq("item_id",t).eq("user_id",r.id).maybeSingle();A=!!I}return{...w,user_name:(C==null?void 0:C.name)||"Unknown",user_initials:((C==null?void 0:C.name)||"U").split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),has_voted:A}}}),{data:p=[],isLoading:f}=Ct({queryKey:["wishlist-comments",t],queryFn:async()=>{const{data:w,error:N}=await G.from("wishlist_comments").select("*").eq("item_id",t).order("created_at",{ascending:!0});if(N)throw N;const C=[...new Set((w==null?void 0:w.map(L=>L.user_id))||[])],{data:A}=await G.from("profiles").select("id, name").in("id",C),I=new Map((A==null?void 0:A.map(L=>[L.id,L]))||[]);return w==null?void 0:w.map(L=>{const R=I.get(L.user_id),$=(R==null?void 0:R.name)||"Unknown";return{...L,user_name:$,user_initials:$.split(" ").map(q=>q[0]).join("").toUpperCase().slice(0,2)}})}}),v=Ot({mutationFn:async w=>{if(w){const{error:N}=await G.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 G.from("wishlist_votes").insert({item_id:t,user_id:r.id});if(N)throw N;return{wasAdded:!0}}},onSuccess:async w=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),w!=null&&w.wasAdded&&d){const N=(d.vote_count||0)+1;G.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:N}}).catch(console.error)}},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),_=Ot({mutationFn:async w=>{const{error:N}=await G.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:w});if(N)throw N},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),b=Ot({mutationFn:async w=>{const{error:N}=await G.from("wishlist_comments").delete().eq("id",w);if(N)throw N},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),n({title:"Comment deleted"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),j=()=>{o.trim()&&_.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(K,{variant:"ghost",size:"sm",onClick:()=>s("/wishlist"),className:"mb-4",children:[e.jsx(Ua,{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:Pt("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(Vd,{className:Pt("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(at,{className:Pt("text-xs",cEe[d.status].color),children:cEe[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(gn,{className:"h-6 w-6",children:e.jsx(xn,{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 (",p.length,")"]}),e.jsxs("div",{className:"flex gap-3 mb-6",children:[e.jsx(Cae,{placeholder:i?"Share your thoughts... Use # to link templates":"Share your thoughts on this idea...",value:o,onChange:l,minHeight:"60px",mentionFormat:"encoded",enableTemplateMentions:i}),e.jsx(K,{onClick:j,disabled:!o.trim()||_.isPending,size:"icon",className:"h-auto",children:_.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(ka,{className:"h-4 w-4"})})]}),f?e.jsx("div",{className:"space-y-4",children:[1,2].map(w=>e.jsx(gs,{className:"h-20 w-full"},w))}):p.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No comments yet. Be the first to share your thoughts!"}):e.jsx("div",{className:"space-y-4",children:p.map(w=>e.jsxs("div",{className:"flex gap-3 p-3 bg-muted/30 rounded-lg",children:[e.jsx(gn,{className:"h-8 w-8",children:e.jsx(xn,{className:"bg-primary/20 text-primary text-xs",children:w.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-sm",children:w.user_name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(w.created_at).toLocaleDateString()})]}),e.jsx(lwe,{content:w.content,className:"text-sm text-foreground"})]}),(r==null?void 0:r.id)===w.user_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>b.mutate(w.id),children:e.jsx(br,{className:"h-4 w-4"})})]},w.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(K,{variant:"link",onClick:()=>s("/wishlist"),children:"Go back to Wishlist"})]})})}const dEe={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"}},uEe=["open","under_review","planned","in_progress","launched","declined"];function zzt(){const{toast:t}=Ia(),s=Dr(),r=ns(),[n,a]=S.useState(""),[o,l]=S.useState("all"),[i,d]=S.useState(!1),[u,p]=S.useState(null),{data:f=[],isLoading:v}=Ct({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:N,error:C}=await G.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(C)throw C;const A=[...new Set((N==null?void 0:N.map(U=>U.user_id))||[])],{data:I}=await G.from("profiles").select("id, name, email").in("id",A),L=new Map((I==null?void 0:I.map(U=>[U.id,U]))||[]),R=(N==null?void 0:N.map(U=>U.id))||[],{data:$}=await G.from("wishlist_comments").select("item_id").in("item_id",R),q=new Map;return $==null||$.forEach(U=>{q.set(U.item_id,(q.get(U.item_id)||0)+1)}),N==null?void 0:N.map(U=>{const V=L.get(U.user_id);return{...U,user_name:(V==null?void 0:V.name)||"Unknown",user_email:(V==null?void 0:V.email)||"",comment_count:q.get(U.id)||0}})}}),_=Ot({mutationFn:async({itemId:N,status:C})=>{const{error:A}=await G.from("wishlist_items").update({status:C}).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=Ot({mutationFn:async N=>{const{error:C}=await G.from("wishlist_items").delete().eq("id",N);if(C)throw C},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),d(!1),p(null),t({title:"Item deleted!"})},onError:N=>{t({title:"Error",description:N.message,variant:"destructive"})}}),j=f.filter(N=>{const C=N.title.toLowerCase().includes(n.toLowerCase())||N.description.toLowerCase().includes(n.toLowerCase())||N.user_name.toLowerCase().includes(n.toLowerCase()),A=o==="all"||N.status===o;return C&&A}),w={total:f.length,open:f.filter(N=>N.status==="open").length,inProgress:f.filter(N=>N.status==="in_progress").length,launched:f.filter(N=>N.status==="launched").length,highVotes:f.filter(N=>N.vote_count>=10).length};return e.jsx(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(K,{variant:"ghost",size:"icon",onClick:()=>s("/admin"),children:e.jsx(Ua,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Wishlist Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Review and manage community ideas"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Ideas"}),e.jsx("p",{className:"text-2xl font-bold",children:w.total})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Open"}),e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:w.open})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"In Progress"}),e.jsx("p",{className:"text-2xl font-bold text-orange-600",children:w.inProgress})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Launched"}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:w.launched})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"10+ Votes"}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:w.highVotes})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(fn,{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(sr,{placeholder:"Filter by status"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Statuses"}),uEe.map(N=>e.jsx(At,{value:N,children:dEe[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(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-[60px]",children:"Votes"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Submitted By"}),e.jsx(jt,{className:"hidden sm:table-cell",children:"Comments"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Pn,{children:j.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):j.map(N=>e.jsxs(js,{className:Pt(N.vote_count>=10&&"bg-primary/5"),children:[e.jsx(lt,{children:e.jsx(at,{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:C=>_.mutate({itemId:N.id,status:C}),children:[e.jsx(Js,{className:"w-[140px] h-8",children:e.jsx(sr,{})}),e.jsx(er,{children:uEe.map(C=>e.jsx(At,{value:C,children:dEe[C].label},C))})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/wishlist/${N.id}`,"_blank"),children:e.jsx(sn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{p(N.id),d(!0)},children:e.jsx(br,{className:"h-4 w-4"})})]})})]},N.id))})]})}),e.jsx(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Delete Wishlist Item"})}),e.jsx("p",{className:"text-muted-foreground",children:"Are you sure you want to delete this idea? This will also delete all votes and comments."}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:()=>u&&b.mutate(u),disabled:b.isPending,children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function Bzt(){const{user:t}=Gs(),[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState(!1),[f,v]=S.useState(null),[_,b]=S.useState(""),[j,w]=S.useState(""),[N,C]=S.useState(""),[A,I]=S.useState(""),[L,R]=S.useState(""),[$,q]=S.useState(!1),[U,V]=S.useState(""),[X,se]=S.useState("once"),[te,Y]=S.useState([]),[de,ie]=S.useState([]),[ae,le]=S.useState(!1),[pe,be]=S.useState(!1),[ye,we]=S.useState([]),[ke,Ze]=S.useState({total:0,dismissed:0});S.useEffect(()=>{_e()},[]);const _e=async()=>{const{data:Ke,error:ct}=await G.from("levelup_briefs").select("*").order("created_at",{ascending:!1});ct?(fe.error("Failed to fetch briefs"),console.error(ct)):r(Ke||[]),a(!1)},Ce=()=>{b(""),w(""),C(""),I(""),R(""),q(!1),V(new Date().toISOString().slice(0,16)),se("once"),Y([]),ie([]),d(null)},Te=()=>{Ce(),l(!0)},Fe=async Ke=>{d(Ke),b(Ke.title),w(Ke.description||""),C(Ke.video_url||""),I(Ke.graphic_url||""),R(Ke.graphic_link_url||""),q(Ke.is_published),V(Ke.publish_date.slice(0,16)),se(Ke.show_frequency);const{data:ct}=await G.from("levelup_brief_links").select("*").eq("brief_id",Ke.id).order("sort_order");Y((ct==null?void 0:ct.map(Ve=>({title:Ve.title,url:Ve.url})))||[]);const{data:Ue}=await G.from("levelup_brief_polls").select("*").eq("brief_id",Ke.id).order("sort_order");if(Ue){const Ve=[];for(const Je of Ue){const{data:Rt}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",Je.id).order("sort_order");Ve.push({question:Je.question,poll_type:Je.poll_type,options:(Rt==null?void 0:Rt.map($t=>$t.option_text))||[]})}ie(Ve)}l(!0)},Ae=async Ke=>{var Ue;const ct=(Ue=Ke.target.files)==null?void 0:Ue[0];if(ct){le(!0);try{const Ve=await G.functions.invoke("bunny-upload",{body:{action:"create",title:ct.name.replace(/\.[^/.]+$/,"")}});if(Ve.error)throw Ve.error;const{videoId:Je,libraryId:Rt}=Ve.data,$t=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Je}});if($t.error)throw $t.error;const{uploadUrl:ls,apiKey:Qt}=$t.data,rs=new XMLHttpRequest;await new Promise((ir,vt)=>{rs.upload.addEventListener("progress",Cs=>{if(Cs.lengthComputable){const or=Math.round(Cs.loaded/Cs.total*100);console.log("Upload progress:",or)}}),rs.addEventListener("load",()=>{rs.status>=200&&rs.status<300?ir():vt(new Error(`Upload failed with status ${rs.status}`))}),rs.addEventListener("error",()=>vt(new Error("Upload failed"))),rs.open("PUT",ls),rs.setRequestHeader("AccessKey",Qt),rs.send(ct)});const as=`https://player.mediadelivery.net/embed/${Rt}/${Je}`;C(as),fe.success("Video uploaded successfully! It may take a few minutes to process.")}catch(Ve){console.error("Upload error:",Ve),fe.error("Failed to upload video")}finally{le(!1)}}},We=async()=>{if(!_.trim()){fe.error("Title is required");return}try{let Ke;if(i){const{error:ct}=await G.from("levelup_briefs").update({title:_,description:j||null,video_url:N||null,graphic_url:A||null,graphic_link_url:L||null,is_published:$,publish_date:U,show_frequency:X}).eq("id",i.id);if(ct)throw ct;Ke=i.id,await G.from("levelup_brief_links").delete().eq("brief_id",Ke);const{data:Ue}=await G.from("levelup_brief_polls").select("id").eq("brief_id",Ke);if(Ue)for(const Ve of Ue)await G.from("levelup_brief_poll_options").delete().eq("poll_id",Ve.id);await G.from("levelup_brief_polls").delete().eq("brief_id",Ke)}else{const{data:ct,error:Ue}=await G.from("levelup_briefs").insert({title:_,description:j||null,video_url:N||null,graphic_url:A||null,graphic_link_url:L||null,is_published:$,publish_date:U,show_frequency:X,created_by:t==null?void 0:t.id}).select().single();if(Ue)throw Ue;Ke=ct.id}if(te.length>0){const ct=te.map((Ue,Ve)=>({brief_id:Ke,title:Ue.title,url:Ue.url,sort_order:Ve}));await G.from("levelup_brief_links").insert(ct)}for(let ct=0;ct0){const Rt=Ue.options.map(($t,ls)=>({poll_id:Ve.id,option_text:$t,sort_order:ls}));await G.from("levelup_brief_poll_options").insert(Rt)}}fe.success(i?"Brief updated":"Brief created"),l(!1),Ce(),_e()}catch(Ke){console.error("Error saving brief:",Ke),fe.error("Failed to save brief")}},ht=async Ke=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:ct}=await G.from("levelup_briefs").delete().eq("id",Ke);if(ct)throw ct;fe.success("Brief deleted"),_e()}catch(ct){console.error("Error deleting brief:",ct),fe.error("Failed to delete brief")}},De=async Ke=>{v(Ke);const{count:ct}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ke.id),{count:Ue}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ke.id).not("dismissed_at","is",null);Ze({total:ct||0,dismissed:Ue||0});const{data:Ve}=await G.from("levelup_brief_polls").select("*").eq("brief_id",Ke.id).order("sort_order");if(Ve){const Je=[];for(const Rt of Ve){const{data:$t}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",Rt.id).order("sort_order"),{data:ls}=await G.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",Rt.id),Qt=[...new Set((ls==null?void 0:ls.map(Cs=>Cs.user_id))||[])];let rs={};if(Qt.length>0){const{data:Cs}=await G.from("profiles").select("id, name, email").in("id",Qt);Cs&&Cs.forEach(or=>{rs[or.id]=or.name||or.email||"Unknown"})}const as=(ls||[]).map(Cs=>({optionId:Cs.option_id,userName:rs[Cs.user_id]||"Unknown",userId:Cs.user_id})),ir={};let vt=0;$t&&$t.forEach(Cs=>{const or=(ls==null?void 0:ls.filter(Ar=>Ar.option_id===Cs.id).length)||0;ir[Cs.id]=or,vt+=or}),Je.push({...Rt,options:$t||[],results:ir,respondents:as,totalResponses:Rt.poll_type==="single"?new Set(ls==null?void 0:ls.map(Cs=>Cs.user_id)).size:vt})}we(Je)}p(!0)},Dt=()=>{Y([...te,{title:"",url:""}])},he=(Ke,ct,Ue)=>{const Ve=[...te];Ve[Ke][ct]=Ue,Y(Ve)},Qe=Ke=>{Y(te.filter((ct,Ue)=>Ue!==Ke))},ot=()=>{ie([...de,{question:"",poll_type:"single",options:["",""]}])},rt=(Ke,ct)=>{const Ue=[...de];Ue[Ke].question=ct,ie(Ue)},Ne=(Ke,ct)=>{const Ue=[...de];Ue[Ke].poll_type=ct,ie(Ue)},it=Ke=>{const ct=[...de];ct[Ke].options.push(""),ie(ct)},qe=(Ke,ct,Ue)=>{const Ve=[...de];Ve[Ke].options[ct]=Ue,ie(Ve)},Xe=(Ke,ct)=>{const Ue=[...de];Ue[Ke].options=Ue[Ke].options.filter((Ve,Je)=>Je!==ct),ie(Ue)},$e=Ke=>{ie(de.filter((ct,Ue)=>Ue!==Ke))};return e.jsxs(Ms,{title:"The LevelUp Brief",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"The LevelUp Brief",description:"Create engaging popup briefs for your agents",children:e.jsxs(K,{onClick:Te,children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Frequency"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:n?e.jsx(js,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(Ke=>e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium",children:Ke.title}),e.jsx(lt,{children:e.jsx(at,{variant:Ke.is_published?"default":"secondary",children:Ke.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"capitalize",children:Ke.show_frequency.replace("_"," ")}),e.jsx(lt,{children:ws(new Date(Ke.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(K,{variant:"ghost",size:"icon",onClick:()=>De(Ke),children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Fe(Ke),children:e.jsx(Oc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ht(Ke.id),children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]})})]},Ke.id))})]})})})]}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:i?"Edit Brief":"Create New Brief"})}),e.jsxs(Na,{defaultValue:"content",className:"w-full",children:[e.jsxs(va,{className:"grid w-full grid-cols-4",children:[e.jsx(ks,{value:"content",children:"Content"}),e.jsx(ks,{value:"media",children:"Media"}),e.jsx(ks,{value:"links",children:"Links"}),e.jsx(ks,{value:"polls",children:"Polls"})]}),e.jsxs(zs,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Title *"}),e.jsx(Re,{value:_,onChange:Ke=>b(Ke.target.value),placeholder:"What's happening at LevelUp..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Qg,{content:j,onChange:Ke=>w(Ke),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(ve,{children:"Publish Date"}),e.jsx(Re,{type:"datetime-local",value:U,onChange:Ke=>V(Ke.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Show Frequency"}),e.jsxs(tr,{value:X,onValueChange:se,children:[e.jsx(Js,{children:e.jsx(sr,{})}),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(Br,{checked:$,onCheckedChange:q}),e.jsx(ve,{children:"Publish immediately"})]})]}),e.jsxs(zs,{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(ve,{children:"Upload Video to Bunny.net"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Re,{type:"file",accept:"video/*",onChange:Ae,disabled:ae})}),ae&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Or paste embed URL"}),e.jsx(Re,{value:N,onChange:Ke=>C(Ke.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(ve,{children:"Upload Image"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Re,{type:"file",accept:"image/*",onChange:async Ke=>{var Ue;const ct=(Ue=Ke.target.files)==null?void 0:Ue[0];if(ct){be(!0);try{const Ve=ct.name.split(".").pop(),Je=`brief-graphics/${Date.now()}.${Ve}`,{error:Rt}=await G.storage.from("banner-images").upload(Je,ct,{upsert:!0});if(Rt)throw Rt;const{data:$t}=G.storage.from("banner-images").getPublicUrl(Je);I($t.publicUrl),fe.success("Image uploaded!")}catch(Ve){console.error(Ve),fe.error("Failed to upload image")}finally{be(!1)}}},disabled:pe})}),pe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Or paste Image URL"}),e.jsx(Re,{value:A,onChange:Ke=>I(Ke.target.value),placeholder:"https://example.com/image.png"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Click-through Link (optional)"}),e.jsx(Re,{value:L,onChange:Ke=>R(Ke.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(zs,{value:"links",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ve,{children:"Quick Links"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:Dt,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),te.map((Ke,ct)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(Re,{value:Ke.title,onChange:Ue=>he(ct,"title",Ue.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(Re,{value:Ke.url,onChange:Ue=>he(ct,"url",Ue.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Qe(ct),children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]},ct)),te.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No links added yet"})]}),e.jsxs(zs,{value:"polls",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ve,{children:"Polls"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ot,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),de.map((Ke,ct)=>e.jsx(Ee,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(Re,{value:Ke.question,onChange:Ue=>rt(ct,Ue.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs(tr,{value:Ke.poll_type,onValueChange:Ue=>Ne(ct,Ue),children:[e.jsx(Js,{className:"w-32",children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"single",children:"Single"}),e.jsx(At,{value:"multi",children:"Multi-select"})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$e(ct),children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"space-y-2 pl-4",children:[Ke.options.map((Ue,Ve)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:Ue,onChange:Je=>qe(ct,Ve,Je.target.value),placeholder:`Option ${Ve+1}`}),Ke.options.length>2&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Xe(ct,Ve),children:e.jsx(br,{className:"h-4 w-4 text-muted-foreground"})})]},Ve)),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>it(ct),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},ct)),de.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls added yet"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:We,children:i?"Update Brief":"Create Brief"})]})]})}),e.jsx(vs,{open:u,onOpenChange:p,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsx(Ss,{children:e.jsxs(Ns,{children:["Results: ",f==null?void 0:f.title]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{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(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{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(Ke=>e.jsxs(Ee,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:Ke.question}),e.jsx("div",{className:"space-y-2",children:Ke.options.map(ct=>{const Ue=Ke.results[ct.id]||0,Ve=Ke.totalResponses>0?Math.round(Ue/Ke.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:ct.option_text}),e.jsxs("span",{className:"text-muted-foreground",children:[Ue," (",Ve,"%)"]})]}),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:`${Ve}%`}})}),Ue>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(Ke.respondents||[]).filter(Je=>Je.optionId===ct.id).map((Je,Rt)=>e.jsx(at,{variant:"secondary",className:"text-xs font-normal",children:Je.userName},Rt))})]},ct.id)})})]},Ke.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const $zt=()=>{const{user:t}=Gs(),{toast:s}=Ia(),r=ns(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=S.useState(null),[f,v]=S.useState(""),{data:_=[],isLoading:b}=Ct({queryKey:["additional-services-admin"],queryFn:async()=>{const{data:L,error:R}=await G.from("additional_services").select("*").order("publish_date",{ascending:!1});if(R)throw R;return L}}),j=Ot({mutationFn:async L=>{let R=L.existingImageUrl;if(L.image){const q=L.image.name.split(".").pop(),U=`${Date.now()}-${Math.random().toString(36).substring(7)}.${q}`,{error:V}=await G.storage.from("service-images").upload(U,L.image);if(V)throw V;const{data:X}=G.storage.from("service-images").getPublicUrl(U);R=X.publicUrl}const $={name:L.item.name,description:L.item.description||null,preview_image_url:R,signup_link_url:L.item.signup_link_url,publish_date:L.item.publish_date?new Date(L.item.publish_date).toISOString():new Date().toISOString(),is_published:L.item.is_published,created_by:t==null?void 0:t.id};if(L.itemId){const{error:q}=await G.from("additional_services").update($).eq("id",L.itemId);if(q)throw q}else{const{error:q}=await G.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"})}}),w=Ot({mutationFn:async L=>{const{error:R}=await G.from("additional_services").delete().eq("id",L);if(R)throw R},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:"Service deleted"})},onError:L=>{s({title:"Error deleting service",description:L.message,variant:"destructive"})}}),N=()=>{d({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),v(""),l(null)},C=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 R=($=L.target.files)==null?void 0:$[0];R&&(p(R),v(URL.createObjectURL(R)))},I=L=>{if(L.preventDefault(),!i.name.trim()){s({title:"Name is required",variant:"destructive"});return}if(!i.signup_link_url.trim()){s({title:"Signup link URL is required",variant:"destructive"});return}j.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(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(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{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(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{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(vs,{open:n,onOpenChange:L=>{a(L),L||N()},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Service"]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{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(ve,{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(ve,{children:"Description"}),e.jsx(Qg,{content:i.description,onChange:L=>d({...i,description:L}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(ve,{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(Br,{id:"is_published",checked:i.is_published,onCheckedChange:L=>d({...i,is_published:L})}),e.jsx(ve,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Preview Image"}),f?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:f,alt:"Preview",className:"w-full max-h-48 object-contain rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{p(null),v("")},children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(Jo,{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(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:j.isPending,children:j.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{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(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-16",children:"Preview"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Signup Link"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:_.map(L=>e.jsxs(js,{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(Jo,{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(sn,{className:"h-3 w-3"}),"Link"]})}),e.jsx(lt,{children:new Date(L.publish_date).toLocaleDateString()}),e.jsx(lt,{children:e.jsx(at,{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(K,{variant:"ghost",size:"icon",onClick:()=>C(L),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&w.mutate(L.id)},children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]})})]},L.id))})]})})})]})})};function qzt(){const{toast:t}=Ia(),[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});S.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:w,error:N}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(N)throw N;r(w.coupons||[])}catch(w){console.error("Error fetching coupons:",w),t({title:"Error",description:"Failed to load coupons",variant:"destructive"})}finally{a(!1)}},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 w={action:"create",name:u.name,duration:u.duration,promotion_code:u.promotionCode.trim()||void 0};u.discountType==="percent"?w.percent_off=parseFloat(u.percentOff):(w.amount_off=Math.round(parseFloat(u.amountOff)*100),w.currency="usd"),u.duration==="repeating"&&(w.duration_in_months=parseInt(u.durationInMonths));const{data:N,error:C}=await G.functions.invoke("stripe-manage-coupons",{body:w});if(C)throw C;t({title:"Success",description:"Coupon created successfully"}),d(!1),p({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""}),f()}catch(w){console.error("Error creating coupon:",w),t({title:"Error",description:w.message||"Failed to create coupon",variant:"destructive"})}finally{l(!1)}},_=async w=>{if(confirm("Are you sure you want to delete this coupon?"))try{const{error:N}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:w}});if(N)throw N;t({title:"Success",description:"Coupon deleted successfully"}),f()}catch(N){console.error("Error deleting coupon:",N),t({title:"Error",description:N.message||"Failed to delete coupon",variant:"destructive"})}},b=w=>w.percent_off?`${w.percent_off}% off`:w.amount_off?`$${(w.amount_off/100).toFixed(2)} off`:"N/A",j=w=>{switch(w.duration){case"once":return"Once";case"forever":return"Forever";case"repeating":return`${w.duration_in_months} months`;default:return w.duration}};return e.jsx(Ms,{title:"Subscription Discounts",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"Subscription Discounts",description:"Create and manage discount coupons for subscriptions",children:e.jsxs(vs,{open:i,onOpenChange:d,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Coupon"]})}),e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{children:"Promotion Code (what users will type)"}),e.jsx(Re,{placeholder:"e.g., BROKERAGE50",value:u.promotionCode,onChange:w=>p({...u,promotionCode:w.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")}),className:"font-mono uppercase"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters and numbers only. This is the code users enter at checkout."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Coupon Name (internal label)"}),e.jsx(Re,{placeholder:"e.g., 50% Off Brokerage Launch",value:u.name,onChange:w=>p({...u,name:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Discount Type"}),e.jsxs(tr,{value:u.discountType,onValueChange:w=>{const N=w==="amount"&&u.duration==="forever"?"once":u.duration;p({...u,discountType:w,duration:N})},children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"percent",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(v5,{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(Kc,{className:"mr-2 h-4 w-4"}),"Fixed Amount Off"]})})]})]})]}),u.discountType==="percent"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Percent Off"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",min:"1",max:"100",placeholder:"20",value:u.percentOff,onChange:w=>p({...u,percentOff:w.target.value})}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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:w=>p({...u,amountOff:w.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Duration"}),e.jsxs(tr,{value:u.duration,onValueChange:w=>p({...u,duration:w}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),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(ve,{children:"Number of Months"}),e.jsx(Re,{type:"number",min:"1",placeholder:"3",value:u.durationInMonths,onChange:w=>p({...u,durationInMonths:w.target.value})})]}),e.jsx(K,{onClick:v,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Active Coupons"}),e.jsx(yr,{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(As,{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(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Promo Code"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Discount"}),e.jsx(jt,{children:"Duration"}),e.jsx(jt,{children:"Redemptions"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:s.map(w=>{var N;return e.jsxs(js,{children:[e.jsx(lt,{className:"font-mono font-medium",children:((N=w.promotion_codes)==null?void 0:N.length)>0?w.promotion_codes.join(", "):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),e.jsx(lt,{children:w.name||"-"}),e.jsx(lt,{children:b(w)}),e.jsx(lt,{children:j(w)}),e.jsx(lt,{children:w.times_redeemed}),e.jsx(lt,{children:e.jsx(at,{variant:w.valid?"default":"secondary",children:w.valid?"Active":"Inactive"})}),e.jsx(lt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(w.id),children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})})]},w.id)})})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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 Kme={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 Uzt(){const[t,s]=S.useState(""),[r,n]=S.useState("all"),[a,o]=S.useState(null),{data:l,isLoading:i,refetch:d}=Ct({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:b,error:j}=await G.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(j)throw j;return b}}),{data:u}=Ct({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:b,error:j}=await G.from("brokerages").select("*").order("name");if(j)throw j;return await Promise.all((b||[]).map(async N=>{const{data:C}=await G.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",N.id),{data:A}=await G.from("user_roles").select("user_id").eq("role","brokerage_manager"),I=(A==null?void 0:A.map($=>$.user_id))||[],L=(C==null?void 0:C.filter($=>I.includes($.id)))||[],R=(C==null?void 0:C.length)||0;return{...N,managers:L,agentCount:R}}))}}),p=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 j=Kme[b.subscription_product_id];return{status:(j==null?void 0:j.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"}},f=l==null?void 0:l.filter(b=>{var w,N;if(!(((w=b.name)==null?void 0:w.toLowerCase().includes(t.toLowerCase()))||((N=b.email)==null?void 0:N.toLowerCase().includes(t.toLowerCase()))))return!1;switch(p(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(_u,{title:"Subscription Management",description:"Track and manage all subscriptions",children:e.jsxs(K,{onClick:()=>d(),variant:"outline",size:"sm",children:[e.jsx(Po,{className:"h-4 w-4 mr-2"}),"Refresh"]})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Users"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:v.totalUsers})]})}),e.jsx(Ee,{className:"border-green-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(uf,{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(Ee,{className:"border-blue-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(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(Ee,{className:"border-purple-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bh,{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(Ee,{className:"border-orange-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Aa,{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(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l_,{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(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Aa,{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(Na,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsx(ks,{value:"users",children:"All Users"}),e.jsx(ks,{value:"brokerages",children:"Brokerages"})]}),e.jsxs(zs,{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(fn,{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(sr,{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(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"User"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Plan"}),e.jsx(jt,{children:"Brokerage"}),e.jsx(jt,{children:"End Date"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:i?e.jsx(js,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(f==null?void 0:f.length)===0?e.jsx(js,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):f==null?void 0:f.map(b=>{var N,C;const j=p(b),w=Kme[b.subscription_product_id];return e.jsxs(js,{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(at,{variant:j.variant,children:j.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":(w==null?void 0:w.name)||j.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:ws(new Date(b.subscription_end_date),"MMM d, yyyy")}):b.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",ws(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(K,{variant:"ghost",size:"sm",onClick:()=>_(b.stripe_customer_id),children:e.jsx(sn,{className:"h-4 w-4"})}),e.jsxs(vs,{children:[e.jsx(Ei,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",onClick:()=>o(b),children:"Details"})}),e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(at,{variant:j.variant,className:"mt-1",children:j.badge})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Plan"}),e.jsx("p",{className:"font-medium",children:b.is_grandfathered?"Grandfathered (Legacy)":b.brokerage_id&&!b.subscription_product_id?"Brokerage Subscription":(w==null?void 0:w.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:((C=b.brokerages)==null?void 0:C.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:ws(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:ws(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(K,{className:"w-full",onClick:()=>_(b.stripe_customer_id),children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},b.id)})})]})})})]}),e.jsx(zs,{value:"brokerages",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:u==null?void 0:u.map(b=>{var w,N;const j=(w=b.managers)==null?void 0:w.some(C=>C.subscription_status==="active"&&(C.subscription_product_id==="prod_Tc08MupgoVySDG"||C.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return e.jsxs(Ee,{children:[e.jsx(Lt,{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(Aa,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:b.name}),e.jsxs(yr,{children:[b.agentCount," agents"]})]})]}),e.jsx(at,{variant:j?"default":"outline",children:j?"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(C=>{const A=Kme[C.subscription_product_id];return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:C.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:C.email})]}),e.jsx("div",{className:"text-right",children:A?e.jsxs("div",{children:[e.jsx(at,{variant:"default",children:A.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:A.price})]}):e.jsx(at,{variant:"outline",children:"No Subscription"})})]},C.id)})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},b.id)})})})]})]})})}function Vzt(){const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(""),[l,i]=S.useState("all"),[d,u]=S.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});S.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:b,error:j}=await G.from("referrals").select(` *, referrer_brokerage:brokerages!referrer_brokerage_id(name), referred_brokerage:brokerages!referred_brokerage_id(name), referred_user:profiles!referred_user_id(name, email) `).order("created_at",{ascending:!1});if(j)throw j;s(b||[]);const w=(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,C=(b==null?void 0:b.filter(A=>A.status==="cancelled").length)||0;u({total:(b==null?void 0:b.length)||0,qualified:w,pending:N,cancelled:C,totalDiscounts:w*25})}catch(b){console.error("Error fetching referrals:",b),fe.error("Failed to load referrals")}finally{n(!1)}},f=async()=>{try{fe.loading("Processing qualifications...");const{error:b}=await G.functions.invoke("process-referral-qualifications");if(b)throw b;fe.dismiss(),fe.success("Qualifications processed successfully"),p()}catch(b){fe.dismiss(),console.error("Error processing qualifications:",b),fe.error("Failed to process qualifications")}},v=t.filter(b=>{var N,C,A,I,L,R;const j=((C=(N=b.referrer_brokerage)==null?void 0:N.name)==null?void 0:C.toLowerCase().includes(a.toLowerCase()))||((I=(A=b.referred_brokerage)==null?void 0:A.name)==null?void 0:I.toLowerCase().includes(a.toLowerCase()))||((R=(L=b.referred_user)==null?void 0:L.email)==null?void 0:R.toLowerCase().includes(a.toLowerCase())),w=l==="all"||b.status===l;return j&&w}),_=b=>{switch(b){case"qualified":return e.jsxs(at,{className:"bg-green-100 text-green-800",children:[e.jsx(gi,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(at,{variant:"secondary",children:[e.jsx(Tn,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(at,{variant:"destructive",children:[e.jsx(kc,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(at,{children:b})}};return e.jsx(Ms,{title:"Referral Program",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"Referral Program",description:"Track and manage brokerage referrals",children:e.jsxs(K,{onClick:f,variant:"outline",children:[e.jsx(Po,{className:"h-4 w-4 mr-2"}),"Process Qualifications"]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Referrals"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gi,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.qualified}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(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(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kc,{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(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Kc,{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(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"All Referrals"}),e.jsx(yr,{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(fn,{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(sr,{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(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Referrer"}),e.jsx(jt,{children:"Referred"}),e.jsx(jt,{children:"Signup Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Qualified Date"}),e.jsx(jt,{children:"Discount"})]})}),e.jsx(Pn,{children:v.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):v.map(b=>{var j,w,N,C;return e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium",children:((j=b.referrer_brokerage)==null?void 0:j.name)||"Unknown"}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{children:((w=b.referred_brokerage)==null?void 0:w.name)||((N=b.referred_user)==null?void 0:N.name)||"Pending setup"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(C=b.referred_user)==null?void 0:C.email})]})}),e.jsx(lt,{children:ws(new Date(b.signup_date),"MMM d, yyyy")}),e.jsx(lt,{children:_(b.status)}),e.jsx(lt,{children:b.qualified_date?ws(new Date(b.qualified_date),"MMM d, yyyy"):"-"}),e.jsx(lt,{children:b.discount_applied?e.jsx(at,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},b.id)})})]})]})]})]})})}const Zme=[{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"}],Hzt=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function Wzt(){const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(!1),[l,i]=S.useState(null),[d,u]=S.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});S.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:C,error:A}=await G.from("onboarding_checklist_items").select("*").order("target_role").order("sort_order");if(A)throw A;s(C||[])}catch(C){console.error("Error fetching checklist items:",C),fe.error("Failed to load checklist items")}finally{n(!1)}},f=()=>{i(null),u({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0}),o(!0)},v=C=>{i(C),u({title:C.title,description:C.description||"",action_type:C.action_type,target_role:C.target_role,is_active:C.is_active}),o(!0)},_=async()=>{if(!d.title.trim()){fe.error("Title is required");return}try{if(l){const{error:C}=await G.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(C)throw C;fe.success("Checklist item updated")}else{const C=t.filter(I=>I.target_role===d.target_role).reduce((I,L)=>Math.max(I,L.sort_order),-1),{error:A}=await G.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:C+1});if(A)throw A;fe.success("Checklist item created")}o(!1),p()}catch(C){console.error("Error saving checklist item:",C),fe.error("Failed to save checklist item")}},b=async C=>{if(confirm("Are you sure you want to delete this checklist item?"))try{const{error:A}=await G.from("onboarding_checklist_items").delete().eq("id",C);if(A)throw A;fe.success("Checklist item deleted"),p()}catch(A){console.error("Error deleting checklist item:",A),fe.error("Failed to delete checklist item")}},j=async C=>{try{const{error:A}=await G.from("onboarding_checklist_items").update({is_active:!C.is_active}).eq("id",C.id);if(A)throw A;fe.success(C.is_active?"Item deactivated":"Item activated"),p()}catch(A){console.error("Error toggling item:",A),fe.error("Failed to update item")}},w=t.filter(C=>C.target_role==="brokerage_manager"),N=t.filter(C=>C.target_role==="agent");return e.jsxs(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(K,{onClick:f,className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Item"]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(at,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx(Oe,{children:w.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-12",children:"#"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Action Type"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:w.map((C,A)=>{var I;return e.jsxs(js,{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:C.title}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:C.description})]})}),e.jsx(lt,{children:e.jsx(at,{variant:"outline",children:((I=Zme.find(L=>L.value===C.action_type))==null?void 0:I.label)||C.action_type})}),e.jsx(lt,{children:e.jsx(Br,{checked:C.is_active,onCheckedChange:()=>j(C)})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>v(C),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(C.id),children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(at,{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(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-12",children:"#"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Action Type"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:N.map((C,A)=>{var I;return e.jsxs(js,{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:C.title}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:C.description})]})}),e.jsx(lt,{children:e.jsx(at,{variant:"outline",children:((I=Zme.find(L=>L.value===C.action_type))==null?void 0:I.label)||C.action_type})}),e.jsx(lt,{children:e.jsx(Br,{checked:C.is_active,onCheckedChange:()=>j(C)})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>v(C),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(C.id),children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]})]}),e.jsx(vs,{open:a,onOpenChange:o,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{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(ve,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:d.title,onChange:C=>u({...d,title:C.target.value}),placeholder:"e.g., Watch your first academy video"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Mr,{id:"description",value:d.description,onChange:C=>u({...d,description:C.target.value}),placeholder:"Optional description for the checklist item",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Target Role"}),e.jsxs(tr,{value:d.target_role,onValueChange:C=>u({...d,target_role:C}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:Hzt.map(C=>e.jsx(At,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Action Type"}),e.jsxs(tr,{value:d.action_type,onValueChange:C=>u({...d,action_type:C}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:Zme.map(C=>e.jsx(At,{value:C.value,children:C.label},C.value))})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"is_active",checked:d.is_active,onCheckedChange:C=>u({...d,is_active:C})}),e.jsx(ve,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:_,children:l?"Save Changes":"Create Item"})]})]})})]})}function Gzt(){const[t,s]=S.useState(""),[r,n]=S.useState("all"),[a,o]=S.useState("name"),[l,i]=S.useState("asc"),[d,u]=S.useState(""),[p,f]=S.useState(""),[v,_]=S.useState(""),[b,j]=S.useState(""),{data:w}=Ct({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:V,error:X}=await G.from("brokerages").select("id, name").order("name");if(X)throw X;return V}}),N=async V=>{let se=[],te=0,Y=!0;for(;Y;){const{data:de,error:ie}=await V(te,te+1e3-1);if(ie)throw ie;de&&de.length>0?(se=[...se,...de],te+=1e3,Y=de.length===1e3):Y=!1}return se},{data:C,isLoading:A}=Ct({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const V=await N((Fe,Ae)=>G.from("profiles").select("id, name, email, brokerage_id, created_at").range(Fe,Ae)),{data:X}=await G.from("brokerages").select("id, name"),se=new Map((X==null?void 0:X.map(Fe=>[Fe.id,Fe.name]))||[]),[{data:te},{data:Y},{data:de},{data:ie},{data:ae},{data:le},{data:pe}]=await Promise.all([G.rpc("get_admin_contact_counts"),G.rpc("get_admin_video_counts"),G.rpc("get_admin_popby_counts"),G.rpc("get_admin_listing_counts"),G.rpc("get_admin_deal_counts"),G.rpc("get_admin_portal_counts"),G.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 we=new Map;de==null||de.forEach(Fe=>we.set(Fe.owner_user_id,Fe.popby_count));const ke=new Map;ie==null||ie.forEach(Fe=>ke.set(Fe.agent_id,Fe.listing_count));const Ze=new Map;ae==null||ae.forEach(Fe=>Ze.set(Fe.owner_user_id,Fe.deal_count));const _e=new Map;le==null||le.forEach(Fe=>_e.set(Fe.owner_user_id,{total:Fe.portal_count,active:Fe.active_portal_count}));const Ce=new Map;return pe==null||pe.forEach(Fe=>Ce.set(Fe.owner_user_id,{total:Fe.card_count,sent:Fe.sent_card_count,views:Fe.total_card_views})),V.map(Fe=>{const Ae=_e.get(Fe.id),We=Ce.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:we.get(Fe.id)||0,listing_count:ke.get(Fe.id)||0,deal_count:Ze.get(Fe.id)||0,portal_count:(Ae==null?void 0:Ae.total)||0,active_portal_count:(Ae==null?void 0:Ae.active)||0,card_count:(We==null?void 0:We.total)||0,sent_card_count:(We==null?void 0:We.sent)||0,total_card_views:(We==null?void 0:We.views)||0,created_at:Fe.created_at}})}}),I=S.useMemo(()=>{if(!C)return[];let V=C.filter(X=>{const se=t.toLowerCase(),te=!t||X.name.toLowerCase().includes(se)||X.email.toLowerCase().includes(se),Y=r==="all"||r==="none"&&!X.brokerage_id||X.brokerage_id===r,de=parseInt(d)||0,ie=parseInt(p)||0,ae=parseInt(v)||0,le=parseInt(b)||0,pe=X.contact_count>=de&&X.video_count>=ie&&X.popby_count>=ae&&X.listing_count>=le;return te&&Y&&pe});return V.sort((X,se)=>{let te=0;return a==="name"?te=X.name.localeCompare(se.name):te=X[a]-se[a],l==="asc"?te:-te}),V},[C,t,r,a,l,d,p,v,b]),L=V=>{a===V?i(l==="asc"?"desc":"asc"):(o(V),i("desc"))},R=()=>{const V=["Name","Email","Brokerage","Contacts","Videos","Popbys","Listings","Deals","Portals (Active)","Cards Created","Cards Sent","Card Views"],X=I.map(ie=>[ie.name,ie.email,ie.brokerage_name||"None",ie.contact_count,ie.video_count,ie.popby_count,ie.listing_count,ie.deal_count,`${ie.portal_count} (${ie.active_portal_count})`,ie.card_count,ie.sent_card_count,ie.total_card_views]),se=[V.join(","),...X.map(ie=>ie.map(ae=>`"${ae}"`).join(","))].join(` `),te=new Blob([se],{type:"text/csv"}),Y=URL.createObjectURL(te),de=document.createElement("a");de.href=Y,de.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,de.click(),URL.revokeObjectURL(Y)},$=S.useMemo(()=>I.length?I.reduce((V,X)=>({contacts:V.contacts+X.contact_count,videos:V.videos+X.video_count,popbys:V.popbys+X.popby_count,listings:V.listings+X.listing_count,deals:V.deals+X.deal_count,portals:V.portals+X.portal_count,activePortals:V.activePortals+X.active_portal_count,cards:V.cards+X.card_count,sentCards:V.sentCards+X.sent_card_count,cardViews:V.cardViews+X.total_card_views}),{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0}):{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0},[I]),q=S.useMemo(()=>I.length?{portals:I.filter(V=>V.portal_count>0).length,cards:I.filter(V=>V.card_count>0).length}:{portals:0,cards:0},[I]),U=({field:V,children:X})=>e.jsx(jt,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>L(V),children:e.jsxs("div",{className:"flex items-center gap-1",children:[X,e.jsx(Hc,{className:`h-3 w-3 ${a===V?"text-primary":"text-muted-foreground"}`})]})});return e.jsx(QN,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ee,{className:"border-blue-500/20 bg-gradient-to-br from-blue-500/5 to-transparent",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(S0,{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(Ee,{className:"border-violet-500/20 bg-gradient-to-br from-violet-500/5 to-transparent",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(_r,{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(Ee,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(yr,{children:"View all users and their Agent OS usage metrics"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:R,children:[e.jsx(xi,{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(fn,{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:V=>s(V.target.value),className:"pl-9"})]})}),e.jsx("div",{children:e.jsxs(tr,{value:r,onValueChange:n,children:[e.jsxs(Js,{children:[e.jsx(Aa,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(sr,{placeholder:"Brokerage"})]}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Brokerages"}),e.jsx(At,{value:"none",children:"No Brokerage"}),w==null?void 0:w.map(V=>e.jsx(At,{value:V.id,children:V.name},V.id))]})]})}),e.jsx("div",{children:e.jsx(Re,{type:"number",placeholder:"Min contacts",value:d,onChange:V=>u(V.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Re,{type:"number",placeholder:"Min videos",value:p,onChange:V=>f(V.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Re,{type:"number",placeholder:"Min popbys",value:v,onChange:V=>_(V.target.value),min:"0"})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-8 text-sm",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children: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(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(U,{field:"name",children:"Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Brokerage"}),e.jsx(U,{field:"contact_count",children:"Contacts"}),e.jsx(U,{field:"video_count",children:"Videos"}),e.jsx(U,{field:"popby_count",children:"Popbys"}),e.jsx(U,{field:"listing_count",children:"Listings"}),e.jsx(U,{field:"deal_count",children:"Deals"}),e.jsx(U,{field:"portal_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(S0,{className:"h-3 w-3 text-blue-500"}),"Portals"]})}),e.jsx(U,{field:"card_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(_r,{className:"h-3 w-3 text-violet-500"}),"Cards"]})})]})}),e.jsx(Pn,{children:I.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No users found matching your filters"})}):I.map(V=>e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium",children:V.name}),e.jsx(lt,{className:"text-muted-foreground",children:V.email}),e.jsx(lt,{children:V.brokerage_name?e.jsx(at,{variant:"secondary",children:V.brokerage_name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(lt,{children:e.jsx(at,{variant:V.contact_count>0?"default":"outline",children:V.contact_count})}),e.jsx(lt,{children:e.jsx(at,{variant:V.video_count>0?"default":"outline",children:V.video_count})}),e.jsx(lt,{children:e.jsx(at,{variant:V.popby_count>0?"default":"outline",children:V.popby_count})}),e.jsx(lt,{children:e.jsx(at,{variant:V.listing_count>0?"default":"outline",children:V.listing_count})}),e.jsx(lt,{children:e.jsx(at,{variant:V.deal_count>0?"default":"outline",children:V.deal_count})}),e.jsx(lt,{children:V.portal_count>0?e.jsxs(nd,{children:[e.jsx(ad,{children:e.jsxs(at,{variant:"default",className:"bg-blue-600 hover:bg-blue-700",children:[V.portal_count,V.active_portal_count>0&&e.jsxs("span",{className:"ml-1 opacity-75",children:["(",V.active_portal_count," active)"]})]})}),e.jsxs(Wc,{children:[e.jsxs("p",{children:[V.portal_count," total portals"]}),e.jsxs("p",{children:[V.active_portal_count," currently active"]})]})]}):e.jsx(at,{variant:"outline",children:"0"})}),e.jsx(lt,{children:V.card_count>0?e.jsxs(nd,{children:[e.jsx(ad,{children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(at,{variant:"default",className:"bg-violet-600 hover:bg-violet-700",children:V.card_count}),V.sent_card_count>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600",children:[e.jsx(ka,{className:"h-3 w-3"}),V.sent_card_count]}),V.total_card_views>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[e.jsx(ya,{className:"h-3 w-3"}),V.total_card_views]})]})}),e.jsxs(Wc,{children:[e.jsxs("p",{children:[V.card_count," cards created"]}),e.jsxs("p",{children:[V.sent_card_count," sent"]}),e.jsxs("p",{children:[V.total_card_views," total views"]})]})]}):e.jsx(at,{variant:"outline",children:"0"})})]},V.id))})]})})]})]})]})})}function Kzt(){Ia(),ns();const[t,s]=S.useState("user-analytics"),{data:r}=Ct({queryKey:["admin-feature-flags"],queryFn:async()=>{const{data:_,error:b}=await G.from("feature_flags").select("*").order("key");if(b)throw b;return _}}),{data:n,isLoading:a}=Ct({queryKey:["admin-relationship-types"],queryFn:async()=>{const{data:_,error:b}=await G.from("relationship_types").select("*").order("sort_order");if(b)throw b;return _}}),{data:o,isLoading:l}=Ct({queryKey:["admin-action-types"],queryFn:async()=>{const{data:_,error:b}=await G.from("action_types").select("*").order("sort_order");if(b)throw b;return _}}),{data:i,isLoading:d}=Ct({queryKey:["admin-action-scripts"],queryFn:async()=>{const{data:_,error:b}=await G.from("action_scripts").select("*, action_type:action_types(*)");if(b)throw b;return _}}),{data:u,isLoading:p}=Ct({queryKey:["admin-touchpoint-plans"],queryFn:async()=>{const{data:_,error:b}=await G.from("touchpoint_plans").select("*").order("name");if(b)throw b;return _}}),{data:f,isLoading:v}=Ct({queryKey:["admin-popby-items"],queryFn:async()=>{const{data:_,error:b}=await G.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(_u,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),e.jsxs(Na,{value:t,onValueChange:s,children:[e.jsxs(va,{className:"grid w-full grid-cols-9",children:[e.jsxs(ks,{value:"user-analytics",className:"gap-2",children:[e.jsx(Xo,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Users"})]}),e.jsxs(ks,{value:"relationship-types",className:"gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Relationships"})]}),e.jsxs(ks,{value:"action-types",className:"gap-2",children:[e.jsx(Zn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Actions"})]}),e.jsxs(ks,{value:"scripts",className:"gap-2",children:[e.jsx(In,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),e.jsxs(ks,{value:"video-scripts",className:"gap-2",children:[e.jsx(lu,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Video Scripts"})]}),e.jsxs(ks,{value:"plans",className:"gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Plans"})]}),e.jsxs(ks,{value:"popbys",className:"gap-2",children:[e.jsx(io,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),e.jsxs(ks,{value:"settings",className:"gap-2",children:[e.jsx($l,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]}),e.jsxs(ks,{value:"feature-flags",className:"gap-2",children:[e.jsx(M0,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Flags"})]})]}),e.jsx(zs,{value:"user-analytics",className:"mt-6",children:e.jsx(Gzt,{})}),e.jsx(zs,{value:"relationship-types",className:"mt-6",children:e.jsx(Zzt,{types:n||[],isLoading:a})}),e.jsx(zs,{value:"action-types",className:"mt-6",children:e.jsx(Yzt,{types:o||[],isLoading:l})}),e.jsx(zs,{value:"scripts",className:"mt-6",children:e.jsx(Xzt,{scripts:i||[],actionTypes:o||[],isLoading:d})}),e.jsx(zs,{value:"video-scripts",className:"mt-6",children:e.jsx(t7t,{})}),e.jsx(zs,{value:"plans",className:"mt-6",children:e.jsx(Qzt,{plans:u||[],actionTypes:o||[],scripts:i||[],isLoading:p})}),e.jsx(zs,{value:"popbys",className:"mt-6",children:e.jsx(e7t,{items:f||[],isLoading:v})}),e.jsx(zs,{value:"settings",className:"mt-6",children:e.jsx(s7t,{})}),e.jsx(zs,{value:"feature-flags",className:"mt-6",children:e.jsx(Jzt,{flags:r||[]})})]})]})})}function Zzt({types:t,isLoading:s}){const{toast:r}=Ia(),n=ns(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=Ot({mutationFn:async p=>{if(p.id){const{error:f}=await G.from("relationship_types").update({name:p.name,description:p.description,icon:p.icon}).eq("id",p.id);if(f)throw f}else{const{error:f}=await G.from("relationship_types").insert([{name:p.name,description:p.description,icon:p.icon,sort_order:t.length}]);if(f)throw f}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-relationship-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:p=>{r({title:"Error",description:p.message,variant:"destructive"})}}),u=async p=>{await G.from("relationship_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-relationship-types"]})};return e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Relationship Types"}),e.jsx(yr,{children:"Define the relationship categories for InnerCircle contacts"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Zs,{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(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-12"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(p=>e.jsxs(js,{children:[e.jsx(lt,{children:e.jsx(Fu,{className:"h-4 w-4 text-muted-foreground cursor-grab"})}),e.jsx(lt,{className:"font-medium",children:p.name}),e.jsx(lt,{className:"text-muted-foreground",children:p.description}),e.jsx(lt,{children:e.jsx(Br,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(lt,{children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(vs,{open:l,onOpenChange:i,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsxs(Ns,{children:[a?"Edit":"Add"," Relationship Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const f=new FormData(p.currentTarget);d.mutate({id:a==null?void 0:a.id,name:f.get("name"),description:f.get("description"),icon:f.get("icon")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{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(ve,{htmlFor:"description",children:"Description"}),e.jsx(Mr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(ve,{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(On,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Yzt({types:t,isLoading:s}){const{toast:r}=Ia(),n=ns(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=Ot({mutationFn:async p=>{if(p.id){const{error:f}=await G.from("action_types").update({name:p.name,description:p.description,icon:p.icon,color:p.color}).eq("id",p.id);if(f)throw f}else{const{error:f}=await G.from("action_types").insert([{name:p.name,description:p.description,icon:p.icon,color:p.color,sort_order:t.length}]);if(f)throw f}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-action-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:p=>{r({title:"Error",description:p.message,variant:"destructive"})}}),u=async p=>{await G.from("action_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-action-types"]})};return e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Action Types"}),e.jsx(yr,{children:"Define the types of touchpoint actions agents can take"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Zs,{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(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Color"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(p=>e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium",children:p.name}),e.jsx(lt,{className:"text-muted-foreground",children:p.description}),e.jsx(lt,{children:p.color&&e.jsx("div",{className:"w-6 h-6 rounded",style:{backgroundColor:p.color}})}),e.jsx(lt,{children:e.jsx(Br,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(lt,{children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(vs,{open:l,onOpenChange:i,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsxs(Ns,{children:[a?"Edit":"Add"," Action Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const f=new FormData(p.currentTarget);d.mutate({id:a==null?void 0:a.id,name:f.get("name"),description:f.get("description"),icon:f.get("icon"),color:f.get("color")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{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(ve,{htmlFor:"description",children:"Description"}),e.jsx(Mr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(ve,{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(ve,{htmlFor:"color",children:"Color"}),e.jsx(Re,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),e.jsxs(On,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Xzt({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=Ia(),a=ns(),[o,l]=S.useState(null),[i,d]=S.useState(!1),u=Ot({mutationFn:async f=>{if(f.id){const{error:v}=await G.from("action_scripts").update({title:f.title,action_type_id:f.action_type_id,tone:f.tone,script_body:f.script_body,active:f.active}).eq("id",f.id);if(v)throw v}else{const{error:v}=await G.from("action_scripts").insert([{title:f.title,action_type_id:f.action_type_id,tone:f.tone,script_body:f.script_body,active:!0}]);if(v)throw v}},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),d(!1),l(null),n({title:"Saved successfully"})},onError:f=>{n({title:"Error",description:f.message,variant:"destructive"})}}),p=Ot({mutationFn:async f=>{const{error:v}=await G.from("action_scripts").delete().eq("id",f);if(v)throw v},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),n({title:"Deleted successfully"})}});return e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Script Library"}),e.jsx(yr,{children:"Create and manage scripts for each action type"})]}),e.jsxs(K,{onClick:()=>{l(null),d(!0)},children:[e.jsx(Zs,{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(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Action Type"}),e.jsx(jt,{children:"Tone"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(f=>{var v;return e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium",children:f.title}),e.jsx(lt,{children:e.jsx(at,{variant:"outline",children:((v=f.action_type)==null?void 0:v.name)||"Unknown"})}),e.jsx(lt,{className:"text-muted-foreground",children:f.tone}),e.jsx(lt,{children:e.jsx(at,{variant:f.active?"default":"secondary",children:f.active?"Active":"Inactive"})}),e.jsxs(lt,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{l(f),d(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutate(f.id),children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]})]},f.id)})})]})}),e.jsx(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsx(Ss,{children:e.jsxs(Ns,{children:[o?"Edit":"Add"," Script"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const v=new FormData(f.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(ve,{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(ve,{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(sr,{placeholder:"Select action type"})}),e.jsx(er,{children:s.map(f=>e.jsx(At,{value:f.id,children:f.name},f.id))})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{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(ve,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Mr,{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(On,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:u.isPending,children:[u.isPending&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Qzt({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=Ia(),o=ns(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,f]=S.useState(null),[v,_]=S.useState(!1),[b,j]=S.useState(null),[w,N]=S.useState(null),{data:C}=Ct({queryKey:["plan-items",p],queryFn:async()=>{if(!p)return[];const{data:U,error:V}=await G.from("touchpoint_plan_items").select("*").eq("plan_id",p).order("month_number");if(V)throw V;return U},enabled:!!p}),A=Ot({mutationFn:async U=>{if(U.id){const{error:V}=await G.from("touchpoint_plans").update({name:U.name,description:U.description,active:U.active}).eq("id",U.id);if(V)throw V}else{const{error:V}=await G.from("touchpoint_plans").insert([{name:U.name,description:U.description,active:!0}]);if(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["admin-touchpoint-plans"]}),u(!1),i(null),a({title:"Saved successfully"})},onError:U=>{a({title:"Error",description:U.message,variant:"destructive"})}}),I=Ot({mutationFn:async U=>{if(U.id){const{error:V}=await G.from("touchpoint_plan_items").update({action_type_id:U.action_type_id,default_script_id:U.default_script_id,notes:U.notes}).eq("id",U.id);if(V)throw V}else{const{error:V}=await G.from("touchpoint_plan_items").insert([{plan_id:U.plan_id,month_number:U.month_number,action_type_id:U.action_type_id,default_script_id:U.default_script_id,notes:U.notes}]);if(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]}),a({title:"Item saved"})}}),L=Ot({mutationFn:async U=>{const{error:V}=await G.from("touchpoint_plan_items").delete().eq("id",U);if(V)throw V},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]})}}),R=Ot({mutationFn:async U=>{const{data:V,error:X}=await G.from("action_scripts").insert([{...U,active:!0}]).select().single();if(X)throw X;return V},onSuccess:async U=>{o.invalidateQueries({queryKey:["admin-action-scripts"]}),b&&await I.mutateAsync({id:b.itemId,plan_id:p,month_number:b.month,action_type_id:b.actionTypeId,default_script_id:U.id}),_(!1),j(null),a({title:"Script created and assigned"})},onError:U=>{a({title:"Error",description:U.message,variant:"destructive"})}}),$=(U,V,X)=>{j({month:U,actionTypeId:V,itemId:X}),_(!0)},q=U=>r.find(V=>V.id===U);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Touchpoint Plans"}),e.jsx(yr,{children:"Create annual touchpoint plans that agents can apply to their contacts"})]}),e.jsxs(K,{onClick:()=>{i(null),u(!0)},children:[e.jsx(Zs,{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(As,{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(U=>e.jsxs(Ee,{className:`cursor-pointer transition-colors ${p===U.id?"border-primary":""}`,onClick:()=>f(U.id),children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:U.name}),e.jsx(K,{variant:"ghost",size:"icon",onClick:V=>{V.stopPropagation(),i(U),u(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})})]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:U.description}),e.jsx(at,{variant:U.active?"default":"secondary",className:"mt-2",children:U.active?"Active":"Inactive"})]})]},U.id))})})]}),p&&e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Plan Schedule"}),e.jsx(yr,{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},(U,V)=>V+1).map(U=>{const V=C==null?void 0:C.find(te=>te.month_number===U),X=V!=null&&V.default_script_id?q(V.default_script_id):null,se=r.filter(te=>te.action_type_id===(V==null?void 0:V.action_type_id)&&te.active);return e.jsxs("div",{className:"p-4 border rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"w-20 font-medium text-sm",children:["Month ",U]}),e.jsxs(tr,{value:(V==null?void 0:V.action_type_id)||"none",onValueChange:te=>{te==="none"&&V?L.mutate(V.id):te!=="none"&&I.mutate({id:V==null?void 0:V.id,plan_id:p,month_number:U,action_type_id:te,default_script_id:null})},children:[e.jsx(Js,{className:"w-40",children:e.jsx(sr,{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))]})]}),V&&e.jsxs(e.Fragment,{children:[e.jsxs(tr,{value:V.default_script_id||"none",onValueChange:te=>{N(null),I.mutate({id:V.id,default_script_id:te==="none"?null:te})},children:[e.jsx(Js,{className:"w-56",children:e.jsx(sr,{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(K,{variant:"outline",size:"sm",onClick:()=>$(U,V.action_type_id,V.id),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"}),"New Script"]}),X&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N((w==null?void 0:w.id)===X.id?null:X),children:(w==null?void 0:w.id)===X.id?"Hide":"Preview"})]})]}),w&&(V==null?void 0:V.default_script_id)===w.id&&e.jsxs("div",{className:"ml-24 p-3 bg-muted rounded-lg text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(at,{variant:"outline",children:w.title}),w.tone&&e.jsx(at,{variant:"secondary",children:w.tone})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:w.script_body})]})]},U)})})})]}),e.jsx(vs,{open:d,onOpenChange:u,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsxs(Ns,{children:[l?"Edit":"Add"," Touchpoint Plan"]})}),e.jsxs("form",{onSubmit:U=>{U.preventDefault();const V=new FormData(U.currentTarget);A.mutate({id:l==null?void 0:l.id,name:V.get("name"),description:V.get("description"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{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(ve,{htmlFor:"description",children:"Description"}),e.jsx(Mr,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(On,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:A.isPending,children:[A.isPending&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})}),e.jsx(vs,{open:v,onOpenChange:_,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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:U=>{U.preventDefault();const V=new FormData(U.currentTarget);R.mutate({title:V.get("title"),action_type_id:b.actionTypeId,tone:V.get("tone"),script_body:V.get("script_body")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{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(ve,{htmlFor:"script_tone",children:"Tone"}),e.jsx(Re,{id:"script_tone",name:"tone",placeholder:"e.g., Friendly, Professional"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Mr,{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(On,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:R.isPending,children:[R.isPending&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function Jzt({flags:t}){const{toast:s}=Ia(),r=ns(),n=async(a,o)=>{const{error:l}=await G.from("feature_flags").update({...o,updated_at:new Date().toISOString()}).eq("id",a.id);l?s({title:"Error",description:l.message,variant:"destructive"}):(r.invalidateQueries({queryKey:["admin-feature-flags"]}),s({title:"Flag updated"}))};return e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Feature Flags"}),e.jsx(yr,{children:"Control which features are enabled for members"})]}),e.jsx(Oe,{children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Flag"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Notes"}),e.jsx(jt,{children:"Last Updated"})]})}),e.jsx(Pn,{children:t.map(a=>e.jsxs(js,{children:[e.jsx(lt,{className:"font-mono text-sm",children:a.key}),e.jsx(lt,{children:e.jsx(Br,{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 e7t({items:t,isLoading:s}){const{toast:r}=Ia(),n=ns(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=Ot({mutationFn:async f=>{if(f.id){const{error:v}=await G.from("popby_items").update({name:f.name,description:f.description}).eq("id",f.id);if(v)throw v}else{const{error:v}=await G.from("popby_items").insert([{name:f.name,description:f.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:f=>{r({title:"Error",description:f.message,variant:"destructive"})}}),u=async f=>{await G.from("popby_items").update({is_active:!f.is_active}).eq("id",f.id),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]})},p=async f=>{await G.from("popby_items").delete().eq("id",f),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),r({title:"Deleted successfully"})};return e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Popby Ideas"}),e.jsx(yr,{children:"Manage global popby ideas that all agents can see"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Zs,{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(As,{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(io,{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(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(f=>e.jsxs(js,{children:[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(Br,{checked:f.is_active,onCheckedChange:()=>u(f)})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(f),i(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p(f.id),children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]})})]},f.id))})]})}),e.jsx(vs,{open:l,onOpenChange:i,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsxs(Ns,{children:[a?"Edit":"Add"," Popby Idea"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const v=new FormData(f.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(ve,{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(ve,{htmlFor:"description",children:"Description"}),e.jsx(Mr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(On,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function t7t(){var _;const{toast:t}=Ia(),s=ns(),[r,n]=S.useState(null),[a,o]=S.useState(!1),{data:l,isLoading:i}=Ct({queryKey:["admin-video-script-categories"],queryFn:async()=>{const{data:b,error:j}=await G.from("video_script_categories").select("*").order("sort_order");if(j)throw j;return b}}),{data:d,isLoading:u}=Ct({queryKey:["admin-video-scripts"],queryFn:async()=>{const{data:b,error:j}=await G.from("video_scripts").select("*, category:video_script_categories(*)").order("title");if(j)throw j;return b}}),p=Ot({mutationFn:async b=>{var j,w;if(b.id){const{error:N}=await G.from("video_scripts").update({title:b.title,script_text:b.script_text,category_id:b.category_id,tags:((j=b.tags)==null?void 0:j.split(",").map(C=>C.trim()).filter(Boolean))||[]}).eq("id",b.id);if(N)throw N}else{const{error:N}=await G.from("video_scripts").insert([{title:b.title,script_text:b.script_text,category_id:b.category_id||null,tags:((w=b.tags)==null?void 0:w.split(",").map(C=>C.trim()).filter(Boolean))||[]}]);if(N)throw N}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-video-scripts"]}),o(!1),n(null),t({title:"Video script saved!"})},onError:b=>t({title:"Error",description:b.message,variant:"destructive"})}),f=async b=>{await G.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 G.from("video_scripts").delete().eq("id",b),s.invalidateQueries({queryKey:["admin-video-scripts"]}),t({title:"Script deleted"}))};return e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Video Scripts"}),e.jsx(yr,{children:"Manage teleprompter scripts for Quick Video Touch"})]}),e.jsxs(K,{onClick:()=>{n(null),o(!0)},children:[e.jsx(Zs,{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(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:d==null?void 0:d.map(b=>{var j;return e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium",children:b.title}),e.jsx(lt,{className:"text-muted-foreground",children:((j=b.category)==null?void 0:j.name)||"Uncategorized"}),e.jsx(lt,{children:e.jsx(Br,{checked:b.is_active,onCheckedChange:()=>f(b)})}),e.jsxs(lt,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{n(b),o(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>v(b.id),children:e.jsx(br,{className:"h-4 w-4"})})]})]},b.id)})})]})}),e.jsx(vs,{open:a,onOpenChange:o,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsx(Ss,{children:e.jsxs(Ns,{children:[r?"Edit":"Add"," Video Script"]})}),e.jsxs("form",{onSubmit:b=>{b.preventDefault();const j=new FormData(b.currentTarget);p.mutate({id:r==null?void 0:r.id,title:j.get("title"),script_text:j.get("script_text"),category_id:j.get("category_id")||null,tags:j.get("tags")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{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(ve,{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(sr,{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(ve,{htmlFor:"script_text",children:"Script Text"}),e.jsx(Mr,{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(ve,{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(On,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:p.isPending,children:[p.isPending&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function s7t(){const{toast:t}=Ia(),[s,r]=S.useState(""),[n,a]=S.useState(!0),[o,l]=S.useState(!1);S.useEffect(()=>{(async()=>{a(!0);try{const{data:u}=await G.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 G.from("settings").upsert({key:"mapbox_public_token",value:s.trim()}),t({title:"Mapbox token saved!"})}catch{t({title:"Error saving token",variant:"destructive"})}l(!1)};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex justify-center py-8",children:e.jsx(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Ai,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(yr,{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(ve,{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(K,{onClick:i,disabled:o,children:[o&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),s&&e.jsx(at,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const r7t=()=>{const[t,s]=S.useState(""),[r,n]=S.useState("grid"),a=Dr(),{data:o=[],isLoading:l}=Ct({queryKey:["additional-services"],queryFn:async()=>{const{data:d,error:u}=await G.from("additional_services").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(u)throw u;return d}}),i=o.filter(d=>{var p;return d.name.toLowerCase().includes(t.toLowerCase())||((p=d.description)==null?void 0:p.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(fn,{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(K,{variant:"outline",size:"sm",onClick:()=>s(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:r==="grid"?"secondary":"outline",size:"icon",onClick:()=>n("grid"),className:"rounded-full",children:e.jsx(mp,{className:"h-4 w-4"})}),e.jsx(K,{variant:r==="list"?"secondary":"outline",size:"icon",onClick:()=>n("list"),className:"rounded-full",children:e.jsx(Uh,{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(Ee,{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(K,{variant:"outline",onClick:()=>s(""),children:"Clear Search"})]}),!l&&i.length>0&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:i.map(d=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${r==="list"?"flex flex-row":""}`,onClick:()=>a(`/additional-services/${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(hn,{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:Qie(d.description)})]})]},d.id))})]})})},n7t=()=>{const{serviceId:t}=Mo(),s=Dr(),{data:r,isLoading:n}=Ct({queryKey:["additional-service",t],queryFn:async()=>{const{data:a,error:o}=await G.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(K,{variant:"ghost",onClick:()=>s("/additional-services"),className:"gap-2",children:[e.jsx(Ua,{className:"h-4 w-4"}),"Back to Services"]}),e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"relative bg-muted",children:r.preview_image_url?e.jsx("img",{src:r.preview_image_url,alt:r.name,className:"w-full h-auto max-h-[500px] object-contain mx-auto"}):e.jsx("div",{className:"w-full h-64 flex items-center justify-center text-muted-foreground",children:e.jsx(hn,{className:"h-16 w-16"})})})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:r.name}),e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(on,{className:"h-4 w-4 mr-1"}),"Published ",ws(new Date(r.publish_date),"MMMM d, yyyy")]})]}),r.description&&e.jsx("div",{className:"prose prose-sm max-w-none text-muted-foreground [&_a]:text-primary [&_a]:underline",dangerouslySetInnerHTML:{__html:r.description}}),e.jsx("div",{className:"pt-4 border-t",children:e.jsxs(K,{size:"lg",className:"gap-2",onClick:()=>window.open(r.signup_link_url,"_blank"),children:[e.jsx(sn,{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(K,{onClick:()=>s("/additional-services"),children:[e.jsx(Ua,{className:"h-4 w-4 mr-2"}),"Back to Services"]})]})})},iE=[{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 a7t(){const[t,s]=S.useState(iE[0].id),r=iE.find(n=>n.id===t)||iE[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(i5,{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(sr,{placeholder:"Select a tool"})}),e.jsx(er,{children:iE.map(n=>e.jsx(At,{value:n.id,children:n.name},n.id))})]})}),e.jsx("div",{className:"hidden md:block",children:e.jsx(Na,{value:t,onValueChange:s,className:"w-full",children:e.jsx(va,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:iE.map(n=>e.jsx(ks,{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 hEe="agent-os-onboarding-completed",cR=[{icon:Gx,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:Dm,iconColor:"text-white",bgGradient:"from-pink-500 via-rose-500 to-red-500",title:"InnerCircle Home",description:"Your daily command center. See today's action items, track your momentum streak, and get a snapshot of your relationship health—all at a glance.",highlights:["Today's touchpoints and special dates","Momentum stats and streak tracking","Relationship health overview","Quick access to all features"]},{icon:hr,iconColor:"text-white",bgGradient:"from-blue-500 via-indigo-500 to-purple-500",title:"Contacts",description:"Import and organize your sphere of influence. Tag contacts by relationship type (Top 25, Past Clients, Referral Partners, etc.) to prioritize your outreach.",highlights:["Import contacts via CSV","Tag by relationship type","Track birthdays and home anniversaries","See relationship health scores"]},{icon:ld,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:io,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:Xo,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"]}],i7t=()=>{const[t,s]=S.useState(!1),[r,n]=S.useState(0),[a,o]=S.useState(!1);S.useEffect(()=>{if(!localStorage.getItem(hEe)){const b=setTimeout(()=>s(!0),500);return()=>clearTimeout(b)}},[]);const l=()=>{r{n(r+1),o(!1)},150)):d()},i=()=>{d()},d=()=>{localStorage.setItem(hEe,"true"),s(!1)},u=cR[r],p=u.icon,f=r===cR.length-1,v=_=>{_||d(),s(_)};return e.jsx(vs,{open:t,onOpenChange:v,children:e.jsxs(ys,{className:"sm:max-w-lg overflow-hidden p-0 gap-0",children:[e.jsxs("div",{className:`relative bg-gradient-to-br ${u.bgGradient} p-8 pb-12 transition-all duration-500`,children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx("div",{className:"absolute -top-4 -right-4 w-32 h-32 bg-white/10 rounded-full blur-2xl animate-pulse"}),e.jsx("div",{className:"absolute -bottom-8 -left-8 w-40 h-40 bg-white/10 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-white/5 rounded-full blur-3xl"})]}),e.jsxs("div",{className:`relative mx-auto flex h-20 w-20 items-center justify-center transition-all duration-300 ${a?"scale-75 opacity-0":"scale-100 opacity-100"}`,children:[e.jsx("div",{className:"absolute inset-0 bg-white/20 rounded-2xl blur-xl"}),e.jsx("div",{className:"relative flex h-20 w-20 items-center justify-center rounded-2xl bg-white/20 backdrop-blur-sm border border-white/30 shadow-2xl",children:e.jsx(p,{className:`h-10 w-10 ${u.iconColor} drop-shadow-lg`})})]}),r===0&&e.jsxs("div",{className:"absolute top-4 right-4 px-3 py-1 rounded-full bg-white/20 backdrop-blur-sm border border-white/30 text-white text-xs font-medium flex items-center gap-1.5",children:[e.jsx(hn,{className:"h-3 w-3"}),"Beta"]})]}),e.jsxs("div",{className:"p-6 pt-4",children:[e.jsxs(Ss,{className:"text-center sm:text-center pb-2",children:[e.jsx(Ns,{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(ua,{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:cR.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}=Gs();return Ct({queryKey:["contact-snoozes",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_snoozes").select("*").gte("snoozed_until",new Date().toISOString());if(r)throw r;return s},enabled:!!t})},l7t=()=>{const t=ns(),{user:s}=Gs();return Ot({mutationFn:async({contactId:r,days:n})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const a=ml(new Date,n);await G.from("contact_snoozes").delete().eq("contact_id",r);const{error:o}=await G.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"]}),an({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{an({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},c7t=()=>{const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("contact_snoozes").delete().eq("contact_id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),an({title:"Snooze cancelled"})},onError:s=>{an({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},d7t=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function Cle({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=S.useState(null),l=l7t(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},d=u=>ws(ml(new Date,u),"MMM d, yyyy");return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{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:d7t.map(u=>e.jsxs("button",{type:"button",onClick:()=>o(u.days),className:Pt("w-full flex items-center justify-between p-3 rounded-lg border transition-colors",a===u.days?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-accent/50"),children:[e.jsx("span",{className:"font-medium",children:u.label}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(on,{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(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:i,disabled:!a||l.isPending,children:l.isPending?"Snoozing...":"Snooze Touch"})]})]})})}const u7t={Crown:Bh,FileText:In,Users:hr,Globe:Pm,Star:Gn,Phone:Zn,MessageSquare:oo,PenTool:n_,Video:kn,Gift:io};function h7t({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=Dr(),[d,u]=S.useState("name"),[p,f]=S.useState("asc"),[v,_]=S.useState(null),[b,j]=S.useState(""),w=L=>{d===L?f(R=>R==="asc"?"desc":"asc"):(u(L),f("asc"))},N=S.useMemo(()=>[...t].sort((L,R)=>{var q,U;let $=0;switch(d){case"name":{const V=`${L.contact.first_name} ${L.contact.last_name||""}`.toLowerCase(),X=`${R.contact.first_name} ${R.contact.last_name||""}`.toLowerCase();$=V.localeCompare(X);break}case"relationship_type":$=(L.relationshipTypeName||"").localeCompare(R.relationshipTypeName||"");break;case"action_type":$=(((q=L.actionType)==null?void 0:q.name)||"").localeCompare(((U=R.actionType)==null?void 0:U.name)||"");break;case"last_touch":$=(L.monthNumber||0)-(R.monthNumber||0);break}return p==="asc"?$:-$}),[t,d,p]),C=L=>u7t[L||"Phone"]||Zn,A=({field:L,children:R})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>w(L),children:[R,d===L?p==="asc"?e.jsx(Vd,{className:"ml-2 h-4 w-4"}):e.jsx(eh,{className:"ml-2 h-4 w-4"}):e.jsx(Hc,{className:"ml-2 h-4 w-4 opacity-50"})]}),I=(L,R,$)=>{_(L),j(`${R} ${$||""}`.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(An,{children:[e.jsx(En,{children:e.jsxs(js,{className:"bg-muted/50",children:[e.jsx(jt,{className:"w-[180px]",children:e.jsx(A,{field:"name",children:"Contact"})}),e.jsx(jt,{className:"w-[130px]",children:e.jsx(A,{field:"relationship_type",children:"Type"})}),e.jsx(jt,{className:"w-[120px]",children:e.jsx(A,{field:"action_type",children:"Action"})}),e.jsx(jt,{className:"w-[130px]",children:"Phone"}),e.jsx(jt,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(Pn,{children:N.map((L,R)=>{var se,te,Y,de,ie,ae;const $=L.isSpecialDate,q=L.specialDateType,U=$?q==="birthday"?Ru:Un:C(((se=L.actionType)==null?void 0:se.icon)||null),V=L.contact.phone,X=L.contact.email;return e.jsxs(js,{className:Pt("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(at,{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(at,{className:Pt("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(Ru,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Un,{className:"h-3 w-3"})," Anniversary"]})}):e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(U,{className:"h-3 w-3"}),(te=L.actionType)==null?void 0:te.name]})})}),e.jsx(lt,{children:V?e.jsx("span",{className:"text-sm font-mono",children:L.contact.phone}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[V&&e.jsx("a",{href:`tel:${L.contact.phone}`,className:"p-1.5 rounded bg-primary/10 hover:bg-primary/20 text-primary transition-colors",title:"Call",children:e.jsx(Zn,{className:"h-3.5 w-3.5"})}),V&&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(oo,{className:"h-3.5 w-3.5"})}),X&&(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(_r,{className:"h-3.5 w-3.5"})}):e.jsx("a",{href:o(L.contact.email,(de=L.script)==null?void 0:de.script_body,(ie=L.script)==null?void 0:ie.email_subject,(ae=L.actionType)==null?void 0:ae.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(_r,{className:"h-3.5 w-3.5"})})),$&&e.jsxs("button",{onClick:()=>{const le=`${L.contact.first_name}${L.contact.last_name?" "+L.contact.last_name:""}`,pe=q==="birthday"?"birthday":"home_anniversary",be=new URLSearchParams({cardType:pe,contactId:L.contact.id,name:le,...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:Pt("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(_r,{className:"h-3.5 w-3.5"}),"Send Card"]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>I(L.contact.id,L.contact.first_name,L.contact.last_name),title:"Snooze",children:e.jsx(pp,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"default",size:"sm",className:"h-7 px-2 text-xs ml-1",onClick:()=>{var le;return s(L.contact.id,L.actionType.id,(le=L.script)==null?void 0:le.id)},disabled:n,children:[e.jsx(da,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${L.contact.id}-${R}`)})})]})}),e.jsx(Cle,{open:!!v,onOpenChange:L=>!L&&_(null),contactId:v||"",contactName:b})]})}function gy(){const{data:t,isLoading:s}=Ct({queryKey:["gmail-integration"],queryFn:async()=>{const{data:a,error:o}=await G.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 m7t({onSelect:t}){const[s,r]=S.useState(null),{data:n=[],isLoading:a}=Ct({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:d,error:u}=await G.from("email_template_categories").select("*").order("sort_order");if(u)throw u;return d}}),{data:o=[],isLoading:l}=Ct({queryKey:["agent-email-templates",s],queryFn:async()=>{let d=G.from("agent_email_templates").select("*").eq("is_active",!0).order("sort_order");s&&(d=d.eq("category_id",s));const{data:u,error:p}=await d;if(p)throw p;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(As,{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(zl,{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(As,{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(Bi,{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(at,{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(Ha,{className:"h-4 w-4 text-muted-foreground shrink-0"})]},d.id))})]})}const p7t=5*1024*1024,Yy=50,f7t=["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 g7t(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function x7t(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 Qv(t,s){let r=t.replace(/\{\{first_name\}\}/gi,s.first_name).replace(/\{\{last_name\}\}/gi,s.last_name||"").replace(/\{\{full_name\}\}/gi,`${s.first_name} ${s.last_name||""}`.trim());return s.updateLink&&(r=r.replace(/\{\{update_link\}\}/gi,s.updateLink)),r}function EM({open:t,onOpenChange:s,contact:r,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const{user:d}=Gs(),u=ns(),p=!!n&&n.length>0,f=p?n:r?[r]:[],v=f[0],_=p?Math.ceil(f.length/Yy):1,b=p&&f.length>Yy,[j,w]=S.useState((v==null?void 0:v.email)||""),[N,C]=S.useState(a),[A,I]=S.useState(o),[L,R]=S.useState(!1),[$,q]=S.useState(!1),[U,V]=S.useState([]),[X,se]=S.useState(a),[te,Y]=S.useState(o),[de,ie]=S.useState("composing"),[ae,le]=S.useState(0),[pe,be]=S.useState(0),[ye,we]=S.useState(0),[ke,Ze]=S.useState(0),_e=S.useRef(!1),[Ce,Te]=S.useState(null);S.useEffect(()=>{t&&(w((v==null?void 0:v.email)||""),se(a),Y(o),C(Qv(a,v||{first_name:""})),I(Qv(o,v||{first_name:""})),q(!a&&!o),V([]),ie("composing"),le(0),be(0),we(0),Ze(0),_e.current=!1,Te(null))},[t,v,a,o]);const Fe=async Xe=>{const $e=Xe.target.files;if(!$e)return;const Ke=U.reduce((Ue,Ve)=>Ue+Ve.size,0),ct=[];for(const Ue of Array.from($e)){if(!f7t.includes(Ue.type)){fe.error(`${Ue.name}: Unsupported file type`);continue}if(Ke+Ue.size>p7t){fe.error("Total attachments exceed 5MB limit");break}try{const Ve=await x7t(Ue);ct.push({name:Ue.name,type:Ue.type,size:Ue.size,data:Ve})}catch{fe.error(`Failed to read ${Ue.name}`)}}V(Ue=>[...Ue,...ct]),Xe.target.value=""},Ae=Xe=>{V($e=>$e.filter((Ke,ct)=>ct!==Xe))},We=Xe=>{se(Xe.subject),Y(Xe.body),C(Qv(Xe.subject,v||{first_name:""})),I(Qv(Xe.body,v||{first_name:""})),q(!1)},ht=Xe=>Xe.split(/\n\n+/).map($e=>`

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

`).join(""),De=async Xe=>{const $e=Qv(N,Xe),Ke=Qv(A,Xe),ct=ht(Ke);try{const{data:Ue,error:Ve}=await G.functions.invoke("gmail-send",{body:{to:Xe.email,subject:$e,body:ct,contactId:Xe.id,attachments:U.map(({name:Je,type:Rt,data:$t})=>({name:Je,type:Rt,data:$t}))}});if(Ve)throw Ve;if(!(Ue!=null&&Ue.success))throw new Error((Ue==null?void 0:Ue.error)||"Failed to send");return d&&await G.from("bulk_email_sends").insert({user_id:d.id,contact_id:Xe.id,contact_email:Xe.email,subject:$e,source:"sphere_gaps"}),!0}catch(Ue){return console.error("Gmail send error:",Ue),fe.error("Failed to send to "+Xe.first_name+": "+(Ue instanceof Error?Ue.message:"Unknown error")),!1}},Dt=()=>{const Xe=ae*Yy;return f.slice(Xe,Xe+Yy)},he=async()=>{if(!N||!A){fe.error("Please fill in subject and message");return}const Xe=Dt();R(!0),ie("sending");let $e=0,Ke=0;for(let Ue=0;UesetTimeout(Je,150));be(Ue=>Ue+$e),we(Ue=>Ue+Ke),R(!1),u.invalidateQueries({queryKey:["bulk-email-sends"]}),ae>=_-1||_e.current?ie("all_done"):ie("batch_complete")},Qe=async()=>{if(!N||!A){fe.error("Please fill in subject and message");return}if(!p){R(!0);const Xe=await De(v);R(!1),Xe&&(u.invalidateQueries({queryKey:["bulk-email-sends"]}),fe.success("Email sent successfully!"),s(!1),i==null||i());return}await he()},ot=async()=>{le(Xe=>Xe+1),Ze(0),await new Promise(Xe=>setTimeout(Xe,50)),await he()};S.useEffect(()=>{},[ae]);const rt=()=>{if(L){_e.current=!0;return}s(!1),i==null||i()},Ne=ae*Yy,it=Math.min(Ne+Yy,f.length),qe=p&&f.length>0?Math.round((pe+ye)/f.length*100):0;return e.jsx(vs,{open:t,onOpenChange:rt,children:e.jsxs(ys,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(_r,{className:"h-5 w-5 text-red-500"}),p?`Send to ${f.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})]}),p&&de==="composing"&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Composing email for ",e.jsxs("span",{className:"font-medium",children:[f.length," contacts"]}),". You'll review each personalized email before sending."]})]}),de==="sending"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(As,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsxs("p",{className:"font-medium",children:["Sending batch ",ae+1," of ",_,"..."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[ke," of ",Dt().length," in this batch"]})]}),e.jsx(Ti,{value:ke/Dt().length*100,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Overall: ",pe+ye," / ",f.length]}),e.jsxs("span",{children:[pe," sent • ",ye," failed"]})]}),e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{_e.current=!0},children:"Stop Sending"})]}),de==="batch_complete"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(da,{className:"h-8 w-8 text-emerald-500 mx-auto"}),e.jsxs("p",{className:"font-medium",children:["Batch ",ae+1," Complete!"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[pe," sent, ",ye," failed so far"]})]}),e.jsx(Ti,{value:qe,className:"h-2"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[f.length-pe-ye," contacts remaining (",_-ae-1," batches left)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:rt,children:"Done for Now"}),e.jsxs(K,{className:"flex-1 gap-2",onClick:ot,children:[e.jsx(ka,{className:"h-4 w-4"}),"Send Next ",Math.min(Yy,f.length-it)," Contacts"]})]})]}),de==="all_done"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(da,{className:"h-10 w-10 text-emerald-500 mx-auto"}),e.jsx("p",{className:"font-semibold text-lg",children:"All Done!"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[pe," emails sent successfully",ye>0&&e.jsxs("span",{className:"text-destructive",children:[" • ",ye," failed"]})]})]}),e.jsx(K,{className:"w-full",onClick:rt,children:"Close"})]}),de==="composing"&&e.jsxs("div",{className:"space-y-4",children:[$?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(In,{className:"h-4 w-4"})," Choose a Template"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>q(!1),className:"h-7 px-2 text-xs",children:[e.jsx(Ur,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),e.jsx(m7t,{onSelect:We})]}):e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>q(!0),children:[e.jsx(In,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(Rl,{}),!p&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"gmail-to",children:"To"}),e.jsx(Re,{id:"gmail-to",value:j,onChange:Xe=>w(Xe.target.value),placeholder:"recipient@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"gmail-subject",children:"Subject"}),e.jsx(Re,{id:"gmail-subject",value:N,onChange:Xe=>{C(Xe.target.value),se(Xe.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(ve,{htmlFor:"gmail-body",children:"Message"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(at,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{I(Xe=>Xe+"{{first_name}}"),Y(Xe=>Xe+"{{first_name}}")},children:"{{first_name}}"}),e.jsx(at,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{I(Xe=>Xe+"{{last_name}}"),Y(Xe=>Xe+"{{last_name}}")},children:"{{last_name}}"})]})]}),e.jsx(Mr,{id:"gmail-body",value:A,onChange:Xe=>{I(Xe.target.value),Y(Xe.target.value)},placeholder:"Write your message...",rows:10,className:"resize-y"}),p&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{first_name}}",", ","{{last_name}}"," to personalize. You'll preview each recipient's email in the next step."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",onClick:()=>{var Xe;return(Xe=document.getElementById("gmail-attachments"))==null?void 0:Xe.click()},disabled:L,children:[e.jsx(oN,{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:Fe})]}),U.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:U.map((Xe,$e)=>e.jsxs(at,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[e.jsx(oN,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[140px] truncate text-xs",children:Xe.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",g7t(Xe.size),")"]}),e.jsx("button",{type:"button",onClick:()=>Ae($e),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Ur,{className:"h-3 w-3"})})]},$e))})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),p?e.jsxs(K,{onClick:()=>{Te(f[0]||null),ie("reviewing")},disabled:!N||!A,className:"gap-2",children:["Review Emails",e.jsx(Fi,{className:"h-4 w-4"})]}):e.jsxs(K,{onClick:Qe,disabled:L||!N||!A,className:"gap-2",children:[L?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(ka,{className:"h-4 w-4"}),L?"Sending...":"Send Email"]})]})]}),de==="reviewing"&&p&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-xs text-primary bg-primary/10 rounded-md px-2.5 py-1.5",children:["✉️ Click any recipient below to preview the ",e.jsx("span",{className:"font-semibold",children:"exact personalized email"})," they will receive."]}),b&&e.jsxs("p",{className:"text-xs text-amber-600 bg-amber-500/10 rounded-md px-2.5 py-1.5",children:["📦 ",f.length," contacts will be sent in ",_," batches of up to ",Yy,". You'll confirm before each batch."]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ve,{children:["Recipients (",f.length,")"]}),e.jsx("div",{className:"bg-muted p-1.5 rounded-md space-y-0.5 max-h-32 overflow-y-auto",children:f.map(Xe=>e.jsxs("div",{className:`text-sm px-2 py-1 rounded cursor-pointer transition-colors ${(Ce==null?void 0:Ce.id)===Xe.id?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>Te(Xe),children:[Xe.first_name," ",Xe.last_name," — ",Xe.email]},Xe.id))})]}),Ce&&e.jsxs("div",{className:"border rounded-lg p-3 bg-muted/30 space-y-2 animate-in fade-in slide-in-from-top-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"text-xs font-semibold text-primary flex items-center gap-1.5",children:[e.jsx(_r,{className:"h-3.5 w-3.5"}),"Preview for ",Ce.first_name," ",Ce.last_name]})}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"To:"})," ",Ce.email]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Subject:"})," ",Qv(X,Ce)]})]}),e.jsx(Rl,{}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-background rounded p-2.5 max-h-40 overflow-y-auto border",children:Qv(te,Ce)})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>{ie("composing"),Te(null)},children:[e.jsx(Ua,{className:"h-4 w-4 mr-1"}),"Back to Edit"]}),e.jsxs(K,{onClick:Qe,disabled:L,className:"gap-2",children:[L?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(ka,{className:"h-4 w-4"}),b?`Send First ${Yy}`:`Send to ${f.length}`]})]})]})]})})}function y7t(){const t=Dr(),{data:s}=Jh(),{data:r}=IL(),n=rbe(),{isGmailConnected:a,gmailEmail:o}=gy(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,f]=S.useState(new Set),v=Gh(new Date),_=ml(v,30),b=I=>{if(!I)return null;const L=I.split(/[-/T]/);if(L.length<3)return null;const R=parseInt(L[1],10)-1,$=parseInt(L[2],10);return isNaN(R)||isNaN($)?null:new Date(v.getFullYear(),R,$)},j=S.useMemo(()=>{if(!s)return[];const I=[];for(const L of s){if(L.birthday){const R=b(L.birthday);R&&(cl(R,v)||PN(R,v)&&IN(R,_))&&I.push({contact:L,type:"birthday",date:R,daysUntil:up(R,v),dateStr:L.birthday})}if(L.home_anniversary){const R=b(L.home_anniversary);R&&(cl(R,v)||PN(R,v)&&IN(R,_))&&I.push({contact:L,type:"anniversary",date:R,daysUntil:up(R,v),dateStr:L.home_anniversary})}}return I.sort((L,R)=>L.daysUntil-R.daysUntil),I},[s]),w=async I=>{const L=(r==null?void 0:r.find(R=>R.name==="Call"))||(r==null?void 0:r[0]);if(L)try{await n.mutateAsync({contactId:I.contact.id,actionTypeId:L.id,notes:`${I.type==="birthday"?"Birthday":"Home Anniversary"} outreach`}),f(R=>new Set(R).add(`${I.contact.id}-${I.type}`)),an({title:"Touch logged!",description:`Logged outreach for ${I.contact.first_name}`})}catch{an({title:"Error",description:"Failed to log touch",variant:"destructive"})}},N=I=>{const L=`${I.contact.first_name}${I.contact.last_name?" "+I.contact.last_name:""}`,R=I.type==="birthday"?"birthday":"home_anniversary",$=new URLSearchParams({cardType:R,contactId:I.contact.id,name:L,...I.contact.address?{address:I.contact.address}:{},...I.type==="anniversary"&&I.dateStr?{date:I.dateStr}:{}});t(`/mission-control/card-studio?${$.toString()}`)},C=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(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(ld,{className:"h-5 w-5 text-primary"}),"Upcoming Milestones",e.jsx(at,{variant:"secondary",className:"text-xs font-normal",children:"Next 30 days"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[j.length," event",j.length!==1?"s":""]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[j.length===0&&e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ru,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No birthdays or anniversaries in the next 30 days."}),e.jsx("p",{className:"text-xs mt-1",children:"Add dates to your contacts to see upcoming milestones here."})]}),j.map((I,L)=>{var U,V;const R=`${I.contact.id}-${I.type}`,$=p.has(R),q=`${((U=I.contact.first_name)==null?void 0:U[0])||""}${((V=I.contact.last_name)==null?void 0:V[0])||""}`.toUpperCase();return e.jsxs("div",{className:Pt("p-3 rounded-lg border transition-colors",I.daysUntil===0&&I.type==="birthday"?"bg-pink-500/10 border-pink-500/30 dark:bg-pink-900/20 dark:border-pink-800/40":I.daysUntil===0&&I.type==="anniversary"?"bg-blue-500/10 border-blue-500/30 dark:bg-blue-900/20 dark:border-blue-800/40":I.type==="birthday"?"bg-pink-50/60 border-pink-200/60 hover:bg-pink-100/60 dark:bg-pink-950/20 dark:border-pink-900/30 dark:hover:bg-pink-950/30":"bg-blue-50/60 border-blue-200/60 hover:bg-blue-100/60 dark:bg-blue-950/20 dark:border-blue-900/30 dark:hover:bg-blue-950/30"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(gn,{className:Pt("h-10 w-10",I.type==="birthday"?"ring-2 ring-pink-300/50 dark:ring-pink-700/50":"ring-2 ring-blue-300/50 dark:ring-blue-700/50"),children:e.jsx(xn,{className:Pt("text-xs font-medium",I.type==="birthday"?"bg-pink-100 text-pink-700 dark:bg-pink-900/40 dark:text-pink-300":"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"),children: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(at,{variant:"outline",className:Pt("text-[10px] shrink-0 whitespace-nowrap",A(I.daysUntil)),children:C(I.daysUntil)})]}),e.jsxs("div",{className:Pt("text-xs flex items-center gap-1.5 mt-0.5",I.type==="birthday"?"text-pink-600/80 dark:text-pink-400/80":"text-blue-600/80 dark:text-blue-400/80"),children:[I.type==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(Ru,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Un,{className:"h-3 w-3"})," Home Anniversary"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:ws(I.date,"MMM d")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 pl-[52px]",children:[I.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Call",asChild:!0,children:e.jsx("a",{href:`tel:${I.contact.phone}`,children:e.jsx(Zn,{className:"h-3.5 w-3.5"})})}),I.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Text",asChild:!0,children:e.jsx("a",{href:`sms:${I.contact.phone}`,children:e.jsx(oo,{className:"h-3.5 w-3.5"})})}),I.contact.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Email",onClick:()=>{a?(i({id:I.contact.id,first_name:I.contact.first_name,last_name:I.contact.last_name,email:I.contact.email}),u(!0)):window.location.href=`mailto:${I.contact.email}`},children:e.jsx(_r,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Record video",onClick:()=>t(`/mission-control/video/record?contactId=${I.contact.id}`),children:e.jsx(kn,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("h-7 px-2 gap-1 text-xs",I.type==="birthday"?"text-pink-600 hover:text-pink-700 dark:text-pink-400":"text-blue-600 hover:text-blue-700 dark:text-blue-400"),title:`Send ${I.type==="birthday"?"birthday":"anniversary"} card`,onClick:()=>N(I),children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Card"})]}),e.jsx(K,{variant:"ghost",size:"icon",className:Pt("h-7 w-7",$&&"text-green-600"),title:"Log a touch",disabled:$||n.isPending,onClick:()=>w(I),children:e.jsx(da,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"View contact",onClick:()=>t(`/mission-control/contacts/${I.contact.id}`),children:e.jsx(ya,{className:"h-3.5 w-3.5"})})]})]},`${R}-${L}`)})]})]}),a&&l&&e.jsx(EM,{open:d,onOpenChange:u,contact:l,gmailEmail:o})]})}const mEe={Crown:Bh,FileText:In,Users:hr,Globe:Pm,Star:Gn,Phone:Zn,MessageSquare:oo,PenTool:n_,Video:kn,Gift:io},v7t={"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 _7t(){var qe,Xe,$e,Ke,ct,Ue;const t=Dr(),{user:s}=Gs(),{data:r}=Ef(),{data:n}=eVe(),{data:a}=Jh(),{data:o}=IL(),{data:l}=aVe(),i=r5t(),d=nbe(),u=t5t(90),p=rbe(),[f,v]=S.useState(null),[_,b]=S.useState(null),[j,w]=S.useState(!1),[N,C]=S.useState(""),[A,I]=S.useState(!1),[L,R]=S.useState(""),[$,q]=S.useState(One()),[U,V]=S.useState("cards"),[X,se]=S.useState(!1),[te,Y]=S.useState(null),[de,ie]=S.useState(null),[ae,le]=S.useState(""),{isGmailConnected:pe,gmailEmail:be}=gy(),ye=()=>{const Ve=parseInt(L,10);if(isNaN(Ve)||Ve<1){an({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}q(Ve),nVe(Ve),I(!1),an({title:"Goal updated",description:`Weekly touch goal set to ${Ve}`})},we=()=>{R($.toString()),I(!0)};S.useEffect(()=>{(async()=>{if(!(s!=null&&s.id))return;const{data:Je}=await G.from("profiles").select("name").eq("id",s.id).single();Je!=null&&Je.name&&C(Je.name.split(" ")[0])})()},[s==null?void 0:s.id]),S.useEffect(()=>{i.mutate()},[]);const ke=Gh(new Date),Ze=ml(ke,7),_e=Ve=>{if(!Ve)return null;const Je=Ve.split(/[-/T]/);if(Je.length<3)return null;const Rt=parseInt(Je[1],10)-1,$t=parseInt(Je[2],10);return isNaN(Rt)||isNaN($t)?null:new Date(ke.getFullYear(),Rt,$t)},Ce=(a==null?void 0:a.filter(Ve=>{const Je=_e(Ve.birthday),Rt=_e(Ve.home_anniversary);return Je&&cl(Je,ke)||Rt&&cl(Rt,ke)}))||[];a!=null&&a.filter(Ve=>{if(!Ve.birthday&&!Ve.home_anniversary)return!1;const Je=Rt=>{if(!Rt)return!1;const $t=_e(Rt);return $t?PN($t,ke)&&IN($t,Ze):!1};return Je(Ve.birthday)||Je(Ve.home_anniversary)}).slice(0,5);const Te=[],Fe=(o==null?void 0:o.find(Ve=>Ve.name==="Call"))||(o==null?void 0:o[0]);for(const Ve of Ce){const Je=_e(Ve.birthday),Rt=_e(Ve.home_anniversary),$t=Je&&cl(Je,ke),ls=Rt&&cl(Rt,ke);$t&&Te.push({contact:Ve,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:(($e=(Xe=(qe=Ve.tags)==null?void 0:qe[0])==null?void 0:Xe.relationship_type)==null?void 0:$e.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),ls&&Te.push({contact:Ve,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:((Ue=(ct=(Ke=Ve.tags)==null?void 0:Ke[0])==null?void 0:ct.relationship_type)==null?void 0:Ue.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"anniversary"})}const We=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((Ve,Je)=>{var $t,ls,Qt;const Rt=o==null?void 0:o[Je%((o==null?void 0:o.length)||1)];return Rt?{contact:Ve,actionType:Rt,planName:"Quick Touch",relationshipTypeName:((Qt=(ls=($t=Ve.tags)==null?void 0:$t[0])==null?void 0:ls.relationship_type)==null?void 0:Qt.name)||"",monthNumber:0}:null}).filter(Boolean))||[],ht=[...Te,...We],De=async(Ve,Je,Rt)=>{await p.mutateAsync({contactId:Ve,actionTypeId:Je,scriptUsedId:Rt}),w(!1),b(null)},Dt=Ve=>{Ve.script?(b(Ve),w(!0)):De(Ve.contact.id,Ve.actionType.id)},he=Ve=>mEe[Ve||"Phone"]||Zn,Qe=Ve=>mEe[Ve||"Users"]||hr,ot=(Ve,Je)=>Ve.replace(/\{\{FirstName\}\}/g,Je.first_name).replace(/\{\{LastName\}\}/g,Je.last_name||"").replace(/\{\{AgentName\}\}/g,N||"there"),rt=(Ve,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}`})[Ve]||`Hello ${Je}!`,Ne=(Ve,Je,Rt)=>{const $t=`sms:${Ve}`;if(Je&&Rt){const ls=ot(Je,Rt);return`${$t}?body=${encodeURIComponent(ls)}`}return $t},it=(Ve,Je,Rt,$t,ls)=>{const Qt=`mailto:${Ve}`,rs=[];if(ls){const as=Rt||rt($t||"Email",ls.first_name);if(rs.push(`subject=${encodeURIComponent(as)}`),Je){const ir=ot(Je,ls);rs.push(`body=${encodeURIComponent(ir)}`)}}return rs.length>0?`${Qt}?${rs.join("&")}`:Qt};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(Ve=>Ve.active).map(Ve=>{const Je=Qe(Ve.icon),Rt=(n==null?void 0:n[Ve.id])||0,$t=f===Ve.id,ls=v7t[Ve.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{$t?(v(null),t("/mission-control/contacts")):(v(Ve.id),t(`/mission-control/contacts?type=${Ve.id}`))},className:` flex items-center gap-2 px-4 py-3 rounded-lg border transition-all ${$t?ls:"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:Ve.name}),e.jsxs("div",{className:`text-sm ${$t?"opacity-90":"text-muted-foreground"}`,children:[Rt," Contacts"]})]})]},Ve.id)})})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),className:"w-full bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(lu,{className:"h-4 w-4 mr-1"}),"Quick Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/contacts"),className:"w-full",variant:"outline",children:["View Contacts",e.jsx(Ha,{className:"h-4 w-4 ml-1"})]}),e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),className:"w-full",children:"Video Library"}),e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/plans"),className:"w-full",children:"Manage Plans"})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Today in Your InnerCircle"}),l!==void 0&&e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),"Plan-based"]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 border rounded-lg p-0.5",children:[e.jsx(K,{variant:U==="cards"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("cards"),title:"Card view",children:e.jsx(mp,{className:"h-4 w-4"})}),e.jsx(K,{variant:U==="table"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("table"),title:"Table view",children:e.jsx(Uh,{className:"h-4 w-4"})})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:ht.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No actions scheduled for today."}),e.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."}),e.jsx(K,{variant:"outline",className:"mt-4",onClick:()=>t("/mission-control/plans"),children:"Manage Plans"})]}):U==="table"?e.jsx(h7t,{actions:ht,onMarkComplete:De,onViewScript:Dt,isLoading:p.isPending,buildSmsLink:Ne,buildEmailLink:it,onGmailCompose:pe?Ve=>{Y(Ve),se(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[ht.map((Ve,Je)=>{var vt,Cs,or,Ar,Wn,ai,bo;const Rt=Ve.isSpecialDate,$t=Ve.specialDateType,ls=Rt?$t==="birthday"?Ru:Un:he(((vt=Ve.actionType)==null?void 0:vt.icon)||null),Qt=Ve.contact.phone,rs=Ve.contact.email,as=Rt?$t==="birthday"?"#EC4899":"#8B5CF6":((Cs=Ve.actionType)==null?void 0:Cs.color)||"#3B82F6",ir=Rt?$t==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(or=Ve.actionType)==null?void 0:or.name;return e.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${Rt?"ring-2 ring-offset-2":""}`,style:Rt?{"--tw-ring-color":as}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:as},children:[e.jsx(ls,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:ir})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>t(`/mission-control/contacts/${Ve.contact.id}`),className:"font-medium text-sm hover:text-primary hover:underline transition-colors text-left",children:[Ve.contact.first_name," ",Ve.contact.last_name]}),e.jsxs("div",{className:"flex gap-1.5",children:[Qt&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`tel:${Ve.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(Zn,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:Ne(Ve.contact.phone,(Ar=Ve.script)==null?void 0:Ar.script_body,Ve.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(oo,{className:"h-3 w-3"}),"Text"]})]}),rs&&(pe?e.jsxs("button",{onClick:()=>{Y({id:Ve.contact.id,first_name:Ve.contact.first_name,last_name:Ve.contact.last_name,email:Ve.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(_r,{className:"h-3 w-3"}),"Email"]}):e.jsxs("a",{href:it(Ve.contact.email,(Wn=Ve.script)==null?void 0:Wn.script_body,(ai=Ve.script)==null?void 0:ai.email_subject,(bo=Ve.actionType)==null?void 0:bo.name,Ve.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(_r,{className:"h-3 w-3"}),"Email"]}))]}),Rt&&e.jsxs("button",{onClick:()=>{const Fa=`${Ve.contact.first_name}${Ve.contact.last_name?" "+Ve.contact.last_name:""}`,yn=$t==="birthday"?"birthday":"home_anniversary",na=new URLSearchParams({cardType:yn,contactId:Ve.contact.id,name:Fa,...Ve.contact.address?{address:Ve.contact.address}:{},...$t==="anniversary"&&Ve.contact.home_anniversary?{date:Ve.contact.home_anniversary}:{}});t(`/mission-control/card-studio?${na.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(_r,{className:"h-3 w-3"}),"Send ",$t==="birthday"?"Birthday":"Anniversary"," Card"]}),!Qt&&!rs&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No contact info"}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[Ve.relationshipTypeName&&e.jsx(at,{variant:"secondary",className:"text-xs",children:Ve.relationshipTypeName}),Ve.monthNumber>0&&e.jsxs(at,{variant:"outline",className:"text-xs",children:["Month ",Ve.monthNumber]})]}),Ve.script&&e.jsx(K,{size:"sm",variant:"outline",className:"w-full",onClick:()=>Dt(Ve),children:"View Script"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1 gap-1",onClick:()=>{ie(Ve.contact.id),le(`${Ve.contact.first_name} ${Ve.contact.last_name||""}`.trim())},children:[e.jsx(pp,{className:"h-3.5 w-3.5"}),"Snooze"]}),e.jsx(K,{size:"sm",className:"flex-1",onClick:()=>{var Fa;return De(Ve.contact.id,Ve.actionType.id,(Fa=Ve.script)==null?void 0:Fa.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]},Ve.contact.id+Je)}),e.jsx("div",{className:"flex-shrink-0 w-[100px] border rounded-lg flex items-center justify-center",children:e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"h-full w-full",children:[e.jsx(ef,{className:"h-5 w-5 mr-2"}),"More"]})}),e.jsx(Td,{children:e.jsx(Ta,{onClick:()=>t("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zt,{className:"text-lg",children:"Momentum"}),e.jsxs(vs,{open:A,onOpenChange:I,children:[e.jsx(Ei,{asChild:!0,children:e.jsx("button",{onClick:we,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx($l,{className:"h-4 w-4 text-muted-foreground hover:text-primary"})})}),e.jsxs(ys,{className:"sm:max-w-[360px]",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{htmlFor:"weekly-goal-ic",children:"Weekly touch goal"}),e.jsx(Re,{id:"weekly-goal-ic",type:"number",min:"1",value:L,onChange:Ve=>R(Ve.target.value),placeholder:"20",onKeyDown:Ve=>{Ve.key==="Enter"&&ye()}})]}),e.jsx(K,{onClick:ye,className:"w-full",children:"Save Goal"})]})]})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Ti,{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($h,{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(Ha,{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(_Ve,{}),e.jsx(y7t,{})]})]}),e.jsx(vs,{open:j,onOpenChange:w,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(Ns,{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:ot(_.script.script_body,_.contact)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>w(!1),children:"Close"}),e.jsx(K,{className:"flex-1",onClick:()=>{var Ve;return De(_.contact.id,_.actionType.id,(Ve=_.script)==null?void 0:Ve.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]})}),e.jsx(i7t,{})]}),pe&&te&&e.jsx(EM,{open:X,onOpenChange:se,contact:te,gmailEmail:be}),e.jsx(Cle,{open:!!de,onOpenChange:Ve=>!Ve&&ie(null),contactId:de||"",contactName:ae})]})}var XKe="Toggle",vwe=S.forwardRef((t,s)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...o}=t,[l,i]=xu({prop:r,onChange:a,defaultProp:n??!1,caller:XKe});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:Cr(t.onClick,()=>{t.disabled||i(!l)})})});vwe.displayName=XKe;var QKe=vwe,X_="ToggleGroup",[JKe]=Ac(X_,[q_]),eZe=q_(),_we=mt.forwardRef((t,s)=>{const{type:r,...n}=t;if(r==="single"){const a=n;return e.jsx(b7t,{...a,ref:s})}if(r==="multiple"){const a=n;return e.jsx(w7t,{...a,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${X_}\``)});_we.displayName=X_;var[tZe,sZe]=JKe(X_),b7t=mt.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=xu({prop:r,defaultProp:n??"",onChange:a,caller:X_});return e.jsx(tZe,{scope:t.__scopeToggleGroup,type:"single",value:mt.useMemo(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:mt.useCallback(()=>i(""),[i]),children:e.jsx(rZe,{...o,ref:s})})}),w7t=mt.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=xu({prop:r,defaultProp:n??[],onChange:a,caller:X_}),d=mt.useCallback(p=>i((f=[])=>[...f,p]),[i]),u=mt.useCallback(p=>i((f=[])=>f.filter(v=>v!==p)),[i]);return e.jsx(tZe,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:d,onItemDeactivate:u,children:e.jsx(rZe,{...o,ref:s})})});_we.displayName=X_;var[j7t,k7t]=JKe(X_),rZe=mt.forwardRef((t,s)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:o,dir:l,loop:i=!0,...d}=t,u=eZe(r),p=$_(l),f={role:"group",dir:p,...d};return e.jsx(j7t,{scope:r,rovingFocus:a,disabled:n,children:a?e.jsx(coe,{asChild:!0,...u,orientation:o,dir:p,loop:i,children:e.jsx(Qr.div,{...f,ref:s})}):e.jsx(Qr.div,{...f,ref:s})})}),Pae="ToggleGroupItem",nZe=mt.forwardRef((t,s)=>{const r=sZe(Pae,t.__scopeToggleGroup),n=k7t(Pae,t.__scopeToggleGroup),a=eZe(t.__scopeToggleGroup),o=r.value.includes(t.value),l=n.disabled||t.disabled,i={...t,pressed:o,disabled:l},d=mt.useRef(null);return n.rovingFocus?e.jsx(doe,{asChild:!0,...a,focusable:!l,active:o,ref:d,children:e.jsx(pEe,{...i,ref:s})}):e.jsx(pEe,{...i,ref:s})});nZe.displayName=Pae;var pEe=mt.forwardRef((t,s)=>{const{__scopeToggleGroup:r,value:n,...a}=t,o=sZe(Pae,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=o.type==="single"?l:void 0;return e.jsx(vwe,{...i,...a,ref:s,onPressedChange:d=>{d?o.onItemActivate(n):o.onItemDeactivate(n)}})}),aZe=_we,iZe=nZe;const oZe=XN("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"}}),N7t=S.forwardRef(({className:t,variant:s,size:r,...n},a)=>e.jsx(QKe,{ref:a,className:Pt(oZe({variant:s,size:r,className:t})),...n}));N7t.displayName=QKe.displayName;const lZe=S.createContext({size:"default",variant:"default"}),cZe=S.forwardRef(({className:t,variant:s,size:r,children:n,...a},o)=>e.jsx(aZe,{ref:o,className:Pt("flex items-center justify-center gap-1",t),...a,children:e.jsx(lZe.Provider,{value:{variant:s,size:r},children:n})}));cZe.displayName=aZe.displayName;const dZe=S.forwardRef(({className:t,children:s,variant:r,size:n,...a},o)=>{const l=S.useContext(lZe);return e.jsx(iZe,{ref:o,className:Pt(oZe({variant:l.variant||r,size:l.size||n}),t),...a,children:s})});dZe.displayName=iZe.displayName;const S7t=[{value:"bidirectional",label:"Two-Way",icon:Hc,tooltip:"Sync contacts in both directions"},{value:"push_only",label:"Push Only",icon:Vd,tooltip:"Only push Agent OS → BoldTrail"},{value:"pull_only",label:"Pull Only",icon:eh,tooltip:"Only pull BoldTrail → Agent OS"}];function dye({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(cZe,{type:"single",value:t,onValueChange:a=>{a&&s(a)},className:"justify-start",children:S7t.map(a=>e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsxs(dZe,{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(Wc,{children:a.tooltip})]},a.value))})]})}function C7t(){const t=ns(),[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(null),[f,v]=S.useState(null),[_,b]=S.useState(0),j=S.useRef(!1),{data:w}=Ct({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:$,error:q}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(q)throw q;return $}}),N=(w==null?void 0:w.sync_direction)||"bidirectional",C=u??N,A=Ot({mutationFn:async()=>{const{data:$,error:q}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(q)throw q;if($!=null&&$.error)throw new Error($.error);return $},onSuccess:$=>{p(null),a($),r(!0)},onError:$=>{fe.error($.message||"Failed to generate sync preview")}}),I=Ot({mutationFn:async()=>{j.current=!1,v("Initializing sync..."),b(5);const{data:$,error:q}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:C}});if(q)throw q;if($!=null&&$.error)throw new Error($.error);const U=$;let V=U.sync_log_id,X=U.next_phase,se=U.next_offset;const te=U.push_total||0,Y=U.pull_total||0,de=te+Y;let ie=0,ae=0;for(;X!=="finalize"&&!j.current;){X==="push"?(v(`Pushing contacts to BoldTrail... (${ie}/${te})`),b(de>0?ie/de*100:0)):X==="pull"&&(v(`Pulling contacts from BoldTrail... (${ae}/${Y})`),b(de>0?(te+ae)/de*100:0));const{data:be,error:ye}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:X,offset:se,sync_log_id:V,sync_direction:C}});if(ye)throw ye;if(be!=null&&be.error)throw new Error(be.error);const we=be;ie+=we.chunk_pushed||0,ae+=we.chunk_pulled||0,we.progress&&v(we.progress),X==="pull"&&Y>0?b(Math.min(95,ae/Y*100)):X==="push"&&te>0&&b(Math.min(95,ie/te*100)),X=we.next_phase,se=we.next_offset}v("Finalizing sync..."),b(95);const{data:le,error:pe}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:V,sync_direction:C}});if(pe)throw pe;return b(100),le},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"]}),fe.success(`Sync complete! Pushed ${$.contacts_pushed||0}, pulled ${$.contacts_pulled||0}, skipped ${$.contacts_skipped||0} duplicates.`)},onError:$=>{v(null),b(0),fe.error($.message||"Sync failed")}});if(!(w!=null&&w.connected))return null;const L=C==="pull_only"?0:(n==null?void 0:n.to_push)??0,R=C==="push_only"?0:(n==null?void 0:n.to_pull)??0;return e.jsxs(e.Fragment,{children:[e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"icon",onClick:()=>A.mutate(),disabled:A.isPending,className:"shrink-0",children:A.isPending?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Hc,{className:"h-4 w-4 text-emerald-600"})})}),e.jsx(Wc,{children:"Sync with BoldTrail"})]}),e.jsx(vs,{open:s,onOpenChange:$=>{I.isPending||r($)},children:e.jsxs(ys,{className:"sm:max-w-lg",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Hc,{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(dye,{value:C,onChange:p,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${C==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:L}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Vd,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${C==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:R}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(eh,{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(hr,{className:"h-3 w-3"})," Already synced"]})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["Agent OS: ",n.agent_os_total," contacts · BoldTrail: ",n.boldtrail_total," contacts"]}),L>0&&e.jsxs(mf,{open:o,onOpenChange:l,children:[e.jsx(pf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Vd,{className:"h-3 w-3 text-emerald-600"}),L," contacts to push to BoldTrail"]}),e.jsx(Vo,{className:`h-3 w-3 transition-transform ${o?"rotate-180":""}`})]})}),e.jsx(ff,{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"]})]})})]}),R>0&&e.jsxs(mf,{open:i,onOpenChange:d,children:[e.jsx(pf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(eh,{className:"h-3 w-3 text-blue-600"}),R," contacts to pull from BoldTrail"]}),e.jsx(Vo,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})}),e.jsx(ff,{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&&R===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(Ti,{value:_||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:f||"Sync in progress..."})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),disabled:I.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>I.mutate(),disabled:I.isPending||L===0&&R===0,className:"gap-2",children:[I.isPending?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Hc,{className:"h-4 w-4"}),I.isPending?"Syncing...":"Sync Now"]})]})]})]})})]})}const uZe=()=>{const{user:t}=Gs();return Ct({queryKey:["popby-items",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.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}=Gs();return Ct({queryKey:["popby-logs",s==null?void 0:s.id,t],queryFn:async()=>{let r=G.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})},bwe=()=>{const{user:t}=Gs();return Ct({queryKey:["relationship-type-popby-defaults",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("relationship_type_popby_defaults").select("*");if(r)throw r;return s},enabled:!!t})},hZe=()=>{const{user:t}=Gs();return Ct({queryKey:["contact-popby-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_popby_settings").select("*");if(r)throw r;return s},enabled:!!t})},mZe=()=>{const{data:t}=Jh(),{data:s}=Ef(),{data:r}=Mle(),{data:n}=hZe(),{data:a}=bwe(),o=new Map;r==null||r.forEach(p=>{const f=o.get(p.contact_id);(!f||new Date(p.completed_at)>new Date(f))&&o.set(p.contact_id,p.completed_at)});const l=new Map;a==null||a.forEach(p=>l.set(p.relationship_type_id,p.frequency_days));const i=new Map;n==null||n.filter(p=>p.is_active).forEach(p=>{i.set(p.contact_id,p.frequency_days)});const d=Gh(new Date);return(t||[]).map(p=>{let f=90;if(i.has(p.id))f=i.get(p.id);else if(p.tags&&p.tags.length>0){const w=p.tags.map(N=>l.get(N.relationship_type_id)).filter(N=>N!==void 0);w.length>0&&(f=Math.min(...w))}const v=o.get(p.id)||null,_=v?Gg(d,Gh(new Date(v))):null,b=_===null||_>=f,j=b&&_!==null?_-f:0;return{...p,lastPopby:v,daysSinceLastPopby:_,frequencyDays:f,isDue:b,daysOverdue:j}}).sort((p,f)=>f.daysOverdue-p.daysOverdue)},pZe=()=>mZe().filter(s=>s.isDue),M7t=()=>{const t=ns(),{user:s}=Gs();return Ot({mutationFn:async r=>{const{error:n}=await G.from("popby_items").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-items"]}),an({title:"Popby item created!"})},onError:r=>{an({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},fZe=()=>{const t=ns(),{user:s}=Gs();return Ot({mutationFn:async r=>{const{error:n}=await G.from("popby_logs").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-logs"]}),an({title:"Popby logged!"})},onError:r=>{an({title:"Error logging popby",description:r.message,variant:"destructive"})}})},T7t=()=>{const t=ns(),{user:s}=Gs();return Ot({mutationFn:async r=>{const{error:n}=await G.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"]}),an({title:"Frequency updated!"})},onError:r=>{an({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},A7t=()=>{const{data:t}=Mle(30),s=pZe(),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 E7t(){const{user:t}=Gs();return Ct({queryKey:["contact-touch-logs",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_touch_logs").select("*").order("completed_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function gZe(t){const{data:s}=E7t(),{data:r}=hZe(),{data:n}=bwe(),{data:a}=o7t();return S.useMemo(()=>{const o=a==null?void 0:a.find(w=>w.contact_id===t.id),l=o?new Date(o.snoozed_until):null,i=Gh(new Date);if(l&&!IN(l,i))return{nextTouchDate:l,daysUntil:Gg(l,i),status:"snoozed",frequencyDays:90,lastTouchDate:null,snoozedUntil:l};const u=((s==null?void 0:s.filter(w=>w.contact_id===t.id))||[]).sort((w,N)=>new Date(N.completed_at).getTime()-new Date(w.completed_at).getTime())[0],p=u?new Date(u.completed_at):null;let f=90;const v=r==null?void 0:r.find(w=>w.contact_id===t.id&&w.is_active);if(v)f=v.frequency_days;else if(t.tags&&t.tags.length>0){const w=t.tags.map(N=>{const C=n==null?void 0:n.find(A=>A.relationship_type_id===N.relationship_type_id);return C==null?void 0:C.frequency_days}).filter(N=>N!==void 0);w.length>0&&(f=Math.min(...w))}if(!p)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:f,lastTouchDate:null,snoozedUntil:null};const _=ml(Gh(p),f),b=Gg(_,i);let j;return b<0?j="overdue":b<=7?j="due-soon":j="on-track",{nextTouchDate:_,daysUntil:b,status:j,frequencyDays:f,lastTouchDate:p,snoozedUntil:null}},[t,s,r,n,a])}function uye({contact:t}){const s=gZe(t),n=(()=>{switch(s.status){case"overdue":return{variant:"destructive",icon:Qo,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:da,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:pp,text:`Snoozed until ${ws(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:on,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return e.jsxs(at,{variant:n.variant,className:Pt("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function P7t({contact:t,onLogTouch:s,onSnooze:r}){const n=gZe(t),a=c7t(),[o,l]=S.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(Qo,{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(da,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"});case"snoozed":return e.jsx(pp,{className:"h-5 w-5 text-slate-600 dark:text-slate-400"});case"never-touched":return e.jsx(on,{className:"h-5 w-5 text-muted-foreground"})}},u=()=>{switch(n.status){case"overdue":return`${Math.abs(n.daysUntil)} days overdue`;case"due-soon":return n.daysUntil===0?"Due today!":`Due in ${n.daysUntil} days`;case"on-track":return`On track - ${n.daysUntil} days remaining`;case"snoozed":return`Snoozed for ${n.daysUntil} more days`;case"never-touched":return"No touches logged yet"}},p=async()=>{await a.mutateAsync(t.id)};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(on,{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:Pt("font-medium",i()),children:u()})]}),n.status==="snoozed"&&n.snoozedUntil&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Snoozed until:"})," ",ws(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:"})," ",ws(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:"})," ",ws(n.lastTouchDate,"MMM d, yyyy")]}),n.status!=="snoozed"&&e.jsxs("div",{className:"text-xs text-muted-foreground border-t pt-2",children:["Touch frequency: Every ",n.frequencyDays," days"]}),n.status==="snoozed"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:p,disabled:a.isPending,children:[e.jsx(Ur,{className:"h-4 w-4 mr-1"}),"Cancel Snooze"]}),s&&e.jsx(K,{size:"sm",className:"flex-1",onClick:s,children:"Log Touch"})]}),n.status!=="snoozed"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>l(!0),children:[e.jsx(pp,{className:"h-4 w-4 mr-1"}),"Snooze"]}),(n.status==="overdue"||n.status==="due-soon"||n.status==="never-touched")&&s&&e.jsx(K,{size:"sm",className:"flex-1",variant:n.status==="overdue"?"default":"outline",onClick:s,children:"Log Touch"})]})]})]}),e.jsx(Cle,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const Yme=768;function PM(){const[t,s]=S.useState(void 0);return S.useEffect(()=>{const r=window.matchMedia(`(max-width: ${Yme-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}const I7t={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"}},L7t={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 mI({score:t,showScore:s=!1,showTooltip:r=!0,size:n="sm",className:a}){const o=I7t[t.status],l=L7t[n],i=e.jsxs("div",{className:Pt("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[e.jsx("span",{className:Pt("rounded-full",o.bgClass,l.dot)}),s?e.jsx("span",{children:t.score}):e.jsx("span",{children:o.label})]});return r?e.jsx(QN,{children:e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:i}),e.jsx(Wc,{side:"top",className:"w-64 p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-semibold",children:"Relationship Score"}),e.jsxs("span",{className:Pt("font-bold",o.textClass),children:[t.score,"/100"]})]}),e.jsx(Ti,{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 D7t=[{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}],dR=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]},O7t=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=Gs(),{toast:o}=Ia(),l=S.useRef(null),[i,d]=S.useState("upload"),[u,p]=S.useState([]),[f,v]=S.useState([]),[_,b]=S.useState({}),[j,w]=S.useState([]),[N,C]=S.useState([]),[A,I]=S.useState(!1),[L,R]=S.useState(null),$=()=>{d("upload"),p([]),v([]),b({}),w([]),C([]),R(null),l.current&&(l.current.value="")},q=()=>{$(),s(!1)},U=be=>{const ye=be.split(` `).map(_e=>_e.trim()).filter(_e=>_e);if(ye.length===0)return{headers:[],data:[]};const we=_e=>{const Ce=[];let Te="",Fe=!1;for(let Ae=0;Ae<_e.length;Ae++){const We=_e[Ae];We==='"'?Fe=!Fe:(We===","||We===" ")&&!Fe?(Ce.push(Te.trim()),Te=""):Te+=We}return Ce.push(Te.trim()),Ce},ke=we(ye[0]),Ze=ye.slice(1).map(we);return{headers:ke,data:Ze}},V=be=>{var ke;const ye=(ke=be.target.files)==null?void 0:ke[0];if(!ye)return;const we=new FileReader;we.onload=Ze=>{var Ae;const _e=(Ae=Ze.target)==null?void 0:Ae.result,{headers:Ce,data:Te}=U(_e);if(Ce.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}p(Ce),v(Te);const Fe={};Ce.forEach(We=>{const ht=We.toLowerCase().replace(/[_\s-]/g,"");ht.includes("firstname")||ht==="first"?Fe.first_name=We:ht.includes("lastname")||ht==="last"?Fe.last_name=We:ht.includes("spouse")&&ht.includes("email")?Fe.spouse_email=We:ht.includes("spouse")||ht.includes("partner")?Fe.spouse_name=We:ht.includes("email")?Fe.email=We:ht.includes("phone")||ht.includes("mobile")||ht.includes("cell")?Fe.phone=We:ht.includes("address")||ht.includes("street")?Fe.address=We:ht==="city"?Fe.city=We:ht==="state"||ht==="province"?Fe.state=We:ht==="zip"||ht==="zipcode"||ht==="postalcode"?Fe.zip=We:ht.includes("company")||ht.includes("organization")||ht.includes("business")?Fe.company_name=We:ht.includes("jobtitle")||ht.includes("title")&&!ht.includes("spouse")?Fe.job_title=We:ht.includes("birthday")||ht.includes("dob")||ht.includes("birthdate")?Fe.birthday=We:ht.includes("anniversary")||ht.includes("homeanniversary")?Fe.home_anniversary=We:(ht.includes("notes")||ht.includes("comment"))&&(Fe.notes=We)}),b(Fe),d("mapping")},we.readAsText(ye)},X=(be,ye)=>{b(we=>{if(ye==="none"){const{[be]:ke,...Ze}=we;return Ze}return{...we,[be]:ye}})},se=be=>{w(ye=>ye.includes(be)?ye.filter(we=>we!==be):[...ye,be])},te=async()=>{if(!(a!=null&&a.id))return;const{data:be}=await G.from("innercircle_contacts").select("id, email, phone").eq("owner_user_id",a.id),ye=new Set((be||[]).filter(Ze=>Ze.email).map(Ze=>Ze.email.toLowerCase())),we=new Set((be||[]).filter(Ze=>Ze.phone).map(Ze=>Ze.phone.replace(/[^0-9]/g,""))),ke=f.map(Ze=>{const _e=ht=>{const De=_[ht];if(!De)return"";const Dt=u.indexOf(De);return Dt>=0?(Ze[Dt]||"").trim():""},Ce=_e("first_name"),Te=_e("email"),Fe=_e("phone"),Ae=Ce.length>0,We=!!(Te&&ye.has(Te.toLowerCase())||Fe&&we.has(Fe.replace(/[^0-9]/g,"")));return{first_name:Ce,last_name:_e("last_name"),email:Te,phone:Fe,address:_e("address"),city:_e("city"),state:_e("state"),zip:_e("zip"),spouse_name:_e("spouse_name"),spouse_email:_e("spouse_email"),company_name:_e("company_name"),job_title:_e("job_title"),birthday:_e("birthday"),home_anniversary:_e("home_anniversary"),notes:_e("notes"),isValid:Ae,isDuplicate:We,error:Ae?void 0:"First name is required"}});C(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}},de=async()=>{if(!(a!=null&&a.id))return;const be=N.filter(Ze=>Ze.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,we=0,ke=0;try{for(const Ze of be)try{let _e=null;if(Ze.email){const{data:Fe}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ze.email).maybeSingle();_e=Fe}if(!_e&&Ze.phone){const Fe=Ze.phone.replace(/[^0-9]/g,""),{data:Ae}=await G.from("innercircle_contacts").select("id, phone").eq("owner_user_id",a.id).not("phone","is",null);if(Ae){const We=Ae.find(ht=>ht.phone&&ht.phone.replace(/[^0-9]/g,"")===Fe);We&&(_e={id:We.id})}}const Ce={owner_user_id:a.id,first_name:Ze.first_name,last_name:Ze.last_name||null,email:Ze.email||null,phone:Ze.phone||null,address:Ze.address||null,city:Ze.city||null,state:Ze.state||null,zip:Ze.zip||null,spouse_name:Ze.spouse_name||null,spouse_email:Ze.spouse_email||null,company_name:Ze.company_name||null,job_title:Ze.job_title||null,birthday:dR(Ze.birthday),home_anniversary:dR(Ze.home_anniversary),notes:Ze.notes||null};let Te=null;if(_e){const{data:Fe}=await G.from("innercircle_contacts").select("*").eq("id",_e.id).single();if(Fe){const Ae={},We=["last_name","email","phone","address","city","state","zip","spouse_name","spouse_email","company_name","job_title","birthday","home_anniversary","notes"];for(const ht of We){const De=Fe[ht],Dt=Ce[ht];(!De||De==="")&&Dt&&(Ae[ht]=Dt)}Object.keys(Ae).length>0&&await G.from("innercircle_contacts").update(Ae).eq("id",_e.id)}Te=_e.id,we++}else{const{data:Fe,error:Ae}=await G.from("innercircle_contacts").insert(Ce).select("id").single();Ae?(console.error("Insert error for contact:",Ze.first_name,Ae),ke++):Fe?(Te=Fe.id,j.length>0&&await G.from("innercircle_contact_tags").insert(j.map(We=>({contact_id:Fe.id,relationship_type_id:We}))),ye++):ke++}if(Te&&Ze.spouse_name){const Fe=Y(Ze.spouse_name);let Ae=null;if(Ze.spouse_email){const{data:ht}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ze.spouse_email).maybeSingle();Ae=ht}if(!Ae){const{data:ht}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("first_name",Fe.first_name).eq("last_name",Fe.last_name||Ze.last_name||"").maybeSingle();Ae=ht}let We=null;if(Ae){We=Ae.id;const ht=dR(Ze.home_anniversary);ht&&await G.from("innercircle_contacts").update({home_anniversary:ht}).eq("id",Ae.id).is("home_anniversary",null)}else{const{data:ht}=await G.from("innercircle_contacts").insert({owner_user_id:a.id,first_name:Fe.first_name,last_name:Fe.last_name||Ze.last_name||null,email:Ze.spouse_email||null,address:Ze.address||null,city:Ze.city||null,state:Ze.state||null,zip:Ze.zip||null,home_anniversary:dR(Ze.home_anniversary),spouse_name:`${Ze.first_name}${Ze.last_name?" "+Ze.last_name:""}`,spouse_email:Ze.email||null,notes:`Spouse of ${Ze.first_name} ${Ze.last_name||""} (imported via CSV)`.trim()}).select("id").single();ht&&(We=ht.id,ye++)}We&&(await G.from("innercircle_contacts").update({spouse_contact_id:We}).eq("id",Te),await G.from("innercircle_contacts").update({spouse_contact_id:Te}).eq("id",We))}}catch(_e){console.error("Error importing contact:",_e),ke++}R({created:ye,updated:we,failed:ke}),d("result"),(ye>0||we>0)&&n(),o({title:"Import Complete",description:`${ye} created, ${we} updated${ke>0?`, ${ke} failed`:""}.`})}catch(Ze){console.error("Import error:",Ze),o({title:"Import Failed",description:Ze.message||"Failed to import contacts",variant:"destructive"})}finally{I(!1)}},ie=N.filter(be=>be.isValid).length,ae=N.filter(be=>!be.isValid).length,le=N.filter(be=>be.isValid&&be.isDuplicate).length,pe=ie-le;return e.jsx(vs,{open:t,onOpenChange:q,children:e.jsxs(ys,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(C0,{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:V,className:"hidden"}),e.jsx(Ya,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click to upload or drag and drop a CSV file"}),e.jsx(K,{onClick:()=>{var 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(K,{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"}),we=URL.createObjectURL(ye),ke=document.createElement("a");ke.href=we,ke.download="contact_import_template.csv",ke.click(),URL.revokeObjectURL(we)},children:[e.jsx(xi,{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(ve,{className:"text-base font-medium",children:"Map CSV Columns to Contact Fields"}),e.jsx("div",{className:"grid gap-3",children:D7t.map(be=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(ve,{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=>X(be.key,ye),children:[e.jsx(Js,{className:"w-48",children:e.jsx(sr,{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(ve,{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(at,{variant:j.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: ",f.length," row(s) found in CSV"]})})]}),i==="preview"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(da,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{children:[pe," new"]})]}),le>0&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Qo,{className:"h-4 w-4"}),e.jsxs("span",{children:[le," existing (will merge gaps)"]})]}),ae>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Qo,{className:"h-4 w-4"}),e.jsxs("span",{children:[ae," invalid"]})]})]}),le>0&&e.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-xs text-muted-foreground",children:"Duplicates matched by email or phone will only fill in missing fields — your existing data won't be overwritten."}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{className:"bg-muted/30",children:[e.jsx(jt,{children:"First Name"}),e.jsx(jt,{children:"Last Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Phone"}),e.jsx(jt,{children:"Status"})]})}),e.jsx(Pn,{children:N.slice(0,100).map((be,ye)=>e.jsxs(js,{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(at,{variant:"outline",className:"bg-accent text-accent-foreground",children:"Merge"}):e.jsx(at,{variant:"secondary",className:"bg-primary/10 text-primary",children:"New"}):e.jsx(at,{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(da,{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(On,{children:[i==="upload"&&e.jsx(K,{variant:"outline",onClick:q,children:"Cancel"}),i==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:$,children:"Back"}),e.jsx(K,{onClick:te,disabled:!_.first_name,children:"Continue"})]}),i==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>d("mapping"),children:"Back"}),e.jsx(K,{onClick:de,disabled:A||ie===0,children:A?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${ie} Contact${ie!==1?"s":""}`})]}),i==="result"&&e.jsx(K,{onClick:q,children:"Done"})]})]})})};function R7t(){return"contacts"in navigator&&"ContactsManager"in window}function F7t(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 p of a){const f=p.replace(/^\s+/,"");if(f.startsWith("N:")||f.startsWith("N;")){const _=f.substring(f.indexOf(":")+1).split(";");l=(_[0]||"").trim(),o=(_[1]||"").trim()}if((f.startsWith("FN:")||f.startsWith("FN;"))&&!o){const _=f.substring(f.indexOf(":")+1).trim().split(" ");o=_[0]||"",l=_.slice(1).join(" ")}(f.startsWith("EMAIL")||f.match(/^item\d+\.EMAIL/i))&&!i&&(i=f.substring(f.indexOf(":")+1).trim()),(f.startsWith("TEL")||f.match(/^item\d+\.TEL/i))&&!d&&(d=f.substring(f.indexOf(":")+1).trim()),(f.startsWith("ADR")||f.match(/^item\d+\.ADR/i))&&!u&&(u=f.substring(f.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 z7t({open:t,onOpenChange:s,onComplete:r}){const{user:n}=Gs(),{data:a}=Jh(),o=Yoe(),l=S.useRef(null),[i,d]=S.useState("choose"),[u,p]=S.useState([]),[f,v]=S.useState(new Set),[_,b]=S.useState(0),[j,w]=S.useState(0),N=R7t(),C=S.useCallback(X=>{if(!a)return X;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 X.map(Y=>{var ae,le;const de=(ae=Y.email)==null?void 0:ae.toLowerCase(),ie=(le=Y.phone)==null?void 0:le.replace(/\D/g,"");return de&&se.has(de)?{...Y,isDuplicate:!0,duplicateField:"email"}:ie&&ie.length>=7&&te.has(ie)?{...Y,isDuplicate:!0,duplicateField:"phone"}:Y})},[a]),A=async()=>{try{const X=["name","email","tel","address"],se=await navigator.contacts.select(X,{multiple:!0});if(!se||se.length===0)return;const te=se.map(ie=>{var pe,be,ye,we;const le=(((pe=ie.name)==null?void 0:pe[0])||"").split(" ");return{first_name:le[0]||"",last_name:le.slice(1).join(" "),email:((be=ie.email)==null?void 0:be[0])||"",phone:((ye=ie.tel)==null?void 0:ye[0])||"",address:(we=ie.address)!=null&&we[0]?[ie.address[0].streetAddress,ie.address[0].city,ie.address[0].region,ie.address[0].postalCode].filter(Boolean).join(", "):""}}),Y=C(te);p(Y);const de=new Set;Y.forEach((ie,ae)=>{ie.isDuplicate||de.add(ae)}),v(de),d("preview")}catch(X){console.error("Contact Picker error:",X),an({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},I=X=>{var Y;const se=(Y=X.target.files)==null?void 0:Y[0];if(!se)return;const te=new FileReader;te.onload=de=>{var be;const ie=(be=de.target)==null?void 0:be.result,ae=F7t(ie);if(ae.length===0){an({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const le=C(ae);p(le);const pe=new Set;le.forEach((ye,we)=>{ye.isDuplicate||pe.add(we)}),v(pe),d("preview")},te.readAsText(se),l.current&&(l.current.value="")},L=async()=>{const X=u.filter((te,Y)=>f.has(Y));if(X.length===0)return;d("importing");let se=0;for(const te of X)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++,w(Math.round(se/X.length*100))}catch(Y){console.error(`Failed to import ${te.first_name} ${te.last_name}:`,Y)}b(se),d("done")},R=X=>{v(se=>{const te=new Set(se);return te.has(X)?te.delete(X):te.add(X),te})},$=()=>{f.size===u.length?v(new Set):v(new Set(u.map((X,se)=>se)))},q=X=>{X||(d("choose"),p([]),v(new Set),b(0),w(0),i==="done"&&r()),s(X)},U=u.filter(X=>X.isDuplicate).length,V=f.size;return e.jsx(vs,{open:t,onOpenChange:q,children:e.jsxs(ys,{className:"sm:max-w-lg max-h-[90vh]",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(O0,{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(K,{onClick:A,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(O0,{className:"h-6 w-6"}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"font-semibold",children:"Select from Phone"}),e.jsx("div",{className:"text-xs opacity-80",children:"Pick contacts directly from your device"})]})]}),e.jsxs("div",{className:"relative",children:[N&&e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),N&&e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"or"})})]}),e.jsxs(K,{variant:N?"outline":"default",onClick:()=>{var X;return(X=l.current)==null?void 0:X.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(Ya,{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",U>0&&e.jsxs("span",{className:"text-amber-600 ml-1",children:["(",U," already exist)"]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:$,children:f.size===u.length?"Deselect All":"Select All"})]}),e.jsx(Bi,{className:"h-[350px] rounded-md border",children:e.jsx("div",{className:"divide-y",children:u.map((X,se)=>e.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${X.isDuplicate?"opacity-60":""}`,onClick:()=>R(se),children:[e.jsx(zo,{checked:f.has(se),onCheckedChange:()=>R(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:[X.first_name," ",X.last_name]}),X.isDuplicate&&e.jsxs(at,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",X.duplicateField,")"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[X.phone&&e.jsx("div",{children:X.phone}),X.email&&e.jsx("div",{className:"truncate",children:X.email})]})]})]},se))})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d("choose"),children:"Back"}),e.jsxs(K,{onClick:L,disabled:V===0,children:["Import ",V," Contact",V!==1?"s":""]})]})]}),i==="importing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(As,{className:"h-8 w-8 animate-spin text-primary"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Importing contacts..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[j,"% complete"]})]}),e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${j}%`}})})]}),i==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx(ua,{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(K,{onClick:()=>q(!1),className:"mt-2",children:"Done"})]})]})})}function Tle(){const t=ti();return Ct({queryKey:["custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_custom_tags").select("*").eq("owner_user_id",t).order("name");if(r)throw r;return s},enabled:!!t})}function B7t(t){return Ct({queryKey:["contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_custom_tag_assignments").select("*, tag:contact_custom_tags(*)").eq("contact_id",t);if(r)throw r;return s},enabled:!!t})}function wwe(){const t=ns(),s=ti();return Ot({mutationFn:async({name:r,color:n})=>{const{data:a,error:o}=await G.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 $7t(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.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 q7t(){const t=ns();return Ot({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 G.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 xZe(){const t=ns();return Ot({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await G.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 U7t(){const t=ns();return Ot({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await G.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 V7t(){const t=ti();return Ct({queryKey:["all-contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await G.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 H7t({selectedIds:t,contacts:s,onClearSelection:r,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const{data:i}=Ef(),d=sbe(),u=ns(),{isGmailConnected:p}=gy(),{data:f}=Tle(),v=wwe(),_=xZe(),[b,j]=S.useState(!1),[w,N]=S.useState(!1),[C,A]=S.useState(!1),[I,L]=S.useState(""),R=t.size;if(R===0)return null;const $=async Y=>{j(!0);try{const ie=Array.from(t).map(le=>({contact_id:le,relationship_type_id:Y})),{error:ae}=await G.from("innercircle_contact_tags").upsert(ie,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(ae)throw ae;u.invalidateQueries({queryKey:["innercircle-contacts"]}),u.invalidateQueries({queryKey:["innercircle-contact-counts"]}),an({title:`Assigned type to ${R} contacts`}),r()}catch(de){an({title:"Error assigning type",description:de.message,variant:"destructive"})}finally{j(!1)}},q=async Y=>{j(!0);try{const de=Array.from(t);for(const ie of de)try{await _.mutateAsync({contactId:ie,tagId:Y})}catch{}u.invalidateQueries({queryKey:["all-contact-custom-tags"]}),an({title:`Tagged ${R} contacts`}),A(!1),L("")}catch(de){an({title:"Error adding tags",description:de.message,variant:"destructive"})}finally{j(!1)}},U=async()=>{if(I.trim()){j(!0);try{const Y=await v.mutateAsync({name:I.trim()});await q(Y.id)}catch(Y){an({title:"Error creating tag",description:Y.message,variant:"destructive"}),j(!1)}}},V=(f==null?void 0:f.filter(Y=>Y.name.toLowerCase().includes(I.toLowerCase())))||[],X=f==null?void 0:f.find(Y=>Y.name.toLowerCase()===I.trim().toLowerCase()),se=()=>{const Y=s.filter(ye=>t.has(ye.id)),de=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],ie=Y.map(ye=>{var we;return[ye.first_name,ye.last_name||"",ye.email||"",ye.phone||"",ye.address||"",ye.birthday||"",ye.home_anniversary||"",ye.notes||"",((we=ye.tags)==null?void 0:we.map(ke=>{var Ze;return(Ze=ke.relationship_type)==null?void 0:Ze.name}).join("; "))||""]}),ae=[de.join(","),...ie.map(ye=>ye.map(we=>`"${(we||"").replace(/"/g,'""')}"`).join(","))].join(` `),le=new Blob([ae],{type:"text/csv"}),pe=URL.createObjectURL(le),be=document.createElement("a");be.href=pe,be.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,be.click(),URL.revokeObjectURL(pe),an({title:`Exported ${R} contacts`})},te=async()=>{if(confirm(`Are you sure you want to delete ${R} contacts? This cannot be undone.`)){j(!0);try{const Y=Array.from(t);for(const de of Y)await d.mutateAsync(de);r()}catch(Y){an({title:"Error deleting contacts",description:Y.message,variant:"destructive"})}finally{j(!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(at,{variant:"secondary",className:"font-semibold",children:[R," 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(Vh,{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(So,{open:C,onOpenChange:A,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",disabled:b,children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs(ko,{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()&&!X?(Y.preventDefault(),U()):Y.key==="Enter"&&X&&(Y.preventDefault(),q(X.id))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[V.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()&&!X&&e.jsxs("button",{onClick:U,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(Zs,{className:"h-3.5 w-3.5"}),'Create "',I.trim(),'"']}),V.length===0&&!I.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create a tag"})]})]})]}),p&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>N(!0),disabled:b,children:[e.jsx(_r,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),a&&n&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>n(Array.from(t)),disabled:b,children:[e.jsx(Fg,{className:"h-3.5 w-3.5 mr-1"}),"Send to Lead Pond"]}),l&&o&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>o(Array.from(t)),disabled:b,children:[e.jsx(k0,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:se,disabled:b,children:[e.jsx(xi,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:te,disabled:b,className:"text-destructive hover:text-destructive",children:[e.jsx(br,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:r,className:"ml-auto",children:[e.jsx(Ur,{className:"h-3.5 w-3.5 mr-1"}),"Clear"]})]}),e.jsx(EM,{open:w,onOpenChange:N,bulkContacts:Array.from(t).map(Y=>{const de=s.find(ie=>ie.id===Y);return de?{id:de.id,first_name:de.first_name,last_name:de.last_name,email:de.email||""}:null}).filter(Y=>Y!==null&&Y.email!==""),onSendComplete:()=>{N(!1),r()}})]})}function fEe({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const d=Dr(),u=`${t.first_name} ${t.last_name||""}`.trim();return e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:p=>p.stopPropagation(),children:e.jsx(ef,{className:"h-4 w-4"})})}),e.jsxs(Td,{align:"end",onClick:p=>p.stopPropagation(),children:[e.jsxs(Ta,{onClick:()=>d(`/mission-control/contacts/${t.id}?tab=activity&action=log`),children:[e.jsx(Zn,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),e.jsxs(Ta,{onClick:()=>d(`/mission-control/video?contactId=${t.id}`),children:[e.jsx(kn,{className:"h-4 w-4 mr-2"}),"Send Video"]}),e.jsxs(Ta,{onClick:()=>d(`/mission-control/popbys?contactId=${t.id}`),children:[e.jsx(Ai,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),e.jsxs(Ta,{onClick:()=>n(t.id,u),children:[e.jsx(pp,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&e.jsxs(Ta,{onClick:()=>a(t.id),children:[e.jsx(Fg,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&e.jsxs(Ta,{onClick:()=>l(t.id),children:[e.jsx(k0,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),e.jsxs(Ta,{onClick:()=>s(t),children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ta,{onClick:()=>r(t.id),className:"text-destructive focus:text-destructive",children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function W7t(){const{user:t}=Gs();return Ct({queryKey:["contact-smart-lists",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_smart_lists").select("*").order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function G7t(){const t=ns(),{user:s}=Gs();return Ot({mutationFn:async({name:r,filters:n,sort_by:a})=>{const{data:o,error:l}=await G.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"]}),an({title:"Smart filter saved"})},onError:r=>{an({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function K7t(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("contact_smart_lists").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),an({title:"Smart filter deleted"})}})}function Z7t({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=W7t(),a=G7t(),o=K7t(),[l,i]=S.useState(!1),[d,u]=S.useState(""),p=t.search||t.type&&t.type!=="all"||t.status&&t.status!=="all",f=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(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Hx,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&e.jsx(at,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),e.jsx(Vo,{className:"h-3.5 w-3.5"})]})}),e.jsxs(Td,{align:"start",className:"w-56",children:[n&&n.length>0?e.jsxs(e.Fragment,{children:[n.map(v=>e.jsxs(Ta,{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(K,{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(br,{className:"h-3 w-3 text-destructive"})})]},v.id)),e.jsx(S_,{})]}):e.jsx(Ta,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),p&&e.jsxs(Ta,{onClick:()=>i(!0),children:[e.jsx(QE,{className:"h-4 w-4 mr-2"}),"Save Current Filter"]})]})]}),e.jsx(vs,{open:l,onOpenChange:i,children:e.jsxs(ys,{className:"max-w-sm",children:[e.jsx(Ss,{children:e.jsx(Ns,{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"&&f(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{onClick:f,disabled:!d.trim()||a.isPending,children:"Save"})]})]})]})})]})}function LE(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 xEe({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=Dr(),i=gEe(t,"birthday",7),d=gEe(s,"anniversary",7);if(!i&&!d)return null;const u=(p,f)=>{f.stopPropagation();const v=new URLSearchParams;n&&v.set("contactId",n),a&&v.set("name",a),o&&v.set("address",o),p==="home_anniversary"&&s&&v.set("date",s),v.set("cardType",p),l(`/mission-control/card-studio?${v.toString()}`)};return e.jsxs("div",{className:Pt("flex flex-wrap gap-1",r),children:[i&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(at,{variant:"secondary",className:Pt("text-[10px] gap-0.5 font-medium",i.daysUntil===0?"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-400 animate-pulse":"bg-pink-50 text-pink-600 dark:bg-pink-900/20 dark:text-pink-400"),children:i.label}),n&&e.jsxs("button",{onClick:p=>u("birthday",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-pink-500/15 text-pink-600 dark:text-pink-400 hover:bg-pink-500/25 transition-colors",title:"Send a birthday card",children:[e.jsx(_r,{className:"h-2.5 w-2.5"}),"Send Card"]})]}),d&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(at,{variant:"secondary",className:Pt("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:p=>u("home_anniversary",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors",title:"Send an anniversary card",children:[e.jsx(_r,{className:"h-2.5 w-2.5"}),"Send Card"]})]})]})}function yEe({deal:t}){if(!t||!t.stage)return null;const{stage:s}=t;return e.jsxs(at,{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 Y7t(){const t=ti();return Ct({queryKey:["contact-deals-map",t],queryFn:async()=>{const{data:s,error:r}=await G.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 X7t({contactId:t,compact:s=!1}){const{data:r}=Tle(),{data:n}=B7t(t),a=wwe(),o=xZe(),l=U7t(),[i,d]=S.useState(!1),[u,p]=S.useState(""),f=S.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()),j=async N=>{v.has(N.id)?await l.mutateAsync({contactId:t,tagId:N.id}):await o.mutateAsync({contactId:t,tagId:N.id})},w=async()=>{if(!(!u.trim()||b))try{const N=await a.mutateAsync({name:u.trim()});await o.mutateAsync({contactId:t,tagId:N.id}),p("")}catch{}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n==null?void 0:n.map(N=>{var C,A,I;return e.jsxs(at,{variant:"outline",className:"text-xs gap-1 pr-1",style:{borderColor:((C=N.tag)==null?void 0:C.color)||"#6366F1",color:((A=N.tag)==null?void 0:A.color)||"#6366F1"},children:[e.jsx(Vh,{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(Ur,{className:"h-2.5 w-2.5"})})]},N.id)}),e.jsxs(So,{open:i,onOpenChange:d,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:s?"h-6 w-6 p-0":"h-6 px-2 text-xs",onClick:N=>N.stopPropagation(),children:[e.jsx(Zs,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs(ko,{className:"w-56 p-2",align:"start",onClick:N=>N.stopPropagation(),children:[e.jsx(Re,{ref:f,placeholder:"Search or create tag...",value:u,onChange:N=>p(N.target.value),onKeyDown:N=>{N.key==="Enter"&&u.trim()&&!b?(N.preventDefault(),w()):N.key==="Enter"&&b&&!v.has(b.id)&&(N.preventDefault(),j(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:()=>j(N),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors",children:[e.jsx("div",{className:"h-3 w-3 rounded-full shrink-0",style:{backgroundColor:N.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:N.name}),v.has(N.id)&&e.jsx(ua,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},N.id)),u.trim()&&!b&&e.jsxs("button",{onClick:w,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx(Zs,{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 vEe({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(at,{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 uR=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function Q7t({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Tle(),a=wwe(),o=q7t(),l=$7t(),[i,d]=S.useState(""),[u,p]=S.useState(uR[0]),[f,v]=S.useState(null),[_,b]=S.useState(""),[j,w]=S.useState(""),N=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:u}),d(""),p(uR[0]),an({title:"Tag created"})}catch(L){an({title:"Error",description:L.message,variant:"destructive"})}},C=async L=>{if(_.trim())try{await o.mutateAsync({id:L,name:_.trim(),color:j}),v(null),an({title:"Tag updated"})}catch(R){an({title:"Error",description:R.message,variant:"destructive"})}},A=async(L,R)=>{if(confirm(`Delete tag "${R}"? It will be removed from all contacts.`))try{await l.mutateAsync(L),an({title:"Tag deleted"})}catch($){an({title:"Error",description:$.message,variant:"destructive"})}},I=L=>{v(L.id),b(L.name),w(L.color)};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(Ns,{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(K,{size:"sm",onClick:N,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:uR.map(L=>e.jsx("button",{onClick:()=>p(L),className:`h-6 w-6 rounded-full border-2 transition-transform ${u===L?"border-foreground scale-110":"border-transparent hover:scale-105"}`,style:{backgroundColor:L}},L))})]}),e.jsxs("div",{className:"mt-2 space-y-1 max-h-[320px] overflow-y-auto",children:[n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading..."}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tags yet. Create one above!"}),r==null?void 0:r.map(L=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:f===L.id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:uR.map(R=>e.jsx("button",{onClick:()=>w(R),className:`h-5 w-5 rounded-full border-2 ${j===R?"border-foreground":"border-transparent"}`,style:{backgroundColor:R}},R))}),e.jsx(Re,{value:_,onChange:R=>b(R.target.value),onKeyDown:R=>R.key==="Enter"&&C(L.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>C(L.id),children:e.jsx(ua,{className:"h-4 w-4 text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>v(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3.5 w-3.5 rounded-full shrink-0",style:{backgroundColor:L.color}}),e.jsx("span",{className:"flex-1 text-sm",children:L.name}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>I(L),children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-destructive hover:text-destructive",onClick:()=>A(L.id,L.name),children:e.jsx(br,{className:"h-3.5 w-3.5"})})]})},L.id))]})]})})}function J7t({open:t,onOpenChange:s}){const{data:r,isLoading:n}=wM(),a=abe(),o=z5t(),l=B5t(),[i,d]=S.useState(""),[u,p]=S.useState(null),[f,v]=S.useState(""),_=async()=>{if(i.trim())try{await a.mutateAsync(i.trim()),d("")}catch(N){fe.error(N.message||"Failed to add lead source")}},b=async N=>{if(f.trim())try{await o.mutateAsync({id:N,name:f.trim()}),p(null)}catch(C){fe.error(C.message||"Failed to update")}},j=async(N,C)=>{if(confirm(`Remove lead source "${C}"? Contacts using it will keep the label but it won't appear in new dropdowns.`))try{await l.mutateAsync(N)}catch(A){fe.error(A.message||"Failed to remove")}},w=N=>{p(N.id),v(N.name)};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Manage Lead Sources"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"New lead source name...",value:i,onChange:N=>d(N.target.value),onKeyDown:N=>N.key==="Enter"&&_(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:_,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsxs("div",{className:"mt-2 space-y-1 max-h-[360px] overflow-y-auto",children:[n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading..."}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No lead sources yet. Create one above!"}),r==null?void 0:r.map(N=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:u===N.id?e.jsxs(e.Fragment,{children:[e.jsx(Re,{value:f,onChange:C=>v(C.target.value),onKeyDown:C=>C.key==="Enter"&&b(N.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>b(N.id),children:e.jsx(ua,{className:"h-4 w-4 text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>p(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-sm",children:N.name}),N.owner_user_id&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>w(N),children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-destructive hover:text-destructive",onClick:()=>j(N.id,N.name),children:e.jsx(br,{className:"h-3.5 w-3.5"})})]}),!N.owner_user_id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default"})]})},N.id))]})]})})}function yZe({value:t,onChange:s,label:r="Lead Source"}){const{data:n}=wM(),a=abe(),[o,l]=S.useState(!1),[i,d]=S.useState(""),u=async()=>{if(i.trim())try{const p=await a.mutateAsync(i.trim());p&&(s(p.id),d(""),l(!1))}catch{}};return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:r}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:t||"_none",onValueChange:p=>s(p==="_none"?"":p),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(sr,{placeholder:"Select lead source"})}),e.jsxs(er,{children:[e.jsx(At,{value:"_none",children:"No source"}),n==null?void 0:n.map(p=>e.jsx(At,{value:p.id,children:p.name},p.id))]})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",className:"shrink-0",onClick:()=>l(!o),children:o?e.jsx(Ur,{className:"h-4 w-4"}):e.jsx(Zs,{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:p=>d(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),u())},className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:u,disabled:!i.trim()||a.isPending,children:"Add"})]})]})}function hye({contactId:t,currentSpouseContactId:s,currentSpouseName:r,currentSpouseEmail:n,onLink:a,onUnlink:o,isEditing:l}){const i=Dr(),[d,u]=S.useState(!1),[p,f]=S.useState(""),{data:v}=Ct({queryKey:["innercircle-contact-spouse",s],queryFn:async()=>{const{data:b,error:j}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone, birthday").eq("id",s).maybeSingle();if(j)throw j;return b},enabled:!!s}),{data:_}=Ct({queryKey:["spouse-search",p],queryFn:async()=>{let b=G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").neq("id",t).order("first_name").limit(20);p.trim()&&(b=b.or(`first_name.ilike.%${p}%,last_name.ilike.%${p}%,email.ilike.%${p}%,phone.ilike.%${p}%`));const{data:j,error:w}=await b;if(w)throw w;return j},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(ve,{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(Xi,{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(K,{variant:"ghost",size:"sm",onClick:o,className:"shrink-0 h-7 px-2",children:[e.jsx(uN,{className:"h-3.5 w-3.5 mr-1"}),"Unlink"]}),!l&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>i(`/mission-control/contacts/${v.id}`),className:"shrink-0 h-7 px-2",children:e.jsx(Fi,{className:"h-3.5 w-3.5"})})]})]})}return!s&&(r||n)?e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{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(Xi,{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(So,{open:d,onOpenChange:u,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"shrink-0 h-7 px-2",children:[e.jsx(Ho,{className:"h-3.5 w-3.5 mr-1"}),"Link Contact"]})}),e.jsx(ko,{className:"w-72 p-2",align:"end",children:e.jsx(_Ee,{search:p,setSearch:f,results:_,onSelect:b=>{a(b),u(!1),f("")}})})]})]})]}):l?e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs(So,{open:d,onOpenChange:u,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full justify-start text-muted-foreground font-normal h-10",children:[e.jsx(Ho,{className:"h-4 w-4 mr-2"}),"Link an existing contact as spouse..."]})}),e.jsx(ko,{className:"w-72 p-2",align:"start",children:e.jsx(_Ee,{search:p,setSearch:f,results:_,onSelect:b=>{a(b),u(!1),f("")}})})]})]}):null}function _Ee({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(fn,{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(Bi,{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 eBt(){var ta;const t=Dr(),[s]=Ec(),{user:r}=Gs(),n=PM(),a=ns(),o=s.get("type"),l=s.get("filter")??s.get("status"),i=s.get("new")==="true",{contactsWithScores:d,isLoading:u}=Joe(),{data:p}=Ef(),{data:f}=Y7t(),{data:v}=Tle(),{data:_}=V7t(),[b,j]=S.useState(new Set),[w,N]=S.useState("any"),C=Yoe(),A=tbe(),I=sbe(),L=tVe(),[R,$]=S.useState(""),[q,U]=S.useState(o||"all"),[V,X]=S.useState(l||"all"),[se,te]=S.useState("date-added"),[Y,de]=S.useState(i),[ie,ae]=S.useState(null),[le,pe]=S.useState(!1),[be,ye]=S.useState(!1),[we,ke]=S.useState(null),[Ze,_e]=S.useState(""),[Ce,Te]=S.useState(new Set),[Fe,Ae]=S.useState(!1),[We,ht]=S.useState(1),[De,Dt]=S.useState(50),[he,Qe]=S.useState("my"),[ot,rt]=S.useState(!1),[Ne,it]=S.useState(!1),{data:qe}=Mf(),{addToLeadPond:Xe}=gKe(qe==null?void 0:qe.teamId),$e=!!((ta=qe==null?void 0:qe.team)!=null&&ta.lead_pond_enabled&&(qe!=null&&qe.teamId)),Ke=!!(qe!=null&&qe.teamId),[ct,Ue]=S.useState([]),[Ve,Je]=S.useState(!1),Rt=Kt=>{Ue([Kt]),Je(!0)},$t=Kt=>{Ue(Kt),Je(!0)},ls=Kt=>{qe!=null&&qe.teamId&&Xe.mutate({contact_id:Kt,team_id:qe.teamId})},Qt=Kt=>{qe!=null&&qe.teamId&&Kt.forEach($r=>{Xe.mutate({contact_id:$r,team_id:qe.teamId})})},rs=S.useCallback(Kt=>{Ae(!1),Te($r=>{const es=new Set($r);return es.has(Kt)?es.delete(Kt):es.add(Kt),es})},[]);S.useEffect(()=>{if(!(r!=null&&r.id))return;const Kt=G.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()=>{G.removeChannel(Kt)}},[a,r==null?void 0:r.id]),S.useEffect(()=>{l&&X(l)},[l]);const[as,ir]=S.useState({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]});S.useEffect(()=>{i&&de(!0)},[i]),S.useEffect(()=>{var Kt;ie&&ir({first_name:ie.first_name||"",last_name:ie.last_name||"",email:ie.email||"",phone:ie.phone||"",address:ie.address||"",city:ie.city||"",state:ie.state||"",zip_code:ie.zip_code||"",birthday:ie.birthday||"",home_anniversary:ie.home_anniversary||"",spouse_name:ie.spouse_name||"",spouse_email:ie.spouse_email||"",lead_source_id:ie.lead_source_id||"",notes:ie.notes||"",tagIds:((Kt=ie.tags)==null?void 0:Kt.map($r=>$r.relationship_type_id))||[]})},[ie]);const vt=S.useMemo(()=>{if(!d)return[];let Kt=d.filter($r=>{var aa,Pr,ii;const es=R===""||`${$r.first_name} ${$r.last_name}`.toLowerCase().includes(R.toLowerCase())||((aa=$r.email)==null?void 0:aa.toLowerCase().includes(R.toLowerCase()))||((Pr=$r.phone)==null?void 0:Pr.includes(R)),nn=q==="all"||((ii=$r.tags)==null?void 0:ii.some(nl=>nl.relationship_type_id===q)),_a=b.size===0||(()=>{const nl=(_==null?void 0:_.filter(mi=>mi.contact_id===$r.id).map(mi=>mi.tag_id))||[];return w==="any"?nl.some(mi=>b.has(mi)):Array.from(b).every(mi=>nl.includes(mi))})();return es&&nn&&_a});return V==="not-touched-90"?Kt=Kt.filter($r=>{const es=$r.relationshipScore.daysSinceTouch;return es===null||es>90}):V==="at-risk"?Kt=Kt.filter($r=>$r.relationshipScore.status==="at-risk"):V==="cooling"?Kt=Kt.filter($r=>$r.relationshipScore.status==="cooling"):V==="warm"?Kt=Kt.filter($r=>$r.relationshipScore.status==="warm"):V==="has-deal"?Kt=Kt.filter($r=>f&&f[$r.id]):V==="no-deal"?Kt=Kt.filter($r=>!f||!f[$r.id]):V==="open-house"&&(Kt=Kt.filter($r=>{var nn;return(((nn=$r.lead_source_ref)==null?void 0:nn.name)||$r.lead_source)==="Open House"})),Kt=[...Kt].sort(($r,es)=>{switch(se){case"important-dates":{const nn=LE($r.birthday),_a=LE(es.birthday),aa=LE($r.home_anniversary),Pr=LE(es.home_anniversary),ii=[nn,aa].filter(mi=>mi!==null).sort((mi,Vl)=>(mi??1/0)-(Vl??1/0))[0]??1/0,nl=[_a,Pr].filter(mi=>mi!==null).sort((mi,Vl)=>(mi??1/0)-(Vl??1/0))[0]??1/0;return ii-nl}case"last-touched":{const nn=$r.relationshipScore.lastTouchDate,_a=es.relationshipScore.lastTouchDate;return!nn&&!_a?0:nn?_a?new Date(nn).getTime()-new Date(_a).getTime():1:-1}case"next-touch":{const nn=$r.relationshipScore.daysSinceTouch,_a=es.relationshipScore.daysSinceTouch;return nn===null&&_a===null?0:nn===null?-1:_a===null?1:_a-nn}case"score":return $r.relationshipScore.score-es.relationshipScore.score;case"date-added":{const nn=$r.created_at,_a=es.created_at;return!nn&&!_a?0:nn?_a?new Date(_a).getTime()-new Date(nn).getTime():-1:1}case"name":default:{const nn=`${$r.first_name||""} ${$r.last_name||""}`.toLowerCase(),_a=`${es.first_name||""} ${es.last_name||""}`.toLowerCase();return nn.localeCompare(_a)}}}),Kt},[d,R,q,b,w,V,se,f,_]),Cs=vt.length,or=Math.max(1,Math.ceil(Cs/De)),Ar=Math.min(We,or),Wn=S.useMemo(()=>{const Kt=(Ar-1)*De;return vt.slice(Kt,Kt+De)},[vt,Ar,De]);S.useEffect(()=>{ht(1)},[R,q,b,w,V,se]);const ai=S.useCallback(()=>{Ae(!1),Te(Kt=>Kt.size>0?new Set:new Set(Wn.map($r=>$r.id)))},[Wn]),bo=S.useCallback(()=>{Ae(!0),Te(new Set(vt.map(Kt=>Kt.id)))},[vt]),Fa=S.useCallback((Kt,$r)=>{$(Kt.search||""),U(Kt.type||"all"),X(Kt.status||"all"),te($r||"name")},[]),yn=()=>{ir({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]})},na=async Kt=>{Kt.preventDefault();const $r={...as,lead_source_id:as.lead_source_id||null};ie?(await A.mutateAsync({id:ie.id,...$r}),ae(null)):(await C.mutateAsync($r),de(!1)),yn()},Nn=async Kt=>{confirm("Are you sure you want to delete this contact?")&&await I.mutateAsync(Kt)};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"})]}),qe&&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 ${he==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),(qe.team.contact_visibility==="full_team"||qe.team.contact_visibility==="leader_only"&&qe.role==="team_leader")&&e.jsxs("button",{onClick:()=>Qe("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${he==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(hr,{className:"h-3.5 w-3.5"}),"Team"]}),qe.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 ${he==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Fg,{className:"h-3.5 w-3.5"}),"Lead Pond"]})]})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(zl,{className:"h-4 w-4 mr-1"}),"Back"]})}),he==="team"?e.jsx(cwe,{}):he==="lead-pond"&&qe?e.jsx(dwe,{teamId:qe.teamId}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 min-w-0",children:[e.jsx(fn,{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:R,onChange:Kt=>$(Kt.target.value),className:"pl-9"})]}),e.jsxs(K,{onClick:()=>de(!0),className:"shrink-0",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Contact"]}),e.jsxs(K,{variant:"outline",onClick:()=>pe(!0),className:"shrink-0",children:[e.jsx(Ya,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(K,{variant:"outline",onClick:()=>ye(!0),className:"shrink-0",children:[e.jsx(O0,{className:"h-4 w-4 mr-1"}),"Import from Phone"]}),e.jsx(C7t,{})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(tr,{value:q,onValueChange:U,children:[e.jsx(Js,{className:"w-[145px] h-9 text-sm",children:e.jsx(sr,{placeholder:"Filter by type"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Types"}),p==null?void 0:p.filter(Kt=>Kt.active).map(Kt=>e.jsx(At,{value:Kt.id,children:Kt.name},Kt.id))]})]}),v&&v.length>0&&e.jsxs(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"h-9 justify-start text-sm",children:[e.jsx(Vh,{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(ko,{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 ${w==="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 ${w==="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(Kt=>{const $r=b.has(Kt.id);return e.jsxs("button",{onClick:()=>{j(es=>{const nn=new Set(es);return nn.has(Kt.id)?nn.delete(Kt.id):nn.add(Kt.id),nn})},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(zo,{checked:$r,className:"pointer-events-none"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:Kt.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:Kt.name})]},Kt.id)})}),b.size>0&&e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>j(new Set),children:"Clear tags"})]})})]}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",title:"Settings",children:e.jsx($l,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs(Td,{align:"end",children:[e.jsxs(Ta,{onClick:()=>rt(!0),children:[e.jsx(Vh,{className:"h-4 w-4 mr-2"}),"Manage Tags"]}),e.jsxs(Ta,{onClick:()=>it(!0),children:[e.jsx(Fg,{className:"h-4 w-4 mr-2"}),"Manage Lead Sources"]})]})]}),e.jsxs(tr,{value:V,onValueChange:X,children:[e.jsx(Js,{className:"w-[145px] h-9 text-sm",children:e.jsx(sr,{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(Hc,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(sr,{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(Z7t,{currentFilters:{search:R,type:q,status:V},currentSortBy:se,onApplySmartList:Fa})]})]})})}),e.jsx(H7t,{selectedIds:Ce,contacts:vt,onClearSelection:()=>{Te(new Set),Ae(!1)},showLeadPondAction:$e,onSendToLeadPond:Qt,showTransferAction:Ke,onTransfer:$t}),Ce.size>0&&Ce.size===Wn.length&&!Fe&&Cs>De&&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 ",Wn.length," contacts on this page are selected."]}),e.jsxs(K,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:bo,children:["Select all ",Cs.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 ",Cs.toLocaleString()," matching contacts are selected.",e.jsx(K,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{Te(new Set),Ae(!1)},children:"Clear selection"})]}),n?e.jsx("div",{className:"space-y-3",children:u?e.jsx(Ee,{className:"p-6 text-center text-muted-foreground",children:"Loading contacts..."}):vt.length===0?e.jsx(Ee,{className:"p-6 text-center text-muted-foreground",children:R||q!=="all"||V!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):Wn.map(Kt=>{var es,nn,_a;const{relationshipScore:$r}=Kt;return e.jsx(Ee,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const aa=new URLSearchParams;R&&aa.set("search",R),q!=="all"&&aa.set("type",q),V!=="all"&&aa.set("filter",V);const Pr=aa.toString();t(`/mission-control/contacts/${Kt.id}${Pr?`?${Pr}`:""}`)},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:[Kt.first_name," ",Kt.last_name]}),e.jsx(Ha,{className:"h-4 w-4 text-muted-foreground shrink-0"})]}),e.jsxs("div",{className:"space-y-1 text-sm mb-3",children:[Kt.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(_r,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:Kt.email})]}),Kt.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Zn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:Kt.phone})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-2",children:[e.jsx(mI,{score:$r,size:"sm"}),e.jsx(uye,{contact:Kt}),(((es=Kt.lead_source_ref)==null?void 0:es.name)||Kt.lead_source)&&e.jsx(at,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:((nn=Kt.lead_source_ref)==null?void 0:nn.name)||Kt.lead_source}),(_a=Kt.tags)==null?void 0:_a.map(aa=>{var Pr;return e.jsx(at,{variant:"secondary",className:"text-xs",children:(Pr=aa.relationship_type)==null?void 0:Pr.name},aa.id)}),e.jsx(vEe,{contactId:Kt.id,tags:_==null?void 0:_.filter(aa=>aa.contact_id===Kt.id)}),e.jsx(yEe,{deal:f==null?void 0:f[Kt.id]})]}),e.jsx(xEe,{birthday:Kt.birthday,homeAnniversary:Kt.home_anniversary,className:"mb-2",contactId:Kt.id,contactName:`${Kt.first_name}${Kt.last_name?" "+Kt.last_name:""}`,contactAddress:[Kt.address,Kt.city,Kt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[$r.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),ws(new Date($r.lastTouchDate),"MMM d")]}):e.jsx("span",{className:"italic",children:"Never contacted"}),Kt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ws(fl(Kt.birthday),"MMM d")]}),Kt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Un,{className:"h-3 w-3"}),ws(fl(Kt.home_anniversary),"MMM d")]}),Kt.created_at&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Zs,{className:"h-3 w-3"}),"Added ",ws(new Date(Kt.created_at),"MMM d, yyyy")]})]})]}),e.jsx("div",{className:"ml-2",onClick:aa=>aa.stopPropagation(),children:e.jsx(fEe,{contact:Kt,onEdit:ae,onDelete:Nn,onSnooze:(aa,Pr)=>{ke(aa),_e(Pr)},showLeadPondAction:$e,onSendToLeadPond:ls,showTransferAction:Ke,onTransfer:Rt})})]})})},Kt.id)})}):e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(An,{className:"min-w-[800px]",children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-[40px]",children:e.jsx(zo,{checked:Wn.length>0&&Wn.every(Kt=>Ce.has(Kt.id)),onCheckedChange:()=>ai()})}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Score"}),e.jsx(jt,{children:"Contact Info"}),e.jsx(jt,{children:"Types / Pipeline"}),e.jsx(jt,{children:"Last Contact"}),e.jsx(jt,{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(Hc,{className:"h-3 w-3"})]})}),e.jsx(jt,{children:"Important Dates"}),e.jsx(jt,{className:"w-[50px]",children:"Actions"})]})}),e.jsx(Pn,{children:u?e.jsx(js,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8",children:"Loading contacts..."})}):vt.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:R||q!=="all"||V!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):Wn.map(Kt=>{var nn,_a,aa;const{relationshipScore:$r}=Kt,es=f==null?void 0:f[Kt.id];return e.jsxs(js,{className:`cursor-pointer hover:bg-accent/50 ${Ce.has(Kt.id)?"bg-accent/30":""}`,onClick:()=>{const Pr=new URLSearchParams;R&&Pr.set("search",R),q!=="all"&&Pr.set("type",q),V!=="all"&&Pr.set("status",V);const ii=Pr.toString();t(`/mission-control/contacts/${Kt.id}${ii?`?${ii}`:""}`)},children:[e.jsx(lt,{onClick:Pr=>Pr.stopPropagation(),children:e.jsx(zo,{checked:Ce.has(Kt.id),onCheckedChange:()=>rs(Kt.id)})}),e.jsxs(lt,{className:"font-medium",children:[Kt.first_name," ",Kt.last_name]}),e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(mI,{score:$r,size:"sm"}),e.jsx(uye,{contact:Kt})]})}),e.jsx(lt,{children:e.jsx(mI,{score:$r,size:"sm",showScore:!0})}),e.jsx(lt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[Kt.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(_r,{className:"h-3 w-3"}),Kt.email]}),Kt.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Zn,{className:"h-3 w-3"}),Kt.phone]})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(((nn=Kt.lead_source_ref)==null?void 0:nn.name)||Kt.lead_source)&&e.jsx(at,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((_a=Kt.lead_source_ref)==null?void 0:_a.name)||Kt.lead_source}),(aa=Kt.tags)==null?void 0:aa.map(Pr=>{var ii;return e.jsx(at,{variant:"secondary",className:"text-xs",children:(ii=Pr.relationship_type)==null?void 0:ii.name},Pr.id)}),e.jsx(vEe,{contactId:Kt.id,tags:_==null?void 0:_.filter(Pr=>Pr.contact_id===Kt.id)}),e.jsx(yEe,{deal:es})]})}),e.jsx(lt,{children:e.jsx("div",{className:"text-sm",children:$r.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Tn,{className:"h-3 w-3"}),ws(new Date($r.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:Kt.created_at?ws(new Date(Kt.created_at),"MMM d, yyyy"):"—"})}),e.jsx(lt,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(xEe,{birthday:Kt.birthday,homeAnniversary:Kt.home_anniversary,contactId:Kt.id,contactName:`${Kt.first_name}${Kt.last_name?" "+Kt.last_name:""}`,contactAddress:[Kt.address,Kt.city,Kt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Kt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ws(fl(Kt.birthday),"MMM d")]}),Kt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Un,{className:"h-3 w-3"}),ws(fl(Kt.home_anniversary),"MMM d")]})]})]})}),e.jsx(lt,{children:e.jsx(fEe,{contact:Kt,onEdit:ae,onDelete:Nn,onSnooze:(Pr,ii)=>{ke(Pr),_e(ii)},showLeadPondAction:$e,onSendToLeadPond:ls,showTransferAction:Ke,onTransfer:Rt})})]},Kt.id)})})]})})}),Cs>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 ",(Ar-1)*De+1,"–",Math.min(Ar*De,Cs)," of ",Cs.toLocaleString()," contacts"]}),e.jsxs(tr,{value:String(De),onValueChange:Kt=>{Dt(Number(Kt)),ht(1)},children:[e.jsx(Js,{className:"w-[80px] h-8",children:e.jsx(sr,{})}),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(K,{variant:"outline",size:"sm",disabled:Ar<=1,onClick:()=>ht(1),children:"First"}),e.jsx(K,{variant:"outline",size:"sm",disabled:Ar<=1,onClick:()=>ht(Kt=>Kt-1),children:e.jsx(zl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",Ar," of ",or]}),e.jsx(K,{variant:"outline",size:"sm",disabled:Ar>=or,onClick:()=>ht(Kt=>Kt+1),children:e.jsx(Ha,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",disabled:Ar>=or,onClick:()=>ht(or),children:"Last"})]})]}),e.jsx(vs,{open:Y||!!ie,onOpenChange:Kt=>{Kt||(de(!1),ae(null),yn())},children:e.jsxs(ys,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:ie?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:na,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"first_name",children:"First Name *"}),e.jsx(Re,{id:"first_name",value:as.first_name,onChange:Kt=>ir({...as,first_name:Kt.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"last_name",children:"Last Name"}),e.jsx(Re,{id:"last_name",value:as.last_name,onChange:Kt=>ir({...as,last_name:Kt.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:as.email,onChange:Kt=>ir({...as,email:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone"}),e.jsx(Re,{id:"phone",value:as.phone,onChange:Kt=>ir({...as,phone:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"address",children:"Address"}),e.jsx(Re,{id:"address",value:as.address,onChange:Kt=>ir({...as,address:Kt.target.value}),placeholder:"Street address"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"city",children:"City"}),e.jsx(Re,{id:"city",value:as.city,onChange:Kt=>ir({...as,city:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"state",children:"State"}),e.jsx(Re,{id:"state",value:as.state,onChange:Kt=>ir({...as,state:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"zip_code",children:"Zip"}),e.jsx(Re,{id:"zip_code",value:as.zip_code,onChange:Kt=>ir({...as,zip_code:Kt.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"birthday",children:"Birthday"}),e.jsx(Re,{id:"birthday",type:"date",value:as.birthday,onChange:Kt=>ir({...as,birthday:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(Re,{id:"home_anniversary",type:"date",value:as.home_anniversary,onChange:Kt=>ir({...as,home_anniversary:Kt.target.value})})]})]}),ie&&e.jsx(hye,{contactId:ie.id,currentSpouseContactId:(ie==null?void 0:ie.spouse_contact_id)||null,currentSpouseName:(ie==null?void 0:ie.spouse_name)||null,currentSpouseEmail:(ie==null?void 0:ie.spouse_email)||null,onLink:Kt=>L.mutate({contactId:ie.id,spouseContactId:Kt}),onUnlink:()=>L.mutate({contactId:ie.id,spouseContactId:null}),isEditing:!0}),e.jsx(yZe,{value:as.lead_source_id,onChange:Kt=>ir({...as,lead_source_id:Kt})}),e.jsxs("div",{children:[e.jsx(ve,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:p==null?void 0:p.filter(Kt=>Kt.active).map(Kt=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(zo,{checked:as.tagIds.includes(Kt.id),onCheckedChange:$r=>{ir($r?{...as,tagIds:[...as.tagIds,Kt.id]}:{...as,tagIds:as.tagIds.filter(es=>es!==Kt.id)})}}),e.jsx("span",{className:"text-sm",children:Kt.name})]},Kt.id))})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"notes",children:"Notes"}),e.jsx(Mr,{id:"notes",value:as.notes,onChange:Kt=>ir({...as,notes:Kt.target.value}),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{de(!1),ae(null),yn()},children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:C.isPending||A.isPending,children:[ie?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(O7t,{open:le,onOpenChange:pe,relationshipTypes:(p==null?void 0:p.filter(Kt=>Kt.active))||[],onSuccess:()=>{pe(!1)}}),e.jsx(z7t,{open:be,onOpenChange:ye,onComplete:()=>ye(!1)}),e.jsx(Cle,{open:!!we,onOpenChange:Kt=>{Kt||ke(null)},contactId:we||"",contactName:Ze}),e.jsx(Q7t,{open:ot,onOpenChange:rt}),e.jsx(J7t,{open:Ne,onOpenChange:it}),e.jsx(xKe,{open:Ve,onOpenChange:Je,contactIds:ct,contactNames:ct.map(Kt=>{const $r=vt.find(es=>es.id===Kt);return $r?`${$r.first_name} ${$r.last_name||""}`.trim():""}),onComplete:()=>{Ue([]),Te(new Set),Ae(!1)}})]})]})})}function tBt(){return Ct({queryKey:["video-script-categories"],queryFn:async()=>{const{data:t,error:s}=await G.from("video_script_categories").select("*").order("sort_order");if(s)throw s;return t}})}function sBt(t){return Ct({queryKey:["video-scripts",t],queryFn:async()=>{let s=G.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 rBt(){const{user:t}=Gs();return Ct({queryKey:["user-video-scripts",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await G.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 nBt(){const{user:t}=Gs(),s=ns();return Ot({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await G.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 aBt(t){const{user:s}=Gs();return Ct({queryKey:["agent-videos",s==null?void 0:s.id,t],queryFn:async()=>{if(!(s!=null&&s.id))return[];let r=G.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 iBt(t){return Ct({queryKey:["agent-video",t],queryFn:async()=>{const{data:s,error:r}=await G.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 iS(){const{user:t}=Gs(),s=ns();return Ot({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await G.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 oBt(){const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.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 lBt(){const t=ns();return Ot({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 G.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 G.from("agent_videos").delete().eq("id",s);if(a)throw a}else{console.log("Soft deleting from database:",s);const{error:a}=await G.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 Ale(){const{user:t}=Gs();return Ct({queryKey:["storage-usage",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await G.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 vZe(){const{data:t,isLoading:s}=Ale(),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 KL(t){const{data:s,error:r}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:t,isAgentVideo:!0}});if(r)throw r;return s}async function ZL(t){const{data:s,error:r}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}async function M3(t){const{data:s,error:r}=await G.functions.invoke("bunny-upload",{body:{action:"status",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}function cBt(){const{user:t}=Gs(),s=ns();return Ot({mutationFn:async({contactId:r,videoId:n,notes:a})=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:o}=await G.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 G.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 dBt(t){return Ct({queryKey:["contact-video-replies",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.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 uBt(t){return Ct({queryKey:["client-portal",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("client_portals").select("*").eq("deal_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function jwe(){const t=ti(),s=ns();return Ot({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.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 YL(){const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.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 hBt(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.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 mBt(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.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 pBt(){const t=ns();return Ot({mutationFn:async({id:s,dealId:r})=>{await G.from("portal_updates").delete().eq("portal_id",s);const{error:n}=await G.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 _Ze(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.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 fBt(){const t=ti();return Ct({queryKey:["portal-custom-questions",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.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 gBt(){const t=ti(),s=ns();return Ot({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.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 xBt(){const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.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 yBt(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("portal_custom_questions").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function z0(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}`:`https://clients.relevelup.com/${t}`}function vBt({contactId:t}){const s=Dr(),r=ns(),[n,a]=S.useState(null),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(""),[f,v]=S.useState(""),[_,b]=S.useState(null),j=YL(),w=_Ze(),{data:N,isLoading:C}=Ct({queryKey:["contact-portals",t],queryFn:async()=>{const{data:q,error:U}=await G.from("deal_pipeline").select("id, deal_name, deal_type").eq("contact_id",t);if(U)throw U;if(!q||q.length===0)return[];const V=q.map(te=>te.id),{data:X,error:se}=await G.from("client_portals").select("*").in("deal_id",V).is("archived_at",null);if(se)throw se;return(X||[]).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}=Ct({queryKey:["contact-portal-updates",A],queryFn:async()=>{if(A.length===0)return{};const{data:q,error:U}=await G.from("portal_updates").select("*").in("portal_id",A).order("created_at",{ascending:!1});if(U)throw U;const V={};return(q||[]).forEach(X=>{V[X.portal_id]||(V[X.portal_id]=X)}),V},enabled:A.length>0}),L=q=>{navigator.clipboard.writeText(z0(q)),a(q),fe.success("Portal link copied!"),setTimeout(()=>a(null),2e3)},R=async q=>{u.trim()&&(await w.mutateAsync({portal_id:q,title:u,content:f||void 0}),d(!1),p(""),v(""),r.invalidateQueries({queryKey:["contact-portal-updates"]}),fe.success("Portal update posted!"))},$=async()=>{_&&(await j.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]}),fe.success("Portal settings updated!"))};return C||!N||N.length===0?null:e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Pm,{className:"h-4 w-4"}),"Client Portal"]})}),e.jsx(Oe,{className:"space-y-3",children:N.map(q=>{var se,te,Y;const U=((se=q.stage_mapping)==null?void 0:se.length)>0?q.stage_mapping:s_e(((te=q.deal)==null?void 0:te.deal_type)||"buyer"),V=U==null?void 0:U[q.current_stage_index??0],X=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"}),V&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Stage: ",V.label||V.name]})]}),e.jsx(at,{variant:q.is_enabled?"default":"secondary",className:"text-[10px] flex-shrink-0",children:q.is_enabled?"Active":"Disabled"})]}),X&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-2",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:X.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ws(new Date(X.created_at),"MMM d, yyyy")})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>L(q.slug),children:[n===q.slug?e.jsx(ua,{className:"h-3 w-3 mr-1"}):e.jsx(ni,{className:"h-3 w-3 mr-1"}),"Copy Link"]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>window.open(z0(q.slug),"_blank"),children:[e.jsx(sn,{className:"h-3 w-3 mr-1"}),"View"]}),e.jsxs(vs,{open:i,onOpenChange:d,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>d(!0),children:[e.jsx(oo,{className:"h-3 w-3 mr-1"}),"Post Update"]})}),e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title"}),e.jsx(Re,{value:u,onChange:de=>p(de.target.value),placeholder:"e.g. Inspection completed!"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Details (optional)"}),e.jsx(Mr,{value:f,onChange:de=>v(de.target.value),placeholder:"Add more details...",rows:3})]}),e.jsxs(K,{onClick:()=>R(q.id),disabled:!u.trim()||w.isPending,className:"w-full",children:[e.jsx(ka,{className:"h-4 w-4 mr-1"}),"Post Update"]})]})]})]}),e.jsxs(vs,{open:o,onOpenChange:l,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{b({...q}),l(!0)},children:[e.jsx($l,{className:"h-3 w-3 mr-1"}),"Settings"]})}),e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Portal Settings"})}),_&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Portal Enabled"}),e.jsx(Br,{checked:_.is_enabled,onCheckedChange:de=>b({..._,is_enabled:de})})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Welcome Message"}),e.jsx(Mr,{value:_.welcome_message||"",onChange:de=>b({..._,welcome_message:de.target.value}),placeholder:"Welcome to your home journey!",rows:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Next Step"}),e.jsx(Re,{value:_.next_step_text||"",onChange:de=>b({..._,next_step_text:de.target.value}),placeholder:"What your client should do next..."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Review URL"}),e.jsx(Re,{value:_.review_url||"",onChange:de=>b({..._,review_url:de.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Show Post-Close Tips"}),e.jsx(Br,{checked:_.show_post_close_tips,onCheckedChange:de=>b({..._,show_post_close_tips:de})})]}),e.jsx(Rl,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:$,disabled:j.isPending,className:"flex-1",children:"Save Settings"}),e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/pipeline?deal=${q.deal_id}`),children:[e.jsx(Fi,{className:"h-4 w-4 mr-1"}),"Full Settings"]})]})]})]})]})]}),N.length>1&&e.jsx(Rl,{})]},q.id)})})]})}function _Bt({videoId:t}){var l;const{data:s,isLoading:r,error:n}=iBt(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(Th,{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 bBt({contactId:t}){const s=Dr(),[r,n]=S.useState(!1),{data:a,isLoading:o}=Ct({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:f,error:v}=await G.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 f},enabled:!!t}),l=async(f,v)=>{const _=v==="done"?"todo":"done";await G.from("deal_tasks").update({status:_,completed_at:_==="done"?new Date().toISOString():null}).eq("id",f),window.dispatchEvent(new CustomEvent("refetch-contact-tasks"))},{refetch:i}=Ct({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:f,error:v}=await G.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 f},enabled:!!t}),d={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"},u=(a==null?void 0:a.filter(f=>f.status!=="done"))||[],p=(a==null?void 0:a.filter(f=>f.status==="done"))||[];return e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(ua,{className:"h-4 w-4"}),"Tasks",u.length>0&&e.jsx(at,{variant:"secondary",className:"text-xs",children:u.length})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/tasks"),children:"View All"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>n(!0),children:e.jsx(Zs,{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&&p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tasks yet"}):e.jsxs(e.Fragment,{children:[u.map(f=>e.jsxs("button",{onClick:async()=>{await l(f.id,f.status),i()},className:"w-full text-left flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 transition-colors group",children:[e.jsx("div",{className:"h-4 w-4 rounded-full border-2 border-muted-foreground/30 shrink-0 group-hover:border-primary"}),e.jsxs("span",{className:"text-sm flex-1 truncate",children:[d[f.priority]," ",f.title]}),f.due_date&&e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ws(new Date(f.due_date),"MMM d")})]},f.id)),p.length>0&&e.jsx("div",{className:"pt-1 border-t mt-1",children:e.jsxs("p",{className:"text-[10px] text-muted-foreground px-2 py-1",children:[p.length," completed"]})})]})}),r&&e.jsx(wBt,{contactId:t,open:r,onOpenChange:f=>{n(f),f||i()}})]})}function wBt({contactId:t,open:s,onOpenChange:r}){const[n,a]=S.useState(""),[o,l]=S.useState("medium"),[i,d]=S.useState(),{data:u}=Ct({queryKey:["session"],queryFn:async()=>{const{data:f}=await G.auth.getSession();return f.session}}),p=async()=>{var v;if(!n.trim()||!((v=u==null?void 0:u.user)!=null&&v.id))return;const{error:f}=await G.from("deal_tasks").insert([{owner_user_id:u.user.id,contact_id:t,title:n.trim(),priority:o,status:"todo",due_date:i?ws(i,"yyyy-MM-dd"):null}]);if(f){console.error("Task create error:",f);return}r(!1)};return e.jsx(vs,{open:s,onOpenChange:r,children:e.jsxs(ys,{className:"sm:max-w-[400px]",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Add Task"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title"}),e.jsx(Re,{value:n,onChange:f=>a(f.target.value),placeholder:"Task title...",onKeyDown:f=>f.key==="Enter"&&p()})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Priority"}),e.jsxs("select",{value:o,onChange:f=>l(f.target.value),className:"w-full h-10 rounded-md border border-input bg-background px-3 text-sm",children:[e.jsx("option",{value:"low",children:"🟢 Low"}),e.jsx("option",{value:"medium",children:"🟡 Medium"}),e.jsx("option",{value:"high",children:"🟠 High"}),e.jsx("option",{value:"urgent",children:"🔴 Urgent"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Due Date"}),e.jsx(Re,{type:"date",value:i?ws(i,"yyyy-MM-dd"):"",onChange:f=>d(f.target.value?new Date(f.target.value+"T00:00:00"):void 0)})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{onClick:p,disabled:!n.trim(),children:"Create Task"})]})]})]})})}function jBt({contactId:t}){const s=Dr(),{data:r,isLoading:n}=Ct({queryKey:["contact-linked-deals",t],queryFn:async()=>{const{data:a,error:o}=await G.from("deal_pipeline").select(` id, deal_name, deal_type, expected_price, property_address, stage:deal_pipeline_stages(id, name, color, icon, is_won_stage, is_lost_stage) `).eq("contact_id",t).order("updated_at",{ascending:!1});if(o)throw o;return a},enabled:!!t});return n||!r||r.length===0?null:e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(th,{className:"h-4 w-4"}),"Linked Deals"]})}),e.jsx(Oe,{className:"space-y-2",children:r.map(a=>{const o=a.stage;return e.jsx("button",{onClick:()=>s(`/mission-control/pipeline?deal=${a.id}`),className:"w-full text-left p-3 rounded-lg border hover:bg-accent transition-colors group",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:a.deal_name}),a.property_address&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:a.property_address}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(at,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&e.jsxs(at,{variant:"outline",className:"text-[10px] gap-1",style:{borderColor:o.color,color:o.color,backgroundColor:`${o.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:o.color}}),o.name]})]})]}),e.jsx(Fi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function kBt(){var qe,Xe,$e,Ke,ct;const{contactId:t}=Mo(),s=Dr(),[r]=Ec(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=V4t(t||""),{data:d}=Ef(),{data:u}=IL(),{data:p}=LL(3650),{data:f}=Mle(365),{data:v}=dBt(t),{contactsWithScores:_}=Joe(),b=tbe(),j=sbe(),w=rbe(),N=tVe(),[C,A]=S.useState(!1),[I,L]=S.useState({}),[R,$]=S.useState(!1),[q,U]=S.useState(null),[V,X]=S.useState(""),[se,te]=S.useState(void 0),[Y,de]=S.useState(""),[ie,ae]=S.useState(null),[le,pe]=S.useState(!1),[be,ye]=S.useState(null),{isGmailConnected:we,gmailEmail:ke}=gy(),{data:Ze}=Ct({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:Ue,error:Ve}=await G.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(Ve)throw Ve;return Ue},enabled:!!t}),_e=Ue=>{if(!Ue)return null;const Ve=Ue.match(/Video ID:\s*([a-f0-9-]+)/i);return Ve?Ve[1]:null},Ce=S.useMemo(()=>{if(!_)return[];let Ue=_.filter(Ve=>{var $t,ls,Qt;const Je=n===""||`${Ve.first_name} ${Ve.last_name}`.toLowerCase().includes(n.toLowerCase())||(($t=Ve.email)==null?void 0:$t.toLowerCase().includes(n.toLowerCase()))||((ls=Ve.phone)==null?void 0:ls.includes(n)),Rt=a==="all"||((Qt=Ve.tags)==null?void 0:Qt.some(rs=>rs.relationship_type_id===a));return Je&&Rt});return o==="not-touched-90"?Ue=Ue.filter(Ve=>{const Je=Ve.relationshipScore.daysSinceTouch;return Je===null||Je>90}):o==="at-risk"?Ue=Ue.filter(Ve=>Ve.relationshipScore.status==="at-risk"):o==="cooling"?Ue=Ue.filter(Ve=>Ve.relationshipScore.status==="cooling"):o==="warm"&&(Ue=Ue.filter(Ve=>Ve.relationshipScore.status==="warm")),Ue.map(Ve=>Ve.id)},[_,n,a,o]),Te=Ce.indexOf(t||""),Fe=Te>0?Ce[Te-1]:null,Ae=Te1&&Te!==-1,ht=Ue=>{const Ve=new URLSearchParams;n&&Ve.set("search",n),a!=="all"&&Ve.set("type",a),o!=="all"&&Ve.set("status",o);const Je=Ve.toString();return`/mission-control/contacts/${Ue}${Je?`?${Je}`:""}`},De=S.useMemo(()=>{const Ue=((p==null?void 0:p.filter(Je=>Je.contact_id===t))||[]).map(Je=>{var Qt,rs,as;const Rt=_e(Je.notes);let $t=((Qt=Je.action_type)==null?void 0:Qt.name)||"Touch",ls=Je.notes;if($t==="Other"&&((rs=Je.notes)!=null&&rs.startsWith("["))){const ir=Je.notes.indexOf("]");ir>0&&($t=Je.notes.substring(1,ir),ls=Je.notes.substring(ir+1).replace(/^\s*—\s*/,"").trim()||null)}return{id:Je.id,type:"touch",completed_at:Je.completed_at,name:$t,color:((as=Je.action_type)==null?void 0:as.color)||"#3B82F6",notes:ls,videoId:Rt}}),Ve=((f==null?void 0:f.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[...Ue,...Ve].sort((Je,Rt)=>new Date(Rt.completed_at).getTime()-new Date(Je.completed_at).getTime())},[p,f,t]),Dt=()=>{var Ue;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:((Ue=l.tags)==null?void 0:Ue.map(Ve=>Ve.relationship_type_id))||[]}),A(!0))},he=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 j.mutateAsync(t),s("/mission-control/contacts"))},rt=((qe=u==null?void 0:u.find(Ue=>Ue.id===q))==null?void 0:qe.name)==="Other",Ne=async()=>{if(!q||rt&&!Y.trim())return;const Ue=se?new Date(se.getFullYear(),se.getMonth(),se.getDate(),12,0,0).toISOString():void 0,Ve=rt?`[${Y.trim()}]${V?" — "+V:""}`:V;await w.mutateAsync({contactId:t,actionTypeId:q,notes:Ve,completedAt:Ue}),$(!1),U(null),X(""),te(void 0),de("")},it=(Ue,Ve)=>{we&&l?(ye({email:Ue,name:Ve||`${l.first_name} ${l.last_name||""}`.trim()}),pe(!0)):window.location.href=`mailto:${Ue}`};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(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/contacts"),children:[e.jsx(zl,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),We&&e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Fe&&s(ht(Fe)),disabled:!Fe,className:"px-2",children:[e.jsx(zl,{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:[Te+1," of ",Ce.length]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Ae&&s(ht(Ae)),disabled:!Ae,className:"px-2",children:[e.jsx("span",{className:"sr-only sm:not-sr-only sm:mr-1",children:"Next"}),e.jsx(Ha,{className:"h-4 w-4"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end flex-wrap",children:[l.email&&e.jsxs(K,{variant:"outline",onClick:()=>it(l.email,`${l.first_name} ${l.last_name||""}`.trim()),children:[e.jsx(_r,{className:"h-4 w-4 mr-1"}),"Email"]}),e.jsxs(K,{variant:"default",onClick:()=>s(`/mission-control/video/record?contact_id=${t}`),className:"bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(kn,{className:"h-4 w-4 mr-1"}),"Quick Video Touch"]}),e.jsxs(vs,{open:R,onOpenChange:$,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Log Action"]})}),e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Log an Action"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Action Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:u==null?void 0:u.filter(Ue=>Ue.active).map(Ue=>e.jsxs("button",{onClick:()=>U(Ue.id),className:` p-3 rounded-lg border text-left transition-all ${q===Ue.id?"border-primary bg-primary/10":"hover:bg-accent"} `,children:[e.jsx("div",{className:"font-medium",children:Ue.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:Ue.description})]},Ue.id))}),rt&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ve,{htmlFor:"custom-action-name",children:"What did you do?"}),e.jsx(Re,{id:"custom-action-name",value:Y,onChange:Ue=>de(Ue.target.value),placeholder:"e.g. Met a client for lunch, Dropped off a gift...",className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Date (optional — backdate if needed)"}),e.jsxs(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal mt-2",!se&&"text-muted-foreground"),children:[e.jsx(on,{className:"h-4 w-4 mr-2"}),se?ws(se,"PPP"):"Today (default)"]})}),e.jsx(ko,{className:"w-auto p-0",align:"start",children:e.jsx(yp,{mode:"single",selected:se,onSelect:te,disabled:Ue=>Ue>new Date,initialFocus:!0,className:Pt("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(Mr,{id:"action-notes",value:V,onChange:Ue=>X(Ue.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(K,{onClick:Ne,disabled:!q||rt&&!Y.trim()||w.isPending,className:"w-full",children:[e.jsx(ua,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(K,{variant:"outline",onClick:Dt,children:[e.jsx(Oc,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:Qe,children:e.jsx(br,{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||""]}),(((Xe=l.lead_source_ref)==null?void 0:Xe.name)||l.lead_source)&&e.jsx(at,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:(($e=l.lead_source_ref)==null?void 0:$e.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:()=>it(l.email),className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(_r,{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(Zn,{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(uye,{contact:l}),(Ke=l.tags)==null?void 0:Ke.map(Ue=>{const Ve=d==null?void 0:d.find(Je=>Je.id===Ue.relationship_type_id);return Ve?e.jsx(at,{variant:"secondary",className:"text-xs",children:Ve.name},Ue.id):null})]}),e.jsx("div",{className:"mt-2",children:e.jsx(X7t,{contactId:t})})]})}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs(Ee,{className:"md:col-span-2",children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Contact Information"})}),e.jsx(Oe,{children:C?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"first_name",children:"First Name"}),e.jsx(Re,{id:"first_name",value:I.first_name,onChange:Ue=>L({...I,first_name:Ue.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"last_name",children:"Last Name"}),e.jsx(Re,{id:"last_name",value:I.last_name,onChange:Ue=>L({...I,last_name:Ue.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:I.email,onChange:Ue=>L({...I,email:Ue.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone"}),e.jsx(Re,{id:"phone",value:I.phone,onChange:Ue=>L({...I,phone:Ue.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"address",children:"Street Address"}),e.jsx(Re,{id:"address",value:I.address,onChange:Ue=>L({...I,address:Ue.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(ve,{htmlFor:"city",children:"City"}),e.jsx(Re,{id:"city",value:I.city,onChange:Ue=>L({...I,city:Ue.target.value}),placeholder:"City"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"state",children:"State"}),e.jsx(Re,{id:"state",value:I.state,onChange:Ue=>L({...I,state:Ue.target.value}),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"zip_code",children:"Zip Code"}),e.jsx(Re,{id:"zip_code",value:I.zip_code,onChange:Ue=>L({...I,zip_code:Ue.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(ve,{htmlFor:"birthday",children:"Birthday"}),e.jsx(Re,{id:"birthday",type:"date",value:I.birthday,onChange:Ue=>L({...I,birthday:Ue.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(Re,{id:"home_anniversary",type:"date",value:I.home_anniversary,onChange:Ue=>L({...I,home_anniversary:Ue.target.value})})]})]}),e.jsx(Rl,{}),e.jsx(hye,{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:Ue=>N.mutate({contactId:t,spouseContactId:Ue}),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(ve,{htmlFor:"company_name",children:"Company"}),e.jsx(Re,{id:"company_name",value:I.company_name,onChange:Ue=>L({...I,company_name:Ue.target.value}),placeholder:"Enter company name"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"job_title",children:"Job Title"}),e.jsx(Re,{id:"job_title",value:I.job_title,onChange:Ue=>L({...I,job_title:Ue.target.value}),placeholder:"Enter job title"})]})]}),e.jsx(yZe,{value:I.lead_source_id||"",onChange:Ue=>L({...I,lead_source_id:Ue})}),e.jsxs("div",{children:[e.jsx(ve,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:d==null?void 0:d.filter(Ue=>Ue.active).map(Ue=>{var Ve;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(zo,{checked:(Ve=I.tagIds)==null?void 0:Ve.includes(Ue.id),onCheckedChange:Je=>{var Rt;L(Je?{...I,tagIds:[...I.tagIds||[],Ue.id]}:{...I,tagIds:(Rt=I.tagIds)==null?void 0:Rt.filter($t=>$t!==Ue.id)})}}),e.jsx("span",{className:"text-sm",children:Ue.name})]},Ue.id)})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"notes",children:"Notes"}),e.jsx(Mr,{id:"notes",value:I.notes,onChange:Ue=>L({...I,notes:Ue.target.value}),rows:4})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:he,disabled:b.isPending,children:"Save Changes"}),e.jsx(K,{variant:"outline",onClick:()=>A(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-4",children:[De.length>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",ws(new Date(De[0].completed_at),"MMM d, yyyy")," ","(",De[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(_r,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("button",{onClick:()=>it(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(Zn,{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(Ai,{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(on,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Birthday: ",ws(fl(l.birthday),"MMMM d")]})]}),l.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Un,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Home Anniversary: ",ws(fl(l.home_anniversary),"MMMM d")]})]}),l.created_at&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Zs,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Date Added: ",ws(new Date(l.created_at),"MMMM d, yyyy")]})]})]}),e.jsx(Rl,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(hye,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:l.spouse_name||null,currentSpouseEmail:l.spouse_email||null,onLink:Ue=>N.mutate({contactId:t,spouseContactId:Ue}),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(Aa,{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(Rl,{}),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:(ct=l.tags)!=null&&ct.length?l.tags.map(Ue=>{var Ve;return e.jsx(at,{variant:"secondary",children:(Ve=Ue.relationship_type)==null?void 0:Ve.name},Ue.id)}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No relationship types assigned"})})]}),l.notes&&e.jsxs(e.Fragment,{children:[e.jsx(Rl,{}),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(P7t,{contact:l,onLogTouch:()=>$(!0)}),e.jsx(jBt,{contactId:t}),e.jsx(vBt,{contactId:t}),e.jsx(bBt,{contactId:t}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Activity Log"})}),e.jsx(Oe,{children:De.length>0?e.jsx("div",{className:"space-y-4",children:De.map(Ue=>{var Ve;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:Ue.color},children:Ue.type==="popby"?e.jsx(io,{className:"h-4 w-4"}):(Ve=Ue.name)==null?void 0:Ve.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:Ue.name}),Ue.videoId&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ae(Ue.videoId),children:[e.jsx(ul,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ws(new Date(Ue.completed_at),"MMM d, yyyy h:mm a")}),Ue.notes&&!Ue.videoId&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ue.notes})]})]},Ue.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(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(oo,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:v.map(Ue=>{var Ve,Je;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(Ve=Ue.video)!=null&&Ve.thumbnail_url?e.jsx("img",{src:Ue.video.thumbnail_url,alt:Ue.video.title||"Video",className:"h-12 w-16 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>ae(Ue.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:()=>ae(Ue.video_id),children:e.jsx(kn,{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=Ue.video)==null?void 0:Je.title)||"Untitled Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>ae(Ue.video_id),children:[e.jsx(ul,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ws(new Date(Ue.created_at),"MMM d, yyyy h:mm a")}),Ue.message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:['"',Ue.message,'"']})]})]},Ue.id)})})})]}),Ze&&Ze.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:Ze.map(Ue=>e.jsxs(vs,{children:[e.jsx(Ei,{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(_r,{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:Ue.subject}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["To: ",Ue.to_email," · ",ws(new Date(Ue.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx(Ha,{className:"h-4 w-4 text-muted-foreground mt-1 flex-shrink-0"})]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(_r,{className:"h-5 w-5 text-sky-500"}),Ue.subject]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["To: ",Ue.to_email," · ",ws(new Date(Ue.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:Ue.body,className:"w-full h-[400px] border-0",sandbox:"",title:`Email: ${Ue.subject}`})})]})]},Ue.id))})})]})]}),e.jsx(vs,{open:!!ie,onOpenChange:Ue=>!Ue&&ae(null),children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Video Preview"})}),ie&&e.jsx(_Bt,{videoId:ie})]})})]})]})}),we&&l&&be&&e.jsx(EM,{open:le,onOpenChange:pe,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(K,{onClick:()=>s("/mission-control/contacts"),children:"Back to Contacts"})]})})}const bEe={Crown:Bh,FileText:In,Users:hr,Globe:Pm,Star:Gn,Phone:Zn,MessageSquare:oo,PenTool:n_,Video:kn,Gift:io},Xme=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function NBt(){var ct,Ue;const t=Dr(),{user:s}=Gs(),{data:r}=Ef(),{data:n}=W4t(),{data:a}=J4t(),{data:o}=eVe(),{data:l}=IL(),{data:i}=H4t(),d=e5t(),u=G4t(),p=Z4t(),f=Y4t(),v=X4t(),_=Q4t(),b=K4t(),[j,w]=S.useState(null),[N,C]=S.useState(!1),[A,I]=S.useState(null),[L,R]=S.useState(""),[$,q]=S.useState(""),[U,V]=S.useState([]),[X,se]=S.useState(null),[te,Y]=S.useState(null),[de,ie]=S.useState(!1),[ae,le]=S.useState(""),[pe,be]=S.useState(""),[ye,we]=S.useState(""),[ke,Ze]=S.useState(""),_e=(Ve,Je)=>a==null?void 0:a.some(Rt=>Rt.plan_id===Ve&&Rt.relationship_type_id===Je&&Rt.active),Ce=Ve=>a==null?void 0:a.find(Je=>Je.relationship_type_id===Ve&&Je.active),Te=async(Ve,Je)=>{const Rt=_e(Ve,Je);await d.mutateAsync({planId:Ve,relationshipTypeId:Je,active:!Rt})},Fe=(n==null?void 0:n.filter(Ve=>Ve.active&&!Ve.owner_user_id))||[],Ae=(n==null?void 0:n.filter(Ve=>Ve.owner_user_id===(s==null?void 0:s.id)))||[],We=r==null?void 0:r.find(Ve=>Ve.id===j),ht=j?Ce(j):null,De=n==null?void 0:n.find(Ve=>Ve.id===(ht==null?void 0:ht.plan_id)),Dt=async()=>{if(!L.trim())return;const Ve=await u.mutateAsync({name:L,description:$});Ve&&U.length>0&&await v.mutateAsync({planId:Ve.id,items:U}),ot()},he=async()=>{!L.trim()||!A||(await p.mutateAsync({id:A,name:L,description:$}),await v.mutateAsync({planId:A,items:U}),ot())},Qe=Ve=>{var Je;I(Ve.id),R(Ve.name),q(Ve.description||""),V(((Je=Ve.items)==null?void 0:Je.map(Rt=>({month_number:Rt.month_number,action_type_id:Rt.action_type_id,default_script_id:Rt.default_script_id||void 0,notes:Rt.notes||void 0})))||[]),C(!0)},ot=()=>{C(!1),I(null),R(""),q(""),V([])},rt=(Ve,Je)=>{Y(Je)},Ne=(Ve,Je,Rt)=>{V($t=>[...$t.filter(Qt=>Qt.month_number!==Ve),{month_number:Ve,action_type_id:Je,default_script_id:Rt}]),se(null),Y(null)},it=Ve=>{V(Je=>Je.filter(Rt=>Rt.month_number!==Ve))},qe=async()=>{if(!ae.trim()||!pe.trim()||!te)return;const Ve=await _.mutateAsync({actionTypeId:te,title:ae,scriptBody:pe,emailSubject:ye||void 0,tone:ke||void 0});Ve&&X!==null&&Ne(X,te,Ve.id),ie(!1),le(""),be(""),we(""),Ze("")},Xe=te?i==null?void 0:i.filter(Ve=>Ve.action_type_id===te&&Ve.active):[],$e=Ve=>bEe[Ve||"Phone"]||Zn,Ke=Ve=>bEe[Ve||"Users"]||hr;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(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(zl,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(K,{onClick:()=>C(!0),className:"w-full sm:w-auto",children:[e.jsx(Zs,{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(Ve=>Ve.active).map(Ve=>{const Je=Ke(Ve.icon),Rt=(o==null?void 0:o[Ve.id])||0,$t=Ce(Ve.id),ls=n==null?void 0:n.find(rs=>rs.id===($t==null?void 0:$t.plan_id)),Qt=j===Ve.id;return e.jsxs("button",{onClick:()=>w(Ve.id),className:` w-full flex items-center gap-3 p-4 rounded-lg border text-left transition-all ${Qt?"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:Ve.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Rt," contacts"]})]}),ls?e.jsxs(at,{variant:"secondary",className:"text-xs",children:[e.jsx(gi,{className:"h-3 w-3 mr-1"}),ls.name.split(" ")[0]]}):e.jsx(at,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},Ve.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:j&&We?e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[(()=>{const Ve=Ke(We.icon);return e.jsx(Ve,{className:"h-5 w-5"})})(),We.name," Touchpoint Plan"]}),e.jsxs(yr,{children:["Choose a plan for your ",We.name," contacts"]})]}),e.jsxs(Oe,{className:"space-y-6",children:[De&&e.jsxs("div",{className:"p-4 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(gi,{className:"h-4 w-4 text-green-500"}),"Currently using: ",De.name]}),De.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:De.description})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>Te(De.id,j),children:"Disable"})]}),De.items&&De.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(on,{className:"h-4 w-4"}),"12-Month Schedule"]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:Xme.map((Ve,Je)=>{var Qt,rs;const Rt=((Qt=De.items)==null?void 0:Qt.filter(as=>as.month_number===Je+1))||[],$t=(rs=Rt[0])==null?void 0:rs.action_type,ls=$t?$e($t.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${Rt.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:Ve}),ls&&e.jsx(ls,{className:"h-4 w-4 mx-auto mt-1",style:{color:($t==null?void 0:$t.color)||"#3B82F6"}})]},Je)})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:De?"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(Ve=>{var Rt;const Je=(De==null?void 0:De.id)===Ve.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:Ve.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Rt=Ve.items)==null?void 0:Rt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Duplicate as my own plan",disabled:b.isPending,onClick:()=>{const $t=`${Ve.name} (Copy)`;b.mutate({sourcePlanId:Ve.id,newName:$t})},children:e.jsx(ni,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:Je?"outline":"default",disabled:Je||d.isPending,onClick:()=>Te(Ve.id,j),children:Je?"Active":"Use This"})]})]},Ve.id)})]}),Ae.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),Ae.map(Ve=>{var Rt;const Je=(De==null?void 0:De.id)===Ve.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:Ve.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Rt=Ve.items)==null?void 0:Rt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>Qe(Ve),children:e.jsx(Ix,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>f.mutate(Ve.id),children:e.jsx(br,{className:"h-4 w-4 text-destructive"})}),e.jsx(K,{size:"sm",variant:Je?"outline":"default",disabled:Je||d.isPending,onClick:()=>Te(Ve.id,j),children:Je?"Active":"Use This"})]})]},Ve.id)})]}),Fe.length===0&&Ae.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No plans available. Create a custom plan to get started."})]})]})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(on,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"Select a contact group to view and assign plans"})]})})})]}),e.jsx(Ee,{className:"bg-muted/50",children:e.jsx(Oe,{className:"py-4",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"How it works:"})," When you assign a plan to a contact group, those contacts will appear in your daily suggested actions based on the plan's schedule."]})})})]}),e.jsx(vs,{open:N,onOpenChange:Ve=>{Ve?C(!0):ot()},children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{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(ve,{htmlFor:"plan-name",children:"Plan Name"}),e.jsx(Re,{id:"plan-name",value:L,onChange:Ve=>R(Ve.target.value),placeholder:"e.g., My VIP Plan"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"plan-description",children:"Description (optional)"}),e.jsx(Mr,{id:"plan-description",value:$,onChange:Ve=>q(Ve.target.value),placeholder:"Describe your plan...",rows:2})]})]}),e.jsxs("div",{children:[e.jsx(ve,{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:Xme.map((Ve,Je)=>{const Rt=Je+1,$t=U.find(rs=>rs.month_number===Rt),ls=$t?l==null?void 0:l.find(rs=>rs.id===$t.action_type_id):null,Qt=ls?$e(ls.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>se(X===Rt?null:Rt),className:` w-full p-3 rounded-lg border text-center transition-all ${$t?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${X===Rt?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:Ve}),Qt?e.jsx(Qt,{className:"h-5 w-5 mx-auto mt-1",style:{color:(ls==null?void 0:ls.color)||"#3B82F6"}}):e.jsx(Zs,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),$t&&e.jsx("button",{type:"button",onClick:rs=>{rs.stopPropagation(),it(Rt)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:e.jsx(Ur,{className:"h-3 w-3"})})]},Je)})}),X!==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 ",Xme[X-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(Ve=>Ve.active).map(Ve=>{const Je=$e(Ve.icon);return e.jsxs("button",{type:"button",onClick:()=>rt(X,Ve.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:Ve.color||"#3B82F6"}}),e.jsx("span",{className:"text-sm",children:Ve.name})]},Ve.id)})})]}),X!==null&&te&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm font-medium",children:"Step 2: Select a script (optional)"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Y(null),children:[e.jsx(zl,{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:()=>Ne(X,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"})]})}),Xe==null?void 0:Xe.map(Ve=>e.jsx("button",{type:"button",onClick:()=>Ne(X,te,Ve.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:Ve.title}),Ve.tone&&e.jsx(at,{variant:"secondary",className:"text-xs mt-1",children:Ve.tone}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:[Ve.script_body.substring(0,100),"..."]})]})},Ve.id)),e.jsxs("button",{type:"button",onClick:()=>ie(!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(Zs,{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"})]})]})]})]})]}),U.length>0&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[U.length," touchpoint",U.length!==1?"s":""," per year"]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:ot,children:"Cancel"}),e.jsxs(K,{onClick:A?he:Dt,disabled:!L.trim()||u.isPending||p.isPending,children:[e.jsx(Bu,{className:"h-4 w-4 mr-2"}),A?"Save Changes":"Create Plan"]})]})]})}),e.jsx(vs,{open:de,onOpenChange:ie,children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Create Custom Script"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script-title",children:"Script Title"}),e.jsx(Re,{id:"script-title",value:ae,onChange:Ve=>le(Ve.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script-tone",children:"Tone (optional)"}),e.jsxs(tr,{value:ke,onValueChange:Ze,children:[e.jsx(Js,{children:e.jsx(sr,{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"})]})]})]}),((Ue=(ct=l==null?void 0:l.find(Ve=>Ve.id===te))==null?void 0:ct.name)==null?void 0:Ue.toLowerCase().includes("email"))&&e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script-email-subject",children:"Email Subject"}),e.jsx(Re,{id:"script-email-subject",value:ye,onChange:Ve=>we(Ve.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script-body",children:"Script Content"}),e.jsx(Mr,{id:"script-body",value:pe,onChange:Ve=>be(Ve.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(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>ie(!1),children:"Cancel"}),e.jsxs(K,{onClick:qe,disabled:!ae.trim()||!pe.trim()||_.isPending,children:[e.jsx(Bu,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}const SBt="0dde5abb-0005-4c8c-a471-30d0cbc9e280",CBt=[{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 MBt(){const t=Dr(),s=pZe(),{data:r}=uZe(),{data:n}=Ef(),{data:a}=bwe(),{data:o}=Mle(90),{data:l}=Jh(),i=A7t(),d=fZe(),u=M7t(),p=T7t(),{data:f=[],isLoading:v}=Ct({queryKey:["popby-templates"],queryFn:async()=>{const{data:de,error:ie}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("category_id",SBt).order("publish_date",{ascending:!1});if(ie)throw ie;const{data:ae}=await G.from("template_likes").select("template_id"),{data:le}=await G.from("template_comments").select("template_id"),pe=new Map;ae==null||ae.forEach(ye=>{pe.set(ye.template_id,(pe.get(ye.template_id)||0)+1)});const be=new Map;return le==null||le.forEach(ye=>{be.set(ye.template_id,(be.get(ye.template_id)||0)+1)}),(de||[]).map(ye=>({...ye,likesCount:pe.get(ye.id)||0,commentsCount:be.get(ye.id)||0}))}}),_=de=>{const ie=l==null?void 0:l.find(ae=>ae.id===de);return ie?`${ie.first_name} ${ie.last_name||""}`.trim():"Unknown"},b=de=>{if(!de)return null;const ie=r==null?void 0:r.find(ae=>ae.id===de);return(ie==null?void 0:ie.name)||null},[j,w]=S.useState(null),[N,C]=S.useState(!1),[A,I]=S.useState(!1),[L,R]=S.useState(!1),[$,q]=S.useState({popby_item_id:"",notes:""}),[U,V]=S.useState({name:"",description:""}),X=async()=>{j&&(await d.mutateAsync({contact_id:j.id,popby_item_id:$.popby_item_id||void 0,notes:$.notes||void 0}),C(!1),w(null),q({popby_item_id:"",notes:""}))},se=async()=>{U.name.trim()&&(await u.mutateAsync({name:U.name.trim(),description:U.description.trim()||void 0}),R(!1),V({name:"",description:""}))},te=async(de,ie)=>{await p.mutateAsync({relationship_type_id:de,frequency_days:parseInt(ie)})},Y=de=>{var ae;const ie=a==null?void 0:a.find(le=>le.relationship_type_id===de);return((ae=ie==null?void 0:ie.frequency_days)==null?void 0:ae.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(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-primary",children:i.thisWeekCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This Week"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-emerald-500",children:i.thisMonthCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This Month"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-amber-500",children:i.dueCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Due Now"})]})})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{onClick:()=>t("/mission-control/popbys/map"),children:[e.jsx(Ai,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(K,{variant:"outline",onClick:()=>I(!0),children:[e.jsx($l,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),e.jsxs(K,{variant:"outline",onClick:()=>R(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsxs(Na,{defaultValue:"due",children:[e.jsxs(va,{children:[e.jsx(ks,{value:"due",children:"Due for Popby"}),e.jsx(ks,{value:"activity",children:"Recent Activity"}),e.jsx(ks,{value:"library",children:"Popby Library"}),e.jsx(ks,{value:"templates",children:"Popby Templates"})]}),e.jsx(zs,{value:"due",className:"space-y-4 mt-4",children:!s||s.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(io,{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(de=>e.jsx(Ee,{className:"hover:shadow-md transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium",children:[de.first_name," ",de.last_name]}),de.daysOverdue>0&&e.jsxs(at,{variant:"destructive",className:"text-xs",children:[de.daysOverdue,"+ days overdue"]}),de.daysSinceLastPopby===null&&e.jsx(at,{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:[de.address&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ai,{className:"h-3 w-3"}),de.city||de.address]}),de.tags&&de.tags.length>0&&e.jsx("span",{children:de.tags.map(ie=>{var ae;return(ae=ie.relationship_type)==null?void 0:ae.name}).join(", ")})]}),de.lastPopby&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",ws(new Date(de.lastPopby),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[de.phone&&e.jsx(K,{size:"sm",variant:"ghost",asChild:!0,children:e.jsx("a",{href:`tel:${de.phone}`,children:e.jsx(Zn,{className:"h-4 w-4"})})}),e.jsxs(K,{size:"sm",onClick:()=>{w(de),C(!0)},children:[e.jsx(gi,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})},de.id))})}),e.jsx(zs,{value:"activity",className:"space-y-4 mt-4",children:!o||o.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(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(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-lg",children:"Recent Popby Log"})}),e.jsx(Oe,{className:"space-y-3",children:o.map(de=>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(io,{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:_(de.contact_id)}),b(de.popby_item_id)&&e.jsx(at,{variant:"secondary",className:"text-xs",children:b(de.popby_item_id)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ws(new Date(de.completed_at),"MMM d, yyyy h:mm a")}),de.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:de.notes})]})]},de.id))})]})}),e.jsx(zs,{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(de=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(io,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-medium",children:de.name}),de.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:de.description}),!de.owner_user_id&&e.jsx(at,{variant:"secondary",className:"mt-2 text-xs",children:"Shared"})]})]})})},de.id)),e.jsx(Ee,{className:"border-dashed cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>R(!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(Zs,{className:"h-8 w-8 mx-auto mb-2"}),e.jsx("p",{children:"Add New Popby Idea"})]})})})]})}),e.jsxs(zs,{value:"templates",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[f.length," template",f.length!==1?"s":""," found"]}),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((de,ie)=>e.jsx(Ee,{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"})]})]})},ie))}),!v&&f.length===0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(dl,{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&&f.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:f.map(de=>e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer",onClick:()=>t(`/templates/${de.id}`),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:de.preview_image_url?e.jsx("img",{src:de.preview_image_url,alt:de.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:de.name}),de.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:Qie(de.description)}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:e.jsx(at,{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(pu,{className:"h-3.5 w-3.5"}),de.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gc,{className:"h-3.5 w-3.5"}),de.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:ie=>{ie.stopPropagation(),t(`/templates/${de.id}`)},children:[e.jsx(sn,{className:"h-4 w-4"}),"View Template"]})]})]},de.id))})]})]}),e.jsx(vs,{open:N,onOpenChange:C,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsxs(Ns,{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(ve,{children:"Popby Item (optional)"}),e.jsxs(tr,{value:$.popby_item_id,onValueChange:de=>q(ie=>({...ie,popby_item_id:de})),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a popby item..."})}),e.jsx(er,{children:r==null?void 0:r.map(de=>e.jsx(At,{value:de.id,children:de.name},de.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Notes (optional)"}),e.jsx(Mr,{placeholder:"Any notes about this popby...",value:$.notes,onChange:de=>q(ie=>({...ie,notes:de.target.value}))})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(K,{onClick:X,disabled:d.isPending,children:"Log Popby"})]})]})}),e.jsx(vs,{open:A,onOpenChange:I,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(Ns,{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(de=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx(ve,{className:"font-medium",children:de.name}),e.jsxs(tr,{value:Y(de.id),onValueChange:ie=>te(de.id,ie),children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{})}),e.jsx(er,{children:CBt.map(ie=>e.jsx(At,{value:ie.value,children:ie.label},ie.value))})]})]},de.id))]}),e.jsx(On,{children:e.jsx(K,{onClick:()=>I(!1),children:"Done"})})]})}),e.jsx(vs,{open:L,onOpenChange:R,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Add Popby Idea"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Name *"}),e.jsx(Re,{placeholder:"e.g., Homemade cookies",value:U.name,onChange:de=>V(ie=>({...ie,name:de.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Mr,{placeholder:"Optional description...",value:U.description,onChange:de=>V(ie=>({...ie,description:de.target.value}))})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),e.jsx(K,{onClick:se,disabled:!U.name.trim()||u.isPending,children:"Add Item"})]})]})})]})})}function TBt(){const t=Dr(),{isAdmin:s}=Gs(),r=S.useRef(null),n=S.useRef(null),a=S.useRef([]),o=mZe(),{data:l}=uZe(),i=fZe(),[d,u]=S.useState(""),[p,f]=S.useState(""),[v,_]=S.useState(!0),[b,j]=S.useState(null),[w,N]=S.useState(null),[C,A]=S.useState(!1),[I,L]=S.useState({popby_item_id:"",notes:""}),R=o.filter(V=>V.address||V.city&&V.state);S.useEffect(()=>{(async()=>{_(!0);try{const{data:X}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();X!=null&&X.value&&u(X.value)}catch(X){console.error("Error fetching mapbox token:",X)}_(!1)})()},[]),S.useEffect(()=>{"geolocation"in navigator&&navigator.geolocation.getCurrentPosition(V=>{j([V.coords.longitude,V.coords.latitude])},V=>{console.log("Could not get location:",V)})},[]),S.useEffect(()=>{if(!(!r.current||!d||n.current))return qc.accessToken=d,n.current=new qc.Map({container:r.current,style:"mapbox://styles/mapbox/streets-v12",zoom:b?12:4,center:b||[-98.5795,39.8283]}),n.current.addControl(new qc.NavigationControl,"top-right"),()=>{var V;(V=n.current)==null||V.remove(),n.current=null}},[d,b]),S.useEffect(()=>{!n.current||!d||(a.current.forEach(V=>V.remove()),a.current=[],R.forEach(async V=>{var se;const X=[V.address,V.city,V.state,V.zip].filter(Boolean).join(", ");if(X)try{const Y=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(X)}.json?access_token=${d}`)).json();if(Y.features&&Y.features.length>0){const[de,ie]=Y.features[0].center,ae=document.createElement("div");ae.className="cursor-pointer",ae.innerHTML=`
${V.first_name[0]}${((se=V.last_name)==null?void 0:se[0])||""}
${V.isDue?'
':""}
`;const le=new qc.Marker(ae).setLngLat([de,ie]).addTo(n.current);ae.addEventListener("click",()=>{N(V)}),a.current.push(le)}}catch(te){console.error("Geocoding error for",V.first_name,te)}}))},[R,d]);const $=()=>{b&&n.current?n.current.flyTo({center:b,zoom:13}):an({title:"Location not available",description:"Please enable location services",variant:"destructive"})},q=async()=>{w&&(await i.mutateAsync({contact_id:w.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:""}))},U=async()=>{if(p.trim())try{await G.from("settings").upsert({key:"mapbox_public_token",value:p.trim()}),u(p.trim()),an({title:"Mapbox token saved!"})}catch{an({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(K,{variant:"ghost",onClick:()=>t("/mission-control/popbys"),children:[e.jsx(Ua,{className:"h-4 w-4 mr-2"}),"Back to Popbys"]}),e.jsxs(K,{onClick:$,children:[e.jsx(dP,{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"}),R.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(Qo,{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."})]})})]}),w&&e.jsx(Ee,{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:[w.first_name," ",w.last_name]}),w.address&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[w.city,", ",w.state]})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>N(null),children:"×"})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[w.isDue?e.jsxs(at,{variant:"destructive",children:[w.daysOverdue,"+ days overdue"]}):e.jsx(at,{variant:"secondary",children:"Up to date"}),w.lastPopby&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last: ",ws(new Date(w.lastPopby),"MMM d")]})]}),e.jsxs("div",{className:"flex gap-2",children:[w.phone&&e.jsx(K,{size:"sm",variant:"outline",asChild:!0,className:"flex-1",children:e.jsxs("a",{href:`tel:${w.phone}`,children:[e.jsx(Zn,{className:"h-4 w-4 mr-1"}),"Call"]})}),w.address&&e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>{const V=[w.address,w.city,w.state,w.zip].filter(Boolean).join(", ");window.open(`https://maps.google.com/maps?daddr=${encodeURIComponent(V)}`,"_blank")},children:[e.jsx(yP,{className:"h-4 w-4 mr-1"}),"Navigate"]}),e.jsxs(K,{size:"sm",className:"flex-1",onClick:()=>A(!0),children:[e.jsx(io,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})}),e.jsx(vs,{open:C,onOpenChange:A,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsxs(Ns,{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(ve,{children:"Popby Item (optional)"}),e.jsxs(tr,{value:I.popby_item_id,onValueChange:V=>L(X=>({...X,popby_item_id:V})),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a popby item..."})}),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(ve,{children:"Notes (optional)"}),e.jsx(Mr,{placeholder:"Any notes about this popby...",value:I.notes,onChange:V=>L(X=>({...X,notes:V.target.value}))})]}),b&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Ai,{className:"h-3 w-3"}),"Your current location will be recorded"]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),e.jsxs(K,{onClick:q,disabled:i.isPending,children:[e.jsx(gi,{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(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx(Ai,{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(ve,{children:"Mapbox Public Token"}),e.jsx(Re,{placeholder:"pk.eyJ1I...",value:p,onChange:V=>f(V.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(K,{onClick:U,className:"w-full",children:"Save Token"}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:()=>t("/mission-control/popbys"),children:[e.jsx(Ua,{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(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(Qo,{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(K,{variant:"outline",className:"w-full",onClick:()=>t("/mission-control/popbys"),children:[e.jsx(Ua,{className:"h-4 w-4 mr-2"}),"Back to Popbys"]})]})})})})}const ABt=sS({property_address:Jl().min(1,"Property address is required"),city:Jl().optional(),state:Jl().optional(),zip:Jl().optional(),transaction_type:q9e(["buyer","seller"]),close_date:Jl().min(1,"Close date is required"),sale_price:WP().min(0,"Sale price must be positive"),commission_amount:WP().optional(),lead_source_id:Jl().optional(),client_type_id:Jl().optional(),contact_id:Jl().optional(),notes:Jl().optional(),is_win:Y_t()});function bZe({open:t,onOpenChange:s,transaction:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(""),[i,d]=S.useState(!1),[u,p]=S.useState(""),f=Xoe(),v=$5t(),{data:_}=wM(),{data:b}=Ef(),{data:j}=Jh(),w=Yoe(),N=abe(),{data:C}=Qoe(),A=(C==null?void 0:C.show_commission)??!0,I=Roe({resolver:Foe(ABt),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}});S.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 U=>{const V={property_address:U.property_address,transaction_type:U.transaction_type,close_date:U.close_date,sale_price:U.sale_price,is_win:U.is_win,commission_amount:U.commission_amount||null,lead_source_id:U.lead_source_id||null,client_type_id:U.client_type_id||null,contact_id:U.contact_id||null,city:U.city||null,state:U.state||null,zip:U.zip||null,notes:U.notes||null};r?await v.mutateAsync({id:r.id,...V}):await f.mutateAsync(V),s(!1)},R=async()=>{if(!o.trim())return;const[U,...V]=o.trim().split(" "),X=V.join(" ")||null,se=await w.mutateAsync({first_name:U,last_name:X,tagIds:[]});se&&(I.setValue("contact_id",se.id),l(""),d(!1),a(!1))},$=async()=>{if(!u.trim())return;const U=await N.mutateAsync(u.trim());U&&(I.setValue("lead_source_id",U.id),p(""))},q=j==null?void 0:j.find(U=>U.id===I.watch("contact_id"));return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-lg max-h-[90vh]",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:r?"Edit Transaction":"Add Transaction"})}),e.jsx(Bi,{className:"max-h-[70vh] pr-4",children:e.jsx(zoe,{...I,children:e.jsxs("form",{onSubmit:I.handleSubmit(L),className:"space-y-4",children:[e.jsx(bc,{control:I.control,name:"property_address",render:({field:U})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Property Address *"}),e.jsx(hc,{children:e.jsx(Re,{placeholder:"123 Main St",...U})}),e.jsx(Eh,{})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(bc,{control:I.control,name:"city",render:({field:U})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"City"}),e.jsx(hc,{children:e.jsx(Re,{placeholder:"City",...U})})]})}),e.jsx(bc,{control:I.control,name:"state",render:({field:U})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"State"}),e.jsx(hc,{children:e.jsx(Re,{placeholder:"TX",...U})})]})}),e.jsx(bc,{control:I.control,name:"zip",render:({field:U})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Zip"}),e.jsx(hc,{children:e.jsx(Re,{placeholder:"75001",...U})})]})})]}),e.jsx(bc,{control:I.control,name:"transaction_type",render:({field:U})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Transaction Type *"}),e.jsxs(tr,{onValueChange:U.onChange,value:U.value,children:[e.jsx(hc,{children:e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select type"})})}),e.jsxs(er,{children:[e.jsx(At,{value:"buyer",children:"Buyer"}),e.jsx(At,{value:"seller",children:"Seller"})]})]}),e.jsx(Eh,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(bc,{control:I.control,name:"close_date",render:({field:U})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Close Date *"}),e.jsx(hc,{children:e.jsx(Re,{type:"date",...U})}),e.jsx(Eh,{})]})}),e.jsx(bc,{control:I.control,name:"sale_price",render:({field:U})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Sale Price *"}),e.jsx(hc,{children:e.jsx(Re,{type:"number",placeholder:"0",...U,onChange:V=>U.onChange(Number(V.target.value))})}),e.jsx(Eh,{})]})})]}),A&&e.jsx(bc,{control:I.control,name:"commission_amount",render:({field:U})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Commission"}),e.jsx(hc,{children:e.jsx(Re,{type:"number",placeholder:"0",...U,value:U.value??"",onChange:V=>U.onChange(V.target.value?Number(V.target.value):void 0)})})]})}),e.jsx(bc,{control:I.control,name:"lead_source_id",render:({field:U})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Lead Source"}),e.jsxs(tr,{onValueChange:U.onChange,value:U.value||"",children:[e.jsx(hc,{children:e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select source"})})}),e.jsx(er,{children:_==null?void 0:_.map(V=>e.jsx(At,{value:V.id,children:V.name},V.id))})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Add custom source...",value:u,onChange:U=>p(U.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:$,disabled:!u.trim(),children:e.jsx(Zs,{className:"h-4 w-4"})})]}),e.jsx(bc,{control:I.control,name:"client_type_id",render:({field:U})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Client Type"}),e.jsxs(tr,{onValueChange:U.onChange,value:U.value||"",children:[e.jsx(hc,{children:e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select client type"})})}),e.jsx(er,{children:b==null?void 0:b.map(V=>e.jsx(At,{value:V.id,children:V.name},V.id))})]})]})}),e.jsx(bc,{control:I.control,name:"contact_id",render:({field:U})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Client Contact"}),e.jsxs(So,{open:n,onOpenChange:a,children:[e.jsx(Co,{asChild:!0,children:e.jsx(hc,{children:e.jsxs(K,{variant:"outline",role:"combobox",className:Pt("w-full justify-between",!U.value&&"text-muted-foreground"),children:[q?`${q.first_name} ${q.last_name||""}`.trim():"Select contact",e.jsx(df,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsxs(ko,{className:"w-full p-0",align:"start",children:[e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search contacts..."}),e.jsxs(kf,{children:[e.jsx(Nf,{children:e.jsxs("div",{className:"p-2 space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"No contact found."}),!i&&e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>d(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add New Contact"]})]})}),e.jsx(Sf,{children:j==null?void 0:j.map(V=>e.jsxs(Nm,{value:`${V.first_name} ${V.last_name||""}`,onSelect:()=>{U.onChange(V.id),a(!1)},children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",V.id===U.value?"opacity-100":"opacity-0")}),V.first_name," ",V.last_name||""]},V.id))})]})]}),i&&e.jsxs("div",{className:"p-2 border-t space-y-2",children:[e.jsx(Re,{placeholder:"Enter contact name...",value:o,onChange:V=>l(V.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",onClick:R,disabled:!o.trim()||w.isPending,children:"Add Contact"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{d(!1),l("")},children:"Cancel"})]})]})]})]})]})}),e.jsx(bc,{control:I.control,name:"notes",render:({field:U})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Notes"}),e.jsx(hc,{children:e.jsx(Mr,{placeholder:"Any notes about this transaction...",...U})})]})}),e.jsx(bc,{control:I.control,name:"is_win",render:({field:U})=>e.jsxs(dc,{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(uc,{children:"Mark as Win 🏆"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Highlight this as a notable success"})]}),e.jsx(hc,{children:e.jsx(Br,{checked:U.value,onCheckedChange:U.onChange})})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:f.isPending||v.isPending,children:[r?"Update":"Add"," Transaction"]})]})]})})})]})})}function kwe({transactions:t,showCommission:s,isLoading:r,agentNameMap:n,readOnly:a}){const[o,l]=S.useState(null),[i,d]=S.useState(null),[u,p]=S.useState(""),[f,v]=S.useState("all"),[_,b]=S.useState("all"),[j,w]=S.useState("all"),[N,C]=S.useState(!1),A=q5t(),I=Xoe(),{data:L}=wM(),{data:R}=Ef(),$=PM(),q=X=>{const{id:se,created_at:te,updated_at:Y,lead_source:de,client_type:ie,contact:ae,...le}=X;I.mutate(le)},U=()=>{i&&(A.mutate(i),d(null))},V=t.filter(X=>{var ae,le,pe,be;const se=u===""||X.property_address.toLowerCase().includes(u.toLowerCase())||((le=(ae=X.contact)==null?void 0:ae.first_name)==null?void 0:le.toLowerCase().includes(u.toLowerCase()))||((be=(pe=X.contact)==null?void 0:pe.last_name)==null?void 0:be.toLowerCase().includes(u.toLowerCase())),te=f==="all"||X.transaction_type===f,Y=_==="all"||X.lead_source_id===_,de=j==="all"||X.client_type_id===j,ie=!N||X.is_win;return se&&te&&Y&&de&&ie});return r?e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6 space-y-4",children:[1,2,3].map(X=>e.jsx(gs,{className:"h-16 w-full"},X))})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs(zt,{children:["Transactions (",V.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(fn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search...",value:u,onChange:X=>p(X.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs(tr,{value:f,onValueChange:v,children:[e.jsx(Js,{className:"w-[100px]",children:e.jsx(sr,{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(sr,{placeholder:"Lead Source"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Sources"}),L==null?void 0:L.map(X=>e.jsx(At,{value:X.id,children:X.name},X.id))]})]}),e.jsxs(K,{variant:N?"default":"outline",size:"sm",onClick:()=>C(!N),children:[e.jsx(rc,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx(Oe,{children:V.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No transactions found"}):$?e.jsx("div",{className:"space-y-3",children:V.map(X=>e.jsxs(Ee,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium truncate",children:X.property_address}),X.is_win&&e.jsx(rc,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[X.city,X.state?`, ${X.state}`:""]})]}),e.jsx(at,{variant:X.transaction_type==="buyer"?"default":"secondary",children:X.transaction_type})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Close Date: "}),n4e(X.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),Tl(X.sale_price)]}),s&&X.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),Tl(X.commission_amount)]}),X.lead_source&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Source: "}),X.lead_source.name]}),X.contact&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Client: "}),X.contact.first_name," ",X.contact.last_name]}),n&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Agent: "}),n[X.owner_user_id]||"Unknown"]})]}),!a&&e.jsxs("div",{className:"flex justify-end gap-2 mt-3 pt-3 border-t",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>l(X),children:e.jsx(Oc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>q(X),children:e.jsx(ni,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(X.id),children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]})]},X.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[n&&e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Property"}),e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Close Date"}),e.jsx(jt,{children:"Sale Price"}),s&&e.jsx(jt,{children:"Commission"}),e.jsx(jt,{children:"Lead Source"}),e.jsx(jt,{children:"Client"}),!a&&e.jsx(jt,{className:"w-[50px]"})]})}),e.jsx(Pn,{children:V.map(X=>{var se;return e.jsxs(js,{children:[n&&e.jsx(lt,{className:"font-medium text-sm",children:n[X.owner_user_id]||"Unknown"}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[X.is_win&&e.jsx(rc,{className:"h-4 w-4 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:X.property_address}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[X.city,X.state?`, ${X.state}`:""]})]})]})}),e.jsx(lt,{children:e.jsx(at,{variant:X.transaction_type==="buyer"?"default":"secondary",children:X.transaction_type})}),e.jsx(lt,{children:n4e(X.close_date)}),e.jsx(lt,{children:Tl(X.sale_price)}),s&&e.jsx(lt,{children:X.commission_amount?Tl(X.commission_amount):"-"}),e.jsx(lt,{children:((se=X.lead_source)==null?void 0:se.name)||"-"}),e.jsx(lt,{children:X.contact?`${X.contact.first_name} ${X.contact.last_name||""}`.trim():"-"}),!a&&e.jsx(lt,{children:e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(Jp,{className:"h-4 w-4"})})}),e.jsxs(Td,{align:"end",children:[e.jsxs(Ta,{onClick:()=>l(X),children:[e.jsx(Oc,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ta,{onClick:()=>q(X),children:[e.jsx(ni,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(Ta,{onClick:()=>d(X.id),className:"text-destructive",children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},X.id)})})]})})})]}),e.jsx(bZe,{open:!!o,onOpenChange:X=>!X&&l(null),transaction:o||void 0}),e.jsx(nc,{open:!!i,onOpenChange:X=>!X&&d(null),children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Transaction?"}),e.jsx(Dl,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:U,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function wZe({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),j=Math.max(_-v,0),w=l>0?j/l:0,N=o/12*100,C=b>=N?"ahead":b>=N*.8?"on-track":"behind";return{percent:b,remaining:j,pace:w,status:C}},d=i(s.totalTransactions,t.transactions_goal),u=i(s.totalVolume,t.volume_goal),p=n?i(s.totalCommission,t.gci_goal):null,f=v=>{switch(v){case"ahead":return e.jsxs(at,{className:"bg-green-500 text-white",children:[e.jsx(Cc,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return e.jsxs(at,{variant:"secondary",children:[e.jsx(P0,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return e.jsxs(at,{variant:"destructive",children:[e.jsx(dN,{className:"h-3 w-3 mr-1"}),"Behind"]});default:return null}};return!t.transactions_goal&&!t.volume_goal&&!t.gci_goal?null:e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hh,{className:"h-5 w-5 text-primary"}),e.jsxs(zt,{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"}),f(d.status)]}),e.jsx(Ti,{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"}),f(u.status)]}),e.jsx(Ti,{value:u.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Tl(s.totalVolume,!0)," of ",Tl(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 ",Tl(u.pace,!0),"/month"]})]}),n&&t.gci_goal&&p&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"GCI"}),f(p.status)]}),e.jsx(Ti,{value:p.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Tl(s.totalCommission,!0)," of ",Tl(t.gci_goal,!0)]}),e.jsxs("span",{children:[Math.round(p.percent),"%"]})]}),p.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Tl(p.pace,!0),"/month"]})]})]})})]})}var EBt=Array.isArray,Bm=EBt,PBt=typeof f0=="object"&&f0&&f0.Object===Object&&f0,jZe=PBt,IBt=jZe,LBt=typeof self=="object"&&self&&self.Object===Object&&self,DBt=IBt||LBt||Function("return this")(),xy=DBt,OBt=xy,RBt=OBt.Symbol,XL=RBt,wEe=XL,kZe=Object.prototype,FBt=kZe.hasOwnProperty,zBt=kZe.toString,oE=wEe?wEe.toStringTag:void 0;function BBt(t){var s=FBt.call(t,oE),r=t[oE];try{t[oE]=void 0;var n=!0}catch{}var a=zBt.call(t);return n&&(s?t[oE]=r:delete t[oE]),a}var $Bt=BBt,qBt=Object.prototype,UBt=qBt.toString;function VBt(t){return UBt.call(t)}var HBt=VBt,jEe=XL,WBt=$Bt,GBt=HBt,KBt="[object Null]",ZBt="[object Undefined]",kEe=jEe?jEe.toStringTag:void 0;function YBt(t){return t==null?t===void 0?ZBt:KBt:kEe&&kEe in Object(t)?WBt(t):GBt(t)}var rv=YBt;function XBt(t){return t!=null&&typeof t=="object"}var nv=XBt,QBt=rv,JBt=nv,e9t="[object Symbol]";function t9t(t){return typeof t=="symbol"||JBt(t)&&QBt(t)==e9t}var IM=t9t,s9t=Bm,r9t=IM,n9t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a9t=/^\w*$/;function i9t(t,s){if(s9t(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||r9t(t)?!0:a9t.test(t)||!n9t.test(t)||s!=null&&t in Object(s)}var Nwe=i9t;function o9t(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var Q_=o9t;const LM=_o(Q_);var l9t=rv,c9t=Q_,d9t="[object AsyncFunction]",u9t="[object Function]",h9t="[object GeneratorFunction]",m9t="[object Proxy]";function p9t(t){if(!c9t(t))return!1;var s=l9t(t);return s==u9t||s==h9t||s==d9t||s==m9t}var Swe=p9t;const bi=_o(Swe);var f9t=xy,g9t=f9t["__core-js_shared__"],x9t=g9t,Qme=x9t,NEe=function(){var t=/[^.]+$/.exec(Qme&&Qme.keys&&Qme.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function y9t(t){return!!NEe&&NEe in t}var v9t=y9t,_9t=Function.prototype,b9t=_9t.toString;function w9t(t){if(t!=null){try{return b9t.call(t)}catch{}try{return t+""}catch{}}return""}var NZe=w9t,j9t=Swe,k9t=v9t,N9t=Q_,S9t=NZe,C9t=/[\\^$.*+?()[\]{}|]/g,M9t=/^\[object .+?Constructor\]$/,T9t=Function.prototype,A9t=Object.prototype,E9t=T9t.toString,P9t=A9t.hasOwnProperty,I9t=RegExp("^"+E9t.call(P9t).replace(C9t,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function L9t(t){if(!N9t(t)||k9t(t))return!1;var s=j9t(t)?I9t:M9t;return s.test(S9t(t))}var D9t=L9t;function O9t(t,s){return t==null?void 0:t[s]}var R9t=O9t,F9t=D9t,z9t=R9t;function B9t(t,s){var r=z9t(t,s);return F9t(r)?r:void 0}var oS=B9t,$9t=oS,q9t=$9t(Object,"create"),Ele=q9t,SEe=Ele;function U9t(){this.__data__=SEe?SEe(null):{},this.size=0}var V9t=U9t;function H9t(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var W9t=H9t,G9t=Ele,K9t="__lodash_hash_undefined__",Z9t=Object.prototype,Y9t=Z9t.hasOwnProperty;function X9t(t){var s=this.__data__;if(G9t){var r=s[t];return r===K9t?void 0:r}return Y9t.call(s,t)?s[t]:void 0}var Q9t=X9t,J9t=Ele,e$t=Object.prototype,t$t=e$t.hasOwnProperty;function s$t(t){var s=this.__data__;return J9t?s[t]!==void 0:t$t.call(s,t)}var r$t=s$t,n$t=Ele,a$t="__lodash_hash_undefined__";function i$t(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=n$t&&s===void 0?a$t:s,this}var o$t=i$t,l$t=V9t,c$t=W9t,d$t=Q9t,u$t=r$t,h$t=o$t;function DM(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var T$t=M$t,A$t=Ple;function E$t(t,s){var r=this.__data__,n=A$t(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var P$t=E$t,I$t=f$t,L$t=j$t,D$t=S$t,O$t=T$t,R$t=P$t;function OM(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s0?1:-1},Ok=function(s){return qN(s)&&s.indexOf("%")===s.length-1},tn=function(s){return rUt(s)&&!QL(s)},oUt=function(s){return Yi(s)},Ud=function(s){return tn(s)||qN(s)},lUt=0,JL=function(s){var r=++lUt;return"".concat(s||"").concat(r)},Rh=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(!tn(s)&&!qN(s))return n;var o;if(Ok(s)){var l=s.indexOf("%");o=r*parseFloat(s.slice(0,l))/100}else o=+s;return QL(o)&&(o=n),a&&o>r&&(o=r),o},w1=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},cUt=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 gUt(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 IEe={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"},B0=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},LEe=null,epe=null,Owe=function t(s){if(s===LEe&&Array.isArray(epe))return epe;var r=[];return S.Children.forEach(s,function(n){Yi(n)||(Qqt.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),epe=r,LEe=s,r};function vf(t,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return B0(a)}):n=[B0(s)],Owe(t).forEach(function(a){var o=vp(a,"type.displayName")||vp(a,"type.name");n.indexOf(o)!==-1&&r.push(a)}),r}function sp(t,s){var r=vf(t,s);return r&&r[0]}var DEe=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!tn(n)||n<=0||!tn(a)||a<=0)},xUt=["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"],yUt=function(s){return s&&s.type&&qN(s.type)&&xUt.indexOf(s.type)>=0},vUt=function(s,r,n,a){var o,l=(o=Jme==null?void 0:Jme[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!bi(s)&&(a&&l.includes(r)||hUt.includes(r))||n&&Dwe.includes(r)},hi=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(S.isValidElement(s)&&(a=s.props),!LM(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;vUt((i=a)===null||i===void 0?void 0:i[l],l,r,n)&&(o[l]=a[l])}),o},fye=function t(s,r){if(s===r)return!0;var n=S.Children.count(s);if(n!==S.Children.count(r))return!1;if(n===0)return!0;if(n===1)return OEe(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 kUt(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 xye(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=jUt(t,wUt),p=a||{width:r,height:n,x:0,y:0},f=zi("recharts-surface",o);return mt.createElement("svg",gye({},hi(u,!0,"svg"),{className:f,width:r,height:n,style:l,viewBox:"".concat(p.x," ").concat(p.y," ").concat(p.width," ").concat(p.height)}),mt.createElement("title",null,i),mt.createElement("desc",null,d),s)}var NUt=["children","className"];function yye(){return yye=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 CUt(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 tl=mt.forwardRef(function(t,s){var r=t.children,n=t.className,a=SUt(t,NUt),o=zi("recharts-layer",n);return mt.createElement("g",yye({className:o},hi(a,!0),{ref:s}),r)}),Ug=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:AUt(t,s,r)}var PUt=EUt,IUt="\\ud800-\\udfff",LUt="\\u0300-\\u036f",DUt="\\ufe20-\\ufe2f",OUt="\\u20d0-\\u20ff",RUt=LUt+DUt+OUt,FUt="\\ufe0e\\ufe0f",zUt="\\u200d",BUt=RegExp("["+zUt+IUt+RUt+FUt+"]");function $Ut(t){return BUt.test(t)}var DZe=$Ut;function qUt(t){return t.split("")}var UUt=qUt,OZe="\\ud800-\\udfff",VUt="\\u0300-\\u036f",HUt="\\ufe20-\\ufe2f",WUt="\\u20d0-\\u20ff",GUt=VUt+HUt+WUt,KUt="\\ufe0e\\ufe0f",ZUt="["+OZe+"]",vye="["+GUt+"]",_ye="\\ud83c[\\udffb-\\udfff]",YUt="(?:"+vye+"|"+_ye+")",RZe="[^"+OZe+"]",FZe="(?:\\ud83c[\\udde6-\\uddff]){2}",zZe="[\\ud800-\\udbff][\\udc00-\\udfff]",XUt="\\u200d",BZe=YUt+"?",$Ze="["+KUt+"]?",QUt="(?:"+XUt+"(?:"+[RZe,FZe,zZe].join("|")+")"+$Ze+BZe+")*",JUt=$Ze+BZe+QUt,eVt="(?:"+[RZe+vye+"?",vye,FZe,zZe,ZUt].join("|")+")",tVt=RegExp(_ye+"(?="+_ye+")|"+eVt+JUt,"g");function sVt(t){return t.match(tVt)||[]}var rVt=sVt,nVt=UUt,aVt=DZe,iVt=rVt;function oVt(t){return aVt(t)?iVt(t):nVt(t)}var lVt=oVt,cVt=PUt,dVt=DZe,uVt=lVt,hVt=TZe;function mVt(t){return function(s){s=hVt(s);var r=dVt(s)?uVt(s):void 0,n=r?r[0]:s.charAt(0),a=r?cVt(r,1).join(""):s.slice(1);return n[t]()+a}}var pVt=mVt,fVt=pVt,gVt=fVt("toUpperCase"),xVt=gVt;const Wle=_o(xVt);function Ml(t){return function(){return t}}const qZe=Math.cos,Lae=Math.sin,Jg=Math.sqrt,Dae=Math.PI,Gle=2*Dae,bye=Math.PI,wye=2*bye,fk=1e-6,yVt=wye-fk;function UZe(t){this._+=t[0];for(let s=1,r=t.length;s=0))throw new Error(`invalid digits: ${t}`);if(s>15)return UZe;const r=10**s;return function(n){this._+=n[0];for(let a=1,o=n.length;afk)if(!(Math.abs(f*d-u*p)>fk)||!o)this._append`L${this._x1=s},${this._y1=r}`;else{let _=n-l,b=a-i,j=d*d+u*u,w=_*_+b*b,N=Math.sqrt(j),C=Math.sqrt(v),A=o*Math.tan((bye-Math.acos((j+v-w)/(2*N*C)))/2),I=A/C,L=A/N;Math.abs(I-1)>fk&&this._append`L${s+I*p},${r+I*f}`,this._append`A${o},${o},0,0,${+(f*_>p*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,p=r+d,f=1^l,v=l?a-o:o-a;this._x1===null?this._append`M${u},${p}`:(Math.abs(this._x1-u)>fk||Math.abs(this._y1-p)>fk)&&this._append`L${u},${p}`,n&&(v<0&&(v=v%wye+wye),v>yVt?this._append`A${n},${n},0,1,${f},${s-i},${r-d}A${n},${n},0,1,${f},${this._x1=u},${this._y1=p}`:v>fk&&this._append`A${n},${n},0,${+(v>=bye)},${f},${this._x1=s+n*Math.cos(o)},${this._y1=r+n*Math.sin(o)}`)}rect(s,r,n,a){this._append`M${this._x0=this._x1=+s},${this._y0=this._y1=+r}h${n=+n}v${+a}h${-n}Z`}toString(){return this._}}function Rwe(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 _Vt(s)}function Fwe(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function VZe(t){this._context=t}VZe.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 Kle(t){return new VZe(t)}function HZe(t){return t[0]}function WZe(t){return t[1]}function GZe(t,s){var r=Ml(!0),n=null,a=Kle,o=null,l=Rwe(i);t=typeof t=="function"?t:t===void 0?HZe:Ml(t),s=typeof s=="function"?s:s===void 0?WZe:Ml(s);function i(d){var u,p=(d=Fwe(d)).length,f,v=!1,_;for(n==null&&(o=a(_=l())),u=0;u<=p;++u)!(u=_;--b)i.point(A[b],I[b]);i.lineEnd(),i.areaEnd()}N&&(A[v]=+t(w,v,f),I[v]=+s(w,v,f),i.point(n?+n(w,v,f):A[v],r?+r(w,v,f):I[v]))}if(C)return i=null,C+""||null}function p(){return GZe().defined(a).curve(l).context(o)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Ml(+f),n=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Ml(+f),u):t},u.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Ml(+f),u):n},u.y=function(f){return arguments.length?(s=typeof f=="function"?f:Ml(+f),r=null,u):s},u.y0=function(f){return arguments.length?(s=typeof f=="function"?f:Ml(+f),u):s},u.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Ml(+f),u):r},u.lineX0=u.lineY0=function(){return p().x(t).y(s)},u.lineY1=function(){return p().x(t).y(r)},u.lineX1=function(){return p().x(n).y(s)},u.defined=function(f){return arguments.length?(a=typeof f=="function"?f:Ml(!!f),u):a},u.curve=function(f){return arguments.length?(l=f,o!=null&&(i=l(o)),u):l},u.context=function(f){return arguments.length?(f==null?o=i=null:i=l(o=f),u):o},u}class KZe{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 bVt(t){return new KZe(t,!0)}function wVt(t){return new KZe(t,!1)}const zwe={draw(t,s){const r=Jg(s/Dae);t.moveTo(r,0),t.arc(0,0,r,0,Gle)}},jVt={draw(t,s){const r=Jg(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()}},ZZe=Jg(1/3),kVt=ZZe*2,NVt={draw(t,s){const r=Jg(s/kVt),n=r*ZZe;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},SVt={draw(t,s){const r=Jg(s),n=-r/2;t.rect(n,n,r,r)}},CVt=.8908130915292852,YZe=Lae(Dae/10)/Lae(7*Dae/10),MVt=Lae(Gle/10)*YZe,TVt=-qZe(Gle/10)*YZe,AVt={draw(t,s){const r=Jg(s*CVt),n=MVt*r,a=TVt*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=Gle*o/5,i=qZe(l),d=Lae(l);t.lineTo(d*r,-i*r),t.lineTo(i*n-d*a,d*n+i*a)}t.closePath()}},tpe=Jg(3),EVt={draw(t,s){const r=-Jg(s/(tpe*3));t.moveTo(0,r*2),t.lineTo(-tpe*r,-r),t.lineTo(tpe*r,-r),t.closePath()}},Bp=-.5,$p=Jg(3)/2,jye=1/Jg(12),PVt=(jye/2+1)*3,IVt={draw(t,s){const r=Jg(s/PVt),n=r/2,a=r*jye,o=n,l=r*jye+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 LVt(t,s){let r=null,n=Rwe(a);t=typeof t=="function"?t:Ml(t||zwe),s=typeof s=="function"?s:Ml(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:Ml(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:Ml(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function Oae(){}function Rae(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 XZe(t){this._context=t}XZe.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:Rae(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:Rae(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function DVt(t){return new XZe(t)}function QZe(t){this._context=t}QZe.prototype={areaStart:Oae,areaEnd:Oae,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:Rae(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function OVt(t){return new QZe(t)}function JZe(t){this._context=t}JZe.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:Rae(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function RVt(t){return new JZe(t)}function eYe(t){this._context=t}eYe.prototype={areaStart:Oae,areaEnd:Oae,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 FVt(t){return new eYe(t)}function FEe(t){return t<0?-1:1}function zEe(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(FEe(o)+FEe(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function BEe(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function spe(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 Fae(t){this._context=t}Fae.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:spe(this,this._t0,BEe(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,spe(this,BEe(this,r=zEe(this,t,s)),r);break;default:spe(this,this._t0,r=zEe(this,t,s));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s,this._t0=r}}};function tYe(t){this._context=new sYe(t)}(tYe.prototype=Object.create(Fae.prototype)).point=function(t,s){Fae.prototype.point.call(this,s,t)};function sYe(t){this._context=t}sYe.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 zVt(t){return new Fae(t)}function BVt(t){return new tYe(t)}function rYe(t){this._context=t}rYe.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=$Ee(t),a=$Ee(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 qVt(t){return new Zle(t,.5)}function UVt(t){return new Zle(t,0)}function VVt(t){return new Zle(t,1)}function T3(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 HVt(t,s){return t[s]}function WVt(t){const s=[];return s.key=t,s}function GVt(){var t=Ml([]),s=kye,r=T3,n=HVt;function a(o){var l=Array.from(t.apply(this,arguments),WVt),i,d=l.length,u=-1,p;for(const f of o)for(i=0,++u;i0){for(var r,n,a=0,o=t[0].length,l;a0){for(var r=0,n=t[s[0]],a,o=n.length;r0)||!((o=(a=t[s[0]]).length)>0))){for(var r=0,n=1,a,o,l;n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function sHt(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 nYe={symbolCircle:zwe,symbolCross:jVt,symbolDiamond:NVt,symbolSquare:SVt,symbolStar:AVt,symbolTriangle:EVt,symbolWye:IVt},rHt=Math.PI/180,nHt=function(s){var r="symbol".concat(Wle(s));return nYe[r]||zwe},aHt=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*rHt;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}},iHt=function(s,r){nYe["symbol".concat(Wle(s))]=r},Bwe=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=tHt(s,XVt),u=UEe(UEe({},d),{},{type:n,size:o,sizeType:i}),p=function(){var w=nHt(n),N=LVt().type(w).size(aHt(o,i,n));return N()},f=u.className,v=u.cx,_=u.cy,b=hi(u,!0);return v===+v&&_===+_&&o===+o?mt.createElement("path",Nye({},b,{className:zi("recharts-symbols",f),transform:"translate(".concat(v,", ").concat(_,")"),d:p()})):null};Bwe.registerSymbol=iHt;function A3(t){"@babel/helpers - typeof";return A3=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},A3(t)}function Sye(){return Sye=Object.assign?Object.assign.bind():function(t){for(var s=1;s`);var C=_.inactive?u:_.color;return mt.createElement("li",Sye({className:w,style:f,key:"legend-item-".concat(b)},UN(n.props,_,b)),mt.createElement(xye,{width:l,height:l,viewBox:p,style:v},n.renderIcon(_)),mt.createElement("span",{className:"recharts-legend-item-text",style:{color:C}},j?j(N,_,b):N))})}},{key:"render",value:function(){var n=this.props,a=n.payload,o=n.layout,l=n.align;if(!a||!a.length)return null;var i={padding:0,margin:0,textAlign:o==="horizontal"?l:"left"};return mt.createElement("ul",{className:"recharts-default-legend",style:i},this.renderItems())}}])}(S.PureComponent);_6($we,"displayName","Legend");_6($we,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var gHt=Ile;function xHt(){this.__data__=new gHt,this.size=0}var yHt=xHt;function vHt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var _Ht=vHt;function bHt(t){return this.__data__.get(t)}var wHt=bHt;function jHt(t){return this.__data__.has(t)}var kHt=jHt,NHt=Ile,SHt=Mwe,CHt=Twe,MHt=200;function THt(t,s){var r=this.__data__;if(r instanceof NHt){var n=r.__data__;if(!SHt||n.lengthi))return!1;var u=o.get(t),p=o.get(s);if(u&&p)return u==s&&p==t;var f=-1,v=!0,_=r&XHt?new GHt:void 0;for(o.set(t,s),o.set(s,t);++f-1&&t%1==0&&t-1&&t%1==0&&t<=tGt}var Hwe=sGt,rGt=rv,nGt=Hwe,aGt=nv,iGt="[object Arguments]",oGt="[object Array]",lGt="[object Boolean]",cGt="[object Date]",dGt="[object Error]",uGt="[object Function]",hGt="[object Map]",mGt="[object Number]",pGt="[object Object]",fGt="[object RegExp]",gGt="[object Set]",xGt="[object String]",yGt="[object WeakMap]",vGt="[object ArrayBuffer]",_Gt="[object DataView]",bGt="[object Float32Array]",wGt="[object Float64Array]",jGt="[object Int8Array]",kGt="[object Int16Array]",NGt="[object Int32Array]",SGt="[object Uint8Array]",CGt="[object Uint8ClampedArray]",MGt="[object Uint16Array]",TGt="[object Uint32Array]",Xl={};Xl[bGt]=Xl[wGt]=Xl[jGt]=Xl[kGt]=Xl[NGt]=Xl[SGt]=Xl[CGt]=Xl[MGt]=Xl[TGt]=!0;Xl[iGt]=Xl[oGt]=Xl[vGt]=Xl[lGt]=Xl[_Gt]=Xl[cGt]=Xl[dGt]=Xl[uGt]=Xl[hGt]=Xl[mGt]=Xl[pGt]=Xl[fGt]=Xl[gGt]=Xl[xGt]=Xl[yGt]=!1;function AGt(t){return aGt(t)&&nGt(t.length)&&!!Xl[rGt(t)]}var EGt=AGt;function PGt(t){return function(s){return t(s)}}var fYe=PGt,qae={exports:{}};qae.exports;(function(t,s){var r=jZe,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})(qae,qae.exports);var IGt=qae.exports,LGt=EGt,DGt=fYe,YEe=IGt,XEe=YEe&&YEe.isTypedArray,OGt=XEe?DGt(XEe):LGt,gYe=OGt,RGt=BWt,FGt=Uwe,zGt=Bm,BGt=pYe,$Gt=Vwe,qGt=gYe,UGt=Object.prototype,VGt=UGt.hasOwnProperty;function HGt(t,s){var r=zGt(t),n=!r&&FGt(t),a=!r&&!n&&BGt(t),o=!r&&!n&&!a&&qGt(t),l=r||n||a||o,i=l?RGt(t.length,String):[],d=i.length;for(var u in t)(s||VGt.call(t,u))&&!(l&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||$Gt(u,d)))&&i.push(u);return i}var WGt=HGt,GGt=Object.prototype;function KGt(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||GGt;return t===r}var ZGt=KGt;function YGt(t,s){return function(r){return t(s(r))}}var xYe=YGt,XGt=xYe,QGt=XGt(Object.keys,Object),JGt=QGt,eKt=ZGt,tKt=JGt,sKt=Object.prototype,rKt=sKt.hasOwnProperty;function nKt(t){if(!eKt(t))return tKt(t);var s=[];for(var r in Object(t))rKt.call(t,r)&&r!="constructor"&&s.push(r);return s}var aKt=nKt,iKt=Swe,oKt=Hwe;function lKt(t){return t!=null&&oKt(t.length)&&!iKt(t)}var eD=lKt,cKt=WGt,dKt=aKt,uKt=eD;function hKt(t){return uKt(t)?cKt(t):dKt(t)}var Yle=hKt,mKt=MWt,pKt=FWt,fKt=Yle;function gKt(t){return mKt(t,fKt,pKt)}var xKt=gKt,QEe=xKt,yKt=1,vKt=Object.prototype,_Kt=vKt.hasOwnProperty;function bKt(t,s,r,n,a,o){var l=r&yKt,i=QEe(t),d=i.length,u=QEe(s),p=u.length;if(d!=p&&!l)return!1;for(var f=d;f--;){var v=i[f];if(!(l?v in s:_Kt.call(s,v)))return!1}var _=o.get(t),b=o.get(s);if(_&&b)return _==s&&b==t;var j=!0;o.set(t,s),o.set(s,t);for(var w=l;++f-1}var vYt=yYt;function _Yt(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=DYt){var u=s?null:IYt(t);if(u)return LYt(u);l=!1,a=PYt,d=new TYt}else d=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function XYt(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 QYt(t){return t.value}function JYt(t,s){if(mt.isValidElement(t))return mt.cloneElement(t,s);if(typeof t=="function")return mt.createElement(t,s);s.ref;var r=YYt(s,qYt);return mt.createElement($we,r)}var pPe=1,F5=function(t){function s(){var r;UYt(this,s);for(var n=arguments.length,a=new Array(n),o=0;opPe||Math.abs(a.height-this.lastBoundingBox.height)>pPe)&&(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?Xy({},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,p=a.chartHeight,f,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();f={left:((u||0)-_.width)/2}}else f=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:((p||0)-b.height)/2}}else v=i==="bottom"?{bottom:d&&d.bottom||0}:{top:d&&d.top||0};return Xy(Xy({},f),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,p=a.payload,f=Xy(Xy({position:"absolute",width:l||"auto",height:i||"auto"},this.getDefaultPosition(d)),d);return mt.createElement("div",{className:"recharts-legend-wrapper",style:f,ref:function(_){n.wrapperNode=_}},JYt(o,Xy(Xy({},this.props),{},{payload:kYe(p,u,QYt)})))}}],[{key:"getWithHeight",value:function(n,a){var o=Xy(Xy({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&tn(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(S.PureComponent);Xle(F5,"displayName","Legend");Xle(F5,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var fPe=XL,eXt=Uwe,tXt=Bm,gPe=fPe?fPe.isConcatSpreadable:void 0;function sXt(t){return tXt(t)||eXt(t)||!!(gPe&&t&&t[gPe])}var rXt=sXt,nXt=hYe,aXt=rXt;function CYe(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=aXt),a||(a=[]);++o0&&r(i)?s>1?CYe(i,s-1,r,n,a):nXt(a,i):n||(a[a.length]=i)}return a}var MYe=CYe;function iXt(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 oXt=iXt,lXt=oXt,cXt=lXt(),dXt=cXt,uXt=dXt,hXt=Yle;function mXt(t,s){return t&&uXt(t,s,hXt)}var TYe=mXt,pXt=eD;function fXt(t,s){return function(r,n){if(r==null)return r;if(!pXt(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 TXt=MXt,ipe=Ewe,AXt=Pwe,EXt=yy,PXt=AYe,IXt=kXt,LXt=fYe,DXt=TXt,OXt=BM,RXt=Bm;function FXt(t,s,r){s.length?s=ipe(s,function(o){return RXt(o)?function(l){return AXt(l,o.length===1?o[0]:o)}:o}):s=[OXt];var n=-1;s=ipe(s,LXt(EXt));var a=PXt(t,function(o,l,i){var d=ipe(s,function(u){return u(o)});return{criteria:d,index:++n,value:o}});return IXt(a,function(o,l){return DXt(o,l,r)})}var zXt=FXt;function BXt(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 $Xt=BXt,qXt=$Xt,yPe=Math.max;function UXt(t,s,r){return s=yPe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=yPe(n.length-s,0),l=Array(o);++a0){if(++s>=JXt)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var rQt=sQt,nQt=QXt,aQt=rQt,iQt=aQt(nQt),oQt=iQt,lQt=BM,cQt=VXt,dQt=oQt;function uQt(t,s){return dQt(cQt(t,s,lQt),t+"")}var hQt=uQt,mQt=Cwe,pQt=eD,fQt=Vwe,gQt=Q_;function xQt(t,s,r){if(!gQt(r))return!1;var n=typeof s;return(n=="number"?pQt(r)&&fQt(s,r.length):n=="string"&&s in r)?mQt(r[s],t):!1}var Qle=xQt,yQt=MYe,vQt=zXt,_Qt=hQt,_Pe=Qle,bQt=_Qt(function(t,s){if(t==null)return[];var r=s.length;return r>1&&_Pe(t,s[0],s[1])?s=[]:r>2&&_Pe(s[0],s[1],s[2])&&(s=[s[0]]),vQt(t,yQt(s,1),[])}),wQt=bQt;const Kwe=_o(wQt);function b6(t){"@babel/helpers - typeof";return b6=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},b6(t)}function Lye(){return Lye=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(lE,"-left"),tn(r)&&s&&tn(s.x)&&r=s.y),"".concat(lE,"-top"),tn(n)&&s&&tn(s.y)&&nj?Math.max(p,d[n]):Math.max(f,d[n])}function RQt(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 FQt(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,p,f;return l.height>0&&l.width>0&&r?(p=jPe({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:d,viewBoxDimension:d.width}),f=jPe({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:d,viewBoxDimension:d.height}),u=RQt({translateX:p,translateY:f,useTranslate3d:i})):u=DQt,{cssProperties:u,cssClasses:OQt({translateX:p,translateY:f,coordinate:r})}}function P3(t){"@babel/helpers - typeof";return P3=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},P3(t)}function kPe(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 NPe(t){for(var s=1;sSPe||Math.abs(n.height-this.state.lastBoundingBox.height)>SPe)&&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,p=a.coordinate,f=a.hasPayload,v=a.isAnimationActive,_=a.offset,b=a.position,j=a.reverseDirection,w=a.useTranslate3d,N=a.viewBox,C=a.wrapperStyle,A=FQt({allowEscapeViewBox:l,coordinate:p,offsetTopLeft:_,position:b,reverseDirection:j,tooltipBox:this.state.lastBoundingBox,useTranslate3d:w,viewBox:N}),I=A.cssClasses,L=A.cssProperties,R=NPe(NPe({transition:v&&o?"transform ".concat(i,"ms ").concat(d):void 0},L),{},{pointerEvents:"none",visibility:!this.state.dismissed&&o&&f?"visible":"hidden",position:"absolute",top:0,left:0},C);return mt.createElement("div",{tabIndex:-1,className:I,style:R,ref:function(q){n.wrapperNode=q}},u)}}])}(S.PureComponent),KQt=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},$M={isSsr:KQt()};function I3(t){"@babel/helpers - typeof";return I3=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},I3(t)}function CPe(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 MPe(t){for(var s=1;s0;return mt.createElement(GQt,{allowEscapeViewBox:l,animationDuration:i,animationEasing:d,isAnimationActive:v,active:o,coordinate:p,hasPayload:R,offset:_,position:w,reverseDirection:N,useTranslate3d:C,viewBox:A,wrapperStyle:I},nJt(u,MPe(MPe({},this.props),{},{payload:L})))}}])}(S.PureComponent);Zwe(jg,"displayName","Tooltip");Zwe(jg,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!$M.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 aJt=xy,iJt=function(){return aJt.Date.now()},oJt=iJt,lJt=/\s/;function cJt(t){for(var s=t.length;s--&&lJt.test(t.charAt(s)););return s}var dJt=cJt,uJt=dJt,hJt=/^\s+/;function mJt(t){return t&&t.slice(0,uJt(t)+1).replace(hJt,"")}var pJt=mJt,fJt=pJt,TPe=Q_,gJt=IM,APe=NaN,xJt=/^[-+]0x[0-9a-f]+$/i,yJt=/^0b[01]+$/i,vJt=/^0o[0-7]+$/i,_Jt=parseInt;function bJt(t){if(typeof t=="number")return t;if(gJt(t))return APe;if(TPe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=TPe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=fJt(t);var r=yJt.test(t);return r||vJt.test(t)?_Jt(t.slice(2),r?2:8):xJt.test(t)?APe:+t}var OYe=bJt,wJt=Q_,lpe=oJt,EPe=OYe,jJt="Expected a function",kJt=Math.max,NJt=Math.min;function SJt(t,s,r){var n,a,o,l,i,d,u=0,p=!1,f=!1,v=!0;if(typeof t!="function")throw new TypeError(jJt);s=EPe(s)||0,wJt(r)&&(p=!!r.leading,f="maxWait"in r,o=f?kJt(EPe(r.maxWait)||0,s):o,v="trailing"in r?!!r.trailing:v);function _(R){var $=n,q=a;return n=a=void 0,u=R,l=t.apply(q,$),l}function b(R){return u=R,i=setTimeout(N,s),p?_(R):l}function j(R){var $=R-d,q=R-u,U=s-$;return f?NJt(U,o-q):U}function w(R){var $=R-d,q=R-u;return d===void 0||$>=s||$<0||f&&q>=o}function N(){var R=lpe();if(w(R))return C(R);i=setTimeout(N,j(R))}function C(R){return i=void 0,v&&n?_(R):(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:C(lpe())}function L(){var R=lpe(),$=w(R);if(n=arguments,a=this,d=R,$){if(i===void 0)return b(d);if(f)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 CJt=SJt,MJt=CJt,TJt=Q_,AJt="Expected a function";function EJt(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(AJt);return TJt(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),MJt(t,s,{leading:n,maxWait:s,trailing:a})}var PJt=EJt;const RYe=_o(PJt);function j6(t){"@babel/helpers - typeof";return j6=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},j6(t)}function PPe(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 fR(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&(te=RYe(te,j,{trailing:!0,leading:!1}));var Y=new ResizeObserver(te),de=L.current.getBoundingClientRect(),ie=de.width,ae=de.height;return X(ie,ae),Y.observe(L.current),function(){Y.disconnect()}},[X,j]);var se=S.useMemo(function(){var te=U.containerWidth,Y=U.containerHeight;if(te<0||Y<0)return null;Ug(Ok(l)||Ok(d),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,d),Ug(!r||r>0,"The aspect(%s) must be greater than zero.",r);var de=Ok(l)?te:l,ie=Ok(d)?Y:d;r&&r>0&&(de?ie=de/r:ie&&(de=ie*r),v&&ie>v&&(ie=v)),Ug(de>0||ie>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.`,de,ie,l,d,p,f,r);var ae=!Array.isArray(_)&&B0(_.type).endsWith("Chart");return mt.Children.map(_,function(le){return mt.isValidElement(le)?S.cloneElement(le,fR({width:de,height:ie},ae?{style:fR({height:"100%",width:"100%",maxHeight:ie,maxWidth:de},le.props.style)}:{})):le})},[r,_,d,v,f,p,U,l]);return mt.createElement("div",{id:w?"".concat(w):void 0,className:zi("recharts-responsive-container",N),style:fR(fR({},I),{},{width:l,height:d,minWidth:p,minHeight:f,maxHeight:v}),ref:L},se)}),Jle=function(s){return null};Jle.displayName="Cell";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 LPe(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 zye(t){for(var s=1;s1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||$M.isSsr)return{width:0,height:0};var n=WJt(r),a=JSON.stringify({text:s,copyStyle:n});if(d4.widthCache[a])return d4.widthCache[a];try{var o=document.getElementById(DPe);o||(o=document.createElement("span"),o.setAttribute("id",DPe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=zye(zye({},HJt),n);Object.assign(o.style,l),o.textContent="".concat(s);var i=o.getBoundingClientRect(),d={width:i.width,height:i.height};return d4.widthCache[a]=d,++d4.cacheCount>VJt&&(d4.cacheCount=0,d4.widthCache={}),d}catch{return{width:0,height:0}}},GJt=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 Wae(t,s){return XJt(t)||YJt(t,s)||ZJt(t,s)||KJt()}function KJt(){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 ZJt(t,s){if(t){if(typeof t=="string")return OPe(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 OPe(t,s)}}function OPe(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 ues(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 qPe(t,s){return fes(t)||pes(t,s)||mes(t,s)||hes()}function hes(){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 mes(t,s){if(t){if(typeof t=="string")return UPe(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 UPe(t,s)}}function UPe(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 de.reduce(function(ie,ae){var le=ae.word,pe=ae.width,be=ie[ie.length-1];if(be&&(a==null||o||be.width+pe+nae.width?ie:ae})};if(!p)return _;for(var j="…",w=function(de){var ie=f.slice(0,de),ae=$Ye({breakAll:u,style:d,children:ie+j}).wordsWithComputedWidth,le=v(ae),pe=le.length>l||b(le).width>Number(a);return[pe,le]},N=0,C=f.length-1,A=0,I;N<=C&&A<=f.length-1;){var L=Math.floor((N+C)/2),R=L-1,$=w(R),q=qPe($,2),U=q[0],V=q[1],X=w(L),se=qPe(X,1),te=se[0];if(!U&&!te&&(N=L+1),U&&te&&(C=L-1),!U&&te){I=V;break}A++}return I||_},VPe=function(s){var r=Yi(s)?[]:s.toString().split(BYe);return[{words:r}]},xes=function(s){var r=s.width,n=s.scaleToFit,a=s.children,o=s.style,l=s.breakAll,i=s.maxLines;if((r||n)&&!$M.isSsr){var d,u,p=$Ye({breakAll:l,children:a,style:o});if(p){var f=p.wordsWithComputedWidth,v=p.spaceWidth;d=f,u=v}else return VPe(a);return ges({breakAll:l,children:a,maxLines:i,style:o},d,u,r,n)}return VPe(a)},HPe="#808080",VN=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,p=s.scaleToFit,f=p===void 0?!1:p,v=s.textAnchor,_=v===void 0?"start":v,b=s.verticalAnchor,j=b===void 0?"end":b,w=s.fill,N=w===void 0?HPe:w,C=$Pe(s,ces),A=S.useMemo(function(){return xes({breakAll:C.breakAll,children:C.children,maxLines:C.maxLines,scaleToFit:f,style:C.style,width:C.width})},[C.breakAll,C.children,C.maxLines,f,C.style,C.width]),I=C.dx,L=C.dy,R=C.angle,$=C.className,q=C.breakAll,U=$Pe(C,des);if(!Ud(n)||!Ud(o))return null;var V=n+(tn(I)?I:0),X=o+(tn(L)?L:0),se;switch(j){case"start":se=cpe("calc(".concat(u,")"));break;case"middle":se=cpe("calc(".concat((A.length-1)/2," * -").concat(i," + (").concat(u," / 2))"));break;default:se=cpe("calc(".concat(A.length-1," * -").concat(i,")"));break}var te=[];if(f){var Y=A[0].width,de=C.width;te.push("scale(".concat((tn(de)?de/Y:1)/Y,")"))}return R&&te.push("rotate(".concat(R,", ").concat(V,", ").concat(X,")")),te.length&&(U.transform=te.join(" ")),mt.createElement("text",Bye({},hi(U,!0),{x:V,y:X,className:zi("recharts-text",$),textAnchor:_,fill:N.includes("url")?HPe:N}),A.map(function(ie,ae){var le=ie.words.join(q?"":" ");return mt.createElement("tspan",{x:V,dy:ae===0?se:i,key:"".concat(le,"-").concat(ae)},le)}))};function y_(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function yes(t,s){return t==null||s==null?NaN:st?1:s>=t?0:NaN}function Ywe(t){let s,r,n;t.length!==2?(s=y_,r=(i,d)=>y_(t(i),d),n=(i,d)=>t(i)-d):(s=t===y_||t===yes?t:ves,r=t,n=t);function a(i,d,u=0,p=i.length){if(u>>1;r(i[f],d)<0?u=f+1:p=f}while(u>>1;r(i[f],d)<=0?u=f+1:p=f}while(uu&&n(i[f-1],d)>-n(i[f],d)?f-1:f}return{left:a,center:l,right:o}}function ves(){return 0}function qYe(t){return t===null?NaN:+t}function*_es(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const bes=Ywe(y_),tD=bes.right;Ywe(qYe).center;class WPe extends Map{constructor(s,r=kes){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(GPe(this,s))}has(s){return super.has(GPe(this,s))}set(s,r){return super.set(wes(this,s),r)}delete(s){return super.delete(jes(this,s))}}function GPe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function wes({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function jes({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function kes(t){return t!==null&&typeof t=="object"?t.valueOf():t}function Nes(t=y_){if(t===y_)return UYe;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 UYe(t,s){return(t==null||!(t>=t))-(s==null||!(s>=s))||(ts?1:0)}const Ses=Math.sqrt(50),Ces=Math.sqrt(10),Mes=Math.sqrt(2);function Gae(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>=Ses?10:o>=Ces?5:o>=Mes?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 ZPe(t,s){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function VYe(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?UYe:Nes(a);n>r;){if(n-r>600){const d=n-r+1,u=s-r+1,p=Math.log(d),f=.5*Math.exp(2*p/3),v=.5*Math.sqrt(p*f*(d-f)/d)*(u-d/2<0?-1:1),_=Math.max(r,Math.floor(s-u*f/d+v)),b=Math.min(n,Math.floor(s+(d-u)*f/d+v));VYe(t,s,_,b,a)}const o=t[s];let l=r,i=n;for(cE(t,r,s),a(t[n],o)>0&&cE(t,r,n);l0;)--i}a(t[r],o)===0?cE(t,r,i):(++i,cE(t,i,n)),i<=s&&(r=i+1),s<=i&&(n=i-1)}return t}function cE(t,s,r){const n=t[s];t[s]=t[r],t[r]=n}function Tes(t,s,r){if(t=Float64Array.from(_es(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return ZPe(t);if(s>=1)return KPe(t);var n,a=(n-1)*s,o=Math.floor(a),l=KPe(VYe(t,o).subarray(0,o+1)),i=ZPe(t.subarray(o+1));return l+(i-l)*(a-o)}}function Aes(t,s,r=qYe){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 Ees(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?xR(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?xR(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=Ies.exec(t))?new Sm(s[1],s[2],s[3],1):(s=Les.exec(t))?new Sm(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=Des.exec(t))?xR(s[1],s[2],s[3],s[4]):(s=Oes.exec(t))?xR(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=Res.exec(t))?sIe(s[1],s[2]/100,s[3]/100,1):(s=Fes.exec(t))?sIe(s[1],s[2]/100,s[3]/100,s[4]):YPe.hasOwnProperty(t)?JPe(YPe[t]):t==="transparent"?new Sm(NaN,NaN,NaN,0):null}function JPe(t){return new Sm(t>>16&255,t>>8&255,t&255,1)}function xR(t,s,r,n){return n<=0&&(t=s=r=NaN),new Sm(t,s,r,n)}function $es(t){return t instanceof sD||(t=T6(t)),t?(t=t.rgb(),new Sm(t.r,t.g,t.b,t.opacity)):new Sm}function Hye(t,s,r,n){return arguments.length===1?$es(t):new Sm(t,s,r,n??1)}function Sm(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}Qwe(Sm,Hye,WYe(sD,{brighter(t){return t=t==null?Kae:Math.pow(Kae,t),new Sm(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?C6:Math.pow(C6,t),new Sm(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Sm(vN(this.r),vN(this.g),vN(this.b),Zae(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:eIe,formatHex:eIe,formatHex8:qes,formatRgb:tIe,toString:tIe}));function eIe(){return`#${Rk(this.r)}${Rk(this.g)}${Rk(this.b)}`}function qes(){return`#${Rk(this.r)}${Rk(this.g)}${Rk(this.b)}${Rk((isNaN(this.opacity)?1:this.opacity)*255)}`}function tIe(){const t=Zae(this.opacity);return`${t===1?"rgb(":"rgba("}${vN(this.r)}, ${vN(this.g)}, ${vN(this.b)}${t===1?")":`, ${t})`}`}function Zae(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function vN(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Rk(t){return t=vN(t),(t<16?"0":"")+t.toString(16)}function sIe(t,s,r,n){return n<=0?t=s=r=NaN:r<=0||r>=1?t=s=NaN:s<=0&&(t=NaN),new Tg(t,s,r,n)}function GYe(t){if(t instanceof Tg)return new Tg(t.h,t.s,t.l,t.opacity);if(t instanceof sD||(t=T6(t)),!t)return new Tg;if(t instanceof Tg)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 Tg(l,i,d,t.opacity)}function Ues(t,s,r,n){return arguments.length===1?GYe(t):new Tg(t,s,r,n??1)}function Tg(t,s,r,n){this.h=+t,this.s=+s,this.l=+r,this.opacity=+n}Qwe(Tg,Ues,WYe(sD,{brighter(t){return t=t==null?Kae:Math.pow(Kae,t),new Tg(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?C6:Math.pow(C6,t),new Tg(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 Sm(dpe(t>=240?t-240:t+120,a,n),dpe(t,a,n),dpe(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new Tg(rIe(this.h),yR(this.s),yR(this.l),Zae(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=Zae(this.opacity);return`${t===1?"hsl(":"hsla("}${rIe(this.h)}, ${yR(this.s)*100}%, ${yR(this.l)*100}%${t===1?")":`, ${t})`}`}}));function rIe(t){return t=(t||0)%360,t<0?t+360:t}function yR(t){return Math.max(0,Math.min(1,t||0))}function dpe(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 Jwe=t=>()=>t;function Ves(t,s){return function(r){return t+r*s}}function Hes(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 Wes(t){return(t=+t)==1?KYe:function(s,r){return r-s?Hes(s,r,t):Jwe(isNaN(s)?r:s)}}function KYe(t,s){var r=s-t;return r?Ves(t,r):Jwe(isNaN(t)?s:t)}const nIe=function t(s){var r=Wes(s);function n(a,o){var l=r((a=Hye(a)).r,(o=Hye(o)).r),i=r(a.g,o.g),d=r(a.b,o.b),u=KYe(a.opacity,o.opacity);return function(p){return a.r=l(p),a.g=i(p),a.b=d(p),a.opacity=u(p),a+""}}return n.gamma=t,n}(1);function Ges(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:Yae(n,a)})),r=upe.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function nts(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?ats:nts,d=u=null,f}function f(v){return v==null||isNaN(v=+v)?o:(d||(d=i(t.map(n),s,r)))(n(l(v)))}return f.invert=function(v){return l(a((u||(u=i(s,t.map(n),Yae)))(v)))},f.domain=function(v){return arguments.length?(t=Array.from(v,Xae),p()):t.slice()},f.range=function(v){return arguments.length?(s=Array.from(v),p()):s.slice()},f.rangeRound=function(v){return s=Array.from(v),r=e2e,p()},f.clamp=function(v){return arguments.length?(l=v?!0:Fh,p()):l!==Fh},f.interpolate=function(v){return arguments.length?(r=v,p()):r},f.unknown=function(v){return arguments.length?(o=v,f):o},function(v,_){return n=v,a=_,p()}}function t2e(){return ece()(Fh,Fh)}function its(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Qae(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 L3(t){return t=Qae(Math.abs(t)),t?t[1]:NaN}function ots(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 lts(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var cts=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function A6(t){if(!(s=cts.exec(t)))throw new Error("invalid format: "+t);var s;return new s2e({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]})}A6.prototype=s2e.prototype;function s2e(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+""}s2e.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 dts(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 ZYe;function uts(t,s){var r=Qae(t,s);if(!r)return t+"";var n=r[0],a=r[1],o=a-(ZYe=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")+Qae(t,Math.max(0,s+o-1))[0]}function iIe(t,s){var r=Qae(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 oIe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:its,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)=>iIe(t*100,s),r:iIe,s:uts,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function lIe(t){return t}var cIe=Array.prototype.map,dIe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function hts(t){var s=t.grouping===void 0||t.thousands===void 0?lIe:ots(cIe.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?lIe:lts(cIe.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(f){f=A6(f);var v=f.fill,_=f.align,b=f.sign,j=f.symbol,w=f.zero,N=f.width,C=f.comma,A=f.precision,I=f.trim,L=f.type;L==="n"?(C=!0,L="g"):oIe[L]||(A===void 0&&(A=12),I=!0,L="g"),(w||v==="0"&&_==="=")&&(w=!0,v="0",_="=");var R=j==="$"?r:j==="#"&&/[boxX]/.test(L)?"0"+L.toLowerCase():"",$=j==="$"?n:/[%p]/.test(L)?l:"",q=oIe[L],U=/[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 V(X){var se=R,te=$,Y,de,ie;if(L==="c")te=q(X)+te,X="";else{X=+X;var ae=X<0||1/X<0;if(X=isNaN(X)?d:q(Math.abs(X),A),I&&(X=dts(X)),ae&&+X==0&&b!=="+"&&(ae=!1),se=(ae?b==="("?b:i:b==="-"||b==="("?"":b)+se,te=(L==="s"?dIe[8+ZYe/3]:"")+te+(ae&&b==="("?")":""),U){for(Y=-1,de=X.length;++Yie||ie>57){te=(ie===46?a+X.slice(Y+1):X.slice(Y))+te,X=X.slice(0,Y);break}}}C&&!w&&(X=s(X,1/0));var le=se.length+X.length+te.length,pe=le>1)+se+X+te+pe.slice(le);break;default:X=pe+se+X+te;break}return o(X)}return V.toString=function(){return f+""},V}function p(f,v){var _=u((f=A6(f),f.type="f",f)),b=Math.max(-8,Math.min(8,Math.floor(L3(v)/3)))*3,j=Math.pow(10,-b),w=dIe[8+b/3];return function(N){return _(j*N)+w}}return{format:u,formatPrefix:p}}var vR,r2e,YYe;mts({thousands:",",grouping:[3],currency:["$",""]});function mts(t){return vR=hts(t),r2e=vR.format,YYe=vR.formatPrefix,vR}function pts(t){return Math.max(0,-L3(Math.abs(t)))}function fts(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(L3(s)/3)))*3-L3(Math.abs(t)))}function gts(t,s){return t=Math.abs(t),s=Math.abs(s)-t,Math.max(0,L3(s)-L3(t))+1}function XYe(t,s,r,n){var a=Uye(t,s,r),o;switch(n=A6(n??",f"),n.type){case"s":{var l=Math.max(Math.abs(t),Math.abs(s));return n.precision==null&&!isNaN(o=fts(a,l))&&(n.precision=o),YYe(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=gts(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=pts(a))&&(n.precision=o-(n.type==="%")*2);break}}return r2e(n)}function J_(t){var s=t.domain;return t.ticks=function(r){var n=s();return $ye(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var a=s();return XYe(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,p=10;for(i0;){if(u=qye(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 Jae(){var t=t2e();return t.copy=function(){return rD(t,Jae())},If.apply(t,arguments),J_(t)}function QYe(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,Xae),r):t.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return QYe(t).unknown(s)},t=arguments.length?Array.from(t,Xae):[0,1],J_(r)}function JYe(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 bts(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 mIe(t){return(s,r)=>-t(-s,r)}function n2e(t){const s=t(uIe,hIe),r=s.domain;let n=10,a,o;function l(){return a=bts(n),o=_ts(n),r()[0]<0?(a=mIe(a),o=mIe(o),t(xts,yts)):t(uIe,hIe),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],p=d[d.length-1];const f=p0){for(;v<=_;++v)for(b=1;bp)break;N.push(j)}}else for(;v<=_;++v)for(b=n-1;b>=1;--b)if(j=v>0?b/o(-v):b*o(v),!(jp)break;N.push(j)}N.length*2{if(i==null&&(i=10),d==null&&(d=n===10?"s":","),typeof d!="function"&&(!(n%1)&&(d=A6(d)).precision==null&&(d.trim=!0),d=r2e(d)),i===1/0)return d;const u=Math.max(1,n*i/s.ticks().length);return p=>{let f=p/o(Math.round(a(p)));return f*nr(JYe(r(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),s}function eXe(){const t=n2e(ece()).domain([1,10]);return t.copy=()=>rD(t,eXe()).base(t.base()),If.apply(t,arguments),t}function pIe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function fIe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function a2e(t){var s=1,r=t(pIe(s),fIe(s));return r.constant=function(n){return arguments.length?t(pIe(s=+n),fIe(s)):s},J_(r)}function tXe(){var t=a2e(ece());return t.copy=function(){return rD(t,tXe()).constant(t.constant())},If.apply(t,arguments)}function gIe(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function wts(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function jts(t){return t<0?-t*t:t*t}function i2e(t){var s=t(Fh,Fh),r=1;function n(){return r===1?t(Fh,Fh):r===.5?t(wts,jts):t(gIe(r),gIe(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},J_(s)}function o2e(){var t=i2e(ece());return t.copy=function(){return rD(t,o2e()).exponent(t.exponent())},If.apply(t,arguments),t}function kts(){return o2e.apply(null,arguments).exponent(.5)}function xIe(t){return Math.sign(t)*t*t}function Nts(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function sXe(){var t=t2e(),s=[0,1],r=!1,n;function a(o){var l=Nts(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert(xIe(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,Xae)).map(xIe)),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 sXe(t.domain(),s).round(r).clamp(t.clamp()).unknown(n)},If.apply(a,arguments),J_(a)}function rXe(){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 nXe().domain([t,s]).range(a).unknown(o)},If.apply(J_(l),arguments)}function aXe(){var t=[.5],s=[0,1],r,n=1;function a(o){return o!=null&&o<=o?s[tD(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 aXe().domain(t).range(s).unknown(r)},If.apply(a,arguments)}const hpe=new Date,mpe=new Date;function Xd(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(uXd(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)=>(hpe.setTime(+o),mpe.setTime(+l),t(hpe),t(mpe),Math.floor(r(hpe,mpe))),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 eie=Xd(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);eie.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Xd(s=>{s.setTime(Math.floor(s/t)*t)},(s,r)=>{s.setTime(+s+r*t)},(s,r)=>(r-s)/t):eie);eie.range;const _0=1e3,of=_0*60,b0=of*60,X0=b0*24,l2e=X0*7,yIe=X0*30,ppe=X0*365,Fk=Xd(t=>{t.setTime(t-t.getMilliseconds())},(t,s)=>{t.setTime(+t+s*_0)},(t,s)=>(s-t)/_0,t=>t.getUTCSeconds());Fk.range;const c2e=Xd(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*_0)},(t,s)=>{t.setTime(+t+s*of)},(t,s)=>(s-t)/of,t=>t.getMinutes());c2e.range;const d2e=Xd(t=>{t.setUTCSeconds(0,0)},(t,s)=>{t.setTime(+t+s*of)},(t,s)=>(s-t)/of,t=>t.getUTCMinutes());d2e.range;const u2e=Xd(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*_0-t.getMinutes()*of)},(t,s)=>{t.setTime(+t+s*b0)},(t,s)=>(s-t)/b0,t=>t.getHours());u2e.range;const h2e=Xd(t=>{t.setUTCMinutes(0,0,0)},(t,s)=>{t.setTime(+t+s*b0)},(t,s)=>(s-t)/b0,t=>t.getUTCHours());h2e.range;const nD=Xd(t=>t.setHours(0,0,0,0),(t,s)=>t.setDate(t.getDate()+s),(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*of)/X0,t=>t.getDate()-1);nD.range;const tce=Xd(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/X0,t=>t.getUTCDate()-1);tce.range;const iXe=Xd(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/X0,t=>Math.floor(t/X0));iXe.range;function lS(t){return Xd(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())*of)/l2e)}const sce=lS(0),tie=lS(1),Sts=lS(2),Cts=lS(3),D3=lS(4),Mts=lS(5),Tts=lS(6);sce.range;tie.range;Sts.range;Cts.range;D3.range;Mts.range;Tts.range;function cS(t){return Xd(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)/l2e)}const rce=cS(0),sie=cS(1),Ats=cS(2),Ets=cS(3),O3=cS(4),Pts=cS(5),Its=cS(6);rce.range;sie.range;Ats.range;Ets.range;O3.range;Pts.range;Its.range;const m2e=Xd(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());m2e.range;const p2e=Xd(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());p2e.range;const Q0=Xd(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());Q0.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Xd(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)});Q0.range;const J0=Xd(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());J0.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Xd(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)});J0.range;function oXe(t,s,r,n,a,o){const l=[[Fk,1,_0],[Fk,5,5*_0],[Fk,15,15*_0],[Fk,30,30*_0],[o,1,of],[o,5,5*of],[o,15,15*of],[o,30,30*of],[a,1,b0],[a,3,3*b0],[a,6,6*b0],[a,12,12*b0],[n,1,X0],[n,2,2*X0],[r,1,l2e],[s,1,yIe],[s,3,3*yIe],[t,1,ppe]];function i(u,p,f){const v=pw).right(l,v);if(_===l.length)return t.every(Uye(u/ppe,p/ppe,f));if(_===0)return eie.every(Math.max(Uye(u,p,f),1));const[b,j]=l[v/l[_-1][2]53)return null;"w"in De||(De.w=1),"Z"in De?(he=gpe(dE(De.y,0,1)),Qe=he.getUTCDay(),he=Qe>4||Qe===0?sie.ceil(he):sie(he),he=tce.offset(he,(De.V-1)*7),De.y=he.getUTCFullYear(),De.m=he.getUTCMonth(),De.d=he.getUTCDate()+(De.w+6)%7):(he=fpe(dE(De.y,0,1)),Qe=he.getDay(),he=Qe>4||Qe===0?tie.ceil(he):tie(he),he=nD.offset(he,(De.V-1)*7),De.y=he.getFullYear(),De.m=he.getMonth(),De.d=he.getDate()+(De.w+6)%7)}else("W"in De||"U"in De)&&("w"in De||(De.w="u"in De?De.u%7:"W"in De?1:0),Qe="Z"in De?gpe(dE(De.y,0,1)).getUTCDay():fpe(dE(De.y,0,1)).getDay(),De.m=0,De.d="W"in De?(De.w+6)%7+De.W*7-(Qe+5)%7:De.w+De.U*7-(Qe+6)%7);return"Z"in De?(De.H+=De.Z/100|0,De.M+=De.Z%100,gpe(De)):fpe(De)}}function q(Ae,We,ht,De){for(var Dt=0,he=We.length,Qe=ht.length,ot,rt;Dt=Qe)return-1;if(ot=We.charCodeAt(Dt++),ot===37){if(ot=We.charAt(Dt++),rt=L[ot in vIe?We.charAt(Dt++):ot],!rt||(De=rt(Ae,ht,De))<0)return-1}else if(ot!=ht.charCodeAt(De++))return-1}return De}function U(Ae,We,ht){var De=u.exec(We.slice(ht));return De?(Ae.p=p.get(De[0].toLowerCase()),ht+De[0].length):-1}function V(Ae,We,ht){var De=_.exec(We.slice(ht));return De?(Ae.w=b.get(De[0].toLowerCase()),ht+De[0].length):-1}function X(Ae,We,ht){var De=f.exec(We.slice(ht));return De?(Ae.w=v.get(De[0].toLowerCase()),ht+De[0].length):-1}function se(Ae,We,ht){var De=N.exec(We.slice(ht));return De?(Ae.m=C.get(De[0].toLowerCase()),ht+De[0].length):-1}function te(Ae,We,ht){var De=j.exec(We.slice(ht));return De?(Ae.m=w.get(De[0].toLowerCase()),ht+De[0].length):-1}function Y(Ae,We,ht){return q(Ae,s,We,ht)}function de(Ae,We,ht){return q(Ae,r,We,ht)}function ie(Ae,We,ht){return q(Ae,n,We,ht)}function ae(Ae){return l[Ae.getDay()]}function le(Ae){return o[Ae.getDay()]}function pe(Ae){return d[Ae.getMonth()]}function be(Ae){return i[Ae.getMonth()]}function ye(Ae){return a[+(Ae.getHours()>=12)]}function we(Ae){return 1+~~(Ae.getMonth()/3)}function ke(Ae){return l[Ae.getUTCDay()]}function Ze(Ae){return o[Ae.getUTCDay()]}function _e(Ae){return d[Ae.getUTCMonth()]}function Ce(Ae){return i[Ae.getUTCMonth()]}function Te(Ae){return a[+(Ae.getUTCHours()>=12)]}function Fe(Ae){return 1+~~(Ae.getUTCMonth()/3)}return{format:function(Ae){var We=R(Ae+="",A);return We.toString=function(){return Ae},We},parse:function(Ae){var We=$(Ae+="",!1);return We.toString=function(){return Ae},We},utcFormat:function(Ae){var We=R(Ae+="",I);return We.toString=function(){return Ae},We},utcParse:function(Ae){var We=$(Ae+="",!0);return We.toString=function(){return Ae},We}}}var vIe={"-":"",_:" ",0:"0"},bu=/^\s*\d+/,zts=/^%/,Bts=/[\\^$*+?|[\]().{}]/g;function Do(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function qts(t,s,r){var n=bu.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function Uts(t,s,r){var n=bu.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function Vts(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function Hts(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function Wts(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function _Ie(t,s,r){var n=bu.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function bIe(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function Gts(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 Kts(t,s,r){var n=bu.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function Zts(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function wIe(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Yts(t,s,r){var n=bu.exec(s.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function jIe(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function Xts(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function Qts(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function Jts(t,s,r){var n=bu.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function ess(t,s,r){var n=bu.exec(s.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function tss(t,s,r){var n=zts.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function sss(t,s,r){var n=bu.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function rss(t,s,r){var n=bu.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function kIe(t,s){return Do(t.getDate(),s,2)}function nss(t,s){return Do(t.getHours(),s,2)}function ass(t,s){return Do(t.getHours()%12||12,s,2)}function iss(t,s){return Do(1+nD.count(Q0(t),t),s,3)}function lXe(t,s){return Do(t.getMilliseconds(),s,3)}function oss(t,s){return lXe(t,s)+"000"}function lss(t,s){return Do(t.getMonth()+1,s,2)}function css(t,s){return Do(t.getMinutes(),s,2)}function dss(t,s){return Do(t.getSeconds(),s,2)}function uss(t){var s=t.getDay();return s===0?7:s}function hss(t,s){return Do(sce.count(Q0(t)-1,t),s,2)}function cXe(t){var s=t.getDay();return s>=4||s===0?D3(t):D3.ceil(t)}function mss(t,s){return t=cXe(t),Do(D3.count(Q0(t),t)+(Q0(t).getDay()===4),s,2)}function pss(t){return t.getDay()}function fss(t,s){return Do(tie.count(Q0(t)-1,t),s,2)}function gss(t,s){return Do(t.getFullYear()%100,s,2)}function xss(t,s){return t=cXe(t),Do(t.getFullYear()%100,s,2)}function yss(t,s){return Do(t.getFullYear()%1e4,s,4)}function vss(t,s){var r=t.getDay();return t=r>=4||r===0?D3(t):D3.ceil(t),Do(t.getFullYear()%1e4,s,4)}function _ss(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+Do(s/60|0,"0",2)+Do(s%60,"0",2)}function NIe(t,s){return Do(t.getUTCDate(),s,2)}function bss(t,s){return Do(t.getUTCHours(),s,2)}function wss(t,s){return Do(t.getUTCHours()%12||12,s,2)}function jss(t,s){return Do(1+tce.count(J0(t),t),s,3)}function dXe(t,s){return Do(t.getUTCMilliseconds(),s,3)}function kss(t,s){return dXe(t,s)+"000"}function Nss(t,s){return Do(t.getUTCMonth()+1,s,2)}function Sss(t,s){return Do(t.getUTCMinutes(),s,2)}function Css(t,s){return Do(t.getUTCSeconds(),s,2)}function Mss(t){var s=t.getUTCDay();return s===0?7:s}function Tss(t,s){return Do(rce.count(J0(t)-1,t),s,2)}function uXe(t){var s=t.getUTCDay();return s>=4||s===0?O3(t):O3.ceil(t)}function Ass(t,s){return t=uXe(t),Do(O3.count(J0(t),t)+(J0(t).getUTCDay()===4),s,2)}function Ess(t){return t.getUTCDay()}function Pss(t,s){return Do(sie.count(J0(t)-1,t),s,2)}function Iss(t,s){return Do(t.getUTCFullYear()%100,s,2)}function Lss(t,s){return t=uXe(t),Do(t.getUTCFullYear()%100,s,2)}function Dss(t,s){return Do(t.getUTCFullYear()%1e4,s,4)}function Oss(t,s){var r=t.getUTCDay();return t=r>=4||r===0?O3(t):O3.ceil(t),Do(t.getUTCFullYear()%1e4,s,4)}function Rss(){return"+0000"}function SIe(){return"%"}function CIe(t){return+t}function MIe(t){return Math.floor(+t/1e3)}var u4,hXe,mXe;Fss({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 Fss(t){return u4=Fts(t),hXe=u4.format,u4.parse,mXe=u4.utcFormat,u4.utcParse,u4}function zss(t){return new Date(t)}function Bss(t){return t instanceof Date?+t:+new Date(+t)}function f2e(t,s,r,n,a,o,l,i,d,u){var p=t2e(),f=p.invert,v=p.domain,_=u(".%L"),b=u(":%S"),j=u("%I:%M"),w=u("%I %p"),N=u("%a %d"),C=u("%b %d"),A=u("%B"),I=u("%Y");function L(R){return(d(R)s(a/(t.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,o)=>Tes(t,o/n))},r.copy=function(){return xXe(s).domain(t)},av.apply(r,arguments)}function ace(){var t=0,s=.5,r=1,n=1,a,o,l,i,d,u=Fh,p,f=!1,v;function _(j){return isNaN(j=+j)?v:(j=.5+((j=+p(j))-o)*(n*js}var bXe=Gss,Kss=ice,Zss=bXe,Yss=BM;function Xss(t){return t&&t.length?Kss(t,Yss,Zss):void 0}var Qss=Xss;const oce=_o(Qss);function Jss(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};Xn.decimalPlaces=Xn.dp=function(){var t=this,s=t.d.length-1,r=(s-t.e)*ec;if(s=t.d[s],s)for(;s%10==0;s/=10)r--;return r<0?0:r};Xn.dividedBy=Xn.div=function(t){return $0(this,new this.constructor(t))};Xn.dividedToIntegerBy=Xn.idiv=function(t){var s=this,r=s.constructor;return yl($0(s,new r(t),0,1),r.precision)};Xn.equals=Xn.eq=function(t){return!this.cmp(t)};Xn.exponent=function(){return Md(this)};Xn.greaterThan=Xn.gt=function(t){return this.cmp(t)>0};Xn.greaterThanOrEqualTo=Xn.gte=function(t){return this.cmp(t)>=0};Xn.isInteger=Xn.isint=function(){return this.e>this.d.length-2};Xn.isNegative=Xn.isneg=function(){return this.s<0};Xn.isPositive=Xn.ispos=function(){return this.s>0};Xn.isZero=function(){return this.s===0};Xn.lessThan=Xn.lt=function(t){return this.cmp(t)<0};Xn.lessThanOrEqualTo=Xn.lte=function(t){return this.cmp(t)<1};Xn.logarithm=Xn.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(cp))throw Error(Cf+"NaN");if(r.s<1)throw Error(Cf+(r.s?"NaN":"-Infinity"));return r.eq(cp)?new n(0):(fc=!1,s=$0(E6(r,o),E6(t,o),o),fc=!0,yl(s,a))};Xn.minus=Xn.sub=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?SXe(s,t):kXe(s,(t.s=-t.s,t))};Xn.modulo=Xn.mod=function(t){var s,r=this,n=r.constructor,a=n.precision;if(t=new n(t),!t.s)throw Error(Cf+"NaN");return r.s?(fc=!1,s=$0(r,t,0,1).times(t),fc=!0,r.minus(s)):yl(new n(r),a)};Xn.naturalExponential=Xn.exp=function(){return NXe(this)};Xn.naturalLogarithm=Xn.ln=function(){return E6(this)};Xn.negated=Xn.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Xn.plus=Xn.add=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?kXe(s,t):SXe(s,(t.s=-t.s,t))};Xn.precision=Xn.sd=function(t){var s,r,n,a=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(_N+t);if(s=Md(a)+1,n=a.d.length-1,r=n*ec+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};Xn.squareRoot=Xn.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(Cf+"NaN")}for(t=Md(i),fc=!1,a=Math.sqrt(+i),a==0||a==1/0?(s=$x(i.d),(s.length+t)%2==0&&(s+="0"),a=Math.sqrt(s),t=VM((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($0(i,o,l+2)).times(.5),$x(o.d).slice(0,l)===(s=$x(n.d)).slice(0,l)){if(s=s.slice(l-3,l+1),a==l&&s=="4999"){if(yl(o,r+1,0),o.times(o).eq(i)){n=o;break}}else if(s!="9999")break;l+=4}return fc=!0,yl(n,r)};Xn.times=Xn.mul=function(t){var s,r,n,a,o,l,i,d,u,p=this,f=p.constructor,v=p.d,_=(t=new f(t)).d;if(!p.s||!t.s)return new f(0);for(t.s*=p.s,r=p.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%iu|0,s=i/iu|0;o[a]=(o[a]+s)%iu|0}for(;!o[--l];)o.pop();return s?++r:o.shift(),t.d=o,t.e=r,fc?yl(t,f.precision):t};Xn.toDecimalPlaces=Xn.todp=function(t,s){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(cy(t,0,UM),s===void 0?s=n.rounding:cy(s,0,8),yl(r,t+Md(r)+1,s))};Xn.toExponential=function(t,s){var r,n=this,a=n.constructor;return t===void 0?r=HN(n,!0):(cy(t,0,UM),s===void 0?s=a.rounding:cy(s,0,8),n=yl(new a(n),t+1,s),r=HN(n,!0,t+1)),r};Xn.toFixed=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?HN(a):(cy(t,0,UM),s===void 0?s=o.rounding:cy(s,0,8),n=yl(new o(a),t+Md(a)+1,s),r=HN(n.abs(),!1,t+Md(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};Xn.toInteger=Xn.toint=function(){var t=this,s=t.constructor;return yl(new s(t),Md(t)+1,s.rounding)};Xn.toNumber=function(){return+this};Xn.toPower=Xn.pow=function(t){var s,r,n,a,o,l,i=this,d=i.constructor,u=12,p=+(t=new d(t));if(!t.s)return new d(cp);if(i=new d(i),!i.s){if(t.s<1)throw Error(Cf+"Infinity");return i}if(i.eq(cp))return i;if(n=d.precision,t.eq(cp))return yl(i,n);if(s=t.e,r=t.d.length-1,l=s>=r,o=i.s,l){if((r=p<0?-p:p)<=jXe){for(a=new d(cp),s=Math.ceil(n/ec+4),fc=!1;r%2&&(a=a.times(i),EIe(a.d,s)),r=VM(r/2),r!==0;)i=i.times(i),EIe(i.d,s);return fc=!0,t.s<0?new d(cp).div(a):yl(a,n)}}else if(o<0)throw Error(Cf+"NaN");return o=o<0&&t.d[Math.max(s,r)]&1?-1:1,i.s=1,fc=!1,a=t.times(E6(i,n+u)),fc=!0,a=NXe(a),a.s=o,a};Xn.toPrecision=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?(r=Md(a),n=HN(a,r<=o.toExpNeg||r>=o.toExpPos)):(cy(t,1,UM),s===void 0?s=o.rounding:cy(s,0,8),a=yl(new o(a),t,s),r=Md(a),n=HN(a,t<=r||r<=o.toExpNeg,t)),n};Xn.toSignificantDigits=Xn.tosd=function(t,s){var r=this,n=r.constructor;return t===void 0?(t=n.precision,s=n.rounding):(cy(t,1,UM),s===void 0?s=n.rounding:cy(s,0,8)),yl(new n(r),t,s)};Xn.toString=Xn.valueOf=Xn.val=Xn.toJSON=Xn[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,s=Md(t),r=t.constructor;return HN(t,s<=r.toExpNeg||s>=r.toExpPos)};function kXe(t,s){var r,n,a,o,l,i,d,u,p=t.constructor,f=p.precision;if(!t.s||!s.s)return s.s||(s=new p(t)),fc?yl(s,f):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(f/ec),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)/iu|0,d[o]%=iu;for(r&&(d.unshift(r),++a),i=d.length;d[--i]==0;)d.pop();return s.d=d,s.e=a,fc?yl(s,f):s}function cy(t,s,r){if(t!==~~t||tr)throw Error(_N+t)}function $x(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,p,f,v,_,b,j,w,N,C,A,I,L,R,$,q,U=n.constructor,V=n.s==a.s?1:-1,X=n.d,se=a.d;if(!n.s)return new U(n);if(!a.s)throw Error(Cf+"Division by zero");for(d=n.e-a.e,$=se.length,L=X.length,_=new U(V),b=_.d=[],u=0;se[u]==(X[u]||0);)++u;if(se[u]>(X[u]||0)&&--d,o==null?C=o=U.precision:l?C=o+(Md(n)-Md(a))+1:C=o,C<0)return new U(0);if(C=C/ec+2|0,u=0,$==1)for(p=0,se=se[0],C++;(u1&&(se=t(se,p),X=t(X,p),$=se.length,L=X.length),I=$,j=X.slice(0,$),w=j.length;w<$;)j[w++]=0;q=se.slice(),q.unshift(0),R=se[0],se[1]>=iu/2&&++R;do p=0,i=s(se,j,$,w),i<0?(N=j[0],$!=w&&(N=N*iu+(j[1]||0)),p=N/R|0,p>1?(p>=iu&&(p=iu-1),f=t(se,p),v=f.length,w=j.length,i=s(f,j,v,w),i==1&&(p--,r(f,$16)throw Error(y2e+Md(t));if(!t.s)return new p(cp);for(fc=!1,i=f,l=new p(.03125);t.abs().gte(.1);)t=t.times(l),u+=5;for(n=Math.log(xk(2,u))/Math.LN10*2+5|0,i+=n,r=a=o=new p(cp),p.precision=i;;){if(a=yl(a.times(t),i),r=r.times(++d),l=o.plus($0(a,r,i)),$x(l.d).slice(0,i)===$x(o.d).slice(0,i)){for(;u--;)o=yl(o.times(o),i);return p.precision=f,s==null?(fc=!0,yl(o,f)):o}o=l}}function Md(t){for(var s=t.e*ec,r=t.d[0];r>=10;r/=10)s++;return s}function xpe(t,s,r){if(s>t.LN10.sd())throw fc=!0,r&&(t.precision=r),Error(Cf+"LN10 precision limit exceeded");return yl(new t(t.LN10),s)}function f1(t){for(var s="";t--;)s+="0";return s}function E6(t,s){var r,n,a,o,l,i,d,u,p,f=1,v=10,_=t,b=_.d,j=_.constructor,w=j.precision;if(_.s<1)throw Error(Cf+(_.s?"NaN":"-Infinity"));if(_.eq(cp))return new j(0);if(s==null?(fc=!1,u=w):u=s,_.eq(10))return s==null&&(fc=!0),xpe(j,u);if(u+=v,j.precision=u,r=$x(b),n=r.charAt(0),o=Md(_),Math.abs(o)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)_=_.times(t),r=$x(_.d),n=r.charAt(0),f++;o=Md(_),n>1?(_=new j("0."+r),o++):_=new j(n+"."+r.slice(1))}else return d=xpe(j,u+2,w).times(o+""),_=E6(new j(n+"."+r.slice(1)),u-v).plus(d),j.precision=w,s==null?(fc=!0,yl(_,w)):_;for(i=l=_=$0(_.minus(cp),_.plus(cp),u),p=yl(_.times(_),u),a=3;;){if(l=yl(l.times(p),u),d=i.plus($0(l,new j(a),u)),$x(d.d).slice(0,u)===$x(i.d).slice(0,u))return i=i.times(2),o!==0&&(i=i.plus(xpe(j,u+2,w).times(o+""))),i=$0(i,new j(f),u),j.precision=w,s==null?(fc=!0,yl(i,w)):i;i=d,a+=2}}function AIe(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=VM(r/ec),t.d=[],n=(r+1)%ec,r<0&&(n+=ec),nrie||t.e<-rie))throw Error(y2e+r)}else t.s=0,t.e=0,t.d=[0];return t}function yl(t,s,r){var n,a,o,l,i,d,u,p,f=t.d;for(l=1,o=f[0];o>=10;o/=10)l++;if(n=s-l,n<0)n+=ec,a=s,u=f[p=0];else{if(p=Math.ceil((n+1)/ec),o=f.length,p>=o)return t;for(u=o=f[p],l=1;o>=10;o/=10)l++;n%=ec,a=n-ec+l}if(r!==void 0&&(o=xk(10,l-a-1),i=u/o%10|0,d=s<0||f[p+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/xk(10,l-a):0:f[p-1])%10&1||r==(t.s<0?8:7))),s<1||!f[0])return d?(o=Md(t),f.length=1,s=s-o-1,f[0]=xk(10,(ec-s%ec)%ec),t.e=VM(-s/ec)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(n==0?(f.length=p,o=1,p--):(f.length=p+1,o=xk(10,ec-n),f[p]=a>0?(u/xk(10,l-a)%xk(10,a)|0)*o:0),d)for(;;)if(p==0){(f[0]+=o)==iu&&(f[0]=1,++t.e);break}else{if(f[p]+=o,f[p]!=iu)break;f[p--]=0,o=1}for(n=f.length;f[--n]===0;)f.pop();if(fc&&(t.e>rie||t.e<-rie))throw Error(y2e+Md(t));return t}function SXe(t,s){var r,n,a,o,l,i,d,u,p,f,v=t.constructor,_=v.precision;if(!t.s||!s.s)return s.s?s.s=-s.s:s=new v(t),fc?yl(s,_):s;if(d=t.d,f=s.d,n=s.e,u=t.e,d=d.slice(),l=u-n,l){for(p=l<0,p?(r=d,l=-l,i=f.length):(r=f,n=u,i=d.length),a=Math.max(Math.ceil(_/ec),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=f.length,p=a0;--a)d[i++]=0;for(a=f.length;a>l;){if(d[--a]0?o=o.charAt(0)+"."+o.slice(1)+f1(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+f1(-a-1)+o,r&&(n=r-l)>0&&(o+=f1(n))):a>=l?(o+=f1(a+1-l),r&&(n=r-a-1)>0&&(o=o+"."+f1(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=f1(n))),t.s<0?"-"+o:o}function EIe(t,s){if(t.length>s)return t.length=s,!0}function CXe(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(_N+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 AIe(l,o.toString())}else if(typeof o!="string")throw Error(_N+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,_rs.test(o))AIe(l,o);else throw Error(_N+o)}if(a.prototype=Xn,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=CXe,a.config=a.set=brs,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(_N+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(_N+r+": "+n);return this}var v2e=CXe(vrs);cp=new v2e(1);const ll=v2e;function wrs(t){return Srs(t)||Nrs(t)||krs(t)||jrs()}function jrs(){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 krs(t,s){if(t){if(typeof t=="string")return Kye(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 Kye(t,s)}}function Nrs(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function Srs(t){if(Array.isArray(t))return Kye(t)}function Kye(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,PIe(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 $rs(t){if(Array.isArray(t))return t}function PXe(t){var s=P6(t,2),r=s[0],n=s[1],a=r,o=n;return r>n&&(a=n,o=r),[a,o]}function IXe(t,s,r){if(t.lte(0))return new ll(0);var n=uce.getDigitCount(t.toNumber()),a=new ll(10).pow(n),o=t.div(a),l=n!==1?.05:.1,i=new ll(Math.ceil(o.div(l).toNumber())).add(r).mul(l),d=i.mul(a);return s?d:new ll(Math.ceil(d))}function qrs(t,s,r){var n=1,a=new ll(t);if(!a.isint()&&r){var o=Math.abs(t);o<1?(n=new ll(10).pow(uce.getDigitCount(t)-1),a=new ll(Math.floor(a.div(n).toNumber())).mul(n)):o>1&&(a=new ll(Math.floor(t)))}else t===0?a=new ll(Math.floor((s-1)/2)):r||(a=new ll(Math.floor(t)));var l=Math.floor((s-1)/2),i=Ars(Trs(function(d){return a.add(new ll(d-l).mul(n)).toNumber()}),Zye);return i(0,s)}function LXe(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 ll(0),tickMin:new ll(0),tickMax:new ll(0)};var o=IXe(new ll(s).sub(t).div(r-1),n,a),l;t<=0&&s>=0?l=new ll(0):(l=new ll(t).add(s).div(2),l=l.sub(new ll(l).mod(o)));var i=Math.ceil(l.sub(t).div(o).toNumber()),d=Math.ceil(new ll(s).sub(l).div(o).toNumber()),u=i+d+1;return u>r?LXe(t,s,r,n,a+1):(u0?d+(r-u):d,i=s>0?i:i+(r-u)),{step:o,tickMin:l.sub(new ll(i).mul(o)),tickMax:l.add(new ll(d).mul(o))})}function Urs(t){var s=P6(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=PXe([r,n]),d=P6(i,2),u=d[0],p=d[1];if(u===-1/0||p===1/0){var f=p===1/0?[u].concat(Xye(Zye(0,a-1).map(function(){return 1/0}))):[].concat(Xye(Zye(0,a-1).map(function(){return-1/0})),[p]);return r>n?Yye(f):f}if(u===p)return qrs(u,a,o);var v=LXe(u,p,l,o),_=v.step,b=v.tickMin,j=v.tickMax,w=uce.rangeStep(b,j.add(new ll(.1).mul(_)),_);return r>n?Yye(w):w}function Vrs(t,s){var r=P6(t,2),n=r[0],a=r[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=PXe([n,a]),i=P6(l,2),d=i[0],u=i[1];if(d===-1/0||u===1/0)return[n,a];if(d===u)return[d];var p=Math.max(s,2),f=IXe(new ll(u).sub(d).div(p-1),o,0),v=[].concat(Xye(uce.rangeStep(new ll(d),new ll(u).sub(new ll(.99).mul(f)),f)),[u]);return n>a?Yye(v):v}var Hrs=AXe(Urs),Wrs=AXe(Vrs),Grs="Invariant failed";function WN(t,s){throw new Error(Grs)}var Krs=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function R3(t){"@babel/helpers - typeof";return R3=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},R3(t)}function nie(){return nie=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 tns(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 sns(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function rns(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,f=a[u].coordinate,v=u>=i-1?a[0].coordinate:a[u+1].coordinate,_=void 0;if(Oh(f-p)!==Oh(v-f)){var b=[];if(Oh(v-f)===Oh(d[1]-d[0])){_=v;var j=f+d[1]-d[0];b[0]=Math.min(j,(j+p)/2),b[1]=Math.max(j,(j+p)/2)}else{_=p;var w=v+d[1]-d[0];b[0]=Math.min(f,(w+f)/2),b[1]=Math.max(f,(w+f)/2)}var N=[Math.min(f,(_+f)/2),Math.max(f,(_+f)/2)];if(s>N[0]&&s<=N[1]||s>=b[0]&&s<=b[1]){l=a[u].index;break}}else{var C=Math.min(p,v),A=Math.max(p,v);if(s>(C+f)/2&&s<=(A+f)/2){l=a[u].index;break}}}else for(var I=0;I0&&I(n[I].coordinate+n[I-1].coordinate)/2&&s<=(n[I].coordinate+n[I+1].coordinate)/2||I===i-1&&s>(n[I].coordinate+n[I-1].coordinate)/2){l=n[I].index;break}return l},_2e=function(s){var r,n=s,a=n.type.displayName,o=(r=s.type)!==null&&r!==void 0&&r.defaultProps?zc(zc({},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},_ns=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 C=N[0].type.defaultProps,A=C!==void 0?zc(zc({},C),N[0].props):N[0].props,I=A.barSize,L=A[w];l[L]||(l[L]=[]);var R=Yi(I)?r:I;l[L].push({item:N[0],stackList:N.slice(1),barSize:Yi(R)?void 0:Rh(R,n,0)})}}return l},bns=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=Rh(r,a,0,!0),p,f=[];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 j=(a-b)/2>>0,w={offset:j-u,size:0};p=l.reduce(function(I,L){var R={item:L.item,position:{offset:w.offset+w.size+u,size:v?_:L.barSize}},$=[].concat(DIe(I),[R]);return w=$[$.length-1].position,L.stackList&&L.stackList.length&&L.stackList.forEach(function(q){$.push({item:q,position:w})}),$},f)}else{var N=Rh(n,a,0,!0);a-2*N-(d-1)*u<=0&&(u=0);var C=(a-2*N-(d-1)*u)/d;C>1&&(C>>=0);var A=i===+i?Math.min(C,i):C;p=l.reduce(function(I,L,R){var $=[].concat(DIe(I),[{item:L.item,position:{offset:N+(C+u)*R+(C-A)/2,size:A}}]);return L.stackList&&L.stackList.length&&L.stackList.forEach(function(q){$.push({item:q,position:$[$.length-1].position})}),$},f)}return p},wns=function(s,r,n,a){var o=n.children,l=n.width,i=n.margin,d=l-(i.left||0)-(i.right||0),u=FXe({children:o,legendWidth:d});if(u){var p=a||{},f=p.width,v=p.height,_=u.align,b=u.verticalAlign,j=u.layout;if((j==="vertical"||j==="horizontal"&&b==="middle")&&_!=="center"&&tn(s[_]))return zc(zc({},s),{},B5({},_,s[_]+(f||0)));if((j==="horizontal"||j==="vertical"&&_==="center")&&b!=="middle"&&tn(s[b]))return zc(zc({},s),{},B5({},b,s[b]+(v||0)))}return s},jns=function(s,r,n){return Yi(r)?!0:s==="horizontal"?r==="yAxis":s==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},zXe=function(s,r,n,a,o){var l=r.props.children,i=vf(l,hce).filter(function(u){return jns(a,o,u.props.direction)});if(i&&i.length){var d=i.map(function(u){return u.props.dataKey});return s.reduce(function(u,p){var f=Ju(p,n);if(Yi(f))return u;var v=Array.isArray(f)?[lce(f),oce(f)]:[f,f],_=d.reduce(function(b,j){var w=Ju(p,j,0),N=v[0]-Math.abs(Array.isArray(w)?w[0]:w),C=v[1]+Math.abs(Array.isArray(w)?w[1]:w);return[Math.min(N,b[0]),Math.max(C,b[1])]},[1/0,-1/0]);return[Math.min(_[0],u[0]),Math.max(_[1],u[1])]},[1/0,-1/0])}return null},kns=function(s,r,n,a,o){var l=r.map(function(i){return zXe(s,i,n,o,a)}).filter(function(i){return!Yi(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},BXe=function(s,r,n,a,o){var l=r.map(function(d){var u=d.props.dataKey;return n==="number"&&u&&zXe(s,d,u,a)||gI(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 p=0,f=u.length;p=2?Oh(i[0]-i[1])*2*u:u,r&&(s.ticks||s.niceTicks)){var p=(s.ticks||s.niceTicks).map(function(f){var v=o?o.indexOf(f):f;return{coordinate:a(v)+u,value:f,offset:u}});return p.filter(function(f){return!QL(f.coordinate)})}return s.isCategorical&&s.categoricalDomain?s.categoricalDomain.map(function(f,v){return{coordinate:a(f)+u,value:f,index:v,offset:u}}):a.ticks&&!n?a.ticks(s.tickCount).map(function(f){return{coordinate:a(f)+u,value:f,offset:u}}):a.domain().map(function(f,v){return{coordinate:a(f)+u,value:o?o[f]:f,index:v,offset:u}})},ype=new WeakMap,_R=function(s,r){if(typeof r!="function")return s;ype.has(s)||ype.set(s,new WeakMap);var n=ype.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},UXe=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:S6(),realScaleType:"band"}:l==="radial"&&i==="angleAxis"?{scale:Jae(),realScaleType:"linear"}:o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:fI(),realScaleType:"point"}:o==="category"?{scale:S6(),realScaleType:"band"}:{scale:Jae(),realScaleType:"linear"};if(qN(a)){var d="scale".concat(Wle(a));return{scale:(TIe[d]||fI)(),realScaleType:TIe[d]?d:"point"}}return bi(a)?{scale:a}:{scale:fI(),realScaleType:"point"}},RIe=1e-4,VXe=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])-RIe,l=Math.max(a[0],a[1])+RIe,i=s(r[0]),d=s(r[n-1]);(il||dl)&&s.domain([r[0],r[n-1]])}},Nns=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])}},Mns=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)}},Tns={sign:Cns,expand:KVt,none:T3,silhouette:ZVt,wiggle:YVt,positive:Mns},Ans=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=Tns[n],l=GVt().keys(a).value(function(i,d){return+Ju(i,d,0)}).order(kye).offset(o);return l(s)},Ens=function(s,r,n,a,o,l){if(!s)return null;var i=l?r.reverse():r,d={},u=i.reduce(function(f,v){var _,b=(_=v.type)!==null&&_!==void 0&&_.defaultProps?zc(zc({},v.type.defaultProps),v.props):v.props,j=b.stackId,w=b.hide;if(w)return f;var N=b[n],C=f[N]||{hasStack:!1,stackGroups:{}};if(Ud(j)){var A=C.stackGroups[j]||{numericAxisId:n,cateAxisId:a,items:[]};A.items.push(v),C.hasStack=!0,C.stackGroups[j]=A}else C.stackGroups[JL("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[v]};return zc(zc({},f),{},B5({},N,C))},d),p={};return Object.keys(u).reduce(function(f,v){var _=u[v];if(_.hasStack){var b={};_.stackGroups=Object.keys(_.stackGroups).reduce(function(j,w){var N=_.stackGroups[w];return zc(zc({},j),{},B5({},w,{numericAxisId:n,cateAxisId:a,items:N.items,stackedData:Ans(s,N.items,o)}))},b)}return zc(zc({},f),{},B5({},v,_))},p)},HXe=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 p=Hrs(u,o,i);return s.domain([lce(p),oce(p)]),{niceTicks:p}}if(o&&a==="number"){var f=s.domain(),v=Wrs(f,o,i);return{niceTicks:v}}return null},FIe=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=Ju(l,r.dataKey,r.domain[i]);return Yi(d)?null:r.scale(d)-o/2+a},Pns=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]},Ins=function(s,r){var n,a=(n=s.type)!==null&&n!==void 0&&n.defaultProps?zc(zc({},s.type.defaultProps),s.props):s.props,o=a.stackId;if(Ud(o)){var l=r[o];if(l){var i=l.items.indexOf(s);return i>=0?l.stackedData[i]:null}}return null},Lns=function(s){return s.reduce(function(r,n){return[lce(n.concat([r[0]]).filter(tn)),oce(n.concat([r[1]]).filter(tn))]},[1/0,-1/0])},WXe=function(s,r,n){return Object.keys(s).reduce(function(a,o){var l=s[o],i=l.stackedData,d=i.reduce(function(u,p){var f=Lns(p.slice(r,n+1));return[Math.min(u[0],f[0]),Math.max(u[1],f[1])]},[1/0,-1/0]);return[Math.min(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})},zIe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,BIe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,t0e=function(s,r,n){if(bi(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(tn(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(zIe.test(s[0])){var o=+zIe.exec(s[0])[1];a[0]=r[0]-o}else bi(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(tn(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(BIe.test(s[1])){var l=+BIe.exec(s[1])[1];a[1]=r[1]+l}else bi(s[1])?a[1]=s[1](r[1]):a[1]=r[1];return a},iie=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=Kwe(r,function(f){return f.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},Uns=function(s,r,n,a,o){var l=s.width,i=s.height,d=s.startAngle,u=s.endAngle,p=Rh(s.cx,l,l/2),f=Rh(s.cy,i,i/2),v=ZXe(l,i,n),_=Rh(s.innerRadius,v,0),b=Rh(s.outerRadius,v,v*.8),j=Object.keys(r);return j.reduce(function(w,N){var C=r[N],A=C.domain,I=C.reversed,L;if(Yi(C.range))a==="angleAxis"?L=[d,u]:a==="radiusAxis"&&(L=[_,b]),I&&(L=[L[1],L[0]]);else{L=C.range;var R=L,$=Rns(R,2);d=$[0],u=$[1]}var q=UXe(C,o),U=q.realScaleType,V=q.scale;V.domain(A).range(L),VXe(V);var X=HXe(V,n0(n0({},C),{},{realScaleType:U})),se=n0(n0(n0({},C),X),{},{range:L,radius:b,realScaleType:U,scale:V,cx:p,cy:f,innerRadius:_,outerRadius:b,startAngle:d,endAngle:u});return n0(n0({},w),{},KXe({},N,se))},{})},Vns=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))},Hns=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=Vns({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:qns(u),angleInRadian:u}},Wns=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}},Gns=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},VIe=function(s,r){var n=s.x,a=s.y,o=Hns({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 p=Wns(r),f=p.startAngle,v=p.endAngle,_=i,b;if(f<=v){for(;_>v;)_-=360;for(;_=f&&_<=v}else{for(;_>f;)_-=360;for(;_=v&&_<=f}return b?n0(n0({},r),{},{radius:l,angle:Gns(_,r)}):null},YXe=function(s){return!S.isValidElement(s)&&!bi(s)&&typeof s!="boolean"?s.className:""};function O6(t){"@babel/helpers - typeof";return O6=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},O6(t)}var Kns=["offset"];function Zns(t){return Jns(t)||Qns(t)||Xns(t)||Yns()}function Yns(){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 Xns(t,s){if(t){if(typeof t=="string")return s0e(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 s0e(t,s)}}function Qns(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Jns(t){if(Array.isArray(t))return s0e(t)}function s0e(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 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 HIe(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 Ld(t){for(var s=1;s=0?1:-1,A,I;a==="insideStart"?(A=_+C*l,I=j):a==="insideEnd"?(A=b-C*l,I=!j):a==="end"&&(A=b+C*l,I=j),I=N<=0?I:!I;var L=Fl(u,p,w,A),R=Fl(u,p,w,A+(I?1:-1)*359),$="M".concat(L.x,",").concat(L.y,` A`).concat(w,",").concat(w,",0,1,").concat(I?0:1,`, `).concat(R.x,",").concat(R.y),q=Yi(s.id)?JL("recharts-radial-line-"):s.id;return mt.createElement("text",R6({},n,{dominantBaseline:"central",className:zi("recharts-radial-bar-label",i)}),mt.createElement("defs",null,mt.createElement("path",{id:q,d:$})),mt.createElement("textPath",{xlinkHref:"#".concat(q)},r))},las=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,p=o.startAngle,f=o.endAngle,v=(p+f)/2;if(a==="outside"){var _=Fl(l,i,u+n,v),b=_.x,j=_.y;return{x:b,y:j,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 w=(d+u)/2,N=Fl(l,i,w,v),C=N.x,A=N.y;return{x:C,y:A,textAnchor:"middle",verticalAnchor:"middle"}},cas=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,p=l.height,f=p>=0?1:-1,v=f*a,_=f>0?"end":"start",b=f>0?"start":"end",j=u>=0?1:-1,w=j*a,N=j>0?"end":"start",C=j>0?"start":"end";if(o==="top"){var A={x:i+u/2,y:d-f*a,textAnchor:"middle",verticalAnchor:_};return Ld(Ld({},A),n?{height:Math.max(d-n.y,0),width:u}:{})}if(o==="bottom"){var I={x:i+u/2,y:d+p+v,textAnchor:"middle",verticalAnchor:b};return Ld(Ld({},I),n?{height:Math.max(n.y+n.height-(d+p),0),width:u}:{})}if(o==="left"){var L={x:i-w,y:d+p/2,textAnchor:N,verticalAnchor:"middle"};return Ld(Ld({},L),n?{width:Math.max(L.x-n.x,0),height:p}:{})}if(o==="right"){var R={x:i+u+w,y:d+p/2,textAnchor:C,verticalAnchor:"middle"};return Ld(Ld({},R),n?{width:Math.max(n.x+n.width-R.x,0),height:p}:{})}var $=n?{width:u,height:p}:{};return o==="insideLeft"?Ld({x:i+w,y:d+p/2,textAnchor:C,verticalAnchor:"middle"},$):o==="insideRight"?Ld({x:i+u-w,y:d+p/2,textAnchor:N,verticalAnchor:"middle"},$):o==="insideTop"?Ld({x:i+u/2,y:d+v,textAnchor:"middle",verticalAnchor:b},$):o==="insideBottom"?Ld({x:i+u/2,y:d+p-v,textAnchor:"middle",verticalAnchor:_},$):o==="insideTopLeft"?Ld({x:i+w,y:d+v,textAnchor:C,verticalAnchor:b},$):o==="insideTopRight"?Ld({x:i+u-w,y:d+v,textAnchor:N,verticalAnchor:b},$):o==="insideBottomLeft"?Ld({x:i+w,y:d+p-v,textAnchor:C,verticalAnchor:_},$):o==="insideBottomRight"?Ld({x:i+u-w,y:d+p-v,textAnchor:N,verticalAnchor:_},$):LM(o)&&(tn(o.x)||Ok(o.x))&&(tn(o.y)||Ok(o.y))?Ld({x:i+Rh(o.x,u),y:d+Rh(o.y,p),textAnchor:"end",verticalAnchor:"end"},$):Ld({x:i+u/2,y:d+p/2,textAnchor:"middle",verticalAnchor:"middle"},$)},das=function(s){return"cx"in s&&tn(s.cx)};function uu(t){var s=t.offset,r=s===void 0?5:s,n=eas(t,Kns),a=Ld({offset:r},n),o=a.viewBox,l=a.position,i=a.value,d=a.children,u=a.content,p=a.className,f=p===void 0?"":p,v=a.textBreakAll;if(!o||Yi(i)&&Yi(d)&&!S.isValidElement(u)&&!bi(u))return null;if(S.isValidElement(u))return S.cloneElement(u,a);var _;if(bi(u)){if(_=S.createElement(u,a),S.isValidElement(_))return _}else _=aas(a);var b=das(o),j=hi(a,!0);if(b&&(l==="insideStart"||l==="insideEnd"||l==="end"))return oas(a,_,j);var w=b?las(a):cas(a);return mt.createElement(VN,R6({className:zi("recharts-label",f)},j,w,{breakAll:v}),_)}uu.displayName="Label";var XXe=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,p=s.outerRadius,f=s.x,v=s.y,_=s.top,b=s.left,j=s.width,w=s.height,N=s.clockWise,C=s.labelViewBox;if(C)return C;if(tn(j)&&tn(w)){if(tn(f)&&tn(v))return{x:f,y:v,width:j,height:w};if(tn(_)&&tn(b))return{x:_,y:b,width:j,height:w}}return tn(f)&&tn(v)?{x:f,y:v,width:0,height:0}:tn(r)&&tn(n)?{cx:r,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:u||0,outerRadius:p||d||i||0,clockWise:N}:s.viewBox?s.viewBox:{}},uas=function(s,r){return s?s===!0?mt.createElement(uu,{key:"label-implicit",viewBox:r}):Ud(s)?mt.createElement(uu,{key:"label-implicit",viewBox:r,value:s}):S.isValidElement(s)?s.type===uu?S.cloneElement(s,{key:"label-implicit",viewBox:r}):mt.createElement(uu,{key:"label-implicit",content:s,viewBox:r}):bi(s)?mt.createElement(uu,{key:"label-implicit",content:s,viewBox:r}):LM(s)?mt.createElement(uu,R6({viewBox:r},s,{key:"label-implicit"})):null:null},has=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=XXe(s),l=vf(a,uu).map(function(d,u){return S.cloneElement(d,{viewBox:r||o,key:"label-".concat(u)})});if(!n)return l;var i=uas(s.label,r||o);return[i].concat(Zns(l))};uu.parseViewBox=XXe;uu.renderCallByParent=has;function mas(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var pas=mas;const fas=_o(pas);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 gas=["valueAccessor"],xas=["data","dataKey","clockWise","id","textBreakAll"];function yas(t){return was(t)||bas(t)||_as(t)||vas()}function vas(){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 _as(t,s){if(t){if(typeof t=="string")return r0e(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 r0e(t,s)}}function bas(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function was(t){if(Array.isArray(t))return r0e(t)}function r0e(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 Sas(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 Cas=function(s){return Array.isArray(s.value)?fas(s.value):s.value};function v_(t){var s=t.valueAccessor,r=s===void 0?Cas:s,n=KIe(t,gas),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,d=n.textBreakAll,u=KIe(n,xas);return!a||!a.length?null:mt.createElement(tl,{className:"recharts-label-list"},a.map(function(p,f){var v=Yi(o)?r(p,f):Ju(p&&p.payload,o),_=Yi(i)?{}:{id:"".concat(i,"-").concat(f)};return mt.createElement(uu,lie({},hi(p,!0),u,_,{parentViewBox:p.parentViewBox,value:v,textBreakAll:d,viewBox:uu.parseViewBox(Yi(l)?p:GIe(GIe({},p),{},{clockWise:l})),key:"label-".concat(f),index:f}))}))}v_.displayName="LabelList";function Mas(t,s){return t?t===!0?mt.createElement(v_,{key:"labelList-implicit",data:s}):mt.isValidElement(t)||bi(t)?mt.createElement(v_,{key:"labelList-implicit",data:s,content:t}):LM(t)?mt.createElement(v_,lie({data:s},t,{key:"labelList-implicit"})):null:null}function Tas(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=vf(n,v_).map(function(l,i){return S.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=Mas(t.label,s);return[o].concat(yas(a))}v_.renderCallByParent=Tas;function z6(t){"@babel/helpers - typeof";return z6=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},z6(t)}function n0e(){return n0e=Object.assign?Object.assign.bind():function(t){for(var s=1;s180),",").concat(+(l>u),`, `).concat(f.x,",").concat(f.y,` `);if(a>0){var _=Fl(r,n,a,l),b=Fl(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},Las=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,p=s.endAngle,f=Oh(p-u),v=bR({cx:r,cy:n,radius:o,angle:u,sign:f,cornerRadius:l,cornerIsExternal:d}),_=v.circleTangency,b=v.lineTangency,j=v.theta,w=bR({cx:r,cy:n,radius:o,angle:p,sign:-f,cornerRadius:l,cornerIsExternal:d}),N=w.circleTangency,C=w.lineTangency,A=w.theta,I=d?Math.abs(u-p):Math.abs(u-p)-j-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 `):QXe({cx:r,cy:n,innerRadius:a,outerRadius:o,startAngle:u,endAngle:p});var L="M ".concat(b.x,",").concat(b.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(_.x,",").concat(_.y,` A`).concat(o,",").concat(o,",0,").concat(+(I>180),",").concat(+(f<0),",").concat(N.x,",").concat(N.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(C.x,",").concat(C.y,` `);if(a>0){var R=bR({cx:r,cy:n,radius:a,angle:u,sign:f,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),$=R.circleTangency,q=R.lineTangency,U=R.theta,V=bR({cx:r,cy:n,radius:a,angle:p,sign:-f,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),X=V.circleTangency,se=V.lineTangency,te=V.theta,Y=d?Math.abs(u-p):Math.abs(u-p)-U-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(+(f<0),",").concat(X.x,",").concat(X.y,` A`).concat(a,",").concat(a,",0,").concat(+(Y>180),",").concat(+(f>0),",").concat($.x,",").concat($.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(q.x,",").concat(q.y,"Z")}else L+="L".concat(r,",").concat(n,"Z");return L},Das={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},JXe=function(s){var r=YIe(YIe({},Das),s),n=r.cx,a=r.cy,o=r.innerRadius,l=r.outerRadius,i=r.cornerRadius,d=r.forceCornerRadius,u=r.cornerIsExternal,p=r.startAngle,f=r.endAngle,v=r.className;if(l0&&Math.abs(p-f)<360?w=Las({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(j,b/2),forceCornerRadius:d,cornerIsExternal:u,startAngle:p,endAngle:f}):w=QXe({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:p,endAngle:f}),mt.createElement("path",n0e({},hi(r,!0),{className:_,d:w,role:"img"}))};function B6(t){"@babel/helpers - typeof";return B6=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},B6(t)}function a0e(){return a0e=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 eis(t,s){return dS(t.getTime(),s.getTime())}function tis(t,s){return t.name===s.name&&t.message===s.message&&t.cause===s.cause&&t.stack===s.stack}function sis(t,s){return t===s}function n6e(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(),p=!1,f=0;(i=u.next())&&!i.done;){if(a[f]){f++;continue}var v=l.value,_=i.value;if(r.equals(v[0],_[0],d,f,t,s,r)&&r.equals(v[1],_[1],v[0],_[0],t,s,r)){p=a[f]=!0;break}f++}if(!p)return!1;d++}return!0}var ris=dS;function nis(t,s,r){var n=r6e(t),a=n.length;if(r6e(s).length!==a)return!1;for(;a-- >0;)if(!rQe(t,s,r,n[a]))return!1;return!0}function fE(t,s,r){var n=t6e(t),a=n.length;if(t6e(s).length!==a)return!1;for(var o,l,i;a-- >0;)if(o=n[a],!rQe(t,s,r,o)||(l=s6e(t,o),i=s6e(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function ais(t,s){return dS(t.valueOf(),s.valueOf())}function iis(t,s){return t.source===s.source&&t.flags===s.flags}function a6e(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,p=0;(i=d.next())&&!i.done;){if(!a[p]&&r.equals(l.value,i.value,l.value,i.value,t,s,r)){u=a[p]=!0;break}p++}if(!u)return!1}return!0}function ois(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 lis(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 rQe(t,s,r,n){return(n===Qas||n===Xas||n===Yas)&&(t.$$typeof||s.$$typeof)?!0:Zas(s,n)&&r.equals(t[n],s[n],n,n,t,s,r)}var cis="[object Arguments]",dis="[object Boolean]",uis="[object Date]",his="[object Error]",mis="[object Map]",pis="[object Number]",fis="[object Object]",gis="[object RegExp]",xis="[object Set]",yis="[object String]",vis="[object URL]",_is=Array.isArray,i6e=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,o6e=Object.assign,bis=Object.prototype.toString.call.bind(Object.prototype.toString);function wis(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,p=t.areSetsEqual,f=t.areTypedArraysEqual,v=t.areUrlsEqual;return function(b,j,w){if(b===j)return!0;if(b==null||j==null)return!1;var N=typeof b;if(N!==typeof j)return!1;if(N!=="object")return N==="number"?l(b,j,w):N==="function"?a(b,j,w):!1;var C=b.constructor;if(C!==j.constructor)return!1;if(C===Object)return i(b,j,w);if(_is(b))return s(b,j,w);if(i6e!=null&&i6e(b))return f(b,j,w);if(C===Date)return r(b,j,w);if(C===RegExp)return u(b,j,w);if(C===Map)return o(b,j,w);if(C===Set)return p(b,j,w);var A=bis(b);return A===uis?r(b,j,w):A===gis?u(b,j,w):A===mis?o(b,j,w):A===xis?p(b,j,w):A===fis?typeof b.then!="function"&&typeof j.then!="function"&&i(b,j,w):A===vis?v(b,j,w):A===his?n(b,j,w):A===cis?i(b,j,w):A===dis||A===pis||A===yis?d(b,j,w):!1}}function jis(t){var s=t.circular,r=t.createCustomConfig,n=t.strict,a={areArraysEqual:n?fE:Jas,areDatesEqual:eis,areErrorsEqual:tis,areFunctionsEqual:sis,areMapsEqual:n?e6e(n6e,fE):n6e,areNumbersEqual:ris,areObjectsEqual:n?fE:nis,arePrimitiveWrappersEqual:ais,areRegExpsEqual:iis,areSetsEqual:n?e6e(a6e,fE):a6e,areTypedArraysEqual:n?fE:ois,areUrlsEqual:lis};if(r&&(a=o6e({},a,r(a))),s){var o=jR(a.areArraysEqual),l=jR(a.areMapsEqual),i=jR(a.areObjectsEqual),d=jR(a.areSetsEqual);a=o6e({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:d})}return a}function kis(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function Nis(t){var s=t.circular,r=t.comparator,n=t.createState,a=t.equals,o=t.strict;if(n)return function(d,u){var p=n(),f=p.cache,v=f===void 0?s?new WeakMap:void 0:f,_=p.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 Sis=tb();tb({strict:!0});tb({circular:!0});tb({circular:!0,strict:!0});tb({createInternalComparator:function(){return dS}});tb({strict:!0,createInternalComparator:function(){return dS}});tb({circular:!0,createInternalComparator:function(){return dS}});tb({circular:!0,createInternalComparator:function(){return dS},strict:!0});function tb(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=jis(t),d=wis(i),u=n?n(d):kis(d);return Nis({circular:r,comparator:d,createState:a,equals:u,strict:l})}function Cis(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function l6e(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):Cis(a)};requestAnimationFrame(n)}function o0e(t){"@babel/helpers - typeof";return o0e=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},o0e(t)}function Mis(t){return Pis(t)||Eis(t)||Ais(t)||Tis()}function Tis(){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 Ais(t,s){if(t){if(typeof t=="string")return c6e(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 c6e(t,s)}}function c6e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r1?1:N<0?0:N},j=function(N){for(var C=N>1?1:N,A=C,I=0;I<8;++I){var L=f(A)-C,R=_(A);if(Math.abs(L-C)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(p,f,v){var _=-(p-f)*n,b=v*o,j=v+(_-b)*i/1e3,w=v*i/1e3+p;return Math.abs(w-f)t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function cos(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 vpe(t){return mos(t)||hos(t)||uos(t)||dos()}function dos(){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 uos(t,s){if(t){if(typeof t=="string")return h0e(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 h0e(t,s)}}function hos(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function mos(t){if(Array.isArray(t))return h0e(t)}function h0e(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 uie(t){return uie=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},uie(t)}var ev=function(t){yos(r,t);var s=vos(r);function r(n,a){var o;pos(this,r),o=s.call(this,n,a);var l=o.props,i=l.isActive,d=l.attributeName,u=l.from,p=l.to,f=l.steps,v=l.children,_=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(f0e(o)),o.changeStyle=o.changeStyle.bind(f0e(o)),!i||_<=0)return o.state={style:{}},typeof v=="function"&&(o.state={style:p}),p0e(o);if(f&&f.length)o.state={style:f[0].style};else if(u){if(typeof v=="function")return o.state={style:u},p0e(o);o.state={style:d?DE({},d,u):u}}else o.state={style:{}};return o}return gos(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,p=o.to,f=o.from,v=this.state.style;if(i){if(!l){var _={style:d?DE({},d,p):p};this.state&&v&&(d&&v[d]!==p||!d&&v!==p)&&this.setState(_);return}if(!(Sis(a.to,p)&&a.canBegin&&a.isActive)){var b=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var j=b||u?f:a.to;if(this.state&&v){var w={style:d?DE({},d,j):j};(d&&v[d]!==j||!d&&v!==j)&&this.setState(w)}this.runAnimation(dg(dg({},this.props),{},{from:j,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var o=this,l=a.from,i=a.to,d=a.duration,u=a.easing,p=a.begin,f=a.onAnimationEnd,v=a.onAnimationStart,_=ios(l,i,Zis(u),d,this.changeStyle),b=function(){o.stopJSAnimation=_()};this.manager.start([v,p,b,d,f])}},{key:"runStepAnimation",value:function(a){var o=this,l=a.steps,i=a.begin,d=a.onAnimationStart,u=l[0],p=u.style,f=u.duration,v=f===void 0?0:f,_=function(j,w,N){if(N===0)return j;var C=w.duration,A=w.easing,I=A===void 0?"ease":A,L=w.style,R=w.properties,$=w.onAnimationEnd,q=N>0?l[N-1]:w,U=R||Object.keys(L);if(typeof I=="function"||I==="spring")return[].concat(vpe(j),[o.runJSAnimation.bind(o,{from:q.style,to:L,duration:C,easing:I}),C]);var V=h6e(U,C,I),X=dg(dg(dg({},q.style),L),{},{transition:V});return[].concat(vpe(j),[X,C,$]).filter(Ris)};return this.manager.start([d].concat(vpe(l.reduce(_,[p,Math.max(v,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=Iis());var o=a.begin,l=a.duration,i=a.attributeName,d=a.to,u=a.easing,p=a.onAnimationStart,f=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 j=i?DE({},i,d):d,w=h6e(Object.keys(j),l,u);b.start([p,o,dg(dg({},j),{},{transition:w}),l,f])}},{key:"render",value:function(){var a=this.props,o=a.children;a.begin;var l=a.duration;a.attributeName,a.easing;var i=a.isActive;a.steps,a.from,a.to,a.canBegin,a.onAnimationEnd,a.shouldReAnimate,a.onAnimationReStart;var d=los(a,oos),u=S.Children.count(o),p=this.state.style;if(typeof o=="function")return o(p);if(!i||u===0||l<=0)return o;var f=function(_){var b=_.props,j=b.style,w=j===void 0?{}:j,N=b.className,C=S.cloneElement(_,dg(dg({},d),{},{style:dg(dg({},w),p),className:N}));return C};return u===1?f(S.Children.only(o)):mt.createElement("div",null,S.Children.map(o,function(v){return f(v)}))}}]),r}(S.PureComponent);ev.displayName="Animate";ev.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};ev.propTypes={from:qo.oneOfType([qo.object,qo.string]),to:qo.oneOfType([qo.object,qo.string]),attributeName:qo.string,duration:qo.number,begin:qo.number,easing:qo.oneOfType([qo.string,qo.func]),steps:qo.arrayOf(qo.shape({duration:qo.number.isRequired,style:qo.object.isRequired,easing:qo.oneOfType([qo.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),qo.func]),properties:qo.arrayOf("string"),onAnimationEnd:qo.func})),children:qo.oneOfType([qo.node,qo.func]),isActive:qo.bool,canBegin:qo.bool,onAnimationEnd:qo.func,shouldReAnimate:qo.bool,onAnimationStart:qo.func,onAnimationReStart:qo.func};function U6(t){"@babel/helpers - typeof";return U6=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},U6(t)}function hie(){return hie=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,p;if(l>0&&o instanceof Array){for(var f=[0,0,0,0],v=0,_=4;v<_;v++)f[v]=o[v]>l?l:o[v];p="M".concat(s,",").concat(r+i*f[0]),f[0]>0&&(p+="A ".concat(f[0],",").concat(f[0],",0,0,").concat(u,",").concat(s+d*f[0],",").concat(r)),p+="L ".concat(s+n-d*f[1],",").concat(r),f[1]>0&&(p+="A ".concat(f[1],",").concat(f[1],",0,0,").concat(u,`, `).concat(s+n,",").concat(r+i*f[1])),p+="L ".concat(s+n,",").concat(r+a-i*f[2]),f[2]>0&&(p+="A ".concat(f[2],",").concat(f[2],",0,0,").concat(u,`, `).concat(s+n-d*f[2],",").concat(r+a)),p+="L ".concat(s+d*f[3],",").concat(r+a),f[3]>0&&(p+="A ".concat(f[3],",").concat(f[3],",0,0,").concat(u,`, `).concat(s,",").concat(r+a-i*f[3])),p+="Z"}else if(l>0&&o===+o&&o>0){var b=Math.min(l,o);p="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 p="M ".concat(s,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return p},Tos=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),p=Math.max(o,o+i),f=Math.min(l,l+d),v=Math.max(l,l+d);return n>=u&&n<=p&&a>=f&&a<=v}return!1},Aos={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},b2e=function(s){var r=_6e(_6e({},Aos),s),n=S.useRef(),a=S.useState(-1),o=bos(a,2),l=o[0],i=o[1];S.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,p=r.width,f=r.height,v=r.radius,_=r.className,b=r.animationEasing,j=r.animationDuration,w=r.animationBegin,N=r.isAnimationActive,C=r.isUpdateAnimationActive;if(d!==+d||u!==+u||p!==+p||f!==+f||p===0||f===0)return null;var A=zi("recharts-rectangle",_);return C?mt.createElement(ev,{canBegin:l>0,from:{width:p,height:f,x:d,y:u},to:{width:p,height:f,x:d,y:u},duration:j,animationEasing:b,isActive:C},function(I){var L=I.width,R=I.height,$=I.x,q=I.y;return mt.createElement(ev,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:j,isActive:N,easing:b},mt.createElement("path",hie({},hi(r,!0),{className:A,d:b6e($,q,L,R,v),ref:n})))}):mt.createElement("path",hie({},hi(r,!0),{className:A,d:b6e(d,u,p,f,v)}))},Eos=["points","className","baseLinePoints","connectNulls"];function V4(){return V4=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 Ios(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 w6e(t){return Ros(t)||Oos(t)||Dos(t)||Los()}function Los(){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 Dos(t,s){if(t){if(typeof t=="string")return g0e(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 g0e(t,s)}}function Oos(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Ros(t){if(Array.isArray(t))return g0e(t)}function g0e(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){j6e(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),j6e(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},yI=function(s,r){var n=Fos(s);r&&(n=[n.reduce(function(o,l){return[].concat(w6e(o),w6e(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},zos=function(s,r,n){var a=yI(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(yI(r.reverse(),n).slice(1))},Bos=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=Pos(s,Eos);if(!r||!r.length)return null;var i=zi("recharts-polygon",n);if(a&&a.length){var d=l.stroke&&l.stroke!=="none",u=zos(r,a,o);return mt.createElement("g",{className:i},mt.createElement("path",V4({},hi(l,!0),{fill:u.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:u})),d?mt.createElement("path",V4({},hi(l,!0),{fill:"none",d:yI(r,o)})):null,d?mt.createElement("path",V4({},hi(l,!0),{fill:"none",d:yI(a,o)})):null)}var p=yI(r,o);return mt.createElement("path",V4({},hi(l,!0),{fill:p.slice(-1)==="Z"?l.fill:"none",className:i,d:p}))};function x0e(){return x0e=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 Gos(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 Kos=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},Zos=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,p=s.width,f=p===void 0?0:p,v=s.height,_=v===void 0?0:v,b=s.className,j=Wos(s,$os),w=qos({x:n,y:o,top:i,left:u,width:f,height:_},j);return!tn(n)||!tn(o)||!tn(f)||!tn(_)||!tn(i)||!tn(u)?null:mt.createElement("path",y0e({},hi(w,!0),{className:zi("recharts-cross",b),d:Kos(n,o,f,_,i,u)}))},Yos=ice,Xos=bXe,Qos=yy;function Jos(t,s){return t&&t.length?Yos(t,Qos(s),Xos):void 0}var els=Jos;const tls=_o(els);var sls=ice,rls=yy,nls=wXe;function als(t,s){return t&&t.length?sls(t,rls(s),nls):void 0}var ils=als;const ols=_o(ils);var lls=["cx","cy","angle","ticks","axisLine"],cls=["ticks","tick","angle","tickFormatter","stroke"];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 vI(){return vI=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 dls(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 uls(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function C6e(t,s){for(var r=0;rA6e?l=a==="outer"?"start":"end":o<-A6e?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=Jb(Jb({},hi(this.props,!1)),{},{fill:"none"},hi(i,!1));if(d==="circle")return mt.createElement(w2e,wk({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:o,r:l}));var p=this.props.ticks,f=p.map(function(v){return Fl(a,o,l,v.coordinate)});return mt.createElement(Bos,wk({className:"recharts-polar-angle-axis-line"},u,{points:f}))}},{key:"renderTicks",value:function(){var n=this,a=this.props,o=a.ticks,l=a.tick,i=a.tickLine,d=a.tickFormatter,u=a.stroke,p=hi(this.props,!1),f=hi(l,!1),v=Jb(Jb({},p),{},{fill:"none"},hi(i,!1)),_=o.map(function(b,j){var w=n.getTickLineCoord(b),N=n.getTickTextAnchor(b),C=Jb(Jb(Jb({textAnchor:N},p),{},{stroke:"none",fill:u},f),{},{index:j,payload:b,x:w.x2,y:w.y2});return mt.createElement(tl,wk({className:zi("recharts-polar-angle-axis-tick",YXe(l)),key:"tick-".concat(b.coordinate)},UN(n.props,b,j)),i&&mt.createElement("line",wk({className:"recharts-polar-angle-axis-tick-line"},v,w)),l&&s.renderTickItem(l,C,d?d(b.value,j):b.value))});return mt.createElement(tl,{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:mt.createElement(tl,{className:zi("recharts-polar-angle-axis",this.props.className)},l&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,a,o){var l;return mt.isValidElement(n)?l=mt.cloneElement(n,a):bi(n)?l=n(a):l=mt.createElement(VN,wk({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(S.PureComponent);fce(gce,"displayName","PolarAngleAxis");fce(gce,"axisType","angleAxis");fce(gce,"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 Sls=xYe,Cls=Sls(Object.getPrototypeOf,Object),Mls=Cls,Tls=rv,Als=Mls,Els=nv,Pls="[object Object]",Ils=Function.prototype,Lls=Object.prototype,pQe=Ils.toString,Dls=Lls.hasOwnProperty,Ols=pQe.call(Object);function Rls(t){if(!Els(t)||Tls(t)!=Pls)return!1;var s=Als(t);if(s===null)return!0;var r=Dls.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&pQe.call(r)==Ols}var Fls=Rls;const zls=_o(Fls);var Bls=rv,$ls=nv,qls="[object Boolean]";function Uls(t){return t===!0||t===!1||$ls(t)&&Bls(t)==qls}var Vls=Uls;const Hls=_o(Vls);function H6(t){"@babel/helpers - typeof";return H6=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},H6(t)}function fie(){return fie=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:p,lowerWidth:f,height:v,x:d,y:u},duration:j,animationEasing:b,isActive:N},function(A){var I=A.upperWidth,L=A.lowerWidth,R=A.height,$=A.x,q=A.y;return mt.createElement(ev,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:j,easing:b},mt.createElement("path",fie({},hi(r,!0),{className:C,d:L6e($,q,I,L,R),ref:n})))}):mt.createElement("g",null,mt.createElement("path",fie({},hi(r,!0),{className:C,d:L6e(d,u,p,f,v)})))},scs=["option","shapeType","propTransformer","activeClassName","isActive"];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 rcs(t,s){if(t==null)return{};var r=ncs(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 ncs(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 D6e(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 gie(t){for(var s=1;s0?vp(A,"paddingAngle",0):0;if(L){var $=p1(L.endAngle-L.startAngle,A.endAngle-A.startAngle),q=Cl(Cl({},A),{},{startAngle:C+R,endAngle:C+$(j)+R});w.push(q),C=q.endAngle}else{var U=A.endAngle,V=A.startAngle,X=p1(0,U-V),se=X(j),te=Cl(Cl({},A),{},{startAngle:C+R,endAngle:C+se+R});w.push(te),C=te.endAngle}}),mt.createElement(tl,null,n.renderSectorsStatically(w))})}},{key:"attachKeyboardHandlers",value:function(n){var a=this;n.onkeydown=function(o){if(!o.altKey)switch(o.key){case"ArrowLeft":{var l=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"ArrowRight":{var i=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[i].focus(),a.setState({sectorToFocus:i});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var n=this.props,a=n.sectors,o=n.isAnimationActive,l=this.state.prevSectors;return o&&a&&a.length&&(!l||!cce(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,p=a.cy,f=a.innerRadius,v=a.outerRadius,_=a.isAnimationActive,b=this.state.isAnimationFinished;if(o||!l||!l.length||!tn(u)||!tn(p)||!tn(f)||!tn(v))return null;var j=zi("recharts-pie",i);return mt.createElement(tl,{tabIndex:this.props.rootTabIndex,className:j,ref:function(N){n.pieRef=N}},this.renderSectors(),d&&this.renderLabels(l),uu.renderCallByParent(this.props,null,!1),(!_||b)&&v_.renderCallByParent(this.props,l,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return a.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:n.sectors!==a.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,a){return n>a?"start":n=360?C:C-1)*d,I=w-C*_-A,L=a.reduce(function(q,U){var V=Ju(U,N,0);return q+(tn(V)?V:0)},0),R;if(L>0){var $;R=a.map(function(q,U){var V=Ju(q,N,0),X=Ju(q,p,U),se=(tn(V)?V:0)/L,te;U?te=$.endAngle+Oh(j)*d*(V!==0?1:0):te=l;var Y=te+Oh(j)*((V!==0?_:0)+se*I),de=(te+Y)/2,ie=(b.innerRadius+b.outerRadius)/2,ae=[{name:X,value:V,payload:q,dataKey:N,type:v}],le=Fl(b.cx,b.cy,ie,de);return $=Cl(Cl(Cl({percent:se,cornerRadius:o,name:X,tooltipPayload:ae,midAngle:de,middleRadius:ie,tooltipPosition:le},q),b),{},{value:Ju(q,N),startAngle:te,endAngle:Y,payload:q,paddingAngle:Oh(j)*d}),$})}return Cl(Cl({},b),{},{sectors:R,data:a})});var Ncs=Math.ceil,Scs=Math.max;function Ccs(t,s,r,n){for(var a=-1,o=Scs(Ncs((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var Mcs=Ccs,Tcs=OYe,z6e=1/0,Acs=17976931348623157e292;function Ecs(t){if(!t)return t===0?t:0;if(t=Tcs(t),t===z6e||t===-z6e){var s=t<0?-1:1;return s*Acs}return t===t?t:0}var yQe=Ecs,Pcs=Mcs,Ics=Qle,_pe=yQe;function Lcs(t){return function(s,r,n){return n&&typeof n!="number"&&Ics(s,r,n)&&(r=n=void 0),s=_pe(s),r===void 0?(r=s,s=0):r=_pe(r),n=n===void 0?s0&&n.handleDrag(a.changedTouches[0])}),ep(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()}),ep(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),ep(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),ep(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),ep(n,"handleSlideDragStart",function(a){var o=V6e(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 Kcs(s,t),Vcs(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,p=u.length-1,f=Math.min(a,o),v=Math.max(a,o),_=s.getIndexInRange(l,f),b=s.getIndexInRange(l,v);return{startIndex:_-_%d,endIndex:b===p?p:b-b%d}}},{key:"getTextOfTick",value:function(n){var a=this.props,o=a.data,l=a.tickFormatter,i=a.dataKey,d=Ju(o[n],i,n);return bi(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,p=d.width,f=d.travellerWidth,v=d.startIndex,_=d.endIndex,b=d.onChange,j=n.pageX-o;j>0?j=Math.min(j,u+p-f-i,u+p-f-l):j<0&&(j=Math.max(j,u-l,u-i));var w=this.getIndex({startX:l+j,endX:i+j});(w.startIndex!==v||w.endIndex!==_)&&b&&b(w),this.setState({startX:l+j,endX:i+j,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var o=V6e(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],p=this.props,f=p.x,v=p.width,_=p.travellerWidth,b=p.onChange,j=p.gap,w=p.data,N={startX:this.state.startX,endX:this.state.endX},C=n.pageX-o;C>0?C=Math.min(C,f+v-_-u):C<0&&(C=Math.max(C,f-u)),N[l]=u+C;var A=this.getIndex(N),I=A.startIndex,L=A.endIndex,R=function(){var q=w.length-1;return l==="startX"&&(i>d?I%j===0:L%j===0)||id?L%j===0:I%j===0)||i>d&&L===q};this.setState(ep(ep({},l,u+C),"brushMoveStartX",n.pageX),function(){b&&R()&&b(A)})}},{key:"handleTravellerMoveKeyboard",value:function(n,a){var o=this,l=this.state,i=l.scaleValues,d=l.startX,u=l.endX,p=this.state[a],f=i.indexOf(p);if(f!==-1){var v=f+n;if(!(v===-1||v>=i.length)){var _=i[v];a==="startX"&&_>=u||a==="endX"&&_<=d||this.setState(ep({},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 mt.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,p=n.padding,f=S.Children.only(u);return f?mt.cloneElement(f,{x:a,y:o,width:l,height:i,margin:p,compact:!0,data:d}):null}},{key:"renderTravellerLayer",value:function(n,a){var o,l,i=this,d=this.props,u=d.y,p=d.travellerWidth,f=d.height,v=d.traveller,_=d.ariaLabel,b=d.data,j=d.startIndex,w=d.endIndex,N=Math.max(n,this.props.x),C=bpe(bpe({},hi(this.props,!1)),{},{x:N,y:u,width:p,height:f}),A=_||"Min value: ".concat((o=b[j])===null||o===void 0?void 0:o.name,", Max value: ").concat((l=b[w])===null||l===void 0?void 0:l.name);return mt.createElement(tl,{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,C))}},{key:"renderSlide",value:function(n,a){var o=this.props,l=o.y,i=o.height,d=o.stroke,u=o.travellerWidth,p=Math.min(n,a)+u,f=Math.max(Math.abs(a-n)-u,0);return mt.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:p,y:l,width:f,height:i})}},{key:"renderText",value:function(){var n=this.props,a=n.startIndex,o=n.endIndex,l=n.y,i=n.height,d=n.travellerWidth,u=n.stroke,p=this.state,f=p.startX,v=p.endX,_=5,b={pointerEvents:"none",fill:u};return mt.createElement(tl,{className:"recharts-brush-texts"},mt.createElement(VN,vie({textAnchor:"end",verticalAnchor:"middle",x:Math.min(f,v)-_,y:l+i/2},b),this.getTextOfTick(a)),mt.createElement(VN,vie({textAnchor:"start",verticalAnchor:"middle",x:Math.max(f,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,p=n.height,f=n.alwaysShowText,v=this.state,_=v.startX,b=v.endX,j=v.isTextActive,w=v.isSlideMoving,N=v.isTravellerMoving,C=v.isTravellerFocused;if(!a||!a.length||!tn(i)||!tn(d)||!tn(u)||!tn(p)||u<=0||p<=0)return null;var A=zi("recharts-brush",o),I=mt.Children.count(l)===1,L=qcs("userSelect","none");return mt.createElement(tl,{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"),(j||w||N||C||f)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var a=n.x,o=n.y,l=n.width,i=n.height,d=n.stroke,u=Math.floor(o+i/2)-1;return mt.createElement(mt.Fragment,null,mt.createElement("rect",{x:a,y:o,width:l,height:i,fill:d,stroke:"none"}),mt.createElement("line",{x1:a+1,y1:u,x2:a+l-1,y2:u,fill:"none",stroke:"#fff"}),mt.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 mt.isValidElement(n)?o=mt.cloneElement(n,a):bi(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,p=n.startIndex,f=n.endIndex;if(o!==a.prevData||u!==a.prevUpdateId)return bpe({prevData:o,prevTravellerWidth:d,prevUpdateId:u,prevX:i,prevWidth:l},o&&o.length?Ycs({data:o,width:l,x:i,travellerWidth:d,startIndex:p,endIndex:f}):{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}}])}(S.PureComponent);ep(U3,"displayName","Brush");ep(U3,"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 Xcs=Gwe;function Qcs(t,s){var r;return Xcs(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var Jcs=Qcs,eds=cYe,tds=yy,sds=Jcs,rds=Bm,nds=Qle;function ads(t,s,r){var n=rds(t)?eds:sds;return r&&nds(t,s,r)&&(s=void 0),n(t,tds(s))}var ids=ads;const ods=_o(ids);var ty=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},H6e=EYe;function lds(t,s,r){s=="__proto__"&&H6e?H6e(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var cds=lds,dds=cds,uds=TYe,hds=yy;function mds(t,s){var r={};return s=hds(s),uds(t,function(n,a,o){dds(r,a,s(n,a,o))}),r}var pds=mds;const fds=_o(pds);function gds(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 Ids(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 Lds(t,s){var r=t.x,n=t.y,a=Pds(t,Mds),o="".concat(r),l=parseInt(o,10),i="".concat(n),d=parseInt(i,10),u="".concat(s.height||a.height),p=parseInt(u,10),f="".concat(s.width||a.width),v=parseInt(f,10);return gE(gE(gE(gE(gE({},s),a),l?{x:l}:{}),d?{y:d}:{}),{},{height:p,width:v,name:s.name,radius:s.radius})}function G6e(t){return mt.createElement(fQe,j0e({shapeType:"rectangle",propTransformer:Lds,activeClassName:"recharts-active-bar"},t))}var Dds=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=tn(n)||oUt(n);return o?s(n,a):(o||WN(),r)}},Ods=["value","background"],jQe;function V3(t){"@babel/helpers - typeof";return V3=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},V3(t)}function Rds(t,s){if(t==null)return{};var r=Fds(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 Fds(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 bie(){return bie=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(de)0&&Math.abs(Y)0&&(te=Math.min((Ze||0)-(Y[_e-1]||0),te))}),Number.isFinite(te)){var de=te/se,ie=j.layout==="vertical"?n.height:n.width;if(j.padding==="gap"&&($=de*ie/2),j.padding==="no-gap"){var ae=Rh(s.barCategoryGap,de*ie),le=de*ie/2;$=le-ae-(le-ae)/ie*ae}}}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=j.range,L&&(q=[q[1],q[0]]);var pe=UXe(j,o,v),be=pe.scale,ye=pe.realScaleType;be.domain(N).range(q),VXe(be);var we=HXe(be,kg(kg({},j),{},{realScaleType:ye}));a==="xAxis"?(X=w==="top"&&!I||w==="bottom"&&I,U=n.left,V=f[R]-X*j.height):a==="yAxis"&&(X=w==="left"&&!I||w==="right"&&I,U=f[R]-X*j.width,V=n.top);var ke=kg(kg(kg({},j),we),{},{realScaleType:ye,x:U,y:V,scale:be,width:a==="xAxis"?n.width:j.width,height:a==="yAxis"?n.height:j.height});return ke.bandSize=iie(ke,we),!j.hide&&a==="xAxis"?f[R]+=(X?-1:1)*ke.height:j.hide||(f[R]+=(X?-1:1)*ke.width),kg(kg({},_),{},vce({},b,ke))},{})},CQe=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)}},Yds=function(s){var r=s.x1,n=s.y1,a=s.x2,o=s.y2;return CQe({x:r,y:n},{x:a,y:o})},MQe=function(){function t(s){Wds(this,t),this.scale=s}return Gds(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)}}])}();vce(MQe,"EPS",1e-4);var j2e=function(s){var r=Object.keys(s).reduce(function(n,a){return kg(kg({},n),{},vce({},a,MQe.create(s[a])))},{});return kg(kg({},r),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return fds(a,function(d,u){return r[u].apply(d,{bandAware:l,position:i})})},isInRange:function(a){return wQe(a,function(o,l){return r[l].isInRange(o)})}})};function Xds(t){return(t%180+180)%180}var Qds=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=Xds(a),l=o*Math.PI/180,i=Math.atan(n/r),d=l>i&&l-1?a[o?s[l]:l]:void 0}}var rus=sus,nus=yQe;function aus(t){var s=nus(t),r=s%1;return s===s?r?s-r:s:0}var ius=aus,ous=jYe,lus=yy,cus=ius,dus=Math.max;function uus(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:cus(r);return a<0&&(a=dus(n+a,0)),ous(t,lus(s),a)}var hus=uus,mus=rus,pus=hus,fus=mus(pus),gus=fus;const xus=_o(gus);var yus=mqt(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("")}),k2e=S.createContext(void 0),N2e=S.createContext(void 0),TQe=S.createContext(void 0),AQe=S.createContext({}),EQe=S.createContext(void 0),PQe=S.createContext(0),IQe=S.createContext(0),Q6e=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,p=yus(o);return mt.createElement(k2e.Provider,{value:n},mt.createElement(N2e.Provider,{value:a},mt.createElement(AQe.Provider,{value:o},mt.createElement(TQe.Provider,{value:p},mt.createElement(EQe.Provider,{value:l},mt.createElement(PQe.Provider,{value:u},mt.createElement(IQe.Provider,{value:d},i)))))))},vus=function(){return S.useContext(EQe)},LQe=function(s){var r=S.useContext(k2e);r==null&&WN();var n=r[s];return n==null&&WN(),n},_us=function(){var s=S.useContext(k2e);return w1(s)},bus=function(){var s=S.useContext(N2e),r=xus(s,function(n){return wQe(n.domain,Number.isFinite)});return r||w1(s)},DQe=function(s){var r=S.useContext(N2e);r==null&&WN();var n=r[s];return n==null&&WN(),n},wus=function(){var s=S.useContext(TQe);return s},jus=function(){return S.useContext(AQe)},S2e=function(){return S.useContext(IQe)},C2e=function(){return S.useContext(PQe)};function H3(t){"@babel/helpers - typeof";return H3=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},H3(t)}function kus(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Nus(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 ihs(t,s){return qQe(t,s+1)}function ohs(t,s,r,n,a){for(var o=(n||[]).slice(),l=s.start,i=s.end,d=0,u=1,p=l,f=function(){var b=n==null?void 0:n[d];if(b===void 0)return{v:qQe(n,u)};var j=d,w,N=function(){return w===void 0&&(w=r(b,j)),w},C=b.coordinate,A=d===0||Sie(t,C,N,p,i);A||(d=0,p=l,u+=1),A&&(p=C+t*(N()/2+a),d+=u)},v;u<=o.length;)if(v=f(),v)return v.v;return[]}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)}function iLe(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 Yu(t){for(var s=1;s0?_.coordinate-w*t:_.coordinate})}else o[v]=_=Yu(Yu({},_),{},{tickCoord:_.coordinate});var N=Sie(t,_.tickCoord,j,i,d);N&&(d=_.tickCoord-t*(j()/2+a),o[v]=Yu(Yu({},_),{},{isShow:!0}))},p=l-1;p>=0;p--)u(p);return o}function hhs(t,s,r,n,a,o){var l=(n||[]).slice(),i=l.length,d=s.start,u=s.end;if(o){var p=n[i-1],f=r(p,i-1),v=t*(p.coordinate+t*f/2-u);l[i-1]=p=Yu(Yu({},p),{},{tickCoord:v>0?p.coordinate-v*t:p.coordinate});var _=Sie(t,p.tickCoord,function(){return f},d,u);_&&(u=p.tickCoord-t*(f/2+a),l[i-1]=Yu(Yu({},p),{},{isShow:!0}))}for(var b=o?i-1:i,j=function(C){var A=l[C],I,L=function(){return I===void 0&&(I=r(A,C)),I};if(C===0){var R=t*(A.coordinate-t*L()/2-d);l[C]=A=Yu(Yu({},A),{},{tickCoord:R<0?A.coordinate-R*t:A.coordinate})}else l[C]=A=Yu(Yu({},A),{},{tickCoord:A.coordinate});var $=Sie(t,A.tickCoord,L,d,u);$&&(d=A.tickCoord+t*(L()/2+a),l[C]=Yu(Yu({},A),{},{isShow:!0}))},w=0;w=2?Oh(a[1].coordinate-a[0].coordinate):1,N=ahs(o,w,_);return d==="equidistantPreserveStart"?ohs(w,N,j,a,l):(d==="preserveStart"||d==="preserveStartEnd"?v=hhs(w,N,j,a,l,d==="preserveStartEnd"):v=uhs(w,N,j,a,l),v.filter(function(C){return C.isShow}))}var mhs=["viewBox"],phs=["viewBox"],fhs=["ticks"];function K3(t){"@babel/helpers - typeof";return K3=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},K3(t)}function W4(){return W4=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 ghs(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 xhs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function lLe(t,s){for(var r=0;r0?d(this.props):d(_)),l<=0||i<=0||!b||!b.length?null:mt.createElement(tl,{className:zi("recharts-cartesian-axis",u),ref:function(w){n.layerReference=w}},o&&this.renderAxisLine(),this.renderTicks(b,this.state.fontSize,this.state.letterSpacing),uu.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,o){var l,i=zi(a.className,"recharts-cartesian-axis-tick-value");return mt.isValidElement(n)?l=mt.cloneElement(n,Id(Id({},a),{},{className:i})):bi(n)?l=n(Id(Id({},a),{},{className:i})):l=mt.createElement(VN,W4({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(S.Component);E2e(HM,"displayName","CartesianAxis");E2e(HM,"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 khs=["x1","y1","x2","y2","key"],Nhs=["offset"];function GN(t){"@babel/helpers - typeof";return GN=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},GN(t)}function cLe(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 Qu(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Ths(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 Ahs=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 mt.createElement("rect",{x:a,y:o,ry:d,width:l,height:i,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function HQe(t,s){var r;if(mt.isValidElement(t))r=mt.cloneElement(t,s);else if(bi(t))r=t(s);else{var n=s.x1,a=s.y1,o=s.x2,l=s.y2,i=s.key,d=dLe(s,khs),u=hi(d,!1);u.offset;var p=dLe(u,Nhs);r=mt.createElement("line",zk({},p,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function Ehs(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=Qu(Qu({},t),{},{x1:s,y1:i,x2:s+r,y2:i,key:"line-".concat(d),index:d});return HQe(a,u)});return mt.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function Phs(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=Qu(Qu({},t),{},{x1:i,y1:s,x2:i,y2:s+r,key:"line-".concat(d),index:d});return HQe(a,u)});return mt.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function Ihs(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 p=i.map(function(v){return Math.round(v+a-a)}).sort(function(v,_){return v-_});a!==p[0]&&p.unshift(0);var f=p.map(function(v,_){var b=!p[_+1],j=b?a+l-v:p[_+1]-v;if(j<=0)return null;var w=_%s.length;return mt.createElement("rect",{key:"react-".concat(_),y:v,x:n,height:j,width:o,stroke:"none",fill:s[w],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return mt.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},f)}function Lhs(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 p=u.map(function(v){return Math.round(v+o-o)}).sort(function(v,_){return v-_});o!==p[0]&&p.unshift(0);var f=p.map(function(v,_){var b=!p[_+1],j=b?o+i-v:p[_+1]-v;if(j<=0)return null;var w=_%n.length;return mt.createElement("rect",{key:"react-".concat(_),x:v,y:l,width:j,height:d,stroke:"none",fill:n[w],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return mt.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},f)}var Dhs=function(s,r){var n=s.xAxis,a=s.width,o=s.height,l=s.offset;return qXe(A2e(Qu(Qu(Qu({},HM.defaultProps),n),{},{ticks:w0(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,r)},Ohs=function(s,r){var n=s.yAxis,a=s.width,o=s.height,l=s.offset;return qXe(A2e(Qu(Qu(Qu({},HM.defaultProps),n),{},{ticks:w0(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,r)},h4={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function WQe(t){var s,r,n,a,o,l,i=S2e(),d=C2e(),u=jus(),p=Qu(Qu({},t),{},{stroke:(s=t.stroke)!==null&&s!==void 0?s:h4.stroke,fill:(r=t.fill)!==null&&r!==void 0?r:h4.fill,horizontal:(n=t.horizontal)!==null&&n!==void 0?n:h4.horizontal,horizontalFill:(a=t.horizontalFill)!==null&&a!==void 0?a:h4.horizontalFill,vertical:(o=t.vertical)!==null&&o!==void 0?o:h4.vertical,verticalFill:(l=t.verticalFill)!==null&&l!==void 0?l:h4.verticalFill,x:tn(t.x)?t.x:u.left,y:tn(t.y)?t.y:u.top,width:tn(t.width)?t.width:u.width,height:tn(t.height)?t.height:u.height}),f=p.x,v=p.y,_=p.width,b=p.height,j=p.syncWithTicks,w=p.horizontalValues,N=p.verticalValues,C=_us(),A=bus();if(!tn(_)||_<=0||!tn(b)||b<=0||!tn(f)||f!==+f||!tn(v)||v!==+v)return null;var I=p.verticalCoordinatesGenerator||Dhs,L=p.horizontalCoordinatesGenerator||Ohs,R=p.horizontalPoints,$=p.verticalPoints;if((!R||!R.length)&&bi(L)){var q=w&&w.length,U=L({yAxis:A?Qu(Qu({},A),{},{ticks:q?w:A.ticks}):void 0,width:i,height:d,offset:u},q?!0:j);Ug(Array.isArray(U),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(GN(U),"]")),Array.isArray(U)&&(R=U)}if((!$||!$.length)&&bi(I)){var V=N&&N.length,X=I({xAxis:C?Qu(Qu({},C),{},{ticks:V?N:C.ticks}):void 0,width:i,height:d,offset:u},V?!0:j);Ug(Array.isArray(X),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(GN(X),"]")),Array.isArray(X)&&($=X)}return mt.createElement("g",{className:"recharts-cartesian-grid"},mt.createElement(Ahs,{fill:p.fill,fillOpacity:p.fillOpacity,x:p.x,y:p.y,width:p.width,height:p.height,ry:p.ry}),mt.createElement(Ehs,zk({},p,{offset:u,horizontalPoints:R,xAxis:C,yAxis:A})),mt.createElement(Phs,zk({},p,{offset:u,verticalPoints:$,xAxis:C,yAxis:A})),mt.createElement(Ihs,zk({},p,{horizontalPoints:R})),mt.createElement(Lhs,zk({},p,{verticalPoints:$})))}WQe.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 Rhs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Fhs(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 kms(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 Nms(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Sms(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r0?l:s&&s.length&&tn(a)&&tn(o)?s.slice(a,o+1):[]};function iJe(t){return t==="number"?[0,"auto"]:void 0}var B0e=function(s,r,n,a){var o=s.graphicalItems,l=s.tooltipAxis,i=Sce(r,s);return n<0||!o||!o.length||n>=i.length?null:o.reduce(function(d,u){var p,f=(p=u.props.data)!==null&&p!==void 0?p:r;f&&s.dataStartIndex+s.dataEndIndex!==0&&s.dataEndIndex-s.dataStartIndex>=n&&(f=f.slice(s.dataStartIndex,s.dataEndIndex+1));var v;if(l.dataKey&&!l.allowDuplicatedCategory){var _=f===void 0?i:f;v=mye(_,l.dataKey,a)}else v=f&&f[n]||i[n];return v?[].concat(Q3(d),[GXe(u,v)]):d},[])},gLe=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=Fms(o,n),i=s.orderedTooltipTicks,d=s.tooltipAxis,u=s.tooltipTicks,p=vns(l,i,u,d);if(p>=0&&u){var f=u[p]&&u[p].value,v=B0e(s,r,p,f),_=zms(n,i,p,o);return{activeTooltipIndex:p,activeLabel:f,activePayload:v,activeCoordinate:_}}return null},Bms=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,p=s.layout,f=s.children,v=s.stackOffset,_=$Xe(p,o);return n.reduce(function(b,j){var w,N=j.type.defaultProps!==void 0?xr(xr({},j.type.defaultProps),j.props):j.props,C=N.type,A=N.dataKey,I=N.allowDataOverflow,L=N.allowDuplicatedCategory,R=N.scale,$=N.ticks,q=N.includeHidden,U=N[l];if(b[U])return b;var V=Sce(s.data,{graphicalItems:a.filter(function(we){var ke,Ze=l in we.props?we.props[l]:(ke=we.type.defaultProps)===null||ke===void 0?void 0:ke[l];return Ze===U}),dataStartIndex:d,dataEndIndex:u}),X=V.length,se,te,Y;hms(N.domain,I,C)&&(se=t0e(N.domain,null,I),_&&(C==="number"||R!=="auto")&&(Y=gI(V,A,"category")));var de=iJe(C);if(!se||se.length===0){var ie,ae=(ie=N.domain)!==null&&ie!==void 0?ie:de;if(A){if(se=gI(V,A,C),C==="category"&&_){var le=cUt(se);L&&le?(te=se,se=yie(0,X)):L||(se=$Ie(ae,se,j).reduce(function(we,ke){return we.indexOf(ke)>=0?we:[].concat(Q3(we),[ke])},[]))}else if(C==="category")L?se=se.filter(function(we){return we!==""&&!Yi(we)}):se=$Ie(ae,se,j).reduce(function(we,ke){return we.indexOf(ke)>=0||ke===""||Yi(ke)?we:[].concat(Q3(we),[ke])},[]);else if(C==="number"){var pe=kns(V,a.filter(function(we){var ke,Ze,_e=l in we.props?we.props[l]:(ke=we.type.defaultProps)===null||ke===void 0?void 0:ke[l],Ce="hide"in we.props?we.props.hide:(Ze=we.type.defaultProps)===null||Ze===void 0?void 0:Ze.hide;return _e===U&&(q||!Ce)}),A,o,p);pe&&(se=pe)}_&&(C==="number"||R!=="auto")&&(Y=gI(V,A,"category"))}else _?se=yie(0,X):i&&i[U]&&i[U].hasStack&&C==="number"?se=v==="expand"?[0,1]:WXe(i[U].stackGroups,d,u):se=BXe(V,a.filter(function(we){var ke=l in we.props?we.props[l]:we.type.defaultProps[l],Ze="hide"in we.props?we.props.hide:we.type.defaultProps.hide;return ke===U&&(q||!Ze)}),C,p,!0);if(C==="number")se=R0e(f,se,U,o,$),ae&&(se=t0e(ae,se,I));else if(C==="category"&&ae){var be=ae,ye=se.every(function(we){return be.indexOf(we)>=0});ye&&(se=be)}}return xr(xr({},b),{},ei({},U,xr(xr({},N),{},{axisType:o,domain:se,categoricalDomain:Y,duplicateDomain:te,originalDomain:(w=N.domain)!==null&&w!==void 0?w:de,isCategorical:_,layout:p})))},{})},$ms=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,p=s.layout,f=s.children,v=Sce(s.data,{graphicalItems:n,dataStartIndex:d,dataEndIndex:u}),_=v.length,b=$Xe(p,o),j=-1;return n.reduce(function(w,N){var C=N.type.defaultProps!==void 0?xr(xr({},N.type.defaultProps),N.props):N.props,A=C[l],I=iJe("number");if(!w[A]){j++;var L;return b?L=yie(0,_):i&&i[A]&&i[A].hasStack?(L=WXe(i[A].stackGroups,d,u),L=R0e(f,L,A,o)):(L=t0e(I,BXe(v,n.filter(function(R){var $,q,U=l in R.props?R.props[l]:($=R.type.defaultProps)===null||$===void 0?void 0:$[l],V="hide"in R.props?R.props.hide:(q=R.type.defaultProps)===null||q===void 0?void 0:q.hide;return U===A&&!V}),"number",p),a.defaultProps.allowDataOverflow),L=R0e(f,L,A,o)),xr(xr({},w),{},ei({},A,xr(xr({axisType:o},a.defaultProps),{},{hide:!0,orientation:vp(Oms,"".concat(o,".").concat(j%2),null),domain:L,originalDomain:I,isCategorical:b,layout:p})))}return w},{})},qms=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,p=s.children,f="".concat(a,"Id"),v=vf(p,o),_={};return v&&v.length?_=Bms(s,{axes:v,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:d,dataEndIndex:u}):l&&l.length&&(_=$ms(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:d,dataEndIndex:u})),_},Ums=function(s){var r=w1(s),n=w0(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:Kwe(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:iie(r,n)}},xLe=function(s){var r=s.children,n=s.defaultShowTooltip,a=sp(r,U3),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}},Vms=function(s){return!s||!s.length?!1:s.some(function(r){var n=B0(r&&r.type);return n&&n.indexOf("Bar")>=0})},yLe=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"}},Hms=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,p=n.height,f=n.children,v=n.margin||{},_=sp(f,U3),b=sp(f,F5),j=Object.keys(d).reduce(function(L,R){var $=d[R],q=$.orientation;return!$.mirror&&!$.hide?xr(xr({},L),{},ei({},q,L[q]+$.width)):L},{left:v.left||0,right:v.right||0}),w=Object.keys(l).reduce(function(L,R){var $=l[R],q=$.orientation;return!$.mirror&&!$.hide?xr(xr({},L),{},ei({},q,vp(L,"".concat(q))+$.height)):L},{top:v.top||0,bottom:v.bottom||0}),N=xr(xr({},w),j),C=N.bottom;_&&(N.bottom+=_.props.height||U3.defaultProps.height),b&&r&&(N=wns(N,a,n,r));var A=u-N.left-N.right,I=p-N.top-N.bottom;return xr(xr({brushBottom:C},N),{},{width:Math.max(A,0),height:Math.max(I,0)})},Wms=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},oJe=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,p=s.formatAxisMap,f=s.defaultProps,v=function(N,C){var A=C.graphicalItems,I=C.stackGroups,L=C.offset,R=C.updateId,$=C.dataStartIndex,q=C.dataEndIndex,U=N.barSize,V=N.layout,X=N.barGap,se=N.barCategoryGap,te=N.maxBarSize,Y=yLe(V),de=Y.numericAxisName,ie=Y.cateAxisName,ae=Vms(A),le=[];return A.forEach(function(pe,be){var ye=Sce(N.data,{graphicalItems:[pe],dataStartIndex:$,dataEndIndex:q}),we=pe.type.defaultProps!==void 0?xr(xr({},pe.type.defaultProps),pe.props):pe.props,ke=we.dataKey,Ze=we.maxBarSize,_e=we["".concat(de,"Id")],Ce=we["".concat(ie,"Id")],Te={},Fe=d.reduce(function(Xe,$e){var Ke=C["".concat($e.axisType,"Map")],ct=we["".concat($e.axisType,"Id")];Ke&&Ke[ct]||$e.axisType==="zAxis"||WN();var Ue=Ke[ct];return xr(xr({},Xe),{},ei(ei({},$e.axisType,Ue),"".concat($e.axisType,"Ticks"),w0(Ue)))},Te),Ae=Fe[ie],We=Fe["".concat(ie,"Ticks")],ht=I&&I[_e]&&I[_e].hasStack&&Ins(pe,I[_e].stackGroups),De=B0(pe.type).indexOf("Bar")>=0,Dt=iie(Ae,We),he=[],Qe=ae&&_ns({barSize:U,stackGroups:I,totalSize:Wms(Fe,ie)});if(De){var ot,rt,Ne=Yi(Ze)?te:Ze,it=(ot=(rt=iie(Ae,We,!0))!==null&&rt!==void 0?rt:Ne)!==null&&ot!==void 0?ot:0;he=bns({barGap:X,barCategoryGap:se,bandSize:it!==Dt?it:Dt,sizeList:Qe[Ce],maxBarSize:Ne}),it!==Dt&&(he=he.map(function(Xe){return xr(xr({},Xe),{},{position:xr(xr({},Xe.position),{},{offset:Xe.position.offset-it/2})})}))}var qe=pe&&pe.type&&pe.type.getComposedData;qe&&le.push({props:xr(xr({},qe(xr(xr({},Fe),{},{displayedData:ye,props:N,dataKey:ke,item:pe,bandSize:Dt,barPosition:he,offset:L,stackedData:ht,layout:V,dataStartIndex:$,dataEndIndex:q}))),{},ei(ei(ei({key:pe.key||"item-".concat(be)},de,Fe[de]),ie,Fe[ie]),"animationId",R)),childIndex:bUt(pe,N.children),item:pe})}),le},_=function(N,C){var A=N.props,I=N.dataStartIndex,L=N.dataEndIndex,R=N.updateId;if(!DEe({props:A}))return null;var $=A.children,q=A.layout,U=A.stackOffset,V=A.data,X=A.reverseStackOrder,se=yLe(q),te=se.numericAxisName,Y=se.cateAxisName,de=vf($,n),ie=Ens(V,de,"".concat(te,"Id"),"".concat(Y,"Id"),U,X),ae=d.reduce(function(we,ke){var Ze="".concat(ke.axisType,"Map");return xr(xr({},we),{},ei({},Ze,qms(A,xr(xr({},ke),{},{graphicalItems:de,stackGroups:ke.axisType===te&&ie,dataStartIndex:I,dataEndIndex:L}))))},{}),le=Hms(xr(xr({},ae),{},{props:A,graphicalItems:de}),C==null?void 0:C.legendBBox);Object.keys(ae).forEach(function(we){ae[we]=p(A,ae[we],le,we.replace("Map",""),r)});var pe=ae["".concat(Y,"Map")],be=Ums(pe),ye=v(A,xr(xr({},ae),{},{dataStartIndex:I,dataEndIndex:L,updateId:R,graphicalItems:de,stackGroups:ie,offset:le}));return xr(xr({formattedGraphicalItems:ye,graphicalItems:de,offset:le,stackGroups:ie},be),ae)},b=function(w){function N(C){var A,I,L;return Nms(this,N),L=Mms(this,N,[C]),ei(L,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),ei(L,"accessibilityManager",new ums),ei(L,"handleLegendBBoxUpdate",function(R){if(R){var $=L.state,q=$.dataStartIndex,U=$.dataEndIndex,V=$.updateId;L.setState(xr({legendBBox:R},_({props:L.props,dataStartIndex:q,dataEndIndex:U,updateId:V},xr(xr({},L.state),{},{legendBBox:R}))))}}),ei(L,"handleReceiveSyncEvent",function(R,$,q){if(L.props.syncId===R){if(q===L.eventEmitterSymbol&&typeof L.props.syncMethod!="function")return;L.applySyncEvent($)}}),ei(L,"handleBrushChange",function(R){var $=R.startIndex,q=R.endIndex;if($!==L.state.dataStartIndex||q!==L.state.dataEndIndex){var U=L.state.updateId;L.setState(function(){return xr({dataStartIndex:$,dataEndIndex:q},_({props:L.props,dataStartIndex:$,dataEndIndex:q,updateId:U},L.state))}),L.triggerSyncEvent({dataStartIndex:$,dataEndIndex:q})}}),ei(L,"handleMouseEnter",function(R){var $=L.getMouseInfo(R);if($){var q=xr(xr({},$),{},{isTooltipActive:!0});L.setState(q),L.triggerSyncEvent(q);var U=L.props.onMouseEnter;bi(U)&&U(q,R)}}),ei(L,"triggeredAfterMouseMove",function(R){var $=L.getMouseInfo(R),q=$?xr(xr({},$),{},{isTooltipActive:!0}):{isTooltipActive:!1};L.setState(q),L.triggerSyncEvent(q);var U=L.props.onMouseMove;bi(U)&&U(q,R)}),ei(L,"handleItemMouseEnter",function(R){L.setState(function(){return{isTooltipActive:!0,activeItem:R,activePayload:R.tooltipPayload,activeCoordinate:R.tooltipPosition||{x:R.cx,y:R.cy}}})}),ei(L,"handleItemMouseLeave",function(){L.setState(function(){return{isTooltipActive:!1}})}),ei(L,"handleMouseMove",function(R){R.persist(),L.throttleTriggeredAfterMouseMove(R)}),ei(L,"handleMouseLeave",function(R){L.throttleTriggeredAfterMouseMove.cancel();var $={isTooltipActive:!1};L.setState($),L.triggerSyncEvent($);var q=L.props.onMouseLeave;bi(q)&&q($,R)}),ei(L,"handleOuterEvent",function(R){var $=_Ut(R),q=vp(L.props,"".concat($));if($&&bi(q)){var U,V;/.*touch.*/i.test($)?V=L.getMouseInfo(R.changedTouches[0]):V=L.getMouseInfo(R),q((U=V)!==null&&U!==void 0?U:{},R)}}),ei(L,"handleClick",function(R){var $=L.getMouseInfo(R);if($){var q=xr(xr({},$),{},{isTooltipActive:!0});L.setState(q),L.triggerSyncEvent(q);var U=L.props.onClick;bi(U)&&U(q,R)}}),ei(L,"handleMouseDown",function(R){var $=L.props.onMouseDown;if(bi($)){var q=L.getMouseInfo(R);$(q,R)}}),ei(L,"handleMouseUp",function(R){var $=L.props.onMouseUp;if(bi($)){var q=L.getMouseInfo(R);$(q,R)}}),ei(L,"handleTouchMove",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.throttleTriggeredAfterMouseMove(R.changedTouches[0])}),ei(L,"handleTouchStart",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.handleMouseDown(R.changedTouches[0])}),ei(L,"handleTouchEnd",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.handleMouseUp(R.changedTouches[0])}),ei(L,"handleDoubleClick",function(R){var $=L.props.onDoubleClick;if(bi($)){var q=L.getMouseInfo(R);$(q,R)}}),ei(L,"handleContextMenu",function(R){var $=L.props.onContextMenu;if(bi($)){var q=L.getMouseInfo(R);$(q,R)}}),ei(L,"triggerSyncEvent",function(R){L.props.syncId!==void 0&&jpe.emit(kpe,L.props.syncId,R,L.eventEmitterSymbol)}),ei(L,"applySyncEvent",function(R){var $=L.props,q=$.layout,U=$.syncMethod,V=L.state.updateId,X=R.dataStartIndex,se=R.dataEndIndex;if(R.dataStartIndex!==void 0||R.dataEndIndex!==void 0)L.setState(xr({dataStartIndex:X,dataEndIndex:se},_({props:L.props,dataStartIndex:X,dataEndIndex:se,updateId:V},L.state)));else if(R.activeTooltipIndex!==void 0){var te=R.chartX,Y=R.chartY,de=R.activeTooltipIndex,ie=L.state,ae=ie.offset,le=ie.tooltipTicks;if(!ae)return;if(typeof U=="function")de=U(le,R);else if(U==="value"){de=-1;for(var pe=0;pe=0){var ht,De;if(te.dataKey&&!te.allowDuplicatedCategory){var Dt=typeof te.dataKey=="function"?We:"payload.".concat(te.dataKey.toString());ht=mye(pe,Dt,de),De=be&&ye&&mye(ye,Dt,de)}else ht=pe==null?void 0:pe[Y],De=be&&ye&&ye[Y];if(Ce||_e){var he=R.props.activeIndex!==void 0?R.props.activeIndex:Y;return[S.cloneElement(R,xr(xr(xr({},U.props),Fe),{},{activeIndex:he})),null,null]}if(!Yi(ht))return[Ae].concat(Q3(L.renderActivePoints({item:U,activePoint:ht,basePoint:De,childIndex:Y,isRange:be})))}else{var Qe,ot=(Qe=L.getItemByXY(L.state.activeCoordinate))!==null&&Qe!==void 0?Qe:{graphicalItem:Ae},rt=ot.graphicalItem,Ne=rt.item,it=Ne===void 0?R:Ne,qe=rt.childIndex,Xe=xr(xr(xr({},U.props),Fe),{},{activeIndex:qe});return[S.cloneElement(it,Xe),null,null]}return be?[Ae,null,null]:[Ae,null]}),ei(L,"renderCustomized",function(R,$,q){return S.cloneElement(R,xr(xr({key:"recharts-customized-".concat(q)},L.props),L.state))}),ei(L,"renderMap",{CartesianGrid:{handler:NR,once:!0},ReferenceArea:{handler:L.renderReferenceElement},ReferenceLine:{handler:NR},ReferenceDot:{handler:L.renderReferenceElement},XAxis:{handler:NR},YAxis:{handler:NR},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=C.id)!==null&&A!==void 0?A:JL("recharts"),"-clip"),L.throttleTriggeredAfterMouseMove=RYe(L.triggeredAfterMouseMove,(I=C.throttleDelay)!==null&&I!==void 0?I:1e3/60),L.state={},L}return Ems(N,w),Cms(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,R=A.height,$=A.layout,q=sp(I,jg);if(q){var U=q.props.defaultIndex;if(!(typeof U!="number"||U<0||U>this.state.tooltipTicks.length-1)){var V=this.state.tooltipTicks[U]&&this.state.tooltipTicks[U].value,X=B0e(this.state,L,U,V),se=this.state.tooltipTicks[U].coordinate,te=(this.state.offset.top+R)/2,Y=$==="horizontal",de=Y?{x:se,y:te}:{y:se,x:te},ie=this.state.formattedGraphicalItems.find(function(le){var pe=le.item;return pe.type.name==="Scatter"});ie&&(de=xr(xr({},de),ie.props.points[U].tooltipPosition),X=ie.props.points[U].tooltipPayload);var ae={activeTooltipIndex:U,isTooltipActive:!0,activeLabel:V,activePayload:X,activeCoordinate:de};this.setState(ae),this.renderCursor(q),this.accessibilityManager.setIndex(U)}}}},{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,R;this.accessibilityManager.setDetails({offset:{left:(L=this.props.margin.left)!==null&&L!==void 0?L:0,top:(R=this.props.margin.top)!==null&&R!==void 0?R:0}})}return null}},{key:"componentDidUpdate",value:function(A){fye([sp(A.children,jg)],[sp(this.props.children,jg)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var A=sp(this.props.children,jg);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(),R=GJt(L),$={chartX:Math.round(A.pageX-R.left),chartY:Math.round(A.pageY-R.top)},q=L.width/I.offsetWidth||1,U=this.inRange($.chartX,$.chartY,q);if(!U)return null;var V=this.state,X=V.xAxisMap,se=V.yAxisMap,te=this.getTooltipEventType(),Y=gLe(this.state,this.props.data,this.props.layout,U);if(te!=="axis"&&X&&se){var de=w1(X).scale,ie=w1(se).scale,ae=de&&de.invert?de.invert($.chartX):null,le=ie&&ie.invert?ie.invert($.chartY):null;return xr(xr({},$),{},{xValue:ae,yValue:le},Y)}return Y?xr(xr({},$),Y):null}},{key:"inRange",value:function(A,I){var L=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,R=this.props.layout,$=A/L,q=I/L;if(R==="horizontal"||R==="vertical"){var U=this.state.offset,V=$>=U.left&&$<=U.left+U.width&&q>=U.top&&q<=U.top+U.height;return V?{x:$,y:q}:null}var X=this.state,se=X.angleAxisMap,te=X.radiusAxisMap;if(se&&te){var Y=w1(se);return VIe({x:$,y:q},Y)}return null}},{key:"parseEventsOfWrapper",value:function(){var A=this.props.children,I=this.getTooltipEventType(),L=sp(A,jg),R={};L&&I==="axis"&&(L.props.trigger==="click"?R={onClick:this.handleClick}:R={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var $=Iae(this.props,this.handleOuterEvent);return xr(xr({},$),R)}},{key:"addListener",value:function(){jpe.on(kpe,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){jpe.removeListener(kpe,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(A,I,L){for(var R=this.state.formattedGraphicalItems,$=0,q=R.length;$");return t}const dJe=S.forwardRef(({id:t,className:s,children:r,config:n,...a},o)=>{const l=S.useId(),i=`chart-${t||l.replace(/:/g,"")}`;return e.jsx(lJe.Provider,{value:{config:n},children:e.jsxs("div",{"data-chart":i,ref:o,className:Pt("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",s),...a,children:[e.jsx(Yms,{id:i,config:n}),e.jsx(Fye,{children:r})]})})});dJe.displayName="Chart";const Yms=({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(Zms).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},uJe=S.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:p,nameKey:f,labelKey:v},_)=>{const{config:b}=cJe(),j=S.useMemo(()=>{var L;if(a||!(s!=null&&s.length))return null;const[N]=s,C=`${v||N.dataKey||N.name||"value"}`,A=$0e(b,N,C),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:Pt("font-medium",d),children:i(I,s)}):I?e.jsx("div",{className:Pt("font-medium",d),children:I}):null},[l,i,s,a,d,b,v]);if(!t||!(s!=null&&s.length))return null;const w=s.length===1&&n!=="dot";return e.jsxs("div",{ref:_,className:Pt("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[w?null:j,e.jsx("div",{className:"grid gap-1.5",children:s.map((N,C)=>{const A=`${f||N.name||N.dataKey||"value"}`,I=$0e(b,N,A),L=p||N.payload.fill||N.color;return e.jsx("div",{className:Pt("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",n==="dot"&&"items-center"),children:u&&(N==null?void 0:N.value)!==void 0&&N.name?u(N.value,N.name,N,C,N.payload):e.jsxs(e.Fragment,{children:[I!=null&&I.icon?e.jsx(I.icon,{}):!o&&e.jsx("div",{className:Pt("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":w&&n==="dashed"}),style:{"--color-bg":L,"--color-border":L}}),e.jsxs("div",{className:Pt("flex flex-1 justify-between leading-none",w?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[w?j:null,e.jsx("span",{className:"text-muted-foreground",children:(I==null?void 0:I.label)||N.name})]}),N.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:N.value.toLocaleString()})]})]})},N.dataKey)})})]})});uJe.displayName="ChartTooltip";const Xms=S.forwardRef(({className:t,hideIcon:s=!1,payload:r,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=cJe();return r!=null&&r.length?e.jsx("div",{ref:o,className:Pt("flex items-center justify-center gap-4",n==="top"?"pb-3":"pt-3",t),children:r.map(i=>{const d=`${a||i.dataKey||"value"}`,u=$0e(l,i,d);return e.jsxs("div",{className:Pt("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[u!=null&&u.icon&&!s?e.jsx(u.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:i.color}}),u==null?void 0:u.label]},i.value)})}):null});Xms.displayName="ChartLegend";function $0e(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 SR=["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 P2e({stats:t,year:s}){const r=t.transactionsByMonth.some(a=>a.count>0),n=t.leadSourceBreakdown.length>0;return!r&&!n?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12 text-center text-muted-foreground",children:"Add transactions to see your performance charts"})}):e.jsxs("div",{className:"grid gap-6",children:[r&&e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Transactions by Month"})}),e.jsx(Oe,{className:"overflow-hidden",children:e.jsx(dJe,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:e.jsx(Fye,{width:"100%",height:"100%",children:e.jsxs(Gms,{data:t.transactionsByMonth,margin:{top:5,right:10,left:0,bottom:5},children:[e.jsx(WQe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(kce,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),e.jsx(Nce,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),e.jsx(jg,{content:e.jsx(uJe,{})}),e.jsx(uS,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Oe,{children:[e.jsx("div",{className:"h-[250px]",children:e.jsx(Fye,{width:"100%",height:"100%",children:e.jsxs(Kms,{children:[e.jsx(iv,{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(Jle,{fill:SR[o%SR.length]},`cell-${o}`))}),e.jsx(jg,{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:SR[o%SR.length]}}),e.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function Qms(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=e_e(s,n,new Date);if(Age(a))return ws(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(Age(n))return ws(n,"yyyy-MM-dd")}catch{}return null}const Jms=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function eps({open:t,onOpenChange:s}){const[r,n]=S.useState([]),[a,o]=S.useState(!1),[l,i]=S.useState(0),{data:d}=wM(),{data:u}=Ef(),p=Xoe(),f=()=>{const N=Jms.join(","),C=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),A=`${N} ${C}`,I=new Blob([A],{type:"text/csv"}),L=URL.createObjectURL(I),R=document.createElement("a");R.href=L,R.download="transaction-import-template.csv",R.click(),URL.revokeObjectURL(L)},v=N=>{const C=N.split(` `).filter(I=>I.trim());if(C.length<2)return[];const A=C[0].split(",").map(I=>I.trim().toLowerCase().replace(/['"]/g,""));return C.slice(1).map((I,L)=>{var ae,le,pe,be;const R=[];let $="",q=!1;for(const ye of I)ye==='"'?q=!q:ye===","&&!q?(R.push($.trim()),$=""):$+=ye;R.push($.trim());const U=ye=>{var ke;const we=A.indexOf(ye);return we>=0?(ke=R[we])==null?void 0:ke.replace(/^["']|["']$/g,"").trim():""},V=(ae=U("transaction_type"))==null?void 0:ae.toLowerCase(),X=(le=U("sale_price"))==null?void 0:le.replace(/[$,]/g,""),se=(pe=U("commission_amount"))==null?void 0:pe.replace(/[$,]/g,""),te=(be=U("is_win"))==null?void 0:be.toLowerCase(),Y=U("close_date"),de=Qms(Y);let ie;return U("property_address")?["buyer","seller"].includes(V)?de?(!X||isNaN(Number(X)))&&(ie="Invalid sale price"):ie=`Invalid date format: "${Y}" - use MM/DD/YYYY or YYYY-MM-DD`:ie='Transaction type must be "buyer" or "seller"':ie="Missing property address",{property_address:U("property_address"),city:U("city"),state:U("state"),zip:U("zip"),transaction_type:V==="seller"?"seller":"buyer",close_date:de||"",sale_price:Number(X)||0,commission_amount:se?Number(se):null,lead_source_name:U("lead_source"),client_type_name:U("client_type"),is_win:["yes","true","1"].includes(te),notes:U("notes"),error:ie}})},_=N=>{var I;const C=(I=N.target.files)==null?void 0:I[0];if(!C)return;const A=new FileReader;A.onload=L=>{var q;const R=(q=L.target)==null?void 0:q.result,$=v(R);n($)},A.readAsText(C)},b=async()=>{const N=r.filter(I=>!I.error);if(N.length===0){fe.error("No valid transactions to import");return}o(!0),i(0);let C=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 p.mutateAsync({property_address:L.property_address,city:L.city||null,state:L.state||null,zip:L.zip||null,transaction_type:L.transaction_type,close_date:L.close_date,sale_price:L.sale_price,commission_amount:L.commission_amount,lead_source_id:(R==null?void 0:R.id)||null,client_type_id:($==null?void 0:$.id)||null,contact_id:null,notes:L.notes||null,is_win:L.is_win}),C++}catch(R){A++,console.error("Failed to import transaction:",R)}i(Math.round((I+1)/N.length*100))}o(!1),C>0&&fe.success(`Imported ${C} transaction${C>1?"s":""}`),A>0&&fe.error(`Failed to import ${A} transaction${A>1?"s":""}`),n([]),s(!1)},j=r.filter(N=>!N.error).length,w=r.filter(N=>N.error).length;return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(K,{variant:"outline",onClick:f,children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Template"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(at,{variant:"outline",children:[r.length," rows found"]}),j>0&&e.jsxs(at,{className:"bg-green-500 text-white",children:[e.jsx(ua,{className:"h-3 w-3 mr-1"}),j," valid"]}),w>0&&e.jsxs(at,{variant:"destructive",children:[e.jsx(Qo,{className:"h-3 w-3 mr-1"}),w," errors"]})]}),e.jsx(Bi,{className:"h-[200px] border rounded-lg",children:e.jsxs("div",{className:"p-2 space-y-2",children:[r.slice(0,10).map((N,C)=>e.jsxs("div",{className:`p-2 rounded text-sm ${N.error?"bg-destructive/10":"bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:N.property_address||"(no address)"}),e.jsx(at,{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(awe,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(iwe,{className:"text-xs",children:N.error})})]},C)),r.length>10&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["...and ",r.length-10," more"]})]})}),a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${l}%`}})}),e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:["Importing... ",l,"%"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:b,disabled:j===0||a,children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Import ",j," Transaction",j!==1?"s":""]})]})]})]})})}const tps=sS({transactions_goal:WP().min(0).optional(),volume_goal:WP().min(0).optional(),gci_goal:WP().min(0).optional()});function sps({open:t,onOpenChange:s,year:r,existingGoals:n}){const a=U5t(),{data:o}=Qoe(),l=(o==null?void 0:o.show_commission)??!0,i=Roe({resolver:Foe(tps),defaultValues:{transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0}});S.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(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{children:[r," Goals"]}),e.jsx(Kr,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(zoe,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(d),className:"space-y-4",children:[e.jsx(bc,{control:i.control,name:"transactions_goal",render:({field:u})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Transactions Goal"}),e.jsx(hc,{children:e.jsx(Re,{type:"number",placeholder:"e.g., 24",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(nre,{children:"Total number of deals you want to close"}),e.jsx(Eh,{})]})}),e.jsx(bc,{control:i.control,name:"volume_goal",render:({field:u})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Volume Goal ($)"}),e.jsx(hc,{children:e.jsx(Re,{type:"number",placeholder:"e.g., 5000000",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(nre,{children:"Total sales volume you want to achieve"}),e.jsx(Eh,{})]})}),l&&e.jsx(bc,{control:i.control,name:"gci_goal",render:({field:u})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"GCI Goal ($)"}),e.jsx(hc,{children:e.jsx(Re,{type:"number",placeholder:"e.g., 150000",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(nre,{children:"Gross commission income target"}),e.jsx(Eh,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:a.isPending,children:"Save Goals"})]})]})})]})})}function I2e({transactions:t,isLoading:s}){const r=S.useRef(null),n=S.useRef(null),a=S.useRef([]),o=S.useRef(null),{isAdmin:l}=Gs(),[i,d]=S.useState(""),[u,p]=S.useState(!0),[f,v]=S.useState(0),[_,b]=S.useState(!1),j=t.filter(N=>N.latitude!=null&&N.longitude!=null),w=t.filter(N=>N.latitude==null||N.longitude==null);return S.useEffect(()=>{(async()=>{p(!0);try{const{data:C}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();C!=null&&C.value&&d(C.value)}catch(C){console.error("Error fetching mapbox token:",C)}p(!1)})()},[]),S.useEffect(()=>{if(!i||w.length===0||_)return;(async()=>{var A;b(!0);let C=0;for(const I of w){const L=[I.property_address,I.city,I.state,I.zip].filter(Boolean).join(", ");if(L)try{const $=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,U]=$.features[0].center;await G.from("scorecard_transactions").update({latitude:U,longitude:q}).eq("id",I.id),I.latitude=U,I.longitude=q,C++}}catch(R){console.error("Geocode error:",R)}}v(C),b(!1)})()},[i,t]),S.useEffect(()=>{if(!r.current||!i||n.current)return;qc.accessToken=i;const N=t.filter(I=>I.latitude!=null&&I.longitude!=null);let C=[-98.5795,39.8283],A=4;if(N.length>0){const I=N.reduce((R,$)=>R+$.longitude,0)/N.length,L=N.reduce((R,$)=>R+$.latitude,0)/N.length;C=[I,L],A=N.length===1?12:10}return n.current=new qc.Map({container:r.current,style:"mapbox://styles/mapbox/light-v11",zoom:A,center:C}),n.current.addControl(new qc.NavigationControl,"top-right"),()=>{var I;(I=n.current)==null||I.remove(),n.current=null}},[i]),S.useEffect(()=>{var C;if(!n.current||!i)return;a.current.forEach(A=>A.remove()),a.current=[],(C=o.current)==null||C.remove();const N=t.filter(A=>A.latitude!=null&&A.longitude!=null);if(N.forEach(A=>{var U;const I=A.transaction_type==="buyer",L=I?"#3B82F6":"#10B981",R=document.createElement("div");R.className="cursor-pointer",R.innerHTML=`
${I?'':''}
`;const $=new qc.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: ${fl(A.close_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${(U=A.lead_source)!=null&&U.name?" · "+A.lead_source.name:""}
${A.contact?`
Client: ${A.contact.first_name} ${A.contact.last_name||""}
`:""}
`),q=new qc.Marker(R).setLngLat([A.longitude,A.latitude]).setPopup($).addTo(n.current);a.current.push(q)}),N.length>1){const A=new qc.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(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center h-[50vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(Ai,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"No Transactions Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add transactions to see them plotted on the map."})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#3B82F6"}}),e.jsx("span",{children:"Buyer"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#10B981"}}),e.jsx("span",{children:"Seller"})]}),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[j.length," of ",t.length," mapped",_&&" · Geocoding..."]})]}),e.jsx("div",{ref:r,className:"w-full h-[55vh] rounded-lg shadow-lg border"})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(Qo,{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 hJe=()=>{const{data:t}=Mf();return Ct({queryKey:["team-scorecard-members",t==null?void 0:t.teamId],queryFn:async()=>{const{data:s,error:r}=await G.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 G.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"})},rps=t=>{const{data:s}=Mf(),{data:r}=hJe();return Ct({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 G.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 nps(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 aps(t,s){return t?t.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2):s[0].toUpperCase()}function ips({year:t}){var v;const{data:s,isLoading:r}=hJe(),{data:n,isLoading:a}=rps(t),o=Dr(),l=r||a,{aggregate:i,memberStats:d,topPerformer:u,agentNameMap:p,teamChartStats:f}=S.useMemo(()=>{if(!s||!n)return{aggregate:null,memberStats:[],topPerformer:null,agentNameMap:{},teamChartStats:null};const _=s.map(V=>nps(V,n));_.sort((V,X)=>X.totalVolume-V.totalVolume);const b={};s.forEach(V=>{b[V.id]=V.name||V.email});const j=n.length,w=n.reduce((V,X)=>V+Number(X.sale_price),0),N=n.reduce((V,X)=>V+(Number(X.commission_amount)||0),0),C=n.filter(V=>V.transaction_type==="buyer").length,A=n.filter(V=>V.transaction_type==="seller").length,I={};n.forEach(V=>{var se;const X=((se=V.lead_source)==null?void 0:se.name)||"Unknown";I[X]=(I[X]||0)+1});const L=Object.entries(I).sort((V,X)=>X[1]-V[1])[0],R={};n.forEach(V=>{const X=fl(V.close_date).toLocaleString("default",{month:"short"});R[X]=(R[X]||0)+1});const q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(V=>({month:V,count:R[V]||0})),U=Object.entries(I).map(([V,X])=>({name:V,count:X})).sort((V,X)=>X.count-V.count);return{aggregate:{totalTxns:j,buyerCount:C,sellerCount:A,totalVolume:w,avgPrice:j>0?w/j: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:U}}},[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(Ee,{className:"py-12",children:e.jsxs(Oe,{className:"text-center space-y-2",children:[e.jsx(hr,{className:"h-10 w-10 mx-auto text-muted-foreground"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No Team Data"}),e.jsxs("p",{className:"text-muted-foreground",children:["No scorecard transactions found for your team members in ",t,"."]})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Members"})]}),e.jsx("p",{className:"text-2xl font-bold",children:i.memberCount})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Team Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:i.totalTxns}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.buyerCount,"B / ",i.sellerCount,"S"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Kc,{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:Tl(i.totalVolume,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Cc,{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:Tl(i.avgPrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Kc,{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:Tl(i.totalGCI,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{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(Ee,{className:"border-primary/30 bg-primary/5",children:e.jsxs(Oe,{className:"pt-4 flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center justify-center h-10 w-10 rounded-full bg-primary/10",children:e.jsx(Ki,{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:Tl(u.totalVolume,!0)})]})]})}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-lg",children:"Member Performance"})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Agent"}),e.jsx(jt,{className:"text-center",children:"Transactions"}),e.jsx(jt,{className:"text-center",children:"B / S"}),e.jsx(jt,{className:"text-right",children:"Volume"}),e.jsx(jt,{className:"text-right",children:"Avg Price"}),e.jsx(jt,{className:"text-right",children:"GCI"}),e.jsx(jt,{className:"text-right"})]})}),e.jsx(Pn,{children:d.map((_,b)=>e.jsxs(js,{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(Ki,{className:"absolute -top-2 -right-2 h-3.5 w-3.5 text-amber-500"}),e.jsxs(gn,{className:"h-8 w-8",children:[e.jsx(Ea,{src:_.member.avatar_url||void 0}),e.jsx(xn,{className:"text-xs",children:aps(_.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:Tl(_.totalVolume,!0)}),e.jsx(lt,{className:"text-right text-sm",children:Tl(_.averagePrice,!0)}),e.jsx(lt,{className:"text-right font-medium",children:Tl(_.totalGCI,!0)}),e.jsx(lt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>o(`/mission-control/scorecard/${_.member.id}`),children:e.jsx(ya,{className:"h-4 w-4"})})})]},_.member.id))})]})})})]}),e.jsxs(Na,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsxs(ks,{value:"transactions",children:[e.jsx(Uh,{className:"h-4 w-4 mr-1"}),"All Transactions"]}),e.jsxs(ks,{value:"charts",children:[e.jsx(Xo,{className:"h-4 w-4 mr-1"}),"Charts"]}),e.jsxs(ks,{value:"map",children:[e.jsx(Ai,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(zs,{value:"transactions",children:e.jsx(kwe,{transactions:n||[],showCommission:!0,isLoading:a,agentNameMap:p,readOnly:!0})}),e.jsx(zs,{value:"charts",children:f&&e.jsx(P2e,{stats:f,year:t})}),e.jsx(zs,{value:"map",children:e.jsx(I2e,{transactions:n||[],isLoading:a})})]})]})}const mJe=new Date().getFullYear(),vLe=Array.from({length:10},(t,s)=>mJe-s);function ops(){var U;const[t,s]=S.useState(mJe),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(!1),[d,u]=S.useState(!1),[p,f]=S.useState("my"),{data:v}=Mf(),_=(v==null?void 0:v.role)==="team_leader",{data:b,isLoading:j}=ibe(t),{yearStats:w,lifetimeStats:N,showCommission:C}=vVe(t),{data:A,isLoading:I}=yVe(t),{data:L}=Qoe(),R=V5t(),$=()=>{if(!b||b.length===0)return;const V=["Property Address","City","State","Zip","Transaction Type","Close Date","Sale Price",...C?["Commission"]:[],"Lead Source","Client Type","Contact Name","Is Win","Notes"],X=b.map(ie=>{var ae,le;return[ie.property_address,ie.city||"",ie.state||"",ie.zip||"",ie.transaction_type,ie.close_date,ie.sale_price,...C?[ie.commission_amount||""]:[],((ae=ie.lead_source)==null?void 0:ae.name)||"",((le=ie.client_type)==null?void 0:le.name)||"",ie.contact?`${ie.contact.first_name} ${ie.contact.last_name||""}`.trim():"",ie.is_win?"Yes":"No",ie.notes||""]}),se=[V,...X].map(ie=>ie.map(ae=>`"${String(ae).replace(/"/g,'""')}"`).join(",")).join(` `),te=new Blob([se],{type:"text/csv"}),Y=URL.createObjectURL(te),de=document.createElement("a");de.href=Y,de.download=`transactions-${t}.csv`,de.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(K,{variant:p==="my"?"default":"ghost",size:"sm",onClick:()=>f("my"),className:"h-8",children:"My Scorecard"}),e.jsxs(K,{variant:p==="team"?"default":"ghost",size:"sm",onClick:()=>f("team"),className:"h-8",children:[e.jsx(hr,{className:"h-4 w-4 mr-1.5"}),"Team"]})]}),p==="team"&&_?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:V=>s(Number(V)),children:[e.jsx(Js,{className:"w-[120px]",children:e.jsx(sr,{})}),e.jsx(er,{children:vLe.map(V=>e.jsx(At,{value:String(V),children:V},V))})]})]}),e.jsx(ips,{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:V=>s(Number(V)),children:[e.jsx(Js,{className:"w-[120px]",children:e.jsx(sr,{})}),e.jsx(er,{children:vLe.map(V=>e.jsx(At,{value:String(V),children:V},V))})]}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(!d),children:e.jsx($l,{className:"h-4 w-4"})})]})]}),d&&e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(zt,{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(ve,{children:"Show Commission"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display commission fields and include in stats"})]}),e.jsx(Br,{checked:(L==null?void 0:L.show_commission)??!0,onCheckedChange:V=>R.mutate({show_commission:V})})]})})]}),q&&!j?e.jsx(Ee,{className:"py-12",children:e.jsxs(Oe,{className:"text-center space-y-4",children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Xo,{className:"h-8 w-8 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Start Tracking Your Success"}),e.jsx("p",{className:"text-muted-foreground max-w-md mx-auto mt-1",children:"Add your past transactions to see your performance metrics, track your goals, and celebrate your wins."})]}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Your First Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Import CSV"]})]}),e.jsxs("div",{className:"pt-4 border-t mt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Need help formatting your data?"}),e.jsx(K,{variant:"link",className:"h-auto p-0",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Download CSV Template"]})})]})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!0),children:[e.jsx(Hh,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(K,{variant:"outline",onClick:$,disabled:q,children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Export"]}),e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"CSV Template"]})})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:w.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[N.totalTransactions," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[w.buyerCount,"/",w.sellerCount]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"B/S split"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Kc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Tl(w.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Tl(N.totalVolume,!0)," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Cc,{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:Tl(w.averagePrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{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:((U=w.topLeadSource)==null?void 0:U.name)||"-"}),w.topLeadSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w.topLeadSource.count," deals"]})]})}),C&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Kc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Tl(w.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Tl(N.totalCommission,!0)," lifetime"]})]})}),C&&w.totalNetToAgent>0&&w.totalNetToAgent!==w.totalCommission&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-teal-600 dark:text-teal-400 mb-1",children:[e.jsx(Kc,{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:Tl(w.totalNetToAgent,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Tl(N.totalNetToAgent,!0)," lifetime"]})]})})]}),A&&e.jsx(wZe,{goals:A,stats:w,year:t,showCommission:C}),e.jsxs(Na,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsx(ks,{value:"transactions",children:"Transactions"}),e.jsx(ks,{value:"charts",children:"Charts"}),e.jsxs(ks,{value:"map",children:[e.jsx(Ai,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(zs,{value:"transactions",children:e.jsx(kwe,{transactions:b||[],showCommission:C,isLoading:j})}),e.jsx(zs,{value:"charts",children:e.jsx(P2e,{stats:w,year:t})}),e.jsx(zs,{value:"map",children:e.jsx(I2e,{transactions:b||[],isLoading:j})})]})]})]})]}),e.jsx(bZe,{open:r,onOpenChange:n}),e.jsx(eps,{open:a,onOpenChange:o}),e.jsx(sps,{open:l,onOpenChange:i,year:t,existingGoals:A})]})}function pJe({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=Gs(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,f]=S.useState(!1);S.useEffect(()=>{(async()=>{if(!(!t||!o)){u(!0);try{const{data:w,error:N}=await G.from("listing_shares").select("id, share_token, click_count, lead_count").eq("listing_id",r).eq("sharing_agent_id",o.id).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(N)throw N;if(w&&w.share_token)i(w);else if(w&&!w.share_token){const{data:C,error:A}=await G.from("listing_shares").update({share_type:"referral_link"}).eq("id",w.id).select("id, share_token, click_count, lead_count").single();if(A)throw A;i(C)}else{const{data:C,error:A}=await G.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(C)}}catch(w){console.error("Error creating share link:",w),fe.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),f(!0),fe.success("Link copied to clipboard!"),setTimeout(()=>f(!1),2e3)}catch{fe.error("Failed to copy link")}},b=j=>{const w=encodeURIComponent(v),N=encodeURIComponent(`Check out this listing: ${a}`);switch(j){case"email":window.open(`mailto:?subject=${N}&body=${w}`);break;case"text":window.open(`sms:?body=${N}%20${w}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${w}`,"_blank");break}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(hn,{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(ve,{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(K,{onClick:_,disabled:d||!v,variant:p?"default":"outline",children:p?e.jsx(ua,{className:"h-4 w-4"}):e.jsx(ni,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Share via"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("email"),disabled:d,children:[e.jsx(_r,{className:"h-4 w-4 mr-2"}),"Email"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("text"),disabled:d,children:[e.jsx(oo,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("facebook"),disabled:d,children:[e.jsx(Hd,{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(ve,{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(ya,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Clicks"})]}),e.jsx("p",{className:"text-2xl font-bold",children:l.click_count})]}),e.jsxs("div",{className:"bg-primary/10 rounded-lg p-3 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 text-primary mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Leads"})]}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:l.lead_count})]})]})]})]})]})})}const lps={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},cps={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},dps={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function CR({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var j,w;const{user:o}=Gs(),{data:l}=hVe(t.id),i=uVe(),[d,u]=S.useState(!1),p=N=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(N),f=((j=t.photos)==null?void 0:j.find(N=>N.is_primary))||((w=t.photos)==null?void 0:w[0]),v=(o==null?void 0:o.id)===t.agent_id,_=async N=>{N.stopPropagation();try{const C=await i.mutateAsync(t.id);fe.success(C.saved?"Listing saved!":"Listing removed from saved")}catch{fe.error("Failed to save listing")}},b=N=>{if(N.stopPropagation(),o)u(!0);else{const C=`https://listings.relevelup.com/${t.slug||t.id}`;navigator.clipboard.writeText(C),fe.success("Link copied to clipboard!")}};return e.jsxs(Ee,{className:"overflow-hidden hover:shadow-lg transition-shadow cursor-pointer group",onClick:s,children:[e.jsxs("div",{className:"relative aspect-[4/3] bg-muted",children:[f?e.jsx("img",{src:f.photo_url,alt:t.property_address||t.city,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(Zx,{className:"h-12 w-12"})}),e.jsx(at,{className:`absolute top-2 left-2 ${lps[t.status]} text-white border-0`,children:cps[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(K,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:_,children:e.jsx(Si,{className:`h-4 w-4 ${l?"fill-pink-500 text-pink-500":""}`})}),e.jsx(K,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:b,title:v?"Copy link":"Share & earn leads",children:v?e.jsx(cd,{className:"h-4 w-4"}):e.jsx(hn,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(pJe,{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:p(t.price)}),t.open_to_referrals&&e.jsxs(at,{variant:"outline",className:"text-xs",children:[e.jsx(hr,{className:"h-3 w-3 mr-1"}),"Referrals"]})]}),e.jsxs("div",{children:[t.property_address&&e.jsx("p",{className:"font-medium truncate",children:t.property_address}),e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Ai,{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(N0,{className:"h-4 w-4"}),t.bedrooms," bd"]}),t.bathrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Vx,{className:"h-4 w-4"}),t.bathrooms," ba"]}),t.square_footage&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Zx,{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(at,{variant:"secondary",className:"text-xs",children:dps[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(ya,{className:"h-3 w-3"}),t.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(cd,{className:"h-3 w-3"}),t.share_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Si,{className:"h-3 w-3"}),t.save_count]})]}),a&&(r||n)&&e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1",onClick:N=>{N.stopPropagation(),r()},children:[e.jsx(Oc,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(K,{variant:"destructive",size:"sm",onClick:N=>{N.stopPropagation(),n()},children:e.jsx(br,{className:"h-4 w-4"})})]})]})]})}const ups=[{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"}],hps=[{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 mps({filters:t,onFiltersChange:s,onClose:r}){const n=()=>{s({sortBy:"newest"})};return e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(zt,{className:"text-lg",children:"Filters"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Clear All"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Ur,{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(ve,{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(sr,{placeholder:"All statuses"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Statuses"}),ups.map(a=>e.jsx(At,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(sr,{placeholder:"All types"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Types"}),hps.map(a=>e.jsx(At,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(ve,{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(ve,{children:"Open to Referrals Only"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show only listings accepting buyer referrals"})]}),e.jsx(Br,{checked:t.openToReferrals||!1,onCheckedChange:a=>s({...t,openToReferrals:a||void 0})})]})]})]})}function pps({leaderboard:t}){const s=n=>{switch(n){case 0:return e.jsx(Ki,{className:"h-5 w-5 text-amber-500"});case 1:return e.jsx(E0,{className:"h-5 w-5 text-gray-400"});case 2:return e.jsx(rc,{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(at,{variant:l===0?"default":"secondary",children:[o.count," ",a]})]},o.agentId))});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Ki,{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(cd,{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(Un,{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(E0,{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(Ki,{className:"h-6 w-6 text-amber-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Community MVP"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Top performer"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Community Leaderboard"})}),e.jsx(Oe,{children:e.jsxs(Na,{defaultValue:"sharers",children:[e.jsxs(va,{className:"w-full",children:[e.jsxs(ks,{value:"sharers",className:"flex-1",children:[e.jsx(cd,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),e.jsxs(ks,{value:"listers",className:"flex-1",children:[e.jsx(Un,{className:"h-4 w-4 mr-2"}),"Top Contributors"]})]}),e.jsx(zs,{value:"sharers",className:"mt-4",children:r(t==null?void 0:t.topSharers,"shares")}),e.jsx(zs,{value:"listers",className:"mt-4",children:r(t==null?void 0:t.topListers,"listings")})]})})]})]})}const _Le={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},bLe={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function fps(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function gps({listings:t,isLoading:s}){const r=Dr(),n=S.useRef(null),a=S.useRef(null),o=S.useRef([]),{isAdmin:l}=Gs(),[i,d]=S.useState(""),[u,p]=S.useState(!0),[f,v]=S.useState(!1),_=t.filter(j=>j.latitude!=null&&j.longitude!=null),b=t.filter(j=>(j.latitude==null||j.longitude==null)&&(j.property_address||j.city));return S.useEffect(()=>{(async()=>{p(!0);try{const{data:w}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();w!=null&&w.value&&d(w.value)}catch(w){console.error("Error fetching mapbox token:",w)}p(!1)})()},[]),S.useEffect(()=>{if(!i||b.length===0||f)return;(async()=>{var w;v(!0);for(const N of b){const C=[N.property_address,N.city,N.state].filter(Boolean).join(", ");if(C)try{const I=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(C)}.json?access_token=${i}&limit=1`)).json();if((w=I.features)!=null&&w[0]){const[L,R]=I.features[0].center;await G.from("listings").update({latitude:R,longitude:L}).eq("id",N.id),N.latitude=R,N.longitude=L}}catch(A){console.error("Geocode error:",A)}}v(!1)})()},[i,t]),S.useEffect(()=>{if(!n.current||!i||a.current)return;qc.accessToken=i;const j=t.filter(C=>C.latitude!=null&&C.longitude!=null);let w=[-98.5795,39.8283],N=4;if(j.length>0){const C=j.reduce((I,L)=>I+L.longitude,0)/j.length,A=j.reduce((I,L)=>I+L.latitude,0)/j.length;w=[C,A],N=j.length===1?12:10}return a.current=new qc.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:N,center:w}),a.current.addControl(new qc.NavigationControl,"top-right"),()=>{var C;(C=a.current)==null||C.remove(),a.current=null}},[i]),S.useEffect(()=>{if(!a.current||!i)return;o.current.forEach(w=>w.remove()),o.current=[];const j=t.filter(w=>w.latitude!=null&&w.longitude!=null);if(j.forEach(w=>{var R,$,q;const N=_Le[w.status]||"#10B981",C=((R=w.photos)==null?void 0:R.find(U=>U.is_primary))||(($=w.photos)==null?void 0:$[0]),A=document.createElement("div");A.className="cursor-pointer",A.innerHTML=`
`;const I=new qc.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${C!=null&&C.photo_url?``:""}
${fps(w.price)}
${w.property_address||""}
${w.city}, ${w.state}
${bLe[w.status]||w.status} ${w.bedrooms?`${w.bedrooms} bed`:""} ${w.bathrooms?`${w.bathrooms} bath`:""}
${(q=w.agent)!=null&&q.name?`
Listed by ${w.agent.name}
`:""}
Click to view details →
`),L=new qc.Marker(A).setLngLat([w.longitude,w.latitude]).setPopup(I).addTo(a.current);o.current.push(L)}),j.length>1){const w=new qc.LngLatBounds;j.forEach(N=>w.extend([N.longitude,N.latitude])),a.current.fitBounds(w,{padding:60,maxZoom:13})}else j.length===1&&a.current.flyTo({center:[j[0].longitude,j[0].latitude],zoom:12})},[t,i,f]),S.useEffect(()=>(window.__navigateToListing__=j=>{r(`/mission-control/listings/${j}`)},()=>{delete window.__navigateToListing__}),[r]),u||s?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center h-[60vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(Ai,{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(_Le).map(([j,w])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:w}}),e.jsx("span",{className:"text-xs",children:bLe[j]})]},j)),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[_.length," of ",t.length," mapped",f&&" · Geocoding..."]})]}),e.jsx("div",{ref:n,className:"w-full h-[60vh] rounded-lg shadow-lg border"})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(Qo,{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 xps(){var U,V,X,se,te,Y,de,ie;const t=Dr(),{brokerageId:s}=Gs(),{data:r,isLoading:n}=iVe(),[a,o]=S.useState("feed"),[l,i]=S.useState(!1),[d,u]=S.useState(""),[p,f]=S.useState({sortBy:"newest"}),{data:v,isLoading:_}=oVe({...p,city:d||p.city}),{data:b,isLoading:j}=S5t(),{data:w,isLoading:N}=lVe(),{data:C,isLoading:A}=A5t(),{data:I,isLoading:L}=I5t(),{data:R}=P5t(),$=dVe(),q=async ae=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await $.mutateAsync(ae),fe.success("Listing deleted successfully")}catch{fe.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(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Un,{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(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-pink-500/10 rounded-lg",children:e.jsx(Si,{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(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-emerald-500/10 rounded-lg",children:e.jsx(Qk,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(w==null?void 0:w.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"My Listings"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:e.jsx(hr,{className:"h-5 w-5 text-sky-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(((U=C==null?void 0:C.sent)==null?void 0:U.length)||0)+(((V=C==null?void 0:C.received)==null?void 0:V.length)||0)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Referrals"})]})]})})]}),e.jsxs(Na,{value:a,onValueChange:o,children:[e.jsxs(va,{className:"w-full justify-start overflow-x-auto",children:[e.jsx(ks,{value:"feed",children:"Community Feed"}),s&&e.jsx(ks,{value:"brokerage",children:"Brokerage"}),e.jsx(ks,{value:"my-listings",children:"My Listings"}),e.jsx(ks,{value:"saved",children:"Saved"}),e.jsx(ks,{value:"referrals",children:"Referrals"}),e.jsx(ks,{value:"map",children:"Map"}),e.jsx(ks,{value:"leaderboard",children:"Leaderboard"})]}),e.jsxs(zs,{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(fn,{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:ae=>u(ae.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:p.sortBy,onValueChange:ae=>f({...p,sortBy:ae}),children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{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(K,{variant:"outline",onClick:()=>i(!l),children:[e.jsx(Hx,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&e.jsx(mps,{filters:p,onFiltersChange:f,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((ae,le)=>e.jsxs(Ee,{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"})]})]},le))}):(v==null?void 0:v.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Un,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No listings found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Be the first to share a listing with the community!"}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Zs,{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(ae=>e.jsx(CR,{listing:ae,onClick:()=>t(`/mission-control/listings/${ae.id}`)},ae.id))})]}),e.jsx(zs,{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((ae,le)=>e.jsxs(Ee,{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"})]})]},le))}):(w==null?void 0:w.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Qk,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No listings yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Share your listings with the LevelUp community!"}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Your First Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w==null?void 0:w.map(ae=>e.jsx(CR,{listing:ae,showActions:!0,onClick:()=>t(`/mission-control/listings/${ae.id}`),onEdit:()=>t(`/mission-control/listings/${ae.id}/edit`),onDelete:()=>q(ae.id)},ae.id))})}),e.jsx(zs,{value:"saved",className:"space-y-4",children:j?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ae,le)=>e.jsxs(Ee,{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"})]})]},le))}):(b==null?void 0:b.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Si,{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(ae=>e.jsx(CR,{listing:ae.listing,onClick:()=>t(`/mission-control/listings/${ae.listing.id}`)},ae.id))})}),e.jsx(zs,{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(cd,{className:"h-4 w-4"}),"Referrals Sent (",((X=C==null?void 0:C.sent)==null?void 0:X.length)||0,")"]}),((se=C==null?void 0:C.sent)==null?void 0:se.length)===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No referrals sent yet"})}):e.jsx("div",{className:"space-y-3",children:(te=C==null?void 0:C.sent)==null?void 0:te.map(ae=>{var le,pe;return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:ae.buyer_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((le=ae.listing)==null?void 0:le.property_address)||((pe=ae.listing)==null?void 0:pe.city)})]}),e.jsx(at,{variant:ae.status==="closed"?"default":"secondary",children:ae.status.replace("_"," ")})]})})},ae.id)})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Referrals Received (",((Y=C==null?void 0:C.received)==null?void 0:Y.length)||0,")"]}),((de=C==null?void 0:C.received)==null?void 0:de.length)===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):e.jsx("div",{className:"space-y-3",children:(ie=C==null?void 0:C.received)==null?void 0:ie.map(ae=>{var le;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:ae.buyer_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["From: ",(le=ae.sender)==null?void 0:le.name]})]}),e.jsx(at,{variant:ae.status==="closed"?"default":"secondary",children:ae.status.replace("_"," ")})]}),e.jsx(K,{size:"sm",variant:"outline",className:"w-full mt-2",onClick:()=>t(`/mission-control/listings/${ae.listing_id}`),children:"View Listing"})]})},ae.id)})})]})]})}),s&&e.jsx(zs,{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((ae,le)=>e.jsxs(Ee,{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"})]})]},le))}):(I==null?void 0:I.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Qk,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No brokerage listings yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No agents in your brokerage have added listings yet."}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Zs,{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(ae=>e.jsx(CR,{listing:ae,onClick:()=>t(`/mission-control/listings/${ae.id}`)},ae.id))})}),e.jsx(zs,{value:"map",children:e.jsx(gps,{listings:v||[],isLoading:_})}),e.jsx(zs,{value:"leaderboard",children:e.jsx(pps,{leaderboard:R})})]})]})}):e.jsx(Ms,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Un,{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 L2e(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 Cce(){const t=ti();return Ct({queryKey:["deal-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function fJe(){const t=ti(),s=ns();return Ot({mutationFn:async()=>{if(!t)throw new Error("Not authenticated");const{error:r}=await G.rpc("initialize_deal_pipeline_stages",{p_user_id:t});if(r)throw r},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-stages"]})}})}function Mce(){const t=ti();return Ct({queryKey:["deal-pipeline-deals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.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 gJe(){const t=ti(),s=ns();return Ot({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.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 G.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 xJe(){const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.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 yps(){const t=ns();return Ot({mutationFn:async({dealId:s,stageId:r,stageName:n})=>{const{data:a,error:o}=await G.from("deal_pipeline").update({stage_id:r}).eq("id",s).select().single();if(o)throw o;return await G.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 vps(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.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 _ps(t){return Ct({queryKey:["deal-activities",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_activities").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function bps(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.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 wps(t){return Ct({queryKey:["deal-checklist",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_checklist_items").select("*").eq("deal_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function jps(){const t=ns();return Ot({mutationFn:async({id:s,is_completed:r,deal_id:n})=>{const{data:a,error:o}=await G.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 kps(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.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 Nps(){const t=ti();return Ct({queryKey:["deal-pipeline-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.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+(L2e(l)||0),0),wonValue:a.reduce((o,l)=>o+(l.expected_price||0),0)}},enabled:!!t})}function Sps(t){const s=ti();return Ct({queryKey:["deal-by-listing",t,s],queryFn:async()=>{if(!s||!t)return null;const{data:r,error:n}=await G.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 Cps(){const t=ns();return Ot({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await G.from("deal_pipeline").update({listing_id:r}).eq("id",s).select().single();if(a)throw a;return await G.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 Mps(){const t=ns();return Ot({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await G.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 Tps({listing:t}){const s=Dr(),[r,n]=S.useState(""),[a,o]=S.useState(!1),{data:l,isLoading:i}=Sps(t.id),{data:d,isLoading:u}=Cce(),{data:p,isLoading:f}=Mce(),v=fJe(),_=Cps(),b=Mps(),j=gJe(),w=(p==null?void 0:p.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(R=>R.name==="Active");case"under_contract":return d.find(R=>R.name==="Under Contract");case"sold":return d.find(R=>R.is_won_stage);default:return d.find(R=>R.name==="Active")}},C=async()=>{o(!0);try{d!=null&&d.length||await v.mutateAsync();const L=N(t.status);await j.mutateAsync({deal_name:t.property_address?`${t.property_address}, ${t.city}`:`${t.city}, ${t.state}`,deal_type:"seller",stage_id:(L==null?void 0:L.id)||null,listing_id:t.id,property_address:t.property_address,city:t.city,state:t.state,expected_price:t.price,expected_commission:t.price*.03,commission_percentage:3,priority:"medium",probability:50}),fe.success("Deal created and linked to listing!")}catch(L){console.error("Failed to create deal:",L),fe.error("Failed to create deal")}finally{o(!1)}},A=async()=>{if(!r){fe.error("Please select a deal");return}try{await _.mutateAsync({dealId:r,listingId:t.id}),fe.success("Listing linked to deal!"),n("")}catch{fe.error("Failed to link listing")}},I=async()=>{if(l)try{await b.mutateAsync({dealId:l.id,listingId:t.id}),fe.success("Listing unlinked from deal")}catch{fe.error("Failed to unlink listing")}};return i||u?e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Wx,{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(As,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?e.jsxs(Ee,{className:"border-primary/20 bg-primary/5",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Ho,{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(at,{variant:"secondary",className:"text-xs",style:{backgroundColor:`${l.deal_pipeline_stages.color}20`,color:l.deal_pipeline_stages.color},children:l.deal_pipeline_stages.name})})]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Status changes sync automatically between the listing and pipeline."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>s("/mission-control/pipeline"),children:["View Pipeline",e.jsx(Fi,{className:"h-3 w-3 ml-1"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:I,disabled:b.isPending,children:b.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(uN,{className:"h-4 w-4"})})]})]})]}):e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Wx,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link this listing to your pipeline to track the deal and sync status changes."}),e.jsxs(K,{onClick:C,disabled:a||j.isPending,className:"w-full",size:"sm",children:[a||j.isPending?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create New Deal"]}),w.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:r,onValueChange:n,children:[e.jsx(Js,{className:"flex-1 text-sm",children:e.jsx(sr,{placeholder:"Link to existing deal..."})}),e.jsx(er,{children:w.map(L=>e.jsx(At,{value:L.id,children:L.deal_name},L.id))})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:A,disabled:!r||_.isPending,children:_.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(Ho,{className:"h-4 w-4"})})]})]})]})]})}const Aps={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Eps={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},wLe={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Pps(){var te,Y,de,ie,ae,le,pe,be,ye;const{listingId:t}=Mo(),s=Dr(),{user:r}=Gs(),{data:n,isLoading:a}=cVe(t||""),{data:o}=hVe(t||""),{data:l}=M5t(t||""),i=uVe(),d=C5t(),u=T5t(),p=dVe(),f=E5t(),[v,_]=S.useState(!1),[b,j]=S.useState(!1),[w,N]=S.useState(!1),[C,A]=S.useState(null),[I,L]=S.useState({buyerName:"",buyerType:"",notes:""}),R=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),$=we=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(we),q=async we=>{const ke=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,Ze=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;u.mutate({listingId:n.id,shareType:we});try{switch(we){case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(ke)}`,"_blank");break;case"copy":await navigator.clipboard.writeText(ke),fe.success("Link copied to clipboard!");break;case"text":window.open(`sms:?body=${encodeURIComponent(`${Ze} ${ke}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent(Ze)}&body=${encodeURIComponent(`Check out this listing: ${ke}`)}`);break}}catch(_e){console.error("Share error:",_e),fe.error("Failed to share")}},U=async()=>{try{await p.mutateAsync(n.id),fe.success("Listing deleted"),s("/mission-control/listings")}catch{fe.error("Failed to delete listing")}},V=async()=>{if(!I.buyerName.trim()){fe.error("Please enter buyer name");return}try{await f.mutateAsync({listingId:n.id,listingAgentId:n.agent_id,buyerName:I.buyerName,buyerType:I.buyerType||void 0,notes:I.notes||void 0}),fe.success("Referral sent successfully!"),j(!1),L({buyerName:"",buyerType:"",notes:""})}catch{fe.error("Failed to send referral")}},X=we=>{var Ae,We;const ke=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,Ze=$((n==null?void 0:n.price)||0),_e=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",Ce=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",Te=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",Fe=[_e,Ce,Te].filter(Boolean).join(" | ");switch(we){case"just_listed":return`🏡 JUST LISTED! ${ke} ${Ze} ${Fe} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(Ae=n==null?void 0:n.city)==null?void 0:Ae.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${ke} Now ${Ze}! ${Fe} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${wLe[(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 #${(We=n==null?void 0:n.city)==null?void 0:We.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(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing could not be found."}),e.jsx(K,{onClick:()=>s("/mission-control/listings"),children:"Back to Listings"})]})})});const se=((te=n.photos)==null?void 0:te.find(we=>we.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(K,{variant:"ghost",onClick:()=>s("/mission-control/listings"),children:[e.jsx(Ua,{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:(de=n.photos)==null?void 0:de.slice(1,5).map((we,ke)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>A(we.photo_url),children:e.jsx("img",{src:we.photo_url,alt:`Photo ${ke+2}`,className:"w-full h-full object-cover"})},we.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(at,{className:`${Aps[n.status]} text-white border-0`,children:Eps[n.status]}),n.is_featured&&e.jsxs(at,{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(at,{variant:"outline",children:[e.jsx(hr,{className:"h-3 w-3 mr-1"}),"Open to Referrals"]})]}),e.jsx("h1",{className:"text-3xl font-bold text-primary mb-2",children:$(n.price)}),n.property_address&&e.jsx("p",{className:"text-xl font-medium",children:n.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(Ai,{className:"h-4 w-4"}),n.city,", ",n.state,n.neighborhood&&` • ${n.neighborhood}`]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>i.mutate(n.id),children:e.jsx(Si,{className:`h-4 w-4 ${o?"fill-pink-500 text-pink-500":""}`})}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>d.mutate(n.id),children:l?e.jsx(X1,{className:"h-4 w-4"}):e.jsx(cf,{className:"h-4 w-4"})}),!R&&e.jsxs(K,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>N(!0),children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Share & Earn Leads"]}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(cd,{className:"h-4 w-4 mr-2"}),"Share"]})}),e.jsxs(Td,{children:[e.jsxs(Ta,{onClick:()=>q("copy"),children:[e.jsx(ni,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),e.jsxs(Ta,{onClick:()=>q("facebook"),children:[e.jsx(Hd,{className:"h-4 w-4 mr-2"}),"Facebook"]}),e.jsxs(Ta,{onClick:()=>q("text"),children:[e.jsx(oo,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(Ta,{onClick:()=>q("email"),children:[e.jsx(_r,{className:"h-4 w-4 mr-2"}),"Email"]})]})]}),R&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/listings/${n.id}/edit`),children:[e.jsx(Oc,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>_(!0),children:e.jsx(br,{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(N0,{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(Vx,{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(Zx,{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(on,{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(at,{variant:"secondary",children:[e.jsx(Aa,{className:"h-3 w-3 mr-1"}),wLe[n.property_type]]}),n.lot_size&&e.jsxs(at,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&e.jsx(at,{variant:"secondary",children:"HOA"})]}),n.description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium mb-2",children:"Description"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.description})]}),n.agent_notes&&n.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.agent_notes})]}),n.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:n.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{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(ya,{className:"h-4 w-4"}),n.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(cd,{className:"h-4 w-4"}),n.share_count," shares"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Si,{className:"h-4 w-4"}),n.save_count," saves"]})]})]})}),n.allow_sharing&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-lg",children:"Share Content"})}),e.jsx(Oe,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(we=>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:[we.replace("_"," ")," Caption"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(X(we)),fe.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:X(we)})]},we))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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:((ae=(ie=n.agent)==null?void 0:ie.name)==null?void 0:ae.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((le=n.agent)==null?void 0:le.name)||"Unknown"}),((be=(pe=n.agent)==null?void 0:pe.brokerage)==null?void 0:be.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:n.agent.brokerage.name})]})]}),!R&&e.jsx("div",{className:"space-y-2",children:((ye=n.agent)==null?void 0:ye.email)&&e.jsx(K,{variant:"outline",className:"w-full",asChild:!0,children:e.jsxs("a",{href:`mailto:${n.agent.email}`,children:[e.jsx(_r,{className:"h-4 w-4 mr-2"}),"Email Agent"]})})})]})]}),R&&e.jsx(Tps,{listing:n}),!R&&n.open_to_referrals&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Send a Buyer"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Have a buyer interested in this property? Send a referral to the listing agent."}),e.jsx(K,{className:"w-full",onClick:()=>j(!0),children:"Send Referral"})]})]})]})]})]}),e.jsx(vs,{open:!!C,onOpenChange:()=>A(null),children:e.jsx(ys,{className:"max-w-4xl",children:e.jsx("img",{src:C||"",alt:"Full size",className:"w-full h-auto"})})}),e.jsx(vs,{open:v,onOpenChange:_,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{children:"Delete Listing"}),e.jsx(Kr,{children:"Are you sure you want to delete this listing? This action cannot be undone."})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:U,disabled:p.isPending,children:p.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(vs,{open:b,onOpenChange:j,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{children:"Buyer Name *"}),e.jsx(Re,{value:I.buyerName,onChange:we=>L({...I,buyerName:we.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Buyer Type"}),e.jsxs(tr,{value:I.buyerType,onValueChange:we=>L({...I,buyerType:we}),children:[e.jsx(Js,{children:e.jsx(sr,{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(ve,{children:"Notes"}),e.jsx(Mr,{value:I.notes,onChange:we=>L({...I,notes:we.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsx(K,{onClick:V,disabled:f.isPending,children:f.isPending?"Sending...":"Send Referral"})]})]})}),e.jsx(pJe,{open:w,onOpenChange:N,listingId:(n==null?void 0:n.id)||"",listingSlug:(n==null?void 0:n.slug)||null,listingTitle:(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`})]})}function Ips({photo:t,onRemove:s,onSetPrimary:r}){const{attributes:n,listeners:a,setNodeRef:o,transform:l,transition:i,isDragging:d}=GKe({id:t.id}),u={transform:C3.Transform.toString(l),transition:i};return e.jsxs("div",{ref:o,style:u,className:Pt("relative aspect-square rounded-lg overflow-hidden bg-muted group",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(Fu,{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(Ur,{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 Lps({photos:t,uploading:s,onUpload:r,onRemove:n,onReorder:a,onSetPrimary:o}){const l=NKe(iye(jle,{activationConstraint:{distance:5}})),i=[...t].sort((u,p)=>(u.sort_order??0)-(p.sort_order??0)),d=u=>{const{active:p,over:f}=u;if(!f||p.id===f.id)return;const v=i.findIndex(N=>N.id===p.id),_=i.findIndex(N=>N.id===f.id),b=[...i],[j]=b.splice(v,1);b.splice(_,0,j);const w=b.map((N,C)=>({...N,sort_order:C}));a(w)};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag photos to reorder. Hover to set primary."}),e.jsx(qKe,{sensors:l,collisionDetection:TKe,onDragEnd:d,children:e.jsx(HKe,{items:i.map(u=>u.id),strategy:Sle,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[i.map(u=>e.jsx(Ips,{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(As,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Ya,{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 Dps({selectedVideoId:t,onVideoSelect:s,listingId:r}){const n=Dr(),{user:a}=Gs(),[o,l]=S.useState(!1),[i,d]=S.useState([]),[u,p]=S.useState(!1),[f,v]=S.useState(null),[_,b]=S.useState({});S.useEffect(()=>{t&&a?j():v(null)},[t,a]);const j=async()=>{if(!t)return;const{data:U,error:V}=await G.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("id",t).eq("is_deleted",!1).single();!V&&U&&(v(U),w(U))},w=async U=>{try{const{data:V,error:X}=await G.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:U.bunny_video_id,isAgentVideo:!0}});!X&&(V!=null&&V.thumbnailUrl)&&b(se=>({...se,[U.id]:{thumbnailUrl:V.thumbnailUrl}}))}catch(V){console.warn("Failed to get signed URL",V)}},N=async()=>{if(a){p(!0);try{const{data:U,error:V}=await G.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("owner_user_id",a.id).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(V)throw V;d(U||[]),U!=null&&U.length&&C(U)}catch(U){console.error("Error fetching videos:",U),fe.error("Failed to load videos")}finally{p(!1)}}},C=async U=>{var V;try{const X=U.map(ie=>ie.bunny_video_id),{data:se,error:te}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:X,isAgentVideo:!0}});if(te)throw te;const Y=(se==null?void 0:se.assets)||{},de={};for(const ie of U)(V=Y[ie.bunny_video_id])!=null&&V.thumbnailUrl&&(de[ie.id]={thumbnailUrl:Y[ie.bunny_video_id].thumbnailUrl});b(ie=>({...ie,...de}))}catch(X){console.warn("Failed to bulk-fetch signed URLs",X)}},A=()=>{l(!0),N()},I=U=>{s(U.id),v(U),l(!1),fe.success("Video selected")},L=()=>{s(null),v(null)},R=()=>{const U=r?`/mission-control/listings/${r}/edit`:"/mission-control/listings/new";n(`/mission-control/video?returnUrl=${encodeURIComponent(U)}`)},$=U=>{if(!U)return"0:00";const V=Math.floor(U/60),X=U%60;return`${V}:${X.toString().padStart(2,"0")}`},q=U=>{var V;return((V=_[U.id])==null?void 0:V.thumbnailUrl)||U.thumbnail_url};return e.jsxs("div",{className:"space-y-3",children:[f?e.jsx(Ee,{className:"overflow-hidden",children:e.jsx(Oe,{className:"p-0",children:e.jsxs("div",{className:"flex items-start gap-4 p-4",children:[e.jsxs("div",{className:"relative w-32 h-20 bg-muted rounded-lg overflow-hidden flex-shrink-0",children:[q(f)?e.jsx("img",{src:q(f),alt:f.title||"Video thumbnail",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(kn,{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(ul,{className:"h-6 w-6 text-white fill-white"})}),f.duration_seconds&&e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1.5 py-0.5 rounded",children:$(f.duration_seconds)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:f.title||"Untitled Video"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Property Video Tour"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:A,children:"Change"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:L,className:"text-destructive hover:text-destructive",children:e.jsx(Ur,{className:"h-4 w-4"})})]})]})})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(kn,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add a video walkthrough to showcase this property"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 justify-center",children:[e.jsxs(K,{type:"button",variant:"outline",onClick:A,className:"gap-2",children:[e.jsx(m5,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(K,{type:"button",variant:"outline",onClick:R,className:"gap-2",children:[e.jsx(Og,{className:"h-4 w-4"}),"Record New Video"]})]})]})})}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(Ss,{children:e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(m5,{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(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(kn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No videos in your library yet"}),e.jsxs(K,{onClick:R,className:"gap-2",children:[e.jsx(Og,{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(U=>e.jsxs("button",{type:"button",onClick:()=>I(U),className:`group relative rounded-lg overflow-hidden border-2 transition-all text-left ${t===U.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(U)?e.jsx("img",{src:q(U),alt:U.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(kn,{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(ul,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity"})}),U.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:$(U.duration_seconds)})]}),e.jsx("div",{className:"p-2 bg-card",children:e.jsx("p",{className:"text-xs font-medium truncate",children:U.title||"Untitled Video"})})]},U.id))})}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs(K,{type:"button",variant:"ghost",onClick:R,className:"gap-2",children:[e.jsx(Og,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const Ops=[{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"}],Rps=[{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 jLe(){const{listingId:t}=Mo(),[s]=Ec(),r=s.get("brokerage"),n=Dr(),{user:a}=Gs(),o=!!t&&t!=="new",l=!!r&&!o,{data:i,isLoading:d}=cVe(o?t:""),u=v5t(),p=_5t(),f=b5t(),v=w5t(),_=j5t(),b=k5t(),j=N5t(),{data:w=[]}=Ct({queryKey:["brokerage-agents",r],queryFn:async()=>{if(!r)return[];const{data:ae,error:le}=await G.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name");if(le)throw le;return ae||[]},enabled:l}),[N,C]=S.useState(""),[A,I]=S.useState(!1),[L,R]=S.useState([]),[$,q]=S.useState([]),[U,V]=S.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});S.useEffect(()=>{var ae,le,pe,be,ye;i&&o&&V({property_address:i.property_address||"",city:i.city||"",state:i.state||"",neighborhood:i.neighborhood||"",price:((ae=i.price)==null?void 0:ae.toString())||"",property_type:i.property_type,status:i.status,bedrooms:((le=i.bedrooms)==null?void 0:le.toString())||"",bathrooms:((pe=i.bathrooms)==null?void 0:pe.toString())||"",square_footage:((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 X=ae=>{if(!ae)return;const le=Array.from(ae);R(be=>[...be,...le]);const pe=le.map(be=>URL.createObjectURL(be));q(be=>[...be,...pe])},se=ae=>{URL.revokeObjectURL($[ae]),R(le=>le.filter((pe,be)=>be!==ae)),q(le=>le.filter((pe,be)=>be!==ae))},te=async ae=>{var le;if(!(!ae||!i)){I(!0);try{for(const pe of Array.from(ae)){const be=pe.name.split(".").pop(),ye=`${a==null?void 0:a.id}/${i.id}/${Date.now()}.${be}`,{error:we}=await G.storage.from("listing-photos").upload(ye,pe);if(we)throw we;const{data:{publicUrl:ke}}=G.storage.from("listing-photos").getPublicUrl(ye);await v.mutateAsync({listingId:i.id,photoUrl:ke,isPrimary:!((le=i.photos)!=null&&le.length)})}fe.success("Photos uploaded!")}catch(pe){console.error("Upload error:",pe),fe.error("Failed to upload photos")}finally{I(!1)}}},Y=async ae=>{for(let le=0;le{if(i)try{await _.mutateAsync({photoId:ae,listingId:i.id}),fe.success("Photo removed")}catch{fe.error("Failed to remove photo")}},ie=async ae=>{if(ae.preventDefault(),!U.city.trim()||!U.state.trim()||!U.price){fe.error("Please fill in required fields (City, State, Price)");return}if(l&&!N){fe.error("Please select an agent to assign this listing to");return}try{const le={property_address:U.property_address||null,city:U.city,state:U.state,neighborhood:U.neighborhood||null,price:Number(U.price),property_type:U.property_type,status:U.status,bedrooms:U.bedrooms?Number(U.bedrooms):null,bathrooms:U.bathrooms?Number(U.bathrooms):null,square_footage:U.square_footage?Number(U.square_footage):null,lot_size:U.lot_size||null,year_built:U.year_built?Number(U.year_built):null,has_hoa:U.has_hoa,description:U.description||null,agent_notes:U.agent_notes||null,agent_notes_public:U.agent_notes_public,mls_link:U.mls_link||null,video_link:U.video_link||null,video_id:U.video_id||null,allow_sharing:U.allow_sharing,open_to_referrals:U.open_to_referrals,open_to_social_promotion:U.open_to_social_promotion,share_with_brokerage:U.share_with_brokerage,is_public:U.is_public};if(o)await f.mutateAsync({id:t,...le}),fe.success("Listing updated!"),n(`/mission-control/listings/${t}`);else{I(!0);let pe;if(l&&N?pe=await p.mutateAsync({agentId:N,...le}):pe=await u.mutateAsync(le),L.length>0)try{await Y(pe.id),$.forEach(be=>URL.revokeObjectURL(be)),R([]),q([])}catch(be){console.error("Photo upload error:",be),fe.error("Listing created but some photos failed to upload")}I(!1),fe.success("Listing created!"),n(l?"/my-brokerage":`/mission-control/listings/${pe.id}`)}}catch(le){console.error("Save error:",le),fe.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:ie,className:"space-y-6",children:[e.jsxs(K,{type:"button",variant:"ghost",onClick:()=>n(l?"/my-brokerage":"/mission-control/listings"),children:[e.jsx(Ua,{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(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Assign to Agent *"})}),e.jsxs(Oe,{children:[e.jsxs(tr,{value:N,onValueChange:C,children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select an agent..."})}),e.jsx(er,{children:w.map(ae=>e.jsx(At,{value:ae.id,children:ae.name||ae.email},ae.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(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(ve,{children:"Property Address"}),e.jsx(Re,{value:U.property_address,onChange:ae=>V({...U,property_address:ae.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"City *"}),e.jsx(Re,{value:U.city,onChange:ae=>V({...U,city:ae.target.value}),placeholder:"City",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"State *"}),e.jsx(Re,{value:U.state,onChange:ae=>V({...U,state:ae.target.value}),placeholder:"State",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Neighborhood"}),e.jsx(Re,{value:U.neighborhood,onChange:ae=>V({...U,neighborhood:ae.target.value}),placeholder:"Neighborhood"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Price *"}),e.jsx(Re,{type:"number",value:U.price,onChange:ae=>V({...U,price:ae.target.value}),placeholder:"500000",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Property Type"}),e.jsxs(tr,{value:U.property_type,onValueChange:ae=>V({...U,property_type:ae}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:Rps.map(ae=>e.jsx(At,{value:ae.value,children:ae.label},ae.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Status"}),e.jsxs(tr,{value:U.status,onValueChange:ae=>V({...U,status:ae}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:Ops.map(ae=>e.jsx(At,{value:ae.value,children:ae.label},ae.value))})]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(ve,{children:"Bedrooms"}),e.jsx(Re,{type:"number",value:U.bedrooms,onChange:ae=>V({...U,bedrooms:ae.target.value}),placeholder:"3"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Bathrooms"}),e.jsx(Re,{type:"number",step:"0.5",value:U.bathrooms,onChange:ae=>V({...U,bathrooms:ae.target.value}),placeholder:"2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Sq Ft"}),e.jsx(Re,{type:"number",value:U.square_footage,onChange:ae=>V({...U,square_footage:ae.target.value}),placeholder:"2000"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Lot Size"}),e.jsx(Re,{value:U.lot_size,onChange:ae=>V({...U,lot_size:ae.target.value}),placeholder:"0.25 acres"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Year Built"}),e.jsx(Re,{type:"number",value:U.year_built,onChange:ae=>V({...U,year_built:ae.target.value}),placeholder:"2005"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(Br,{checked:U.has_hoa,onCheckedChange:ae=>V({...U,has_hoa:ae})}),e.jsx(ve,{children:"Has HOA"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Description & Links"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Mr,{value:U.description,onChange:ae=>V({...U,description:ae.target.value}),placeholder:"Tell the story of this property...",rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Agent Notes"}),e.jsx(Mr,{value:U.agent_notes,onChange:ae=>V({...U,agent_notes:ae.target.value}),placeholder:"Notes for other agents...",rows:2}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:U.agent_notes_public,onCheckedChange:ae=>V({...U,agent_notes_public:ae})}),e.jsx(ve,{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(ve,{children:"MLS Link"}),e.jsx(Re,{value:U.mls_link,onChange:ae=>V({...U,mls_link:ae.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Video Link"}),e.jsx(Re,{value:U.video_link,onChange:ae=>V({...U,video_link:ae.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(kn,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx(Oe,{children:e.jsx(Dps,{selectedVideoId:U.video_id,onVideoSelect:ae=>V({...U,video_id:ae}),listingId:o?t:void 0})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Photos"})}),e.jsx(Oe,{children:o&&(i!=null&&i.photos)?e.jsx(Lps,{photos:i.photos,uploading:A,onUpload:ae=>te(ae),onRemove:ae=>de(ae),onReorder:ae=>{b.mutate({photos:ae.map(le=>({id:le.id,sort_order:le.sort_order,is_primary:le.is_primary}))})},onSetPrimary:ae=>{i&&j.mutate({photoId:ae,listingId:i.id})}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[$.map((ae,le)=>e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:ae,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:()=>se(le),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90",children:e.jsx(Ur,{className:"h-3 w-3"})}),le===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"})]},le)),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(As,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Ya,{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:ae=>X(ae.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(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(ve,{children:"Allow Sharing"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Other agents can share this listing"})]}),e.jsx(Br,{checked:U.allow_sharing,onCheckedChange:ae=>V({...U,allow_sharing:ae})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Open to Referrals"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept buyer referrals"})]}),e.jsx(Br,{checked:U.open_to_referrals,onCheckedChange:ae=>V({...U,open_to_referrals:ae})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Social Promotion"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Can be promoted on social media"})]}),e.jsx(Br,{checked:U.open_to_social_promotion,onCheckedChange:ae=>V({...U,open_to_social_promotion:ae})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Share with Brokerage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visible to agents in your brokerage"})]}),e.jsx(Br,{checked:U.share_with_brokerage,onCheckedChange:ae=>V({...U,share_with_brokerage:ae})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Make Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Publish on listings.relevelup.com to get leads"})]}),e.jsx(Br,{checked:U.is_public,onCheckedChange:ae=>V({...U,is_public:ae})})]})]})]}),e.jsx(K,{type:"submit",className:"w-full",size:"lg",disabled:u.isPending||f.isPending,children:u.isPending||f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):o?"Update Listing":"Create Listing"})]})]})]})})}function Tce({maxDurationSeconds:t=30,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=S.useRef(null),i=S.useRef(null),d=S.useRef(null),u=S.useRef([]),p=S.useRef(null),f=S.useRef(null),v=S.useRef(null),_=S.useRef(null),b=PM(),[j,w]=S.useState(!0),[N,C]=S.useState(!0),[A,I]=S.useState(null),[L,R]=S.useState(!1),[$,q]=S.useState(!1),[U,V]=S.useState(null),[X,se]=S.useState(null),[te,Y]=S.useState(0),[de,ie]=S.useState("user"),[ae,le]=S.useState(0),[pe,be]=S.useState(!1),[ye,we]=S.useState(!0),[ke,Ze]=S.useState(null),[_e,Ce]=S.useState(!1),[Te,Fe]=S.useState(null),Ae=S.useRef(null),We=S.useRef(r);We.current=r;const ht=S.useCallback(Ve=>{w(Ve)},[]),De=S.useRef(j),Dt=S.useCallback(async()=>{var Je,Rt;C(!0),Ze(null);const Ve=b&&j;console.log("[VideoRecorder] initCamera start",{isMobile:b,usePortraitMode:j,shouldBePortrait:Ve,facingMode:de});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(as=>as.stop()));const $t=b&&Ve?{facingMode:{ideal:de},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:de},width:{ideal:1280},height:{ideal:720}};console.log("[VideoRecorder] requesting getUserMedia",$t);const ls=await navigator.mediaDevices.getUserMedia({video:$t,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),ls.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");d.current=ls,I(!0);const rs=ls.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",rs.width,"x",rs.height),l.current){const as=l.current;as.srcObject=ls,as.muted=!0,as.playsInline=!0,as.autoplay=!0,as.setAttribute("muted",""),as.setAttribute("playsinline",""),as.setAttribute("autoplay","");try{(Je=as.load)==null||Je.call(as)}catch(vt){console.warn("[VideoRecorder] videoEl.load failed",vt)}const ir=async()=>{try{return await as.play(),console.log("[VideoRecorder] preview play ok"),Ce(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:as.readyState,videoWidth:as.videoWidth,videoHeight:as.videoHeight})},300),!0}catch(vt){return console.warn("[VideoRecorder] preview play blocked",vt),Ce(!0),!1}};await new Promise(vt=>{let Cs=!1;const or=()=>{Cs||(Cs=!0,vt())},Ar=()=>{ir().finally(or)};as.onloadedmetadata=Ar,as.onloadeddata=Ar,setTimeout(or,1500)})}try{f.current=new AudioContext;const as=f.current.createMediaStreamSource(ls);v.current=f.current.createAnalyser(),v.current.fftSize=256,as.connect(v.current);const ir=()=>{if(v.current){const vt=new Uint8Array(v.current.frequencyBinCount);v.current.getByteFrequencyData(vt);const Cs=vt.reduce((or,Ar)=>or+Ar)/vt.length;le(Math.min(100,Cs/128*100))}_.current=requestAnimationFrame(ir)};ir()}catch(as){console.warn("Audio context not available:",as)}}catch($t){console.error("Camera initialization error:",$t),I(!1);let ls="Failed to access camera or microphone.";$t.name==="NotAllowedError"?ls="Camera permission denied. Please allow camera access in your browser settings.":$t.name==="NotFoundError"?ls="No camera found. Please connect a camera and try again.":$t.name==="NotReadableError"?ls="Camera is in use by another application. Please close other apps using the camera.":$t.message&&(ls=$t.message),Ze(ls),(Rt=We.current)==null||Rt.call(We,ls)}finally{C(!1)}},[de,b,j]);S.useEffect(()=>{De.current!==j&&A&&!L&&!X&&(De.current=j,Dt())},[j,A,L,X,Dt]),S.useEffect(()=>(Dt(),()=>{d.current&&d.current.getTracks().forEach(Ve=>Ve.stop()),p.current&&clearInterval(p.current),_.current&&cancelAnimationFrame(_.current),f.current&&f.current.close(),Ae.current&&clearInterval(Ae.current),X&&URL.revokeObjectURL(X)}),[Dt,X]),S.useEffect(()=>{if(N||A!==!0||X)return;const Ve=d.current,Je=l.current;!Ve||!Je||(Je.srcObject!==Ve&&(Je.srcObject=Ve,Je.muted=!0,Je.playsInline=!0,Je.autoplay=!0,Je.setAttribute("muted",""),Je.setAttribute("playsinline",""),Je.setAttribute("autoplay","")),Je.play().then(()=>Ce(!1)).catch(Rt=>{Ce(!0),console.warn("Live preview play blocked on mount:",Rt)}))},[A,N,X]),S.useEffect(()=>{n==null||n(L)},[L,n]);const he=S.useCallback(async()=>{if(X)return;const Ve=l.current;if(Ve)try{await Ve.play(),Ce(!1)}catch(Je){Ce(!0),console.warn("Live preview still blocked (needs user gesture):",Je)}},[X]),Qe=S.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),p.current&&(clearInterval(p.current),p.current=null),R(!1),q(!1)},[]),ot=S.useCallback(()=>{if(!d.current)return;he(),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($t=>MediaRecorder.isTypeSupported($t)),Rt=new MediaRecorder(d.current,Je?{mimeType:Je,videoBitsPerSecond:25e5}:{videoBitsPerSecond:25e5});Rt.ondataavailable=$t=>{$t.data.size>0&&u.current.push($t.data)},Rt.onstop=()=>{var rs;const $t=Rt.mimeType||Je||((rs=u.current[0])==null?void 0:rs.type)||"video/webm",ls=new Blob(u.current,{type:$t});V(ls);const Qt=URL.createObjectURL(ls);se(Qt)},i.current=Rt,Rt.start(100),R(!0),p.current=setInterval(()=>{Y($t=>$t>=t-1?(Qe(),t):$t+1)},1e3)},[he,t,Qe]),rt=S.useCallback(()=>{Ae.current&&(clearInterval(Ae.current),Ae.current=null),Fe(3);let Ve=3;Ae.current=setInterval(()=>{Ve-=1,Ve<=0?(Ae.current&&clearInterval(Ae.current),Ae.current=null,Fe(null),ot()):Fe(Ve)},1e3)},[ot]),Ne=S.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),q(!0),p.current&&clearInterval(p.current))},[]),it=S.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),q(!1),p.current=setInterval(()=>{Y(Ve=>Ve>=t-1?(Qe(),t):Ve+1)},1e3))},[t,Qe]),qe=S.useCallback(()=>{X&&URL.revokeObjectURL(X),V(null),se(null),Y(0),be(!1),we(!0),l.current&&d.current&&(l.current.srcObject=d.current,l.current.muted=!0,he())},[he,X]),Xe=S.useCallback(()=>{ie(Ve=>Ve==="user"?"environment":"user")},[]),$e=S.useCallback(()=>{U&&s(U,te)},[U,te,s]),Ke=S.useCallback(()=>{l.current&&X&&(pe?l.current.pause():(we(!1),l.current.muted=!1,l.current.play()),be(!pe))},[X,pe]);S.useEffect(()=>{if(!X)return;const Ve=l.current;if(!Ve)return;we(!1),Ve.pause(),Ve.removeAttribute("src"),Ve.srcObject=null,Ve.load(),Ve.src=X,Ve.currentTime=0,Ve.playsInline=!0,Ve.muted=!1,Ve.onended=()=>be(!1);const Je=()=>{var ls;const Rt=Ve.error,$t=Rt?`Recorded video failed to play (code ${Rt.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",Rt),(ls=We.current)==null||ls.call(We,$t)};return Ve.addEventListener("error",Je),Ve.load(),()=>{Ve.removeEventListener("error",Je)}},[X]);const ct=Ve=>{const Je=Math.floor(Ve/60),Rt=Ve%60;return`${Je}:${Rt.toString().padStart(2,"0")}`},Ue=b&&j?"aspect-[9/16]":"aspect-video";return N?e.jsx("div",{className:Pt("flex items-center justify-center bg-black rounded-lg",Ue,a),children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(As,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),e.jsx("p",{children:"Initializing camera..."})]})}):A===!1?e.jsx("div",{className:Pt("flex items-center justify-center bg-black rounded-lg",Ue,a),children:e.jsxs("div",{className:"text-center text-white p-8 max-w-md",children:[e.jsx(Qo,{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(K,{onClick:()=>Dt(),variant:"secondary",className:"w-full",children:[e.jsx(Po,{className:"h-4 w-4 mr-2"}),"Try Again"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-3",children:"💡 Tip: If you're viewing this in an embedded preview, try opening the app in a new browser tab for full camera access."})]})]})}):e.jsxs("div",{className:Pt("flex flex-col gap-2",a),children:[b&&!L&&!X&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(iN,{className:Pt("h-4 w-4",j?"text-muted-foreground":"text-primary")}),e.jsx(ve,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Landscape"}),e.jsx(Br,{id:"orientation-toggle",checked:j,onCheckedChange:ht}),e.jsx(ve,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),e.jsx(O0,{className:Pt("h-4 w-4",j?"text-primary":"text-muted-foreground")})]}),e.jsxs("div",{className:Pt("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{he()},children:[e.jsx("video",{ref:l,src:X??void 0,className:Pt("w-full bg-black",j&&!X?"object-contain":"object-cover",Ue,de==="user"&&!X&&"scale-x-[-1]"),playsInline:!0,controls:!!X,muted:X?ye:!0,autoPlay:!X},X??"live"),!X&&_e&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:e.jsx(K,{type:"button",variant:"secondary",onClick:()=>void he(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!X&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),Te!==null&&!X&&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:Te},Te),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:Pt("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:[ct(te)," / ",ct(t)]})]}),L&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(Ti,{value:te/t*100,className:"h-1 rounded-none"})}),!X&&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(xP,{className:"h-4 w-4 text-white"}),e.jsx("div",{className:"w-20 h-2 bg-white/20 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-green-500 transition-all duration-75",style:{width:`${ae}%`}})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:X?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:qe,children:[e.jsx(Po,{className:"h-5 w-5 mr-2"}),"Re-record"]}),e.jsx(K,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:Ke,children:pe?e.jsx(pp,{className:"h-5 w-5"}):e.jsx(ul,{className:"h-5 w-5"})}),e.jsxs(K,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:$e,children:[e.jsx(ua,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:Xe,disabled:L||Te!==null,children:e.jsx(D0,{className:"h-5 w-5"})}),!L&&Te===null?e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:rt,children:e.jsx(kn,{className:"h-6 w-6"})}):e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:$?it:Ne,children:$?e.jsx(ul,{className:"h-5 w-5"}):e.jsx(pp,{className:"h-5 w-5"})}),e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:Qe,children:e.jsx(Zx,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const yJe="teleprompter_settings",Spe={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function Fps(){try{const t=localStorage.getItem(yJe);return t?{...Spe,...JSON.parse(t)}:Spe}catch{return Spe}}function zps(t){try{localStorage.setItem(yJe,JSON.stringify(t))}catch{}}function vJe({text:t,isVisible:s,onToggleVisibility:r,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=S.useRef(null),d=S.useRef(null),u=S.useRef(0),p=S.useRef(0),[f,v]=S.useState(Fps),{scrollSpeed:_,fontSize:b,lineHeight:j,opacity:w,position:N,isMirrored:C}=f,A=S.useCallback((se,te)=>{v(Y=>{const de={...Y,[se]:te};return zps(de),de})},[]),[I,L]=S.useState(!1),[R,$]=S.useState(null),q=S.useCallback(se=>{if(!i.current)return;u.current===0&&(u.current=se);const te=se-u.current;u.current=se,p.current+=_*te/1e3;const Y=Math.floor(p.current);Y>0&&(i.current.scrollTop+=Y,p.current-=Y);const{scrollTop:de,scrollHeight:ie,clientHeight:ae}=i.current;if(de+ae>=ie){L(!1);return}d.current=requestAnimationFrame(q)},[_]);S.useEffect(()=>(I?(u.current=0,p.current=0,d.current=requestAnimationFrame(q)):d.current&&cancelAnimationFrame(d.current),()=>{d.current&&cancelAnimationFrame(d.current)}),[I,q]),S.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 U=S.useCallback(()=>{i.current&&(i.current.scrollTop=0),L(!1)},[]),V=S.useCallback(()=>{L(se=>!se)},[]);if(!s)return e.jsx("div",{className:Pt("absolute top-4 right-4 pointer-events-auto z-10",l),children:e.jsxs(K,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(ya,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const X={top:"top-0 pt-16",center:"top-1/2 -translate-y-1/2",bottom:"bottom-0 pb-24"};return e.jsxs("div",{className:Pt("absolute inset-0 pointer-events-none",l),children:[R!==null&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"text-white font-bold drop-shadow-lg animate-scale-in",style:{fontSize:"96px",lineHeight:1,textShadow:"0 4px 16px rgba(0,0,0,0.8)"},children:R},R),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),e.jsx("div",{className:Pt("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",X[N],R!==null&&"opacity-30"),style:{opacity:R!==null?.3:w},children:e.jsxs("div",{ref:i,className:Pt("mx-auto max-w-2xl px-6 overflow-y-auto scrollbar-hide h-full",C&&"scale-x-[-1]"),style:{maskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)",WebkitMaskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)"},children:[e.jsx("div",{className:"h-full",style:{minHeight:"100%"}}),e.jsx("p",{className:"text-white text-center font-medium drop-shadow-lg",style:{fontSize:`${b}px`,lineHeight:j,textShadow:"0 2px 4px rgba(0,0,0,0.8)"},children:t}),e.jsx("div",{className:"h-full"})]})}),e.jsxs("div",{className:"absolute top-4 right-4 flex items-center gap-2 pointer-events-auto",children:[e.jsxs(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsx(K,{variant:"secondary",size:"icon",className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx($l,{className:"h-4 w-4"})})}),e.jsx(ko,{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(ve,{className:"text-xs",children:"Scroll Speed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:_})]}),e.jsx(Pg,{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(ve,{className:"text-xs",children:"Font Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[b,"px"]})]}),e.jsx(Pg,{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(ve,{className:"text-xs",children:"Line Spacing"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:j.toFixed(1)})]}),e.jsx(Pg,{value:[j*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(ve,{className:"text-xs",children:"Opacity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(w*100),"%"]})]}),e.jsx(Pg,{value:[w*100],onValueChange:([se])=>A("opacity",se/100),min:30,max:100,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{className:"text-xs",children:"Position"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:N==="top"?"default":"outline",size:"sm",onClick:()=>A("position","top"),children:e.jsx(Rg,{className:"h-4 w-4"})}),e.jsx(K,{variant:N==="center"?"default":"outline",size:"sm",onClick:()=>A("position","center"),children:e.jsx(P0,{className:"h-4 w-4"})}),e.jsx(K,{variant:N==="bottom"?"default":"outline",size:"sm",onClick:()=>A("position","bottom"),children:e.jsx(Vo,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs",children:"Mirror Mode"}),e.jsx(Br,{checked:C,onCheckedChange:se=>A("isMirrored",se)})]})]})})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:V,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:I?e.jsx(pp,{className:"h-4 w-4"}):e.jsx(ul,{className:"h-4 w-4"})}),e.jsx(K,{variant:"secondary",size:"icon",onClick:U,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(D0,{className:"h-4 w-4"})}),e.jsxs(K,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(Em,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function Bps({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=Ia(),[o,l]=S.useState(""),[i,d]=S.useState(null),[u,p]=S.useState("levelup"),{data:f,isLoading:v}=tBt(),{data:_,isLoading:b}=sBt(),{data:j,isLoading:w}=rBt(),N=nBt(),C=S.useMemo(()=>_?_.filter($=>{const q=!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())||$.tags.some(V=>V.toLowerCase().includes(o.toLowerCase())),U=!i||$.category_id===i;return q&&U}):[],[_,o,i]),A=S.useMemo(()=>j?j.filter($=>!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())):[],[j,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"})}},R=v||b||w;return e.jsxs("div",{className:Pt("flex flex-col h-full",n),children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(fn,{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(Na,{value:u,onValueChange:$=>p($),className:"flex-1 flex flex-col",children:[e.jsxs(va,{className:"mx-4 mt-4 grid grid-cols-2",children:[e.jsxs(ks,{value:"levelup",children:[e.jsx(In,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(ks,{value:"my-scripts",children:[e.jsx(Dg,{className:"h-4 w-4 mr-2"}),"My Scripts"]})]}),e.jsxs(zs,{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(at,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>d(null),children:"All"}),f==null?void 0:f.map($=>e.jsx(at,{variant:i===$.id?"default":"outline",className:"cursor-pointer",onClick:()=>d($.id),children:$.name},$.id))]}),e.jsx(Bi,{className:"flex-1 max-h-[50vh]",children:R?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):C.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(In,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No scripts found"})]}):e.jsx("div",{className:"space-y-2",children:C.map($=>e.jsxs(Ee,{className:Pt("cursor-pointer hover:bg-accent/50 transition-colors",r===$.id&&"ring-2 ring-primary"),onClick:()=>I($),children:[e.jsx(Lt,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(zt,{className:"text-sm font-medium truncate",children:$.title}),$.category&&e.jsx(at,{variant:"secondary",className:"mt-1 text-xs",children:$.category.name})]}),e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:q=>{q.stopPropagation(),L($)},children:e.jsx(Dg,{className:"h-4 w-4"})}),e.jsx(Ha,{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(zs,{value:"my-scripts",className:"flex-1 flex flex-col mt-0 p-4",children:[s&&e.jsxs(K,{variant:"outline",className:"mb-4",onClick:s,children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create New Script"]}),e.jsx(Bi,{className:"flex-1 max-h-[50vh]",children:w?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(As,{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(Dg,{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(Ee,{className:Pt("cursor-pointer hover:bg-accent/50 transition-colors",r===$.id&&"ring-2 ring-primary"),onClick:()=>I($),children:[e.jsx(Lt,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(zt,{className:"text-sm font-medium truncate",children:$.title}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:$.is_custom?e.jsx(at,{variant:"outline",className:"text-xs",children:"Custom"}):e.jsx(at,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),e.jsx(Ha,{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 $ps({selectedTemplate:t,onSelect:s,contactName:r,saving:n=!1}){const[a,o]=S.useState(()=>{const i=E5(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(ve,{className:"text-sm font-medium",children:"Share Page Template"}),n&&e.jsx(As,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"space-y-3",children:kjt.map(i=>{const d=Njt(i.id),u=a.has(i.id),p=d.some(f=>f.id===t);return e.jsxs(mf,{open:u,onOpenChange:()=>l(i.id),children:[e.jsxs(pf,{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,")"]}),p&&!u&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:"✓"})]}),e.jsx(Vo,{className:Pt("h-4 w-4 text-muted-foreground transition-transform",u&&"rotate-180")})]}),e.jsx(ff,{className:"pt-2",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:d.map(f=>{const v=t===f.id;return e.jsxs("button",{type:"button",onClick:()=>s(f.id),disabled:n,className:Pt("relative rounded-lg border-2 p-2.5 text-left transition-all hover:shadow-sm disabled:opacity-50 disabled:cursor-not-allowed",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(ua,{className:"h-2.5 w-2.5 text-primary-foreground"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"opacity-70 shrink-0",children:f.icon}),e.jsx("span",{className:"text-sm font-medium truncate",children:f.name})]})]},f.id)})})})]},i.id)})}),r&&t!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Will show: "',E5(t).headerText(r),'"']})]})}function _Je({open:t,onOpenChange:s,video:r,contactName:n,onTemplateUpdated:a}){const[o,l]=S.useState(r.page_template||"default"),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[f,v]=S.useState(r.page_template||"default"),[_,b]=S.useState([]),[j,w]=S.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[N,C]=S.useState(!1),[A,I]=S.useState(!1),L=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";S.useEffect(()=>{t&&_.length===0&&R()},[t]);const R=async()=>{I(!0);try{const{data:de,error:ie}=await G.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ie)throw ie;const ae=(de||[]).map(le=>({id:le.id,name:[le.first_name,le.last_name].filter(Boolean).join(" ")||"Unnamed",email:le.email||null}));b(ae)}catch(de){console.error("Failed to fetch contacts:",de)}finally{I(!1)}},$=async de=>{w(de),C(!1),d(!0);try{const{error:ie}=await G.from("agent_videos").update({contact_id:(de==null?void 0:de.id)||null,recipient_name:(de==null?void 0:de.name)||null}).eq("id",r.id);if(ie)throw ie;fe.success(de?`Assigned to ${de.name}`:"Contact removed"),a==null||a()}catch(ie){console.error("Failed to update contact:",ie),fe.error("Failed to update contact")}finally{d(!1)}},q=async de=>{l(de),d(!0);try{const{error:ie}=await G.from("agent_videos").update({page_template:de}).eq("id",r.id);if(ie)throw ie;v(de),fe.success("Template saved!"),a==null||a()}catch(ie){console.error("Failed to save template:",ie),fe.error("Failed to save template"),l(f)}finally{d(!1)}},U=(j==null?void 0:j.name)||null,V=()=>{const de=r.title||"Video Message",ie=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:r.thumbnail_url||"";return``},X=async()=>{if(!r.thumbnail_url){fe.error("Video thumbnail not available yet");return}const de=V(),ie=`Watch: ${r.title||"Video Message"} ${L}`;try{const ae=new Blob([de],{type:"text/html"}),le=new Blob([ie],{type:"text/plain"}),pe=new ClipboardItem({"text/html":ae,"text/plain":le});await navigator.clipboard.write([pe]),fe.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(ie+` `+de),fe.success("Copied! Paste into your email.")}},se=async()=>{await navigator.clipboard.writeText(L),p(!0),fe.success("Share link copied!"),setTimeout(()=>p(!1),2e3)},te=()=>{const ie=E5(o).headerText(U),ae=o==="default"?`Check out this video: ${L}`:`${ie} Check out this special video: ${L}`;window.open(`sms:?body=${encodeURIComponent(ae)}`,"_self")},Y=()=>{const de=E5(o),ie=de.headerText(U),ae=o==="default"?r.title||"Video Message":ie,le=`${de.subText} Watch the video: ${L}`,pe=j!=null&&j.email?encodeURIComponent(j.email):"";window.open(`mailto:${pe}?subject=${encodeURIComponent(ae)}&body=${encodeURIComponent(le)}`,"_self")};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Lo,{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(ve,{className:"text-sm font-medium",children:"Personalize for Contact (Optional)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(So,{open:N,onOpenChange:C,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":N,className:"flex-1 justify-between",disabled:i,children:[j?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Xi,{className:"h-4 w-4 text-muted-foreground"}),j.name]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(df,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(ko,{className:"w-[300px] p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search contacts..."}),e.jsxs(kf,{children:[e.jsx(Nf,{children:A?"Loading...":"No contacts found."}),e.jsx(Sf,{children:_.map(de=>e.jsxs(Nm,{value:de.name,onSelect:()=>$(de),children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",(j==null?void 0:j.id)===de.id?"opacity-100":"opacity-0")}),de.name]},de.id))})]})]})})]}),j&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$(null),disabled:i,className:"shrink-0",children:e.jsx(Ur,{className:"h-4 w-4"})})]}),j&&o!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Page will show: "',E5(o).headerText(j.name),'"']})]}),e.jsx($ps,{selectedTemplate:o,onSelect:q,contactName:U,saving:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(K,{onClick:se,variant:u?"default":"outline",className:"shrink-0 gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ua,{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(ve,{children:"Share for Email"}),e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:X,children:[e.jsx(Jo,{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(ve,{children:"Quick Share"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:te,children:[e.jsx(oo,{className:"h-4 w-4"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:Y,children:[e.jsx(_r,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(On,{children:e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function qps(){var rt;const t=Dr(),[s]=Ec(),{toast:r}=Ia(),n=s.get("contact_id"),a=s.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:d}=vZe(),{data:u}=Jh(),p=iS(),f=cBt(),[v,_]=S.useState("record"),[b,j]=S.useState(""),[w,N]=S.useState(!1),[C,A]=S.useState(!1),[I,L]=S.useState(!1),[R,$]=S.useState(null),[q,U]=S.useState(0),[V,X]=S.useState(0),[se,te]=S.useState(null),[Y,de]=S.useState(null),[ie,ae]=S.useState(n||""),[le,pe]=S.useState(""),[be,ye]=S.useState(""),[we,ke]=S.useState(null),[Ze,_e]=S.useState(null),[Ce,Te]=S.useState(null),[Fe,Ae]=S.useState(!1),We=S.useCallback(async(Ne,it)=>{$(Ne),_("uploading");try{const{videoId:qe,uploadUrl:Xe}=await KL(le||"Quick Video Touch");te(qe);const{apiKey:$e}=await ZL(qe),Ke=new XMLHttpRequest;Ke.upload.onprogress=Je=>{Je.lengthComputable&&U(Je.loaded/Je.total*100)},await new Promise((Je,Rt)=>{Ke.onload=()=>{Ke.status>=200&&Ke.status<300?Je():Rt(new Error(`Upload failed: ${Ke.status}`))},Ke.onerror=()=>Rt(new Error("Upload failed")),Ke.open("PUT",Xe),Ke.setRequestHeader("AccessKey",$e),Ke.send(Ne)}),_("processing");let ct=0;const Ue=Date.now(),Ve=90*1e3;for(;ct<4;){if(await new Promise(Rt=>setTimeout(Rt,3e3)),Date.now()-Ue>Ve){const Rt=Ne.size/1048576,$t=`https://iframe.mediadelivery.net/play/${qe}/${qe}`;await p.mutateAsync({bunny_video_id:qe,playback_url:$t,file_size_mb:Rt,title:le||"Quick Video Touch",notes:be||void 0,contact_id:ie&&ie!=="none"?ie: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 M3(qe);if(ct=Je.status,X(Je.encodeProgress||0),ct===4)de({playbackUrl:Je.directPlayUrl,thumbnailUrl:Je.thumbnailUrl,previewUrl:Je.previewUrl||null,duration:Je.length||it,fileSizeMb:(Je.storageSize||Ne.size)/(1024*1024)});else if(ct===5||ct===6)throw new Error("Video processing failed")}_("details")}catch(qe){console.error("Upload error:",qe),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),_("record")}},[le,r]),ht=async()=>{if(!(!se||!Y))try{const Ne=ie&&ie!=="none"?ie:null,it=await p.mutateAsync({bunny_video_id:se,contact_id:Ne,playback_url:Y.playbackUrl,thumbnail_url:Y.thumbnailUrl,preview_url:Y.previewUrl,duration_seconds:Y.duration,file_size_mb:Y.fileSizeMb,title:le||"Quick Video Touch",notes:be,task_id:a||null,status:"ready"});ke(it.id),_e(it.share_token||null),Ne&&await f.mutateAsync({contactId:Ne,videoId:it.id,notes:be}),r({title:"Video saved successfully!"}),_("share")}catch(Ne){console.error("Save video error:",Ne),r({title:"Failed to save video",description:(Ne==null?void 0:Ne.message)||"Please try again.",variant:"destructive"})}},De=(Ne,it)=>{navigator.clipboard.writeText(it),Te(Ne),setTimeout(()=>Te(null),2e3),r({title:"Copied to clipboard!"})},Dt=()=>Ze?`https://video.relevelup.com/${Ze}`:(Y==null?void 0:Y.playbackUrl)||"",he=()=>{const Ne=u==null?void 0:u.find(Ke=>Ke.id===ie),it=Ne?`${Ne.first_name}`:"",qe=(Ne==null?void 0:Ne.phone)||"",Xe=(Ne==null?void 0:Ne.email)||"",$e=Dt();return{text:`Hey${it?` ${it}`:""}! I recorded a quick video for you: ${$e}`,link:$e,contactPhone:qe,contactEmail:Xe}},Qe=()=>{const{text:Ne,contactPhone:it}=he(),qe=it?`sms:${it}?body=${encodeURIComponent(Ne)}`:`sms:?body=${encodeURIComponent(Ne)}`;window.open(qe,"_self")},ot=()=>{const{link:Ne,contactEmail:it}=he(),qe="Check out this video",Xe=`I recorded a quick video for you: ${Ne}`,$e=it?`mailto:${it}?subject=${encodeURIComponent(qe)}&body=${encodeURIComponent(Xe)}`:`mailto:?subject=${encodeURIComponent(qe)}&body=${encodeURIComponent(Xe)}`;window.open($e,"_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(K,{variant:"ghost",size:"icon",onClick:()=>t(-1),children:e.jsx(Ua,{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(Tce,{maxDurationSeconds:60,onRecordingComplete:We,onRecordingStateChange:L,className:"w-full",teleprompterContent:w&&b&&e.jsx(vJe,{text:b,isVisible:w,onToggleVisibility:()=>N(!1),isRecording:I,startCountdown:!0})}),!w&&b&&e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>N(!0),children:[e.jsx(In,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(Ee,{className:"lg:col-span-1",children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Mr,{placeholder:"Type or paste your script here...",value:b,onChange:Ne=>j(Ne.target.value),rows:6}),e.jsxs(gM,{open:C,onOpenChange:A,children:[e.jsx(r_e,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full",children:[e.jsx(In,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),e.jsxs(rS,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[e.jsx(xM,{className:"p-4 border-b",children:e.jsx(yM,{children:"Select a Script"})}),e.jsx(Bps,{onSelectScript:Ne=>{j(Ne.text),A(!1),N(!0)},className:"h-[calc(100vh-80px)]"})]})]}),b&&e.jsx(K,{className:"w-full",onClick:()=>N(!0),children:"Use Script"})]})]})]}),v==="uploading"&&e.jsx(Ee,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center",children:[e.jsx(Ya,{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(Ti,{value:q,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[q.toFixed(0),"%"]})]})}),v==="processing"&&e.jsx(Ee,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center space-y-4",children:[e.jsx(As,{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(Ti,{value:V,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[V.toFixed(0),"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:`This usually takes 30-60 seconds. If it takes longer, we'll auto-save your video and you can find it in your Video Library — look for the "processing" badge.`})]})}),v==="details"&&e.jsxs(Ee,{className:"max-w-lg mx-auto",children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Video Details"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title"}),e.jsx(Re,{value:le,onChange:Ne=>pe(Ne.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Attach to Contact (Optional)"}),e.jsxs(tr,{value:ie,onValueChange:ae,children:[e.jsx(Js,{children:e.jsx(sr,{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(Lo,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),u==null?void 0:u.map(Ne=>e.jsx(At,{value:Ne.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xi,{className:"h-4 w-4"}),Ne.first_name," ",Ne.last_name]})},Ne.id))]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Notes"}),e.jsx(Mr,{value:be,onChange:Ne=>ye(Ne.target.value),placeholder:"Add notes about this video...",rows:3})]}),e.jsxs(K,{className:"w-full",onClick:ht,disabled:p.isPending,children:[p.isPending&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),v==="share"&&e.jsxs(Ee,{className:"max-w-lg mx-auto",children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(ua,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Share your video with one click:"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs(K,{variant:"outline",className:"justify-start",onClick:Qe,children:[e.jsx(oo,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:ot,children:[e.jsx(_r,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>De("link",he().link),children:[e.jsx(Lo,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Ce==="link"&&e.jsx(ua,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>Ae(!0),children:[e.jsx(Bl,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),children:"View Library"}),e.jsx(K,{onClick:()=>{_("record"),$(null),te(null),de(null)},children:"Record Another"})]})]})]}),we&&Ze&&e.jsx(_Je,{open:Fe,onOpenChange:Ae,video:{id:we,share_token:Ze,title:le||null,contact_id:ie||null,thumbnail_url:(Y==null?void 0:Y.thumbnailUrl)||null},contactName:((rt=u==null?void 0:u.find(Ne=>Ne.id===ie))==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(Th,{className:"h-16 w-16 text-destructive mx-auto mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Storage Limit Reached"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"You've reached your video storage limit. Delete videos from your library to record more."}),e.jsx(K,{onClick:()=>t("/mission-control/video-library"),children:"Open Video Library"})]})})}function Ups({open:t,onOpenChange:s}){const{data:r}=Jh(),{data:n}=Ale(),a=iS(),o=S.useRef(null),[l,i]=S.useState(null),[d,u]=S.useState(""),[p,f]=S.useState(""),[v,_]=S.useState(""),[b,j]=S.useState(!1),[w,N]=S.useState(0),[C,A]=S.useState("idle"),I=(n==null?void 0:n.total_storage_mb)||0,R=((n==null?void 0:n.max_storage_mb)||1024)-I,$=X=>{var Y;const se=(Y=X.target.files)==null?void 0:Y[0];if(!se)return;if(!se.type.startsWith("video/")){fe.error("Please select a video file");return}const te=se.size/(1024*1024);if(te>500){fe.error("Video file must be less than 500MB");return}if(te>R){fe.error(`Not enough storage. You have ${R.toFixed(1)} MB remaining.`);return}i(se),d||u(se.name.replace(/\.[^/.]+$/,""))},q=async()=>{if(!l){fe.error("Please select a video file");return}j(!0),N(0),A("creating");try{const{data:X,error:se}=await G.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}=X;A("uploading");const{data:de,error:ie}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:te,isAgentVideo:!0}});if(ie)throw new Error(ie.message);await new Promise((pe,be)=>{const ye=new XMLHttpRequest;ye.upload.addEventListener("progress",we=>{if(we.lengthComputable){const ke=Math.round(we.loaded/we.total*100);N(ke)}}),ye.addEventListener("load",()=>{ye.status>=200&&ye.status<300?pe():be(new Error(`Upload failed with status ${ye.status}`))}),ye.addEventListener("error",()=>be(new Error("Upload failed"))),ye.open("PUT",de.uploadUrl),ye.setRequestHeader("AccessKey",de.apiKey),ye.send(l)}),A("processing");const ae=l.size/(1024*1024),le=`https://iframe.mediadelivery.net/embed/${Y}/${te}`;await a.mutateAsync({bunny_video_id:te,playback_url:le,file_size_mb:ae,title:d||l.name,notes:p||void 0,contact_id:v||void 0,status:"processing",touch_type:"video_upload"}),fe.success("Video uploaded successfully! Processing may take a few minutes."),U()}catch(X){console.error("Upload error:",X),fe.error(X instanceof Error?X.message:"Failed to upload video")}finally{j(!1),A("idle")}},U=()=>{b||(i(null),u(""),f(""),_(""),N(0),A("idle"),s(!1))},V=()=>{switch(C){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${w}%`;case"processing":return"Saving video...";default:return""}};return e.jsx(vs,{open:t,onOpenChange:U,children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{children:"Video File"}),l?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(kn,{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(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:X=>{X.stopPropagation(),i(null)},children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>{var X;return(X=o.current)==null?void 0:X.click()},children:[e.jsx(Ya,{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(ve,{htmlFor:"title",children:"Title"}),e.jsx(Re,{id:"title",value:d,onChange:X=>u(X.target.value),placeholder:"Enter video title",disabled:b})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Associate with Contact (optional)"}),e.jsxs(tr,{value:v||"__none__",onValueChange:X=>_(X==="__none__"?"":X),disabled:b,children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a contact"})}),e.jsxs(er,{children:[e.jsx(At,{value:"__none__",children:"No contact"}),r==null?void 0:r.map(X=>e.jsxs(At,{value:X.id,children:[X.first_name," ",X.last_name||""]},X.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(Mr,{id:"notes",value:p,onChange:X=>f(X.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(As,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:V()})]}),e.jsx(Ti,{value:C==="uploading"?w:C==="processing"?100:10})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:U,disabled:b,children:"Cancel"}),e.jsx(K,{onClick:q,disabled:!l||b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function Vps(t){return Ct({queryKey:["video-share-recipients",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("video_share_recipients").select("*").eq("video_id",t).order("sent_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Hps(){const{user:t}=Gs();return Ct({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 G.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 Wps(){const{user:t}=Gs();return Ct({queryKey:["video-share-history",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await G.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 Gps(){const{user:t}=Gs(),s=ns();return Ot({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await G.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 Kps(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=open`}function Zps(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=click`}function Yps({open:t,onOpenChange:s,video:r,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=S.useState([]),[d,u]=S.useState(null),[p,f]=S.useState(!1),[v,_]=S.useState(!1),[b,j]=S.useState(""),[w,N]=S.useState(""),[C,A]=S.useState(""),[I,L]=S.useState(!1),R=Gps(),$=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||"",U=r.title||"Video Message";S.useEffect(()=>{t&&l.length===0&&V()},[t]),S.useEffect(()=>{if(t&&(N(`I recorded a video for you — ${U}`),A("Hey! I recorded a quick video just for you. Click below to watch it:"),u(null),j(""),r.contact_id)){const ie=l.find(ae=>ae.id===r.contact_id);ie&&(u(ie),j(ie.email||""))}},[t,r.contact_id,l]);const V=async()=>{_(!0);try{const{data:ie,error:ae}=await G.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ae)throw ae;i(ie||[])}catch{console.error("Failed to fetch contacts")}finally{_(!1)}},X=ie=>{u(ie),f(!1),j(ie.email||""),A(`Hey ${ie.first_name}! I recorded a quick video just for you. Click below to watch it:`),N(`I recorded a video for you — ${U}`)},se=()=>{u(null),j(""),A("Hey! I recorded a quick video just for you. Click below to watch it:")},te=ie=>`${ie.first_name} ${ie.last_name||""}`.trim(),Y=ie=>{const ae=C.split(/\n\n+/).map(be=>`

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

`).join(""),le=ie?Zps(ie):$,pe=ie?``:"";return`
${ae}

▶ Watch Video

${pe}
`},de=async()=>{if(!b){fe.error("Please enter a recipient email");return}if(!$){fe.error("Video does not have a share link");return}L(!0);try{let ie;try{const be=d?te(d):b.split("@")[0];ie=(await R.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 ae=Y(ie),{data:le,error:pe}=await G.functions.invoke("gmail-send",{body:{to:b,subject:w,body:ae,contactId:(d==null?void 0:d.id)||null}});if(pe)throw pe;if(!(le!=null&&le.success))throw new Error((le==null?void 0:le.error)||"Failed to send");fe.success("Video email sent!"),s(!1),o==null||o()}catch(ie){console.error("Gmail send error:",ie),fe.error("Failed to send: "+(ie instanceof Error?ie.message:"Unknown error"))}finally{L(!1)}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-[560px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(_r,{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(ve,{children:"Send to Contact"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(So,{open:p,onOpenChange:f,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"flex-1 justify-between",children:[d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Xi,{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(df,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(ko,{className:"w-[350px] p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search contacts..."}),e.jsxs(kf,{children:[e.jsx(Nf,{children:v?"Loading...":"No contacts found."}),e.jsx(Sf,{children:l.filter(ie=>ie.email).map(ie=>e.jsxs(Nm,{value:`${ie.first_name} ${ie.last_name||""} ${ie.email||""}`,onSelect:()=>X(ie),children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",(d==null?void 0:d.id)===ie.id?"opacity-100":"opacity-0")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:te(ie)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ie.email})]})]},ie.id))})]})]})})]}),d&&e.jsx(K,{variant:"ghost",size:"icon",onClick:se,className:"shrink-0",children:e.jsx(Ur,{className:"h-4 w-4"})})]})]}),!d&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"video-to",children:"Or type email address"}),e.jsx(Re,{id:"video-to",value:b,onChange:ie=>j(ie.target.value),placeholder:"recipient@example.com",type:"email"})]}),e.jsx(Rl,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"video-subject",children:"Subject"}),e.jsx(Re,{id:"video-subject",value:w,onChange:ie=>N(ie.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(Mr,{id:"video-message",value:C,onChange:ie=>A(ie.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(ve,{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:U,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(ul,{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(ul,{className:"h-5 w-5 text-primary ml-0.5"})})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Recipients will see the thumbnail with a play button. Clicking opens the video page."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),disabled:I,children:"Cancel"}),e.jsxs(K,{onClick:de,disabled:I||!b||!w,className:"gap-2",children:[I?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(ka,{className:"h-4 w-4"}),I?"Sending...":"Send Video Email"]})]})]})]})})}const Xps=()=>{const{user:t}=Gs();return Ct({queryKey:["team-videos",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.rpc("get_team_videos",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})};function Qps({recipient:t}){return t.watched_at?e.jsxs(at,{className:"bg-emerald-100 text-emerald-800 text-[10px]",children:[e.jsx(ul,{className:"h-2.5 w-2.5 mr-0.5"}),"Watched"]}):t.clicked_at?e.jsxs(at,{className:"bg-blue-100 text-blue-800 text-[10px]",children:[e.jsx(jm,{className:"h-2.5 w-2.5 mr-0.5"}),"Clicked"]}):t.opened_at?e.jsxs(at,{className:"bg-amber-100 text-amber-800 text-[10px]",children:[e.jsx(ya,{className:"h-2.5 w-2.5 mr-0.5"}),"Opened"]}):e.jsxs(at,{variant:"outline",className:"text-[10px]",children:[e.jsx(ka,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]})}function Jps({open:t,onOpenChange:s,videoId:r,videoTitle:n}){const{data:a=[],isLoading:o}=Vps(r);return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-2xl max-h-[80vh]",children:[e.jsx(Ss,{children:e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Xo,{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(Bi,{className:"h-[400px]",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Recipient"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Sent"}),e.jsx(jt,{children:"Last Activity"})]})}),e.jsx(Pn,{children:a.map(l=>e.jsxs(js,{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(Qps,{recipient:l})}),e.jsx(lt,{className:"text-xs text-muted-foreground",children:ws(new Date(l.sent_at),"MMM d, h:mm a")}),e.jsx(lt,{className:"text-xs text-muted-foreground",children:l.last_activity_at?Cd(new Date(l.last_activity_at),{addSuffix:!0}):"—"})]},l.id))})]})})]})]})})}function efs(){const{data:t,isLoading:s}=Hps(),{data:r=[],isLoading:n}=Wps(),[a,o]=S.useState(null),l=s||n,i=r.reduce((d,u)=>{const p=u.agent_videos,f=(p==null?void 0:p.id)||u.video_id;return d[f]||(d[f]={videoId:f,title:(p==null?void 0:p.title)||"Untitled",thumbnailUrl:p==null?void 0:p.thumbnail_url,recipients:[]}),d[f].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(Ee,{children:[e.jsx(Lt,{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(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Sent"}),e.jsx(ka,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(t==null?void 0:t.totalSent)||0})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Open Rate"}),e.jsx(ya,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.openRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalOpened)||0," opened"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(jm,{className:"h-4 w-4 text-blue-500"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.clickRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalClicked)||0," clicked"]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{className:"text-sm font-medium",children:"Send History by Video"}),e.jsx(yr,{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(f=>f.opened_at).length,p=d.recipients.filter(f=>f.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:f=>{const v=f.currentTarget;v.style.display="none",v.parentElement.innerHTML='
'}}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(kn,{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(ka,{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(ya,{className:"h-3 w-3"})," ",u]}),e.jsxs("span",{className:"text-xs text-blue-600 flex items-center gap-1",children:[e.jsx(jm,{className:"h-3 w-3"})," ",p]})]})]}),e.jsx(Cc,{className:"h-4 w-4 text-muted-foreground"})]},d.videoId)})})})]}),e.jsx(Jps,{open:!!a,onOpenChange:d=>!d&&o(null),videoId:(a==null?void 0:a.id)||null,videoTitle:(a==null?void 0:a.title)||""})]})}function tfs({previewSrc:t,thumbnailSrc:s,alt:r,isHovered:n}){const[a,o]=S.useState(!1),[l,i]=S.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(kn,{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 sfs({video:t,previewSrc:s,thumbnailSrc:r,onOpen:n,onDelete:a,onRename:o,onNavigateToContact:l,onGetEmbedCode:i,onCopyEmailHtml:d,onEmbedToCrm:u,onShareWithTemplate:p,onSendViaGmail:f,isGmailConnected:v,getContactName:_,getShareUrl:b,copyToClipboard:j,formatDuration:w}){const[N,C]=S.useState(!1);return e.jsxs(Ee,{className:"overflow-hidden group cursor-pointer",onClick:n,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),children:[e.jsxs("div",{className:"relative aspect-video bg-muted overflow-hidden",children:[e.jsx(tfs,{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(ul,{className:"h-6 w-6 text-primary ml-1"})})}),e.jsx("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:w(t.duration_seconds)}),t.status!=="ready"&&e.jsx(at,{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(Xi,{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:ws(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(ya,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]}),v&&t.share_token&&e.jsxs(K,{variant:"outline",size:"sm",className:"mt-2 gap-1.5 text-xs h-7",onClick:A=>{A.stopPropagation(),f==null||f()},children:[e.jsx(_r,{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(Xi,{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:ws(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(ya,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]})]}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:A=>A.stopPropagation(),children:e.jsx(Jp,{className:"h-4 w-4"})})}),e.jsxs(Td,{align:"end",className:"bg-popover",children:[e.jsxs(Ta,{onClick:A=>{A.stopPropagation(),n()},children:[e.jsx(ya,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(S_,{}),e.jsxs(Ta,{onClick:A=>{A.stopPropagation(),p()},children:[e.jsx(Bl,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),e.jsxs(Ta,{onClick:A=>{A.stopPropagation(),j(b(t),"Share link")},children:[e.jsx(Lo,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(Ta,{onClick:A=>{A.stopPropagation(),i()},children:[e.jsx(Jk,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),e.jsxs(Ta,{onClick:A=>{A.stopPropagation(),d()},children:[e.jsx(_r,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(Ta,{onClick:A=>{A.stopPropagation(),u()},children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),v&&t.share_token&&e.jsxs(Ta,{onClick:A=>{A.stopPropagation(),f==null||f()},children:[e.jsx(ka,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),e.jsxs(Ta,{onClick:A=>{A.stopPropagation(),o()},children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsx(S_,{}),t.contact_id&&e.jsxs(Ta,{onClick:A=>{A.stopPropagation(),l()},children:[e.jsx(Xi,{className:"h-4 w-4 mr-2"}),"View Contact"]}),e.jsxs(Ta,{onClick:A=>{A.stopPropagation(),a()},className:"text-destructive",children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function rfs(){var Je,Rt;const t=Dr(),{data:s,isLoading:r,refetch:n}=aBt(),{data:a}=Ale(),{data:o}=Jh(),l=lBt(),i=oBt(),{isGmailConnected:d,gmailEmail:u}=gy(),{data:p}=Mf(),{data:f=[],isLoading:v}=Xps(),[_,b]=S.useState("my"),[j,w]=S.useState(""),[N,C]=S.useState(null),[A,I]=S.useState(!1),[L,R]=S.useState(!1),[$,q]=S.useState(!1),[U,V]=S.useState(!1),[X,se]=S.useState(!1),[te,Y]=S.useState(""),[de,ie]=S.useState(!1),[ae,le]=S.useState(!1),[pe,be]=S.useState(!1),[ye,we]=S.useState(!1),[ke,Ze]=S.useState(""),[_e,Ce]=S.useState({}),Te=$t=>{if(!$t)return"Unassigned";const ls=o==null?void 0:o.find(Qt=>Qt.id===$t);return ls?`${ls.first_name} ${ls.last_name||""}`.trim():"Unknown"},Fe=$t=>{if(!$t)return"0:00";const ls=Math.floor($t/60),Qt=$t%60;return`${ls}:${Qt.toString().padStart(2,"0")}`},Ae=s==null?void 0:s.filter($t=>{if(!j)return!0;const ls=Te($t.contact_id).toLowerCase(),Qt=($t.title||"").toLowerCase(),rs=($t.notes||"").toLowerCase();return ls.includes(j.toLowerCase())||Qt.includes(j.toLowerCase())||rs.includes(j.toLowerCase())}),[We,ht]=S.useState(!1);S.useEffect(()=>{if(We)return;(async()=>{if(!(s!=null&&s.length))return;const ls=s.filter(rs=>rs.status==="processing"&&rs.bunny_video_id);if(!ls.length)return;let Qt=!1;for(const rs of ls)try{const{data:as,error:ir}=await G.functions.invoke("bunny-upload",{body:{action:"status",videoId:rs.bunny_video_id,isAgentVideo:!0}});if(ir||!as)continue;as.status===4&&(await G.from("agent_videos").update({status:"ready",playback_url:as.directPlayUrl,thumbnail_url:as.thumbnailUrl,preview_url:as.previewUrl,duration_seconds:as.length||rs.duration_seconds,updated_at:new Date().toISOString()}).eq("id",rs.id),Qt=!0)}catch(as){console.warn("Reconcile check failed for video",rs.id,as)}ht(!0),Qt&&n()})()},[s,We,n]),S.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const ls=s.filter(vt=>(vt==null?void 0:vt.bunny_video_id)&&!_e[vt.id]);if(!ls.length)return;const Qt=ls.map(vt=>vt.bunny_video_id),{data:rs,error:as}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Qt,isAgentVideo:!0}});if(as)throw as;const ir=(rs==null?void 0:rs.assets)||{};Ce(vt=>{const Cs={...vt};for(const or of ls)ir[or.bunny_video_id]&&(Cs[or.id]={previewUrl:ir[or.bunny_video_id].previewUrl,thumbnailUrl:ir[or.bunny_video_id].thumbnailUrl});return Cs})})().catch(ls=>console.warn("Failed to load signed Bunny asset URLs",ls))},[s,_e]);const De=(a==null?void 0:a.total_storage_mb)||0,Dt=(a==null?void 0:a.max_storage_mb)||1024,he=De/Dt*100,Qe=he>=80,ot=he>=100,rt=async($t,ls)=>{await navigator.clipboard.writeText($t),fe.success(`${ls} copied to clipboard`)},Ne=$t=>$t.share_token?`https://video.relevelup.com/${$t.share_token}`:$t.playback_url||"",it=$t=>{const ls=Ne($t),Qt=o==null?void 0:o.find(or=>or.id===$t.contact_id),rs=Te($t.contact_id),as=rs!=="Unassigned"?rs.split(" ")[0]:"",ir=(Qt==null?void 0:Qt.phone)||"",vt=`Hey${as?` ${as}`:""}! I recorded a quick video message for you. Check it out: ${ls}`,Cs=ir?`sms:${ir}?body=${encodeURIComponent(vt)}`:`sms:?body=${encodeURIComponent(vt)}`;window.open(Cs,"_self")},qe=$t=>{const ls=o==null?void 0:o.find(Cs=>Cs.id===$t.contact_id),Qt=(ls==null?void 0:ls.email)||"",rs=Ne($t),as="Check out this video",ir=`I recorded a quick video for you: ${rs}`,vt=Qt?`mailto:${Qt}?subject=${encodeURIComponent(as)}&body=${encodeURIComponent(ir)}`:`mailto:?subject=${encodeURIComponent(as)}&body=${encodeURIComponent(ir)}`;window.open(vt,"_self")},Xe=$t=>{var as;const ls=Ne($t),Qt=$t.title||"Video Message",rs=$t.share_token?`https://video.relevelup.com/thumb/${$t.share_token}`:((as=_e[$t.id])==null?void 0:as.thumbnailUrl)||$t.thumbnail_url||"";return``},$e=async $t=>{if(!$t.thumbnail_url&&!$t.share_token){fe.error("Video thumbnail not available yet");return}const ls=Xe($t),Qt=Ne($t),rs=`Watch: ${$t.title||"Video Message"} ${Qt}`;try{const as=new Blob([ls],{type:"text/html"}),ir=new Blob([rs],{type:"text/plain"}),vt=new ClipboardItem({"text/html":as,"text/plain":ir});await navigator.clipboard.write([vt]),fe.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(rs+` `+ls),fe.success("Copied! Paste into your email.")}},Ke=async $t=>{try{fe.loading("Preparing download...",{id:"download"});const{data:ls,error:Qt}=await G.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:$t.bunny_video_id,isAgentVideo:!0}});if(Qt||!(ls!=null&&ls.downloadUrl))throw new Error((Qt==null?void 0:Qt.message)||"Failed to get download URL");const as=`${(($t.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,ir=await fetch(ls.downloadUrl);if(!ir.ok)throw new Error("Failed to fetch video file");const vt=await ir.blob(),Cs=URL.createObjectURL(vt),or=document.createElement("a");or.href=Cs,or.download=as,or.rel="noreferrer",document.body.appendChild(or),or.click(),or.remove(),URL.revokeObjectURL(Cs),fe.success("Download started",{id:"download"})}catch(ls){console.error("Download error:",ls),fe.error("Could not force download (your browser may block it).",{id:"download"})}},ct=async $t=>{C($t),ie(!0),Y(""),se(!0);try{const{data:ls,error:Qt}=await G.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:$t.bunny_video_id,title:$t.title,isAgentVideo:!0,shareToken:$t.share_token}});if(Qt||!(ls!=null&&ls.html))throw new Error("Failed to generate CRM embed code");Y(ls.html)}catch(ls){console.error("CRM embed error:",ls),fe.error("Failed to generate CRM embed code"),se(!1)}finally{ie(!1)}},Ue=$t=>{C($t),I(!0)},Ve=async()=>{if(N)try{await l.mutateAsync({id:N.id,bunnyVideoId:N.bunny_video_id,hardDelete:!0}),R(!1),C(null),fe.success("Video deleted successfully")}catch{fe.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"}),p&&((Je=p.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(hr,{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(Xo,{className:"h-3.5 w-3.5"}),"Analytics"]})]})]}),_==="my"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>q(!0),children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Upload Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Record New Video"]})]})]}),_==="team"?e.jsx(nfs,{videos:f,isLoading:v,searchTerm:j,setSearchTerm:w}):_==="analytics"?e.jsx(efs,{}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:Qe?"border-amber-500":ot?"border-destructive":"",children:e.jsxs(Oe,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(iP,{className:`h-5 w-5 ${ot?"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:[De.toFixed(1)," MB / ",Dt>=1024?`${(Dt/1024).toFixed(0)} GB`:`${Dt} MB`]})]}),e.jsx(Ti,{value:Math.min(he,100),className:`h-2 ${ot?"[&>div]:bg-destructive":Qe?"[&>div]:bg-amber-500":""}`})]}),Qe&&!ot&&e.jsxs(at,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(Qo,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),ot&&e.jsxs(at,{variant:"destructive",children:[e.jsx(Qo,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),ot&&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(fn,{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:j,onChange:$t=>w($t.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"})}):(Ae==null?void 0:Ae.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(kn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No videos yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Record your first video touch to get started"}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(Zs,{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:Ae==null?void 0:Ae.map($t=>{var ls,Qt;return e.jsx(sfs,{video:$t,previewSrc:(ls=_e[$t.id])==null?void 0:ls.previewUrl,thumbnailSrc:(Qt=_e[$t.id])==null?void 0:Qt.thumbnailUrl,onOpen:()=>Ue($t),onDelete:()=>{C($t),R(!0)},onRename:()=>{C($t),Ze($t.title||""),we(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${$t.contact_id}`),onGetEmbedCode:()=>{C($t),V(!0)},onCopyEmailHtml:()=>$e($t),onEmbedToCrm:()=>ct($t),onShareWithTemplate:()=>{C($t),le(!0)},onSendViaGmail:()=>{C($t),be(!0)},isGmailConnected:d,getContactName:Te,getShareUrl:Ne,copyToClipboard:rt,formatDuration:Fe},$t.id)})}),e.jsx(vs,{open:A,onOpenChange:I,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(Xi,{className:"h-3 w-3"}),Te(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(As,{className:"h-8 w-8 text-primary animate-spin"})})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Video is still processing"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:"Your video is being encoded and will be ready shortly. This usually takes 1–3 minutes. Check back soon!"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{I(!1),n()},children:[e.jsx(Po,{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 $t=N.playback_url;return $t.includes("iframe.mediadelivery.net/play/")&&($t=$t.replace("/play/","/embed/"),$t+=($t.includes("?")?"&":"?")+"autoplay=false&responsive=true"),$t.includes("iframe.mediadelivery.net")?e.jsx("iframe",{src:$t,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:()=>fe.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(kn,{className:"h-12 w-12 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground ml-2",children:"Video not available"})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>it(N),children:[e.jsx(oo,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!d&&e.jsxs(K,{variant:"outline",onClick:()=>qe(N),children:[e.jsx(_r,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>rt(Ne(N),"Share link"),children:[e.jsx(ni,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(K,{variant:"outline",onClick:()=>$e(N),children:[e.jsx(_r,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(K,{variant:"outline",onClick:()=>Ke(N),children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),ct(N)},children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),le(!0)},children:[e.jsx(Bl,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),d&&(N==null?void 0:N.share_token)&&e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),be(!0)},children:[e.jsx(ka,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]})]}),e.jsx("div",{className:"flex justify-end pt-2 border-t",children:e.jsxs(K,{variant:"destructive",onClick:()=>{I(!1),R(!0)},children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),e.jsx(vs,{open:L,onOpenChange:R,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{children:"Delete Video"}),e.jsx(Kr,{children:"Are you sure you want to delete this video? This action cannot be undone."})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Ve,disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(Ups,{open:$,onOpenChange:q}),e.jsx(vs,{open:U,onOpenChange:V,children:e.jsxs(ys,{className:"sm:max-w-lg",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{children:"Embed Code"}),e.jsx(Mr,{readOnly:!0,rows:5,value:``,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{className:"flex-1",onClick:()=>{const $t=``;rt($t,"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(_Je,{open:ae,onOpenChange:le,video:N,contactName:Te(N.contact_id)}),N&&e.jsx(Yps,{open:pe,onOpenChange:be,video:N,gmailEmail:u,signedThumbnailUrl:(Rt=_e[N.id])==null?void 0:Rt.thumbnailUrl}),e.jsx(vs,{open:ye,onOpenChange:we,children:e.jsxs(ys,{className:"max-w-sm",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{children:"Rename Video"}),e.jsx(Kr,{children:"Enter a new title for this video."})]}),e.jsx(Re,{value:ke,onChange:$t=>Ze($t.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:$t=>{$t.key==="Enter"&&ke.trim()&&i.mutate({id:N.id,title:ke.trim()},{onSuccess:()=>{fe.success("Video renamed"),we(!1)}})}}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>we(!1),children:"Cancel"}),e.jsx(K,{disabled:!ke.trim()||i.isPending,onClick:()=>{i.mutate({id:N.id,title:ke.trim()},{onSuccess:()=>{fe.success("Video renamed"),we(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(vs,{open:X,onOpenChange:se,children:e.jsxs(ys,{className:"sm:max-w-lg",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(sn,{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."})]}),de?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(As,{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(ve,{children:"CRM Email HTML"}),e.jsx(Mr,{readOnly:!0,rows:12,value:te,className:"font-mono text-xs"})]}),e.jsxs(K,{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 nfs({videos:t,isLoading:s,searchTerm:r,setSearchTerm:n}){const a=S.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=S.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(fn,{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(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No team videos"}),e.jsx("p",{className:"text-muted-foreground",children:t.length===0?"Your teammates haven't recorded any videos yet.":"No videos match your search."})]})}):e.jsx("div",{className:"space-y-6",children:o.map(([i,d])=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(gn,{className:"h-7 w-7",children:[e.jsx(Ea,{src:d.avatar||""}),e.jsx(xn,{children:(d.name||"?").charAt(0).toUpperCase()})]}),e.jsx("h3",{className:"font-semibold text-sm",children:d.name}),e.jsx(at,{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(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"relative aspect-video bg-muted flex items-center justify-center",children:[u.thumbnail_url?e.jsx("img",{src:u.thumbnail_url,alt:u.title||"Video",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:p=>{p.target.style.display="none"}}):e.jsx(kn,{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(Xi,{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(ya,{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"}),ws(new Date(u.created_at),"MMM d")]})]})]})]},u.id))})]},i))})]})}const afs=()=>{const{user:t}=Gs();return Ct({queryKey:["team-deals",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.rpc("get_team_deals",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},kLe=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function ifs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=afs(),[a,o]=S.useState(""),[l,i]=S.useState("all"),d=S.useMemo(()=>{if(!r)return new Map;const b=new Map;let j=0;return r.forEach(w=>{b.has(w.owner_user_id)||(b.set(w.owner_user_id,{name:w.owner_name||"Unknown",avatar:w.owner_avatar_url,color:kLe[j%kLe.length]}),j++)}),b},[r]),u=S.useMemo(()=>Array.from(d.entries()).map(([b,j])=>({id:b,...j})),[d]),p=S.useMemo(()=>{if(!r)return[];let b=r;if(l!=="all"&&(b=b.filter(j=>j.owner_user_id===l)),a.trim()){const j=a.toLowerCase();b=b.filter(w=>{var N,C,A,I;return w.deal_name.toLowerCase().includes(j)||((N=w.contact_name)==null?void 0:N.toLowerCase().includes(j))||((C=w.property_address)==null?void 0:C.toLowerCase().includes(j))||((A=w.city)==null?void 0:A.toLowerCase().includes(j))||((I=w.owner_name)==null?void 0:I.toLowerCase().includes(j))})}return b},[r,a,l]),f=S.useMemo(()=>{const b=new Map;return p.forEach(j=>{const w=j.stage_name||"Unknown";b.has(w)||b.set(w,{name:w,color:j.stage_color,icon:j.stage_icon,deals:[],totalValue:0});const N=b.get(w);N.deals.push(j),N.totalValue+=j.sale_price||0}),Array.from(b.values())},[p]),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(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-[95vw] w-full max-h-[90vh] flex flex-col",children:[e.jsx(Ss,{children:e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Team Pipeline"]})}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{className:"relative flex-1 max-w-xs",children:[e.jsx(fn,{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(sr,{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))}):f.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(hr,{className:"h-10 w-10 mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No team deals found"}),e.jsx("p",{className:"text-sm",children:"Team members' deals will appear here."})]})}):e.jsx("div",{className:"flex gap-3 h-full overflow-x-auto pb-2",children:f.map(b=>{const j=b.icon&&Xve[b.icon]||Gc;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(j,{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(at,{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(Bi,{className:"flex-1 p-2",children:e.jsx("div",{className:"space-y-2",children:b.deals.map(w=>{const N=d.get(w.owner_user_id);return e.jsx(ofs,{deal:w,ownerColor:(N==null?void 0:N.color)||"#888",ownerName:(N==null?void 0:N.name)||"Unknown",ownerAvatar:(N==null?void 0:N.avatar)||null,formatPrice:_},w.id)})})})]},b.name)})})}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-2 border-t shrink-0",children:[p.length," deal",p.length!==1?"s":""," across ",f.length," stage",f.length!==1?"s":""," from ",u.length," member",u.length!==1?"s":""]})]})})}function ofs({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(gn,{className:"h-4 w-4",children:[e.jsx(Ea,{src:n||""}),e.jsx(xn,{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(at,{variant:"outline",className:Pt("text-[10px] px-1.5 py-0 shrink-0",l.className),children:l.label})]}),t.contact_name&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:t.contact_name}),(t.property_address||t.city)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Un,{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(Kc,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:a(t.sale_price)})]})]})}function lfs({members:t,enabledMembers:s,onToggleMember:r,isOpen:n,onToggleOpen:a}){const o=s.size;return e.jsxs("div",{className:Pt("shrink-0 border-r border-border/50 bg-muted/20 transition-all duration-300 flex flex-col",n?"w-[220px]":"w-[48px]"),children:[e.jsx("div",{className:"p-2 border-b border-border/50 shrink-0",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 px-2",onClick:a,children:[e.jsx(hr,{className:"h-4 w-4 shrink-0 text-primary"}),n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs font-semibold flex-1 text-left",children:"Team"}),o>0&&e.jsx("span",{className:"text-[10px] bg-primary text-primary-foreground rounded-full px-1.5 py-0.5",children:o}),e.jsx(zl,{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(Bi,{className:"flex-1 p-2",children:[e.jsx("div",{className:"space-y-1",children:t.map(l=>{const i=s.has(l.id);return e.jsxs("button",{onClick:()=>r(l.id),className:Pt("w-full flex items-center gap-2 px-2 py-2 rounded-lg text-left transition-colors",i?"bg-primary/10 hover:bg-primary/15":"hover:bg-muted/50"),children:[e.jsxs("div",{className:"relative",children:[e.jsxs(gn,{className:"h-7 w-7",children:[e.jsx(Ea,{src:l.avatar_url||""}),e.jsx(xn,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:l.color},children:l.name.charAt(0).toUpperCase()})]}),i&&e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-background",style:{backgroundColor:l.color}})]}),e.jsx("span",{className:Pt("text-xs truncate flex-1",i?"font-medium text-foreground":"text-muted-foreground"),children:l.name}),e.jsx(Br,{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(gn,{className:Pt("h-7 w-7 transition-all",i?"ring-2 ring-offset-1 ring-offset-background":"opacity-50"),style:i?{"--tw-ring-color":l.color}:{},children:[e.jsx(Ea,{src:l.avatar_url||""}),e.jsx(xn,{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 NLe=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function cfs(){const t=ti(),{data:s}=Mf(),r=(s==null?void 0:s.role)==="team_leader",n=s==null?void 0:s.teamId,a=Ct({queryKey:["team-pipeline-members",n,t],queryFn:async()=>{const{data:o,error:l}=await G.from("team_members").select("user_id, role").eq("team_id",n).neq("user_id",t);if(l)throw l;if(!o||o.length===0)return[];const i=o.map(p=>p.user_id),{data:d,error:u}=await G.from("profiles").select("id, name, avatar_url").in("id",i);if(u)throw u;return(d||[]).map((p,f)=>({id:p.id,name:p.name||"Unknown",avatar_url:p.avatar_url,color:NLe[f%NLe.length]}))},enabled:!!n&&!!t&&r,staleTime:5*60*1e3});return{isTeamLeader:r,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function dfs(t){return Ct({queryKey:["team-member-deals",t],queryFn:async()=>{if(t.length===0)return[];const{data:s,error:r}=await G.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 bJe({stages:t,currentStageId:s,onStageSelect:r,disabled:n}){const[a,o]=S.useState(!1),l=t.find(d=>d.id===s),i=d=>{d.id!==s&&r(d.id,d.name),o(!1)};return e.jsxs(Kd,{open:a,onOpenChange:o,children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{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(Ha,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(Td,{align:"end",className:"w-48 z-50 bg-popover",onClick:d=>d.stopPropagation(),children:t.map(d=>{const u=d.icon&&Xve[d.icon]||Gc,p=d.id===s;return e.jsxs(Ta,{onClick:()=>i(d),className:Pt("flex items-center gap-2 cursor-pointer",p&&"bg-accent"),children:[e.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center shrink-0",style:{backgroundColor:`${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}),p&&e.jsx(ua,{className:"h-4 w-4 text-primary"})]},d.id)})})]})}const ufs={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"}},hfs={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 wJe({deal:t,onClick:s,isDragging:r,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var C,A;const d=PM(),u=ufs[t.deal_type],p=hfs[t.priority],f=S.useMemo(()=>t.target_close_date?Gg(fl(t.target_close_date),new Date):null,[t.target_close_date]),v=f!==null&&f<0,_=f!==null&&f<=7&&f>=0,b=S.useMemo(()=>{var R;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const I=((R=t.listing)==null?void 0:R.created_at)||t.listing_date;if(!I)return null;const L=t.contract_date?fl(t.contract_date):new Date;return Gg(L,fl(I))},[t]),j=l&&!t.scorecard_transaction_id,w=!!t.scorecard_transaction_id,N=I=>I?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I):null;return e.jsx(Ee,{className:Pt("cursor-pointer transition-all duration-200 hover:shadow-md hover:border-primary/30 group overflow-hidden",r&&"opacity-50 rotate-2 shadow-xl",v&&"border-red-200 bg-red-50/30",j&&"border-amber-300 bg-amber-50/30 dark:bg-amber-950/20"),onClick:s,style:i?{borderLeftWidth:4,borderLeftColor:i.color}:void 0,children:e.jsxs(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(gn,{className:"h-4 w-4",children:[e.jsx(Ea,{src:i.avatar_url||""}),e.jsx(xn,{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(at,{variant:"outline",className:Pt("text-[10px] px-1.5 py-0 shrink-0",u.color),children:u.label})]}),t.contact&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(gn,{className:"h-5 w-5",children:e.jsxs(xn,{className:"text-[10px] bg-primary/10 text-primary",children:[(C=t.contact.first_name)==null?void 0:C[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(Ho,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"text-primary truncate",children:"Linked to Listing Exchange"})]}),j&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 px-2 py-1 rounded",children:[e.jsx(Ki,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:"Add to Scorecard"})]}),w&&l&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx(da,{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(eP,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsxs("span",{className:Pt("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(Un,{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(Kc,{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=L2e(t);return I!==null&&I!==t.expected_commission?e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:["• ",N(I)," Net"]}):null})()]}),e.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:Pt("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",p.color),children:[e.jsx("div",{className:Pt("w-1.5 h-1.5 rounded-full",p.dot)}),e.jsx("span",{className:"capitalize",children:t.priority})]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[t.probability,"%"]})]}),o&&d&&n&&a?e.jsx(bJe,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(I,L)=>a(t.id,I,L)}):t.target_close_date?e.jsxs("div",{className:Pt("flex items-center gap-1 text-[10px]",v&&"text-red-600",_&&!v&&"text-amber-600",!v&&!_&&"text-muted-foreground"),children:[v?e.jsx(Qo,{className:"h-3 w-3"}):e.jsx(on,{className:"h-3 w-3"}),e.jsx("span",{children:v?`${Math.abs(f)}d overdue`:_?`${f}d left`:ws(fl(t.target_close_date),"MMM d")})]}):null]})]})})}function mfs({stage:t,deals:s,onDealClick:r,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:d=!1,getOwnerInfo:u}){const p=S.useRef(null),f=s.reduce((w,N)=>w+(N.expected_price||0),0),v=s.reduce((w,N)=>w+(N.expected_commission||0),0),_=s.reduce((w,N)=>w+(L2e(N)||0),0),b=w=>w>=1e6?`$${(w/1e6).toFixed(1)}M`:w>=1e3?`$${(w/1e3).toFixed(0)}K`:`$${w.toFixed(0)}`,j=t.icon&&Xve[t.icon]||Gc;return e.jsxs("div",{ref:p,className:Pt("flex flex-col h-full min-w-[280px] max-w-[320px] bg-muted/30 rounded-xl border border-border/50 transition-all duration-200",i&&"border-primary/50 bg-primary/5 ring-2 ring-primary/20"),onDragOver:w=>o(w,t.id),onDrop:w=>l(w,t.id),children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:t.color,borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color}20`},children:e.jsx(j,{className:"h-4 w-4",style:{color:t.color}})}),e.jsx("div",{children:e.jsx("h3",{className:"font-semibold text-sm",children:t.name})})]}),e.jsx(at,{variant:"secondary",className:"text-xs font-medium px-2",children:s.length})]}),f>0&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-wrap",children:[e.jsx("span",{className:"font-medium text-foreground",children:b(f)}),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(Bi,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(w=>e.jsx("div",{draggable:!0,onDragStart:N=>{N.dataTransfer.effectAllowed="move",a(w.id,t.id)},children:e.jsx(wJe,{deal:w,onClick:()=>r(w),isWonStage:d,ownerInfo:(u==null?void 0:u(w))||null})},w.id)),s.length===0&&e.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground text-sm",children:[e.jsx("p",{className:"mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-xs",children:"Drag deals here or add new"})]})]})}),e.jsx("div",{className:"p-2 border-t border-border/50 shrink-0",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground hover:text-foreground",onClick:()=>n(t.id),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})})]})}function pfs({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:Hh,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Pipeline Value",value:r((t==null?void 0:t.pipelineValue)||0),icon:Xo,color:"text-purple-500",bgColor:"bg-purple-500/10"},{label:"Expected GCI",value:r((t==null?void 0:t.expectedCommission)||0),icon:Kc,color:"text-emerald-500",bgColor:"bg-emerald-500/10"},{label:"Net to Agent",value:r((t==null?void 0:t.expectedNetToAgent)||0),icon:zP,color:"text-teal-500",bgColor:"bg-teal-500/10"},{label:"Won Deals",value:(t==null?void 0:t.wonDeals)||0,icon:Ki,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(Ee,{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(Ee,{className:"border-border/50 hover:shadow-sm transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:Pt("p-2 rounded-lg",a.bgColor),children:e.jsx(a.icon,{className:Pt("h-5 w-5",a.color)})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:a.label}),e.jsx("p",{className:"text-xl font-bold",children:a.value})]})]})})},a.label))})}function ffs({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=Gs(),[a,o]=S.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(hn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(at,{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(mf,{open:a,onOpenChange:o,children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs(pf,{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(hn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),t.portal_enabled&&e.jsx(at,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),e.jsx(Vo,{className:Pt("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),e.jsx(ff,{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(ve,{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(Br,{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(ve,{className:"text-sm font-medium",children:"Portal Visibility"}),e.jsxs(w_e,{value:t.visibility,onValueChange:i=>l({visibility:i}),className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{className:Pt("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t.visibility==="private"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[e.jsx(Nne,{value:"private"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(zu,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:"Private"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Link-only access"})]})]}),e.jsxs("label",{className:Pt("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t.visibility==="public"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[e.jsx(Nne,{value:"public"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Pm,{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(zo,{id:"require_onboarding",checked:t.require_onboarding,onCheckedChange:i=>l({require_onboarding:!!i}),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx(ve,{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(zo,{id:"allow_spouse",checked:t.allow_spouse,onCheckedChange:i=>l({allow_spouse:!!i})}),e.jsx(ve,{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(ve,{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(ve,{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(ve,{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(ve,{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(ve,{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(sr,{})}),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 gfs=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],xfs=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function yfs({open:t,onOpenChange:s,deal:r,defaultStageId:n}){const{data:a}=Cce(),{data:o}=Jh(),{data:l}=lVe(),i=Yoe(),d=gJe(),u=xJe(),p=jwe(),[f,v]=S.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[_,b]=S.useState(""),[j,w]=S.useState(!1),[N,C]=S.useState(!1),[A,I]=S.useState({first_name:"",last_name:"",email:"",phone:""}),L=(l==null?void 0:l.filter(te=>((r==null?void 0:r.listing_id)===te.id,!0)))||[],[R,$]=S.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:""});S.useEffect(()=>{var te,Y,de,ie,ae,le,pe,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:((de=r.brokerage_split_pct)==null?void 0:de.toString())||"",team_split_pct:((ie=r.team_split_pct)==null?void 0:ie.toString())||"",referral_fee_pct:((ae=r.referral_fee_pct)==null?void 0:ae.toString())||"",franchise_fee_pct:((le=r.franchise_fee_pct)==null?void 0:le.toString())||"",transaction_fee:((pe=r.transaction_fee)==null?void 0:pe.toString())||"",target_close_date:r.target_close_date?fl(r.target_close_date):void 0,contract_date:r.contract_date?fl(r.contract_date):void 0,listing_date:r.listing_date?fl(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 de,ie,ae;const Y=_.toLowerCase();return((de=te.first_name)==null?void 0:de.toLowerCase().includes(Y))||((ie=te.last_name)==null?void 0:ie.toLowerCase().includes(Y))||((ae=te.email)==null?void 0:ae.toLowerCase().includes(Y))}).slice(0,5),U=()=>{const te=parseFloat(R.expected_price)||0,Y=parseFloat(R.commission_percentage)||0;return te*(Y/100)},V=()=>{const te=U();if(!te)return null;let Y=te;const de=parseFloat(R.brokerage_split_pct)||0,ie=parseFloat(R.team_split_pct)||0,ae=parseFloat(R.referral_fee_pct)||0,le=parseFloat(R.franchise_fee_pct)||0,pe=parseFloat(R.transaction_fee)||0;return de&&(Y=Y*((100-de)/100)),ie&&(Y=Y*((100-ie)/100)),ae&&(Y=Y-te*ae/100),le&&(Y=Y-te*le/100),pe&&(Y=Y-pe),Math.max(0,Y)},X=async te=>{var Y,de,ie;if(te.preventDefault(),!R.deal_name.trim()){fe.error("Please enter a deal name");return}try{const ae={deal_name:R.deal_name,deal_type:R.deal_type,stage_id:R.stage_id||null,contact_id:R.contact_id||null,listing_id:R.listing_id||null,property_address:R.property_address||null,city:R.city||null,state:R.state||null,zip_code:R.zip_code||null,expected_price:R.expected_price?parseFloat(R.expected_price):null,expected_commission:U()||null,commission_percentage:R.commission_percentage?parseFloat(R.commission_percentage):3,brokerage_split_pct:R.brokerage_split_pct?parseFloat(R.brokerage_split_pct):null,team_split_pct:R.team_split_pct?parseFloat(R.team_split_pct):null,referral_fee_pct:R.referral_fee_pct?parseFloat(R.referral_fee_pct):null,franchise_fee_pct:R.franchise_fee_pct?parseFloat(R.franchise_fee_pct):null,transaction_fee:R.transaction_fee?parseFloat(R.transaction_fee):null,net_commission:V(),target_close_date:((Y=R.target_close_date)==null?void 0:Y.toISOString().split("T")[0])||null,contract_date:((de=R.contract_date)==null?void 0:de.toISOString().split("T")[0])||null,listing_date:((ie=R.listing_date)==null?void 0:ie.toISOString().split("T")[0])||null,priority:R.priority,probability:parseInt(R.probability)||50,notes:R.notes||null};if(r)await u.mutateAsync({id:r.id,...ae}),fe.success("Deal updated successfully");else{const le=await d.mutateAsync(ae);if(fe.success("Deal created successfully"),f.portal_enabled&&(le!=null&&le.id))try{await p.mutateAsync({deal_id:le.id,visibility:f.visibility,require_onboarding:f.require_onboarding,allow_spouse:f.allow_spouse,client_name:f.client_name||null,client_email:f.client_email||null,client_phone:f.client_phone||null,invite_method:f.invite_method}),fe.success("Client portal created!")}catch{fe.error("Deal created, but portal setup failed")}}s(!1)}catch{fe.error("Failed to save deal")}},se=d.isPending||u.isPending;return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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:X,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"col-span-2 space-y-2",children:[e.jsx(ve,{htmlFor:"deal_name",children:"Deal Name *"}),e.jsx(Re,{id:"deal_name",value:R.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(ve,{children:"Deal Type"}),e.jsxs(tr,{value:R.deal_type,onValueChange:te=>$(Y=>({...Y,deal_type:te})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:gfs.map(te=>e.jsx(At,{value:te.value,children:te.label},te.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Stage"}),e.jsxs(tr,{value:R.stage_id||"none",onValueChange:te=>$(Y=>({...Y,stage_id:te==="none"?"":te})),children:[e.jsx(Js,{children:e.jsx(sr,{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(ve,{children:"Link to Contact"}),e.jsxs("div",{className:"relative",children:[e.jsx(fn,{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),w(!0),C(!1),te.target.value||$(Y=>({...Y,contact_id:""}))},onFocus:()=>w(!0),placeholder:"Search contacts...",className:"pl-9"}),j&&_&&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}`),w(!1)},children:[e.jsx(Xi,{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:""}),C(!0),w(!1)},children:[e.jsx(xc,{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(xc,{className:"h-3.5 w-3.5"}),"Quick Add Contact"]}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>C(!1),children:"Cancel"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(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(K,{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()),C(!1))}catch{}},children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-3.5 w-3.5 mr-1 animate-spin"})," Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xc,{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(ve,{className:"flex items-center gap-2",children:[e.jsx(Ho,{className:"h-4 w-4"}),"Link to Listing Exchange"]}),e.jsxs(tr,{value:R.listing_id||"none",onValueChange:te=>{const Y=te==="none"?"":te,de=L.find(ie=>ie.id===Y);$(de?ie=>{var ae;return{...ie,listing_id:Y,deal_type:"seller",property_address:de.property_address||ie.property_address,city:de.city||ie.city,state:de.state||ie.state,expected_price:((ae=de.price)==null?void 0:ae.toString())||ie.expected_price}}:ie=>({...ie,listing_id:Y}))},children:[e.jsx(Js,{children:e.jsx(sr,{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(ve,{htmlFor:"property_address",children:"Address"}),e.jsx(Re,{id:"property_address",value:R.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(ve,{htmlFor:"city",children:"City"}),e.jsx(Re,{id:"city",value:R.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(ve,{htmlFor:"state",children:"State"}),e.jsx(Re,{id:"state",value:R.state,onChange:te=>$(Y=>({...Y,state:te.target.value})),maxLength:2,placeholder:"TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"zip_code",children:"ZIP"}),e.jsx(Re,{id:"zip_code",value:R.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(ve,{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:R.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(ve,{htmlFor:"commission_percentage",children:"Commission %"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{id:"commission_percentage",type:"number",step:"0.1",value:R.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(ve,{children:"Expected GCI"}),e.jsx(Re,{value:U()?`$${U().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(ve,{className:"text-xs",children:"Brokerage Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",step:"1",min:"0",max:"100",value:R.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(ve,{className:"text-xs",children:"Team Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",step:"1",min:"0",max:"100",value:R.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(ve,{className:"text-xs",children:"Referral Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",step:"1",min:"0",max:"100",value:R.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(ve,{className:"text-xs",children:"Franchise Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",step:"1",min:"0",max:"100",value:R.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(ve,{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:R.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(ve,{className:"text-xs",children:"Net to Agent"}),e.jsx(Re,{value:V()?`$${Math.round(V()).toLocaleString()}`:"-",disabled:!0,className:"bg-muted h-8 text-sm font-semibold"})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Dates & Status"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Target Close Date"}),e.jsxs(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!R.target_close_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),R.target_close_date?ws(R.target_close_date,"PPP"):"Pick a date"]})}),e.jsx(ko,{className:"w-auto p-0",align:"start",children:e.jsx(yp,{mode:"single",selected:R.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(ve,{children:"Contract Date"}),e.jsxs(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!R.contract_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),R.contract_date?ws(R.contract_date,"PPP"):"Pick a date"]})}),e.jsx(ko,{className:"w-auto p-0",align:"start",children:e.jsx(yp,{mode:"single",selected:R.contract_date,onSelect:te=>$(Y=>({...Y,contract_date:te})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),(R.deal_type==="seller"||R.deal_type==="dual")&&!R.listing_id&&e.jsxs("div",{className:"space-y-2 col-span-2",children:[e.jsx(ve,{children:"Listing Date (for Days on Market)"}),e.jsxs(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!R.listing_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),R.listing_date?ws(R.listing_date,"PPP"):"Pick a date"]})}),e.jsx(ko,{className:"w-auto p-0",align:"start",children:e.jsx(yp,{mode:"single",selected:R.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(ve,{children:"Priority"}),e.jsxs(tr,{value:R.priority,onValueChange:te=>$(Y=>({...Y,priority:te})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:xfs.map(te=>e.jsx(At,{value:te.value,children:te.label},te.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Win Probability"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",min:"0",max:"100",value:R.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(ve,{htmlFor:"notes",children:"Notes"}),e.jsx(Mr,{id:"notes",value:R.notes,onChange:te=>$(Y=>({...Y,notes:te.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!r&&e.jsx(ffs,{formData:f,onChange:v}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:se,children:[se&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Deal":"Create Deal"]})]})]})]})})}function vfs(t){return Ct({queryKey:["deal-files",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_files").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function _fs(){const t=ti(),s=ns();return Ot({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 G.storage.from("deal-files").upload(o,n);if(l)throw l;const{data:i,error:d}=await G.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 bfs(){const t=ns();return Ot({mutationFn:async({fileId:s,storagePath:r,dealId:n})=>{await G.storage.from("deal-files").remove([r]);const{error:a}=await G.from("deal_files").delete().eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}function wfs(){const t=ns();return Ot({mutationFn:async({fileId:s,visible:r,dealId:n})=>{const{error:a}=await G.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 jfs(t){const{data:s,error:r}=await G.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;return s.signedUrl}const SLe={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function kfs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=fBt(),a=gBt(),o=xBt(),l=yBt(),[i,d]=S.useState(!1),[u,p]=S.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[f,v]=S.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}),p({question_text:"",field_type:"text",options:[],is_required:!1}),v(""),d(!1),fe.success("Question added")}catch{fe.error("Failed to add question")}},b=async C=>{try{await l.mutateAsync(C),fe.success("Question removed")}catch{fe.error("Failed to remove question")}},j=async(C,A)=>{try{await o.mutateAsync({id:C,is_required:A})}catch{fe.error("Failed to update question")}},w=()=>{f.trim()&&(p(C=>({...C,options:[...C.options,f.trim()]})),v(""))},N=C=>{p(A=>({...A,options:A.options.filter((I,L)=>L!==C)}))};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-md max-h-[85vh] flex flex-col",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(Bi,{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(As,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),r==null?void 0:r.map(C=>{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(Fu,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:C.question_text}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(at,{variant:"secondary",className:"text-xs",children:SLe[C.field_type]||C.field_type}),C.is_required&&e.jsx(at,{variant:"outline",className:"text-xs",children:"Required"})]}),C.field_type==="dropdown"&&((A=C.options)==null?void 0:A.length)>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Options: ",C.options.join(", ")]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(Br,{checked:C.is_required,onCheckedChange:I=>j(C.id,I),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>b(C.id),children:e.jsx(br,{className:"h-3.5 w-3.5"})})]})]})},C.id)}),!n&&(r==null?void 0:r.length)===0&&!i&&e.jsxs("div",{className:"text-center py-8 border border-dashed rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"No custom questions yet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add questions that clients will answer during onboarding."})]}),i&&e.jsxs("div",{className:"border-2 border-primary/20 rounded-lg p-4 space-y-3 bg-primary/5",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Question"}),e.jsx(Re,{value:u.question_text,onChange:C=>p(A=>({...A,question_text:C.target.value})),className:"mt-1",placeholder:"e.g., Do you have a home to sell first?",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Answer Type"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(SLe).map(([C,A])=>e.jsx("button",{type:"button",onClick:()=>p(I=>({...I,field_type:C,options:[]})),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${u.field_type===C?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:A},C))})]}),u.field_type==="dropdown"&&e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Options"}),e.jsxs("div",{className:"space-y-1.5 mt-1.5",children:[u.options.map((C,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:C}),e.jsx("button",{onClick:()=>N(A),className:"text-muted-foreground hover:text-destructive",children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]},A)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:f,onChange:C=>v(C.target.value),onKeyDown:C=>C.key==="Enter"&&(C.preventDefault(),w()),placeholder:"Add option...",className:"h-8 text-sm"}),e.jsx(K,{variant:"outline",size:"sm",onClick:w,disabled:!f.trim(),className:"h-8",children:e.jsx(Zs,{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(Br,{checked:u.is_required,onCheckedChange:C=>p(A=>({...A,is_required:C}))}),e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Required"})]})}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>d(!1),className:"flex-1",children:"Cancel"}),e.jsxs(K,{size:"sm",onClick:_,disabled:!u.question_text.trim()||a.isPending,className:"flex-1",children:[a.isPending?e.jsx(As,{className:"h-3 w-3 mr-1 animate-spin"}):null,"Add Question"]})]})]})]})}),e.jsxs("div",{className:"flex justify-between pt-4 border-t shrink-0",children:[i?e.jsx("div",{}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>d(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Question"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Done"})]})]})})}function Nfs({portalId:t,ownerId:s,clientEmail:r,linkedPortalId:n,onLink:a}){const[o,l]=S.useState(""),[i,d]=S.useState(!1),{data:u,isLoading:p}=Ct({queryKey:["all-owner-portals",s],queryFn:async()=>{const{data:b,error:j}=await G.from("client_portals").select(` id, slug, client_name, client_email, deal_id, archived_at, deal_pipeline (id, deal_name, deal_type, property_address) `).eq("owner_user_id",s).neq("id",t).is("archived_at",null).eq("is_enabled",!0);if(j)throw j;return b},enabled:i||!!n}),f=S.useMemo(()=>!n||!u?null:u.find(b=>b.id===n),[n,u]),v=S.useMemo(()=>!u||!r?[]:u.filter(b=>{var j;return((j=b.client_email)==null?void 0:j.toLowerCase())===r.toLowerCase()&&b.id!==t}),[u,r,t]),_=S.useMemo(()=>{if(!u||!o.trim())return[];const b=o.toLowerCase();return u.filter(j=>{var N,C,A,I;const w=j.deal_pipeline;return((N=j.client_name)==null?void 0:N.toLowerCase().includes(b))||((C=j.client_email)==null?void 0:C.toLowerCase().includes(b))||((A=w==null?void 0:w.deal_name)==null?void 0:A.toLowerCase().includes(b))||((I=w==null?void 0:w.property_address)==null?void 0:I.toLowerCase().includes(b))})},[u,o]);if(n){const b=f==null?void 0:f.deal_pipeline;return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(Ho,{className:"h-4 w-4 text-primary shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:(f==null?void 0:f.client_name)||(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(K,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive shrink-0",onClick:()=>a(null),children:[e.jsx(uN,{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(ve,{className:"text-sm font-medium",children:"Link Another Transaction"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Combine buy + sell into one portal"})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>d(!i),children:[e.jsx(Ho,{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 j=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(at,{variant:"outline",className:"text-[10px] shrink-0 bg-amber-100 border-amber-300 text-amber-700",children:(j==null?void 0:j.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(j==null?void 0:j.deal_name)||b.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:j==null?void 0:j.property_address})]}),e.jsx(Ho,{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(fn,{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})]}),p&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(As,{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 j=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(at,{variant:"outline",className:"text-[10px] shrink-0",children:(j==null?void 0:j.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(j==null?void 0:j.deal_name)||b.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:b.client_email})]})]},b.id)})}),o&&_.length===0&&!p&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No portals found"})]})]})}function D2e({userId:t,onSelect:s,triggerLabel:r="Library",triggerSize:n="sm",triggerVariant:a="outline",triggerClassName:o}){const[l,i]=S.useState(!1),[d,u]=S.useState([]),[p,f]=S.useState(!1),[v,_]=S.useState("");S.useEffect(()=>{!l||!t||(f(!0),G.from("agent_videos").select("id, title, recipient_name, playback_url, thumbnail_url, created_at, duration_seconds").eq("owner_user_id",t).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1}).limit(50).then(({data:j})=>{u(j||[]),f(!1)}))},[l,t]);const b=d.filter(j=>!v||(j.title||j.recipient_name||"").toLowerCase().includes(v.toLowerCase()));return e.jsxs(vs,{open:l,onOpenChange:i,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:a,size:n,className:o||"gap-1.5 shrink-0",children:[e.jsx(lu,{className:"h-3.5 w-3.5"}),r]})}),e.jsxs(ys,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(fn,{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:j=>_(j.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-2 min-h-0",children:p?e.jsxs(e.Fragment,{children:[e.jsx(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(j=>e.jsxs("button",{onClick:()=>{s(j.playback_url||""),i(!1)},className:"w-full flex items-center gap-3 p-3 rounded-lg border border-border hover:border-primary/50 hover:bg-accent/50 transition-colors text-left",children:[e.jsx("div",{className:"w-16 h-10 rounded bg-muted flex items-center justify-center shrink-0 overflow-hidden",children:j.thumbnail_url?e.jsx("img",{src:j.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:w=>{const N=w.currentTarget.parentElement;if(N){w.currentTarget.remove();const C=document.createElement("span");C.innerHTML="🎬",C.className="text-lg",N.appendChild(C)}}}):e.jsx(kn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:j.title||j.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.duration_seconds?`${Math.round(j.duration_seconds)}s`:"",j.created_at?` · ${new Date(j.created_at).toLocaleDateString()}`:""]})]})]},j.id))})]})]})}function O2e({contactId:t,onVideoReady:s}){const[r,n]=S.useState(!1),[a,o]=S.useState("record"),[l,i]=S.useState(0),[d,u]=S.useState(0),p=iS(),f=()=>{o("record"),i(0),u(0)},v=b=>{!b&&(a==="uploading"||a==="processing")||(n(b),b||f())},_=S.useCallback(async(b,j)=>{o("uploading");try{const w="Card Video",{videoId:N,libraryId:C}=await KL(w),{uploadUrl:A,apiKey:I}=await ZL(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 R=0;const $=Date.now(),q=9e4,U=`https://iframe.mediadelivery.net/embed/${C}/${N}`;for(;R<4;){if(await new Promise(te=>setTimeout(te,3e3)),Date.now()-$>q){const te=b.size/1048576;await p.mutateAsync({bunny_video_id:N,playback_url:`https://iframe.mediadelivery.net/play/${C}/${N}`,file_size_mb:te,title:w,contact_id:t||void 0,status:"processing",touch_type:"video"}),s(U),fe.success("Video saved — still encoding. It will be ready shortly."),o("done"),setTimeout(()=>{n(!1),f()},1500);return}const se=await M3(N);if(R=se.status,u(se.encodeProgress||0),R===5||R===6)throw new Error("Video processing failed")}const V=await M3(N),X=(V.storageSize||b.size)/(1024*1024);await p.mutateAsync({bunny_video_id:N,contact_id:t||void 0,playback_url:V.directPlayUrl||U,thumbnail_url:V.thumbnailUrl,preview_url:V.previewUrl||null,duration_seconds:V.length||j,file_size_mb:X,title:w,status:"ready",touch_type:"video"}),s(U),fe.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),f()},1500)}catch(w){console.error("Recording upload error:",w),fe.error("Failed to process video. Please try again."),o("record")}},[t,s,p]);return e.jsxs(vs,{open:r,onOpenChange:v,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 w-full",children:[e.jsx(kn,{className:"h-3.5 w-3.5"}),"Record Video"]})}),e.jsxs(ys,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Record a Video for Your Card"})}),a==="record"&&e.jsx(Tce,{maxDurationSeconds:60,onRecordingComplete:_,onError:b=>fe.error(b)}),a==="uploading"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(As,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Uploading video..."}),e.jsx(Ti,{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(As,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Processing video..."}),e.jsx(Ti,{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(gi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}function jJe({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=YL(),[o,l]=S.useState(!1),[i,d]=S.useState(r.next_step_text||""),[u,p]=S.useState(r.next_step_video_url||""),[f,v]=S.useState(r.inspection_date||""),[_,b]=S.useState(r.appraisal_date||""),[j,w]=S.useState(r.welcome_message||""),[N,C]=S.useState(r.review_url||""),[A,I]=S.useState(r.show_post_close_tips),[L,R]=S.useState(r.notify_client),[$,q]=S.useState(r.require_onboarding),[U,V]=S.useState(r.allow_spouse),[X,se]=S.useState(r.visibility),[te,Y]=S.useState(r.stage_mapping||[]),[de,ie]=S.useState(null),[ae,le]=S.useState(r.linked_portal_id||null),{data:pe}=Ct({queryKey:["pipeline-stages-for-portal",n],queryFn:async()=>{const{data:_e,error:Ce}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",n).order("sort_order",{ascending:!0});if(Ce)throw Ce;return _e},enabled:t});S.useEffect(()=>{d(r.next_step_text||""),p(r.next_step_video_url||""),v(r.inspection_date||""),b(r.appraisal_date||""),w(r.welcome_message||""),C(r.review_url||""),I(r.show_post_close_tips),R(r.notify_client),q(r.require_onboarding),V(r.allow_spouse),se(r.visibility),Y(r.stage_mapping||[]),le(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:f||null,appraisal_date:_||null,welcome_message:j||null,review_url:N||null,show_post_close_tips:A,notify_client:L,require_onboarding:$,allow_spouse:U,visibility:X,stage_mapping:te.length>0?te:null,linked_portal_id:ae});const _e=r.linked_portal_id;ae&&ae!==_e&&await G.from("client_portals").update({linked_portal_id:r.id}).eq("id",ae),!ae&&_e&&await G.from("client_portals").update({linked_portal_id:null}).eq("id",_e),fe.success("Portal settings saved"),s(!1)}catch{fe.error("Failed to save settings")}},ye=()=>{Y([...te,{label:""}])},we=_e=>{Y(te.filter((Ce,Te)=>Te!==_e)),de===_e&&ie(null)},ke=(_e,Ce,Te)=>{const Fe=[...te];Fe[_e]={...Fe[_e],[Ce]:Te},Y(Fe)},Ze=()=>{const Ce=s_e(null).map(Te=>({label:Te.label,description:Te.description,stageId:void 0}));Y(Ce)};return e.jsxs(e.Fragment,{children:[e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-lg max-h-[85vh] flex flex-col",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Portal Settings"})}),e.jsxs(Na,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(va,{className:"grid grid-cols-3 shrink-0",children:[e.jsx(ks,{value:"general",children:"General"}),e.jsx(ks,{value:"timeline",children:"Timeline"}),e.jsx(ks,{value:"content",children:"Content"})]}),e.jsxs(Bi,{className:"flex-1 mt-4",children:[e.jsxs(zs,{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(ve,{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(_e=>e.jsx("button",{onClick:()=>se(_e),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${X===_e?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:_e.charAt(0).toUpperCase()+_e.slice(1)},_e))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{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(Br,{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(ve,{className:"text-sm font-medium",children:"Custom Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage intake form questions"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>l(!0),className:"text-xs",children:"Manage"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{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(Br,{checked:U,onCheckedChange:V})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{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(Br,{checked:A,onCheckedChange:I})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{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(Br,{checked:L,onCheckedChange:R})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(Nfs,{portalId:r.id,ownerId:n,clientEmail:r.client_email,linkedPortalId:ae,onLink:le})}),e.jsx("div",{children:e.jsx(Re,{type:"date",value:f,onChange:_e=>v(_e.target.value),className:"mt-1"})}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Appraisal Date"}),e.jsx(Re,{type:"date",value:_,onChange:_e=>b(_e.target.value),className:"mt-1"})]})]}),e.jsx(zs,{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(ve,{className:"text-sm font-medium",children:"Client-Facing Stages"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Customize the client-friendly stage labels shown on the portal timeline"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:Ze,className:"text-xs",children:"Auto-map"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground bg-muted/50 rounded-md p-2",children:'💡 These labels are what clients see. Click "More" on any stage to customize its description and add a video link. Internal pipeline stages are automatically translated to friendly names.'}),te.length===0&&e.jsxs("div",{className:"border border-dashed rounded-lg p-4 text-center",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"No custom mapping — using default client-friendly journey stages"}),e.jsx(K,{variant:"outline",size:"sm",onClick:Ze,children:"Customize journey labels"})]}),e.jsx("div",{className:"space-y-2 mt-2",children:te.map((_e,Ce)=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fu,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(Re,{value:_e.label,onChange:Te=>ke(Ce,"label",Te.target.value),placeholder:`Stage ${Ce+1} label`,className:"flex-1 h-9 text-sm"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-primary",onClick:()=>ie(de===Ce?null:Ce),children:de===Ce?"Less":"More"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>we(Ce),children:e.jsx(br,{className:"h-3.5 w-3.5"})})]}),de===Ce&&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(ve,{className:"text-xs text-muted-foreground",children:"Description"}),e.jsx("textarea",{value:_e.description||"",onChange:Te=>ke(Ce,"description",Te.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(ve,{className:"text-xs text-muted-foreground",children:"Video"}),_e.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:_e.video_url.length>40?_e.video_url.slice(0,40)+"...":_e.video_url}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>ke(Ce,"video_url",""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(O2e,{onVideoReady:Te=>ke(Ce,"video_url",Te)}),e.jsx(D2e,{userId:n,onSelect:Te=>ke(Ce,"video_url",Te),triggerSize:"sm",triggerClassName:"gap-1.5 shrink-0 flex-1"}),e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const Te=prompt("Paste a YouTube or Loom URL:");Te&&ke(Ce,"video_url",Te)},children:[e.jsx(Lo,{className:"h-3 w-3"}),"Paste URL"]})]})]})]})]},Ce))}),te.length>0&&e.jsxs(K,{variant:"outline",size:"sm",onClick:ye,className:"mt-2 text-xs w-full",children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add Stage"]})]})}),e.jsxs(zs,{value:"content",className:"space-y-4 mt-0 px-1",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Welcome Message"}),e.jsx("textarea",{value:j,onChange:_e=>w(_e.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(ve,{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:_e=>d(_e.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(ve,{className:"text-sm font-medium",children:"Next Step Video (optional)"}),e.jsx(Re,{value:u,onChange:_e=>p(_e.target.value),className:"mt-1",placeholder:"YouTube or Loom URL"})]}),e.jsxs("div",{children:[e.jsx(ve,{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:_e=>C(_e.target.value),className:"mt-1",placeholder:"https://g.page/r/..."})]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:be,disabled:a.isPending,children:[a.isPending?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Bu,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})}),e.jsx(kfs,{open:o,onOpenChange:l})]})}function kJe({open:t,onOpenChange:s,portalId:r,portalSlug:n,notifyClient:a}){const[o,l]=S.useState(""),[i,d]=S.useState(""),[u,p]=S.useState(""),[f,v]=S.useState(!1),[_,b]=S.useState(a??!1),j=_Ze(),w=async()=>{if(o.trim())try{if(await j.mutateAsync({portal_id:r,title:o.trim(),content:i.trim()||void 0,video_url:u.trim()||void 0,is_stage_change:f}),_&&n)try{const N=z0(n);await G.functions.invoke("send-portal-notification",{body:{portal_id:r,update_title:o.trim(),update_content:i.trim()||null,portal_url:N}}),fe.success("Update posted & client notified")}catch(N){console.error("Notification failed:",N),fe.success("Update posted (notification failed to send)")}else fe.success("Update posted to portal");l(""),d(""),p(""),v(!1),s(!1)}catch{fe.error("Failed to post update")}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{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(ve,{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(ve,{className:"text-sm font-medium",children:"Video URL (optional)"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(Re,{value:u,onChange:N=>p(N.target.value),className:"pl-9",placeholder:"YouTube or Loom link"}),e.jsx(kn,{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(!f),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${f?"bg-emerald-500/10 text-emerald-700 border-emerald-200":"bg-background text-muted-foreground border-input"}`,children:"📊 Stage Change"}),e.jsxs("button",{type:"button",onClick:()=>b(!_),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors flex items-center gap-1.5 ${_?"bg-blue-500/10 text-blue-700 border-blue-200":"bg-background text-muted-foreground border-input"}`,children:[_?e.jsx(cf,{className:"h-3 w-3"}):e.jsx(X1,{className:"h-3 w-3"}),_?"Notify Client":"No Notification"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:w,disabled:!o.trim()||j.isPending,children:[j.isPending?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ka,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})})}function NJe({open:t,onOpenChange:s,portal:r,dealName:n}){const a=YL(),{isGmailConnected:o,gmailEmail:l}=gy(),[i,d]=S.useState(r.client_name||""),[u,p]=S.useState(r.client_email||""),[f,v]=S.useState(!1),[_,b]=S.useState(!1),j=z0(r.slug),w=i.split(" ")[0]||"there",N=`Your Transaction Portal – ${n}`,C=`Hi ${w}, I've set up a dedicated portal where you can track the progress of your transaction in real-time. Here's your link: ${j} You can view your timeline, key dates, documents, and any updates I post along the way. Let me know if you have any questions!`,A=()=>{navigator.clipboard.writeText(j),b(!0),setTimeout(()=>b(!1),2e3),fe.success("Portal link copied!")},I=async()=>{if(!u.trim()){fe.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:R}=await G.functions.invoke("gmail-send",{body:{to:u,subject:N,body:C.replace(/\n/g,"
")}});if(R)throw R;fe.success(`Invite sent to ${u}`),s(!1)}catch(R){fe.error(R.message||"Failed to send invite")}finally{v(!1)}},L=()=>{const R=encodeURIComponent(N),$=encodeURIComponent(C);window.open(`mailto:${u}?subject=${R}&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(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Invite Client to Portal"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Client Name"}),e.jsx(Re,{value:i,onChange:R=>d(R.target.value),className:"mt-1",placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Client Email"}),e.jsx(Re,{type:"email",value:u,onChange:R=>p(R.target.value),className:"mt-1",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Portal Link"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-muted/50 rounded-md px-3 py-2",children:e.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:j})}),e.jsx(K,{variant:"outline",size:"icon",onClick:A,className:"shrink-0",children:_?e.jsx(ua,{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(K,{onClick:I,disabled:f||!u.trim(),className:"w-full",children:[f?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(_r,{className:"h-4 w-4 mr-2"}),"Send via Gmail (",l,")"]}):e.jsxs(K,{onClick:L,disabled:!u.trim(),className:"w-full",variant:"outline",children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),e.jsxs(K,{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 Sfs({deal:t}){const{isAdmin:s,user:r}=Gs(),{data:n,isLoading:a}=uBt(t.id),o=jwe(),l=YL(),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[f,v]=S.useState(!1),[_,b]=S.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(hn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(As,{className:"h-3 w-3 animate-spin ml-auto"})]})});const j=async()=>{var L,R;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:((R=t.contact)==null?void 0:R.phone)||void 0}),fe.success("Client portal enabled!")}catch{fe.error("Failed to create portal")}finally{d(!1)}},w=async L=>{if(n)try{await l.mutateAsync({id:n.id,is_enabled:L}),fe.success(L?"Portal enabled":"Portal disabled")}catch{fe.error("Failed to update portal")}},N=()=>{if(!n)return;const L=z0(n.slug);navigator.clipboard.writeText(L),fe.success("Portal link copied!")},C=()=>{if(!n)return;const L=z0(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(hn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Create a beautiful portal so your client can track their deal progress in real-time."}),e.jsxs(K,{onClick:j,disabled:i,size:"sm",className:"w-full",children:[i?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const A=z0(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(hn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(at,{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(Br,{checked:n.is_enabled,onCheckedChange:w})]}),e.jsxs("div",{className:"space-y-1.5 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Visibility:"}),e.jsx(at,{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(K,{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(K,{variant:"outline",size:"sm",onClick:C,className:"text-xs flex-1 min-w-0",children:[e.jsx(sn,{className:"h-3 w-3 mr-1 shrink-0"}),"Preview"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>b(!0),className:"text-xs flex-1 min-w-0",children:[e.jsx(ka,{className:"h-3 w-3 mr-1 shrink-0"}),"Invite"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>v(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(y5,{className:"h-3 w-3 mr-1 shrink-0"}),"Post Update"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>p(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx($l,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]})]}),e.jsx(jJe,{open:u,onOpenChange:p,portal:n,dealOwnerId:I}),e.jsx(kJe,{open:f,onOpenChange:v,portalId:n.id,portalSlug:n.slug,notifyClient:n.notify_client}),e.jsx(NJe,{open:_,onOpenChange:b,portal:n,dealName:t.deal_name})]})}const Cfs=["Client","Co-Buyer","Co-Seller","Spouse","Lender","Title Company","Inspector","Appraiser","Attorney","Contractor","Other"];function Mfs(t){return Ct({queryKey:["deal-contacts",t],queryFn:async()=>{const{data:s,error:r}=await G.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 Tfs(){const t=ns();return Ot({mutationFn:async({dealId:s,contactId:r,role:n})=>{const{data:a,error:o}=await G.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]}),fe.success("Contact linked to deal")},onError:s=>{var r;(r=s.message)!=null&&r.includes("duplicate")?fe.error("This contact is already linked to this deal"):fe.error("Failed to link contact")}})}function Afs(){const t=ns();return Ot({mutationFn:async({id:s,dealId:r})=>{const{error:n}=await G.from("deal_contacts").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-contacts",r.dealId]}),fe.success("Contact removed from deal")},onError:()=>{fe.error("Failed to remove contact")}})}function Efs({dealId:t,primaryContactId:s}){const r=Dr(),{data:n,isLoading:a}=Mfs(t),{data:o}=Jh(),l=Tfs(),i=Afs(),[d,u]=S.useState(!1),[p,f]=S.useState(""),[v,_]=S.useState("Client"),b=new Set((n==null?void 0:n.map(A=>A.contact_id))||[]);s&&b.add(s);const j=o==null?void 0:o.filter(A=>{var L,R,$;if(b.has(A.id))return!1;if(!p.trim())return!0;const I=p.toLowerCase();return((L=A.first_name)==null?void 0:L.toLowerCase().includes(I))||((R=A.last_name)==null?void 0:R.toLowerCase().includes(I))||(($=A.email)==null?void 0:$.toLowerCase().includes(I))}).slice(0,8),w=A=>{l.mutate({dealId:t,contactId:A,role:v}),u(!1),f("")},N=A=>{i.mutate({id:A,dealId:t})},C={Client:"bg-primary/10 text-primary","Co-Buyer":"bg-blue-500/10 text-blue-600","Co-Seller":"bg-emerald-500/10 text-emerald-600",Spouse:"bg-pink-500/10 text-pink-600",Lender:"bg-amber-500/10 text-amber-600","Title Company":"bg-purple-500/10 text-purple-600",Inspector:"bg-orange-500/10 text-orange-600",Appraiser:"bg-cyan-500/10 text-cyan-600",Attorney:"bg-slate-500/10 text-slate-600",Contractor:"bg-lime-500/10 text-lime-600",Other:"bg-muted text-muted-foreground"};return!(n!=null&&n.length)&&!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(hr,{className:"h-4 w-4"}),"Additional Contacts"]})}),e.jsxs(So,{open:d,onOpenChange:u,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"w-full text-muted-foreground",children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"}),"Link a contact (lender, spouse, vendor...)"]})}),e.jsx(ko,{className:"w-80 p-3",align:"start",children:e.jsx(CLe,{search:p,setSearch:f,selectedRole:v,setSelectedRole:_,filteredContacts:j,onAdd:w})})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Linked Contacts",n&&n.length>0&&e.jsx(at,{variant:"secondary",className:"text-[10px] px-1.5",children:n.length})]}),e.jsxs(So,{open:d,onOpenChange:u,children:[e.jsx(Co,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx(Zs,{className:"h-3.5 w-3.5"})})}),e.jsx(ko,{className:"w-80 p-3",align:"end",children:e.jsx(CLe,{search:p,setSearch:f,selectedRole:v,setSelectedRole:_,filteredContacts:j,onAdd:w})})]})]}),e.jsx("div",{className:"space-y-1.5",children:n==null?void 0:n.map(A=>{var I,L,R,$,q,U,V,X;return e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/40 group",children:[e.jsx(gn,{className:"h-7 w-7",children:e.jsxs(xn,{className:"text-[10px] bg-primary/10 text-primary",children:[(L=(I=A.contact)==null?void 0:I.first_name)==null?void 0:L[0],($=(R=A.contact)==null?void 0:R.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," ",(U=A.contact)==null?void 0:U.last_name]})}),e.jsx(at,{variant:"outline",className:`text-[10px] px-1.5 py-0 shrink-0 ${C[A.role]||C.Other}`,children:A.role}),e.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[((V=A.contact)==null?void 0:V.phone)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`tel:${A.contact.phone}`,children:e.jsx(Zn,{className:"h-3 w-3"})})}),((X=A.contact)==null?void 0:X.email)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`mailto:${A.contact.email}`,children:e.jsx(_r,{className:"h-3 w-3"})})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>N(A.id),children:e.jsx(br,{className:"h-3 w-3"})})]})]},A.id)})})]})}function CLe({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(sr,{placeholder:"Role"})}),e.jsx(er,{children:Cfs.map(l=>e.jsx(At,{value:l,children:l},l))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(fn,{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(Bi,{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 Pfs={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"}},Ifs={note:oo,call:Zn,email:_r,meeting:on,stage_change:sn,task_completed:da,document:Un,system:Tn};function Lfs({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var Te,Fe;const{data:l,isLoading:i}=_ps((t==null?void 0:t.id)||""),{data:d,isLoading:u}=wps((t==null?void 0:t.id)||""),p=bps(),f=kps(),v=jps(),_=vps(),{data:b,isLoading:j}=vfs((t==null?void 0:t.id)||""),w=_fs(),N=bfs(),C=wfs(),A=S.useRef(null),[I,L]=S.useState(""),[R,$]=S.useState(""),[q,U]=S.useState(!1),[V,X]=S.useState(!1);if(!t)return null;const se=Pfs[t.deal_type],te=(()=>{var ht;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const Ae=((ht=t.listing)==null?void 0:ht.created_at)||t.listing_date;if(!Ae)return null;const We=t.contract_date?fl(t.contract_date):new Date;return Gg(We,fl(Ae))})(),Y=Ae=>Ae?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Ae):"-",de=async()=>{if(I.trim())try{await p.mutateAsync({deal_id:t.id,activity_type:"note",title:"Note added",description:I}),L(""),fe.success("Note added")}catch{fe.error("Failed to add note")}},ie=async()=>{if(R.trim())try{await f.mutateAsync({deal_id:t.id,title:R,sort_order:((d==null?void 0:d.length)||0)+1}),$(""),fe.success("Task added")}catch{fe.error("Failed to add task")}},ae=async(Ae,We)=>{try{await v.mutateAsync({id:Ae,is_completed:We,deal_id:t.id})}catch{fe.error("Failed to update task")}},le=async()=>{try{await _.mutateAsync(t.id),fe.success("Deal deleted"),r(!1)}catch{fe.error("Failed to delete deal")}},pe=(d==null?void 0:d.filter(Ae=>Ae.is_completed).length)||0,be=(d==null?void 0:d.length)||0,ye=(b==null?void 0:b.length)||0,we=Ae=>Ae<1024?`${Ae} B`:Ae<1024*1024?`${(Ae/1024).toFixed(1)} KB`:`${(Ae/(1024*1024)).toFixed(1)} MB`,ke=Ae=>Ae?Ae.startsWith("image/")?Jo:Ae.includes("pdf")?In:c5:c5,Ze=async Ae=>{const We=Ae.target.files;if(!(!We||!t)){X(!0);try{for(const ht of Array.from(We)){if(ht.size>20*1024*1024){fe.error(`${ht.name} exceeds 20MB limit`);continue}await w.mutateAsync({dealId:t.id,file:ht})}fe.success("File(s) uploaded")}catch{fe.error("Failed to upload file")}finally{X(!1),A.current&&(A.current.value="")}}},_e=async(Ae,We)=>{if(t)try{await N.mutateAsync({fileId:Ae,storagePath:We,dealId:t.id}),fe.success("File deleted")}catch{fe.error("Failed to delete file")}},Ce=async(Ae,We)=>{try{const ht=await jfs(Ae),De=document.createElement("a");De.href=ht,De.download=We,De.target="_blank",document.body.appendChild(De),De.click(),document.body.removeChild(De)}catch{fe.error("Failed to download file")}};return e.jsxs(e.Fragment,{children:[e.jsx(gM,{open:s,onOpenChange:r,children:e.jsxs(rS,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[e.jsx(xM,{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(at,{variant:"outline",className:Pt("text-xs",se.color),children:se.label}),e.jsxs(at,{variant:"secondary",className:"text-xs capitalize",children:[t.priority," priority"]})]}),e.jsx(yM,{className:"text-xl",children:t.deal_name})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>n(t),children:e.jsx(Oc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"text-destructive hover:bg-destructive/10",onClick:()=>U(!0),children:e.jsx(br,{className:"h-4 w-4"})})]})]})}),e.jsx(Bi,{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(gn,{className:"h-10 w-10",children:e.jsxs(xn,{className:"bg-primary/10 text-primary",children:[(Te=t.contact.first_name)==null?void 0:Te[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(K,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`tel:${t.contact.phone}`,children:e.jsx(Zn,{className:"h-4 w-4"})})}),t.contact.email&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`mailto:${t.contact.email}`,children:e.jsx(_r,{className:"h-4 w-4"})})})]})]}),e.jsx(Efs,{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(Un,{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(K,{onClick:()=>a(t),className:"w-full bg-green-600 hover:bg-green-700",children:[e.jsx(Ki,{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(da,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{children:"Synced to Scorecard"})]}),te!==null&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 col-span-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Days on Market"}),e.jsxs("p",{className:Pt("text-lg font-bold",te>90?"text-red-600":te>60?"text-amber-600":"text-foreground"),children:[te," ",t.contract_date?"(final)":"days"]})]}),t.target_close_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(on,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Close: ",ws(fl(t.target_close_date),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Kc,{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(Sfs,{deal:t}),e.jsxs(Na,{defaultValue:"tasks",className:"w-full",children:[e.jsxs(va,{className:"w-full grid grid-cols-3",children:[e.jsxs(ks,{value:"tasks",className:"gap-1",children:[e.jsx(da,{className:"h-4 w-4"}),"Tasks ",be>0&&`(${pe}/${be})`]}),e.jsxs(ks,{value:"files",className:"gap-1",children:[e.jsx(oN,{className:"h-4 w-4"}),"Files ",ye>0&&`(${ye})`]}),e.jsxs(ks,{value:"activity",className:"gap-1",children:[e.jsx(Tn,{className:"h-4 w-4"}),"Activity"]})]}),e.jsxs(zs,{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:R,onChange:Ae=>$(Ae.target.value),onKeyDown:Ae=>Ae.key==="Enter"&&ie()}),e.jsx(K,{onClick:ie,disabled:!R.trim(),children:e.jsx(Zs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[d==null?void 0:d.map(Ae=>e.jsxs("div",{className:Pt("flex items-center gap-3 p-3 rounded-lg border transition-colors",Ae.is_completed?"bg-muted/50 border-border":"bg-background"),children:[e.jsx(zo,{checked:Ae.is_completed,onCheckedChange:We=>ae(Ae.id,!!We)}),e.jsx("span",{className:Pt("flex-1 text-sm",Ae.is_completed&&"line-through text-muted-foreground"),children:Ae.title}),Ae.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ws(new Date(Ae.due_date),"MMM d")})]},Ae.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(zs,{value:"files",className:"mt-4 space-y-3",children:[e.jsx("input",{type:"file",ref:A,className:"hidden",multiple:!0,onChange:Ze,accept:".pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.webp,.gif,.txt,.csv"}),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var Ae;return(Ae=A.current)==null?void 0:Ae.click()},disabled:V,children:[V?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ya,{className:"h-4 w-4 mr-2"}),V?"Uploading...":"Upload Files"]}),e.jsxs("div",{className:"space-y-2",children:[b==null?void 0:b.map(Ae=>{const We=ke(Ae.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(We,{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:Ae.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[we(Ae.file_size)," · ",ws(new Date(Ae.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(QN,{children:e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${Ae.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>C.mutate({fileId:Ae.id,visible:!Ae.visible_on_portal,dealId:t.id}),children:Ae.visible_on_portal?e.jsx(ya,{className:"h-4 w-4"}):e.jsx(Em,{className:"h-4 w-4"})})}),e.jsx(Wc,{side:"top",children:Ae.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ce(Ae.storage_path,Ae.file_name),children:e.jsx(xi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>_e(Ae.id,Ae.storage_path),children:e.jsx(Ur,{className:"h-4 w-4"})})]})]},Ae.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(zs,{value:"activity",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Mr,{placeholder:"Add a note...",value:I,onChange:Ae=>L(Ae.target.value),rows:2}),e.jsxs(K,{onClick:de,disabled:!I.trim(),size:"sm",className:"w-full",children:[e.jsx(ka,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),e.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(Ae=>{const We=Ifs[Ae.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(We,{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:Ae.title}),Ae.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:Ae.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Cd(new Date(Ae.created_at),{addSuffix:!0})})]})]},Ae.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(nc,{open:q,onOpenChange:U,children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Deal?"}),e.jsxs(Dl,{children:['This will permanently delete "',t.deal_name,'" and all associated data. This action cannot be undone.']})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:le,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function Dfs({open:t,onOpenChange:s,deal:r,onComplete:n}){const a=Xoe(),o=xJe(),{data:l}=wM(),{data:i}=Ef(),[d,u]=S.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:ws(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});S.useEffect(()=>{if(r&&t){const v=r.deal_type==="seller"?"seller":"buyer",_=r.expected_price||0,b=r.commission_percentage||3,j=r.expected_commission||_*b/100;u({property_address:r.property_address||r.deal_name||"",city:r.city||"",state:r.state||"",zip:r.zip_code||"",transaction_type:v,close_date:r.actual_close_date||r.target_close_date||ws(new Date,"yyyy-MM-dd"),sale_price:_,commission_amount:j,lead_source_id:"",client_type_id:"",notes:r.notes||""})}},[r,t]);const p=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}),fe.success("Deal added to Scorecard! 🎉"),s(!1),n==null||n()}catch(_){console.error("Error syncing to scorecard:",_),fe.error("Failed to add to scorecard")}},f=v=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(v);return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-[550px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{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(Ki,{className:"h-6 w-6 text-green-600 dark:text-green-400"})}),e.jsx(Ns,{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:p,className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"property_address",className:"flex items-center gap-2",children:[e.jsx(Un,{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(ve,{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(ve,{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(ve,{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(ve,{children:"Transaction Type *"}),e.jsxs(tr,{value:d.transaction_type,onValueChange:v=>u(_=>({..._,transaction_type:v})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),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(ve,{htmlFor:"close_date",className:"flex items-center gap-2",children:[e.jsx(on,{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(ve,{htmlFor:"sale_price",className:"flex items-center gap-2",children:[e.jsx(Kc,{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:f(d.sale_price)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"commission_amount",className:"flex items-center gap-2",children:[e.jsx(v5,{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:f(d.commission_amount)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(sr,{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(ve,{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(sr,{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(ve,{htmlFor:"notes",children:"Notes"}),e.jsx(Mr,{id:"notes",value:d.notes,onChange:v=>u(_=>({..._,notes:v.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(On,{className:"gap-2 sm:gap-0 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Skip for now"}),e.jsx(K,{type:"submit",disabled:a.isPending||o.isPending,className:"bg-green-600 hover:bg-green-700",children:a.isPending?"Adding...":e.jsxs(e.Fragment,{children:["Add to Scorecard",e.jsx(Fi,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}const Ofs={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"}},MLe={urgent:0,high:1,medium:2,low:3};function Rfs({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=S.useState("target_close_date"),[l,i]=S.useState("asc"),d=_=>{a===_?i(b=>b==="asc"?"desc":"asc"):(o(_),i("asc"))},u=S.useMemo(()=>[...t].sort((_,b)=>{var w,N;let j=0;switch(a){case"deal_name":j=_.deal_name.localeCompare(b.deal_name);break;case"stage":{const C=((w=s.find(I=>I.id===_.stage_id))==null?void 0:w.sort_order)||0,A=((N=s.find(I=>I.id===b.stage_id))==null?void 0:N.sort_order)||0;j=C-A;break}case"expected_price":j=(_.expected_price||0)-(b.expected_price||0);break;case"expected_commission":j=(_.expected_commission||0)-(b.expected_commission||0);break;case"target_close_date":{const C=_.target_close_date?fl(_.target_close_date).getTime():1/0,A=b.target_close_date?fl(b.target_close_date).getTime():1/0;j=C-A;break}case"priority":j=MLe[_.priority]-MLe[b.priority];break}return l==="asc"?j:-j}),[t,s,a,l]),p=_=>_?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_):"—",f=_=>_?s.find(b=>b.id===_):null,v=({field:_,children:b})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>d(_),children:[b,a===_?l==="asc"?e.jsx(Vd,{className:"ml-2 h-4 w-4"}):e.jsx(eh,{className:"ml-2 h-4 w-4"}):e.jsx(Hc,{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(An,{children:[e.jsx(En,{children:e.jsxs(js,{className:"bg-muted/50",children:[e.jsx(jt,{className:"w-[250px]",children:e.jsx(v,{field:"deal_name",children:"Deal Name"})}),e.jsx(jt,{className:"w-[150px]",children:e.jsx(v,{field:"stage",children:"Stage"})}),e.jsx(jt,{className:"w-[100px]",children:"Type"}),e.jsx(jt,{className:"w-[120px]",children:e.jsx(v,{field:"expected_price",children:"Price"})}),e.jsx(jt,{className:"w-[120px]",children:e.jsx(v,{field:"expected_commission",children:"GCI"})}),e.jsx(jt,{className:"w-[130px]",children:e.jsx(v,{field:"target_close_date",children:"Close Date"})}),e.jsx(jt,{className:"w-[100px]",children:e.jsx(v,{field:"priority",children:"Priority"})})]})}),e.jsx(Pn,{children:u.map(_=>{f(_.stage_id);const b=Ofs[_.deal_type],j=_.target_close_date?Gg(fl(_.target_close_date),new Date):null,w=j!==null&&j<0,N=j!==null&&j<=7&&j>=0;return e.jsxs(js,{className:Pt("cursor-pointer hover:bg-muted/50 transition-colors",w&&"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:C=>C.stopPropagation(),children:e.jsx(bJe,{stages:s,currentStageId:_.stage_id||"",onStageSelect:(C,A)=>n(_.id,C,A)})}),e.jsx(lt,{children:e.jsx(at,{variant:"outline",className:Pt("text-xs",b.color),children:b.label})}),e.jsx(lt,{children:e.jsx("span",{className:"font-medium",children:p(_.expected_price)})}),e.jsx(lt,{children:e.jsx("span",{className:"text-emerald-600",children:p(_.expected_commission)})}),e.jsx(lt,{children:_.target_close_date?e.jsxs("div",{className:Pt("flex items-center gap-1 text-sm",w&&"text-red-600",N&&!w&&"text-amber-600"),children:[w&&e.jsx(Qo,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:ws(fl(_.target_close_date),"MMM d, yyyy")})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(lt,{children:e.jsx(at,{variant:"outline",className:Pt("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 Ffs(){const t=ti();return Ct({queryKey:["deal-tasks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.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 zfs(t){const s=ti();return Ct({queryKey:["deal-tasks","deal",t,s],queryFn:async()=>{if(!s||!t)return[];const{data:r,error:n}=await G.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 Bfs(){const t=ti(),s=ns();return Ot({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.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 $fs(){const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("deal_tasks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function qfs(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("deal_tasks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function R2e(){const t=ns();return Ot({mutationFn:async({id:s,status:r})=>{const{data:n,error:a}=await G.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 Ufs(){const t=ns();return Ot({mutationFn:async s=>{if(s.length===0)return;const{error:r}=await G.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 Vfs(t){const s=ti();return Ct({queryKey:["deal-task-templates",s,t],queryFn:async()=>{if(!s)return[];let r=G.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 Hfs(){const t=ti(),s=ns();return Ot({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.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 Wfs(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("deal_task_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-task-templates"]})}})}function Gfs(){const t=ti(),s=ns();return Ot({mutationFn:async({dealId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await G.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 G.from("deal_tasks").select("title, stage_id").eq("deal_id",r).eq("stage_id",n),i=new Set((l||[]).map(f=>f.title)),d=a.filter(f=>!i.has(f.title)).map((f,v)=>({owner_user_id:t,deal_id:r,stage_id:n,title:f.title,description:f.description,priority:f.priority,due_date:f.default_due_offset_days?new Date(Date.now()+f.default_due_offset_days*864e5).toISOString().split("T")[0]:null,sort_order:v,status:"todo"}));if(d.length===0)return[];const{data:u,error:p}=await G.from("deal_tasks").insert(d).select();if(p)throw p;return u},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}const Kfs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Zfs({open:t,onOpenChange:s,dealId:r,dealName:n,fromStageName:a,toStageName:o,toStageId:l,onConfirm:i}){const{data:d,isLoading:u}=zfs(t?r:void 0),p=Ufs(),f=Gfs(),[v,_]=S.useState(new Set),[b,j]=S.useState(!1),w=(d||[]).filter(I=>I.status!=="done");S.useEffect(()=>{w.length>0&&_(new Set(w.map(I=>I.id)))},[d]);const N=I=>{_(L=>{const R=new Set(L);return R.has(I)?R.delete(I):R.add(I),R})},C=async()=>{j(!0);try{const I=Array.from(v);I.length>0&&await p.mutateAsync(I),await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(I){console.error("Stage move failed:",I),fe.error((I==null?void 0:I.message)||"Failed to move deal. Please try again.")}finally{j(!1)}},A=async()=>{j(!0);try{await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(I){console.error("Stage move (skip) failed:",I),fe.error((I==null?void 0:I.message)||"Failed to move deal. Please try again.")}finally{j(!1)}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-[480px]",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(at,{variant:"outline",className:"text-sm",children:a}),e.jsx(Fi,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(at,{className:"text-sm bg-primary",children:o})]}),u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You have ",e.jsx("span",{className:"font-medium text-foreground",children:w.length})," incomplete task",w.length!==1?"s":"",". Select which to mark as done:"]}),e.jsx(Bi,{className:"max-h-[250px]",children:e.jsx("div",{className:"space-y-1",children:w.map(I=>e.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-muted/50 cursor-pointer transition-colors",children:[e.jsx(zo,{checked:v.has(I.id),onCheckedChange:()=>N(I.id)}),e.jsxs("span",{className:"text-sm flex-1",children:[Kfs[I.priority]," ",I.title]}),I.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full",style:{backgroundColor:I.stage.color+"20",color:I.stage.color},children:I.stage.name})]},I.id))})}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>{v.size===w.length?_(new Set):_(new Set(w.map(I=>I.id)))},children:v.size===w.length?"Deselect All":"Select All"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:A,disabled:b,children:"Skip"}),e.jsxs(K,{size:"sm",onClick:C,disabled:b,children:[b&&e.jsx(As,{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(da,{className:"h-8 w-8 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"All tasks completed! Ready to move."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:C,disabled:b,children:[b&&e.jsx(As,{className:"h-4 w-4 mr-1 animate-spin"}),"Move to ",o]})]})]})]})})}function Yfs(){const t=ti();return Ct({queryKey:["all-client-portals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("client_portals").select("*").eq("owner_user_id",t);if(r)throw r;return s||[]},enabled:!!t})}function Xfs({dealId:t,dealName:s,contactName:r,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const d=jwe(),u=YL(),p=hBt(),f=mBt(),[v,_]=S.useState(!1),b=!!(n!=null&&n.archived_at),j=async()=>{_(!0);try{await d.mutateAsync({deal_id:t,visibility:"private",require_onboarding:!0}),fe.success("Portal enabled!")}catch{fe.error("Failed to create portal")}finally{_(!1)}},w=async L=>{if(n)try{await u.mutateAsync({id:n.id,is_enabled:L}),fe.success(L?"Portal enabled":"Portal disabled")}catch{fe.error("Failed to update portal")}},N=()=>{n&&(navigator.clipboard.writeText(z0(n.slug)),fe.success("Link copied!"))},C=()=>{n&&window.open(z0(n.slug),"_blank")},A=async()=>{if(n)try{await p.mutateAsync(n.id),fe.success("Portal archived")}catch{fe.error("Failed to archive portal")}},I=async()=>{if(n)try{await f.mutateAsync(n.id),fe.success("Portal restored")}catch{fe.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(at,{variant:"outline",className:"text-[10px] bg-muted text-muted-foreground",children:"Archived"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||r||"No client name"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:I,className:"text-xs gap-1",children:[e.jsx(KE,{className:"h-3.5 w-3.5"}),"Restore"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>i(n),className:"text-xs gap-1 text-destructive hover:text-destructive",children:[e.jsx(br,{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(at,{variant:"outline",className:n.is_enabled?"text-[10px] bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-[10px] bg-muted text-muted-foreground",children:n.is_enabled?"Active":"Disabled"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||r||"No client name"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:N,title:"Copy link",children:e.jsx(ni,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:C,title:"Preview",children:e.jsx(sn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(n,s),title:"Invite client",children:e.jsx(ka,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(n),title:"Post update",children:e.jsx(y5,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>a(n),title:"Settings",children:e.jsx($l,{className:"h-3.5 w-3.5"})}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(ef,{className:"h-3.5 w-3.5"})})}),e.jsx(Td,{align:"end",children:e.jsxs(Ta,{onClick:A,children:[e.jsx(n5,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),e.jsx(Br,{checked:n.is_enabled,onCheckedChange:w,className:"ml-1"})]})]}):e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg border-dashed bg-muted/20",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r||"No contact"})]}),e.jsxs(K,{size:"sm",onClick:j,disabled:v,className:"shrink-0 ml-4",children:[v?e.jsx(As,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(hn,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function Qfs(){const{data:t,isLoading:s}=Mce(),{data:r,isLoading:n}=Yfs(),[a,o]=S.useState(""),[l,i]=S.useState("all"),d=pBt(),[u,p]=S.useState(null),[f,v]=S.useState(null),[_,b]=S.useState(null),[j,w]=S.useState(null),N=ti(),C=s||n,A=new Map;r==null||r.forEach(V=>A.set(V.deal_id,V));const L=[...(t||[]).filter(V=>{var de,ie,ae,le,pe;const X=A.get(V.id),se=a.toLowerCase(),te=!se||V.deal_name.toLowerCase().includes(se)||((ie=(de=V.contact)==null?void 0:de.first_name)==null?void 0:ie.toLowerCase().includes(se))||((le=(ae=V.contact)==null?void 0:ae.last_name)==null?void 0:le.toLowerCase().includes(se))||((pe=X==null?void 0:X.client_name)==null?void 0:pe.toLowerCase().includes(se));let Y=!0;return l==="active"?Y=!!(X!=null&&X.is_enabled)&&!(X!=null&&X.archived_at):l==="disabled"?Y=!!X&&!X.is_enabled&&!X.archived_at:l==="archived"?Y=!!(X!=null&&X.archived_at):l==="none"?Y=!X:l==="all"&&(Y=!(X!=null&&X.archived_at)||!X),te&&Y})].sort((V,X)=>{const se=A.get(V.id),te=A.get(X.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}),R=(r==null?void 0:r.filter(V=>!V.archived_at).length)||0,$=(r==null?void 0:r.filter(V=>V.is_enabled&&!V.archived_at).length)||0,q=(r==null?void 0:r.filter(V=>V.archived_at).length)||0,U=async()=>{if(j)try{await d.mutateAsync({id:j.id,dealId:j.deal_id}),fe.success("Portal permanently deleted"),w(null)}catch{fe.error("Failed to delete portal")}};return C?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(As,{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(hn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"font-medium",children:[R," Portals"]})]}),e.jsxs("span",{className:"text-muted-foreground",children:[$," active · ",R-$," 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(fn,{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:V=>o(V.target.value),className:"pl-9 pr-8"}),a&&e.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:["all","active","disabled","archived","none"].map(V=>e.jsx(K,{variant:l===V?"secondary":"ghost",size:"sm",onClick:()=>i(V),className:"text-xs px-3 capitalize",children:V==="none"?"No Portal":V},V))})]}),e.jsx(Bi,{className:"h-[calc(100vh-22rem)]",children:e.jsxs("div",{className:"space-y-2 pb-4",children:[L.map(V=>{const X=A.get(V.id)||null,se=V.contact?`${V.contact.first_name||""} ${V.contact.last_name||""}`.trim():"";return e.jsx(Xfs,{dealId:V.id,dealName:V.deal_name,contactName:se,portal:X,onSettingsOpen:p,onComposerOpen:te=>v(te),onInviteOpen:(te,Y)=>b({portal:te,dealName:Y}),onDeleteConfirm:w},V.id)}),L.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 bg-muted rounded-full flex items-center justify-center",children:e.jsx(hn,{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(jJe,{open:!!u,onOpenChange:V=>!V&&p(null),portal:u,dealOwnerId:N||""}),f&&e.jsx(kJe,{open:!!f,onOpenChange:V=>!V&&v(null),portalId:f.id,portalSlug:f.slug,notifyClient:f.notify_client}),_&&e.jsx(NJe,{open:!!_,onOpenChange:V=>!V&&b(null),portal:_.portal,dealName:_.dealName}),e.jsx(nc,{open:!!j,onOpenChange:V=>!V&&w(null),children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Permanently delete this portal?"}),e.jsx(Dl,{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(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:U,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class Jfs extends S.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 egs(){var ls;const t=PM(),{data:s,isLoading:r}=Cce(),{data:n,isLoading:a,refetch:o}=Mce(),{data:l,isLoading:i}=Nps(),d=fJe(),u=yps(),[p,f]=S.useState("board"),[v,_]=S.useState(!1),[b,j]=S.useState(!1),[w,N]=S.useState(null),[C,A]=S.useState(null),[I,L]=S.useState(null),[R,$]=S.useState(null),[q,U]=S.useState(!1),[V,X]=S.useState(null),[se,te]=S.useState(""),[Y,de]=S.useState("all"),[ie,ae]=S.useState(!1),[le,pe]=S.useState(!1),[be,ye]=S.useState(new Set),[we,ke]=S.useState(null),{data:Ze}=Mf(),{isTeamLeader:_e,teamMembers:Ce}=cfs(),Te=S.useMemo(()=>Array.from(be),[be]),{data:Fe}=dfs(Te),Ae=S.useMemo(()=>{const Qt=new Map;return Ce.forEach(rs=>Qt.set(rs.id,{name:rs.name,avatar_url:rs.avatar_url,color:rs.color})),Qt},[Ce]),We=S.useCallback(Qt=>Qt.owner_user_id&&Ae.get(Qt.owner_user_id)||null,[Ae]),ht=S.useCallback(Qt=>{ye(rs=>{const as=new Set(rs);return as.has(Qt)?as.delete(Qt):as.add(Qt),as})},[]);S.useEffect(()=>{!r&&s&&s.length===0&&d.mutate()},[r,s]);const[De,Dt]=Ec(),he=S.useRef(!1);S.useEffect(()=>{const Qt=De.get("deal");if(Qt&&n&&n.length>0&&!he.current){const rs=n.find(as=>as.id===Qt);rs&&(he.current=!0,N(rs),j(!0),De.delete("deal"),Dt(De,{replace:!0}))}},[n,De]);const Qe=S.useMemo(()=>{if(!Fe||!s)return[];const Qt=new Map(s.map(rs=>[rs.name,rs.id]));return Fe.map(rs=>{const as=rs._stage_name&&Qt.get(rs._stage_name)||null;return{...rs,stage_id:as||rs.stage_id}})},[Fe,s]),ot=S.useMemo(()=>[...n||[],...Qe],[n,Qe]),rt=ot.filter(Qt=>{var vt,Cs,or,Ar,Wn,ai;const rs=se.toLowerCase(),as=!rs||Qt.deal_name.toLowerCase().includes(rs)||((Cs=(vt=Qt.contact)==null?void 0:vt.first_name)==null?void 0:Cs.toLowerCase().includes(rs))||((Ar=(or=Qt.contact)==null?void 0:or.last_name)==null?void 0:Ar.toLowerCase().includes(rs))||((Wn=Qt.property_address)==null?void 0:Wn.toLowerCase().includes(rs))||((ai=Qt.city)==null?void 0:ai.toLowerCase().includes(rs)),ir=Y==="all"||Qt.deal_type===Y;return as&&ir}),Ne=S.useMemo(()=>{if(!s)return l||null;const Qt=new Set(s.filter(vt=>vt.is_won_stage).map(vt=>vt.id)),rs=new Set(s.filter(vt=>vt.is_lost_stage).map(vt=>vt.id)),as=ot.filter(vt=>!Qt.has(vt.stage_id)&&!rs.has(vt.stage_id)),ir=ot.filter(vt=>Qt.has(vt.stage_id));return{totalDeals:ot.length,activeDeals:as.length,wonDeals:ir.length,pipelineValue:as.reduce((vt,Cs)=>vt+(Cs.expected_price||0),0),expectedCommission:as.reduce((vt,Cs)=>vt+(Cs.expected_commission||0),0),expectedNetToAgent:as.reduce((vt,Cs)=>{const or=Cs.expected_commission||0;if(!or)return vt;let Ar=or;return Cs.brokerage_split_pct&&(Ar-=or*(Cs.brokerage_split_pct/100)),Cs.team_split_pct&&(Ar-=or*(Cs.team_split_pct/100)),Cs.franchise_fee_pct&&(Ar-=or*(Cs.franchise_fee_pct/100)),Cs.referral_fee_pct&&(Ar-=or*(Cs.referral_fee_pct/100)),Cs.transaction_fee&&(Ar-=Cs.transaction_fee),vt+Math.max(0,Ar)},0),wonValue:ir.reduce((vt,Cs)=>vt+(Cs.expected_price||0),0)}},[ot,s,l]),it=Qt=>{N(Qt),j(!0)},qe=Qt=>{A(Qt||null),N(null),_(!0)},Xe=Qt=>{N(Qt),j(!1),_(!0)},$e=(Qt,rs)=>{L(Qt)},Ke=(Qt,rs)=>{Qt.preventDefault(),Qt.dataTransfer.dropEffect="move",$(rs)},ct=async(Qt,rs)=>{if(Qt.preventDefault(),$(null),!I)return;const as=n==null?void 0:n.find(Cs=>Cs.id===I),ir=s==null?void 0:s.find(Cs=>Cs.id===rs),vt=s==null?void 0:s.find(Cs=>Cs.id===(as==null?void 0:as.stage_id));if(!as||!ir||as.stage_id===rs){L(null);return}ke({dealId:I,dealName:as.deal_name,fromStageName:(vt==null?void 0:vt.name)||"Unknown",toStageName:ir.name,toStageId:rs,isWonStage:ir.is_won_stage,deal:as}),L(null)},Ue=async()=>{if(!we)return;const{dealId:Qt,toStageId:rs,toStageName:as,isWonStage:ir,deal:vt}=we;if(await u.mutateAsync({dealId:Qt,stageId:rs,stageName:as}),fe.success(`Moved to ${as}`),ir&&!vt.scorecard_transaction_id){const Cs={...vt,stage_id:rs};X(Cs),U(!0)}},Ve=S.useCallback(async(Qt,rs,as)=>{const ir=n==null?void 0:n.find(or=>or.id===Qt),vt=s==null?void 0:s.find(or=>or.id===rs),Cs=s==null?void 0:s.find(or=>or.id===(ir==null?void 0:ir.stage_id));!ir||!vt||ir.stage_id===rs||ke({dealId:Qt,dealName:ir.deal_name,fromStageName:(Cs==null?void 0:Cs.name)||"Unknown",toStageName:as,toStageId:rs,isWonStage:vt.is_won_stage,deal:ir})},[n,s]),Je=Qt=>rt.filter(rs=>rs.stage_id===Qt),Rt=r||a,$t=t?"list":p;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(K,{variant:"outline",size:"icon",onClick:()=>o(),className:"shrink-0",children:e.jsx(Po,{className:"h-4 w-4"})}),!t&&e.jsx(QN,{children:e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsxs(K,{variant:p==="board"?"secondary":"ghost",size:"sm",onClick:()=>f("board"),className:"px-3 gap-1.5",children:[e.jsx(mp,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),e.jsx(Wc,{children:"Kanban board view"})]}),e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsxs(K,{variant:p==="list"?"secondary":"ghost",size:"sm",onClick:()=>f("list"),className:"px-3 gap-1.5",children:[e.jsx(Uh,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(Wc,{children:"Grouped list view"})]}),e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsxs(K,{variant:p==="table"?"secondary":"ghost",size:"sm",onClick:()=>f("table"),className:"px-3 gap-1.5",children:[e.jsx(w5,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(Wc,{children:"Sortable table view"})]}),e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsxs(K,{variant:p==="portals"?"secondary":"ghost",size:"sm",onClick:()=>f("portals"),className:"px-3 gap-1.5",children:[e.jsx(hn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(Wc,{children:"Client portal management"})]})]})}),Ze&&!_e&&e.jsxs(K,{variant:"outline",onClick:()=>ae(!0),children:[e.jsx(hr,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(K,{onClick:()=>qe(),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),$t!=="portals"&&e.jsx(pfs,{stats:Ne,isLoading:i}),$t!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(fn,{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:Qt=>te(Qt.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(Ur,{className:"h-4 w-4"})})]}),e.jsxs(tr,{value:Y,onValueChange:de,children:[e.jsx(Js,{className:"w-[140px]",children:e.jsx(sr,{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:[_e&&!t&&Ce.length>0&&e.jsx(lfs,{members:Ce,enabledMembers:be,onToggleMember:ht,isOpen:le,onToggleOpen:()=>pe(Qt=>!Qt)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:Rt?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(Qt=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(gs,{className:"h-full rounded-xl"})},Qt))}):$t==="board"?e.jsxs(Bi,{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(Qt=>e.jsx(mfs,{stage:Qt,deals:Je(Qt.id),onDealClick:it,onAddDeal:qe,onDragStart:$e,onDragOver:Ke,onDrop:ct,isDragOver:R===Qt.id,isWonStage:Qt.is_won_stage,getOwnerInfo:We},Qt.id))}),e.jsx(Ioe,{orientation:"horizontal"})]}):$t==="table"?e.jsx(Bi,{className:"h-full",children:e.jsx(Rfs,{deals:rt,stages:s||[],onDealClick:it,onStageChange:Ve})}):$t==="portals"?e.jsx(Qfs,{}):e.jsx(Bi,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(Qt=>{const rs=Je(Qt.id);return rs.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:Qt.color}}),e.jsx("h3",{className:"font-semibold",children:Qt.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",rs.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:rs.map(as=>e.jsx(wJe,{deal:as,onClick:()=>it(as),stages:s,onStageChange:Ve,showStagePicker:!0,isWonStage:Qt.is_won_stage,ownerInfo:We(as)},as.id))})]},Qt.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(mp,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start tracking your opportunities by adding your first deal"}),e.jsxs(K,{onClick:()=>qe(),children:[e.jsx(Zs,{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(fn,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No matching deals"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Try adjusting your search or filters"}),e.jsx(K,{variant:"outline",onClick:()=>{te(""),de("all")},children:"Clear Filters"})]})]})})})]})]}),e.jsx(yfs,{open:v,onOpenChange:_,deal:w,defaultStageId:C}),e.jsx(Lfs,{deal:w,open:b,onOpenChange:j,onEdit:Xe,isWonStage:w?(ls=s==null?void 0:s.find(Qt=>Qt.id===w.stage_id))==null?void 0:ls.is_won_stage:!1,onAddToScorecard:Qt=>{X(Qt),U(!0),j(!1)}}),e.jsx(Dfs,{open:q,onOpenChange:U,deal:V,onComplete:()=>{o(),X(null)}}),we&&e.jsx(Zfs,{open:!!we,onOpenChange:Qt=>{Qt||ke(null)},dealId:we.dealId,dealName:we.dealName,fromStageName:we.fromStageName,toStageName:we.toStageName,toStageId:we.toStageId,onConfirm:Ue}),e.jsx(ifs,{open:ie,onOpenChange:ae})]})}function tgs(){return e.jsx(Jfs,{children:e.jsx(egs,{})})}function SJe({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var te;const o=Bfs(),l=$fs(),{data:i}=Mce(),d=ti(),{data:u}=Ct({queryKey:["contacts-for-tasks",d],queryFn:async()=>{if(!d)return[];const{data:Y,error:de}=await G.from("innercircle_contacts").select("id, first_name, last_name").eq("owner_user_id",d).order("first_name").limit(500);if(de)throw de;return Y},enabled:!!d&&t}),[p,f]=S.useState(""),[v,_]=S.useState(""),[b,j]=S.useState("none"),[w,N]=S.useState("none"),[C,A]=S.useState("medium"),[I,L]=S.useState("todo"),[R,$]=S.useState(),[q,U]=S.useState(!1),[V,X]=S.useState(!1);S.useEffect(()=>{r?(f(r.title),_(r.description||""),j(r.deal_id||"none"),N(r.contact_id||"none"),A(r.priority),L(r.status),$(r.due_date?Ah(r.due_date):void 0)):(f(""),_(""),j(n||"none"),N("none"),A("medium"),L("todo"),$(void 0))},[r,t,n]);const se=async()=>{if(!p.trim()){fe.error("Task title is required");return}try{const Y={title:p.trim(),description:v.trim()||null,deal_id:b==="none"?null:b,contact_id:w==="none"?null:w,stage_id:a||null,priority:C,status:I,due_date:R?ws(R,"yyyy-MM-dd"):null};r?(await l.mutateAsync({id:r.id,...Y}),fe.success("Task updated")):(await o.mutateAsync(Y),fe.success("Task created")),s(!1)}catch{fe.error("Failed to save task")}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-[480px]",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:r?"Edit Task":"New Task"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title *"}),e.jsx(Re,{value:p,onChange:Y=>f(Y.target.value),placeholder:"e.g., Send inspection report"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Mr,{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(ve,{children:"Priority"}),e.jsxs(tr,{value:C,onValueChange:Y=>A(Y),children:[e.jsx(Js,{children:e.jsx(sr,{})}),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(ve,{children:"Status"}),e.jsxs(tr,{value:I,onValueChange:Y=>L(Y),children:[e.jsx(Js,{children:e.jsx(sr,{})}),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(ve,{children:"Due Date"}),e.jsxs(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!R&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),R?ws(R,"PPP"):"Pick a date"]})}),e.jsx(ko,{className:"w-auto p-0",align:"start",children:e.jsx(yp,{mode:"single",selected:R,onSelect:$,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Link to Deal"}),e.jsxs(So,{open:q,onOpenChange:U,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(Aa,{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(df,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(ko,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search deals..."}),e.jsxs(kf,{children:[e.jsx(Nf,{children:"No deals found."}),e.jsxs(Sf,{children:[e.jsxs(Nm,{value:"no-deal",onSelect:()=>{j("none"),U(!1)},children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",b==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(Y=>e.jsxs(Nm,{value:Y.deal_name,onSelect:()=>{j(Y.id),U(!1)},children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",b===Y.id?"opacity-100":"opacity-0")}),Y.deal_name]},Y.id))]})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Link to Contact"}),e.jsxs(So,{open:V,onOpenChange:X,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(Xi,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),w!=="none"?(()=>{const Y=u==null?void 0:u.find(de=>de.id===w);return Y?`${Y.first_name} ${Y.last_name}`:"Select contact"})():"No Contact"]}),e.jsx(df,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(ko,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search contacts..."}),e.jsxs(kf,{children:[e.jsx(Nf,{children:"No contacts found."}),e.jsxs(Sf,{children:[e.jsxs(Nm,{value:"no-contact",onSelect:()=>{N("none"),X(!1)},children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",w==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),u==null?void 0:u.map(Y=>e.jsxs(Nm,{value:`${Y.first_name} ${Y.last_name}`,onSelect:()=>{N(Y.id),X(!1)},children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",w===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(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:se,disabled:o.isPending||l.isPending,children:r?"Save Changes":"Create Task"})]})]})]})})}const sgs={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 rgs({tasks:t}){const s=R2e(),r=qfs(),n=Dr(),[a,o]=S.useState(null),l=async p=>{const f=p.status==="done"?"todo":"done";try{await s.mutateAsync({id:p.id,status:f})}catch{fe.error("Failed to update task")}},i=async p=>{try{await r.mutateAsync(p),fe.success("Task deleted")}catch{fe.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(da,{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(p=>{if(p.deal){const f=d.get(p.deal.id)||{dealName:p.deal.deal_name,tasks:[]};f.tasks.push(p),d.set(p.deal.id,f)}else u.push(p)}),e.jsxs("div",{className:"space-y-4",children:[u.length>0&&e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 px-4 py-2 border-b",children:e.jsx("h3",{className:"font-medium text-sm text-muted-foreground",children:"General Tasks"})}),u.map(p=>e.jsx(TLe,{task:p,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:f=>n(`/mission-control/pipeline?deal=${f}`)},p.id))]}),Array.from(d.entries()).map(([p,f])=>e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(`/mission-control/pipeline?deal=${p}`),className:"w-full bg-muted/30 px-4 py-2 border-b flex items-center gap-2 hover:bg-muted/50 transition-colors text-left",children:[e.jsx(Aa,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("h3",{className:"font-medium text-sm",children:f.dealName}),e.jsxs(at,{variant:"secondary",className:"ml-auto text-xs",children:[f.tasks.filter(v=>v.status==="done").length,"/",f.tasks.length]}),e.jsx(Ha,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),f.tasks.map(v=>e.jsx(TLe,{task:v,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:_=>n(`/mission-control/pipeline?deal=${_}`)},v.id))]},p)),a&&e.jsx(SJe,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function TLe({task:t,onToggle:s,onDelete:r,onEdit:n,onNavigateDeal:a}){const o=t.status==="done",l=!o&&t.due_date&&Xx(Ah(t.due_date))&&!$d(Ah(t.due_date)),i=!o&&t.due_date&&$d(Ah(t.due_date)),d=sgs[t.priority];return e.jsxs("div",{className:Pt("flex items-center gap-3 px-4 py-3 border-b last:border-b-0 group hover:bg-muted/30 transition-colors",o&&"opacity-60"),children:[e.jsx("button",{onClick:()=>s(t),className:"shrink-0",children:o?e.jsx(da,{className:"h-5 w-5 text-emerald-500"}):e.jsx(Gc,{className:"h-5 w-5 text-muted-foreground hover:text-primary transition-colors"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:Pt("text-sm font-medium truncate",o&&"line-through text-muted-foreground"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[t.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:t.stage.color+"20",color:t.stage.color},children:t.stage.name}),t.contact&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(Xi,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]})]}),e.jsxs(at,{variant:"outline",className:Pt("text-[10px] shrink-0",d.color),children:[d.dot," ",d.label]}),t.due_date&&e.jsxs("span",{className:Pt("text-xs shrink-0 flex items-center gap-1",l&&"text-destructive font-medium",i&&"text-amber-600 font-medium",!l&&!i&&"text-muted-foreground"),children:[e.jsx(Tn,{className:"h-3 w-3"}),ws(Ah(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(Oc,{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(br,{className:"h-3.5 w-3.5 text-destructive"})})]})]})}const ngs=[{status:"todo",label:"To Do",icon:Gc,color:"border-t-slate-400"},{status:"in_progress",label:"In Progress",icon:ym,color:"border-t-blue-500"},{status:"done",label:"Done",icon:da,color:"border-t-emerald-500"}],ags={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function igs({tasks:t}){const s=R2e(),r=S.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{fe.error("Failed to move task")}};return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:ngs.map(o=>e.jsxs("div",{className:Pt("border rounded-lg border-t-4 bg-muted/20",o.color),onDragOver:l=>l.preventDefault(),onDrop:l=>a(l,o.status),children:[e.jsxs("div",{className:"px-4 py-3 flex items-center gap-2",children:[e.jsx(o.icon,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold text-sm",children:o.label}),e.jsx(at,{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(ogs,{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 ogs({task:t,onDragStart:s}){const r=t.status==="done",n=!r&&t.due_date&&Xx(Ah(t.due_date))&&!$d(Ah(t.due_date)),a=!r&&t.due_date&&$d(Ah(t.due_date));return e.jsx("div",{draggable:!0,onDragStart:o=>s(o,t.id),className:Pt("bg-background border rounded-lg p-3 cursor-grab active:cursor-grabbing shadow-sm hover:shadow-md transition-shadow",n&&"border-destructive/50"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs mt-0.5",children:ags[t.priority]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:Pt("text-sm font-medium",r&&"line-through text-muted-foreground"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[t.deal&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(Aa,{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(Xi,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]}),t.due_date&&e.jsxs("div",{className:Pt("text-[10px] mt-1.5 flex items-center gap-1",n&&"text-destructive font-medium",a&&"text-amber-600 font-medium",!n&&!a&&"text-muted-foreground"),children:[e.jsx(Tn,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",ws(Ah(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 ALe={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function lgs({tasks:t}){const[s,r]=S.useState(new Date),n=R2e(),a=mc(s),o=Kp(s),l=ih(a),i=Moe(o),d=hvt({start:l,end:i}),u=S.useMemo(()=>{const v=new Map;return t.forEach(_=>{if(!_.due_date)return;const b=_.due_date,j=v.get(b)||[];j.push(_),v.set(b,j)}),v},[t]),p=S.useMemo(()=>t.filter(v=>!v.due_date),[t]),f=async v=>{const _=v.status==="done"?"todo":"done";try{await n.mutateAsync({id:v.id,status:_})}catch{fe.error("Failed to update task")}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(Mk(s,1)),children:e.jsx(zl,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold",children:ws(s,"MMMM yyyy")}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(Wh(s,1)),children:e.jsx(Ha,{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 _=ws(v,"yyyy-MM-dd"),b=u.get(_)||[],j=Aoe(v,s),w=$d(v);return e.jsxs("div",{className:Pt("border-r border-b min-h-[100px] p-1",!j&&"bg-muted/30",w&&"bg-primary/5"),children:[e.jsx("div",{className:Pt("text-xs font-medium mb-1 text-right px-1",!j&&"text-muted-foreground/40",w&&"text-primary font-bold"),children:ws(v,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[b.slice(0,3).map(N=>e.jsxs("button",{onClick:()=>f(N),className:Pt("w-full text-left text-[10px] px-1 py-0.5 rounded truncate flex items-center gap-0.5 hover:bg-muted transition-colors",N.status==="done"?"text-muted-foreground line-through":"text-foreground"),children:[N.status==="done"?e.jsx(da,{className:"h-2.5 w-2.5 text-emerald-500 shrink-0"}):e.jsx(Gc,{className:"h-2.5 w-2.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[ALe[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"]})]})]},_)})}),p.length>0&&e.jsxs("div",{className:"border rounded-lg p-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:["No Due Date (",p.length,")"]}),e.jsx("div",{className:"space-y-1",children:p.map(v=>e.jsxs("button",{onClick:()=>f(v),className:Pt("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(da,{className:"h-3.5 w-3.5 text-emerald-500 shrink-0"}):e.jsx(Gc,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[ALe[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 cgs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function dgs({open:t,onOpenChange:s,stages:r}){var N;const[n,a]=S.useState(((N=r[0])==null?void 0:N.id)||""),{data:o,isLoading:l}=Vfs(n||void 0),i=Hfs(),d=Wfs(),[u,p]=S.useState(""),[f,v]=S.useState("medium"),[_,b]=S.useState(""),j=async()=>{if(!(!u.trim()||!n))try{await i.mutateAsync({stage_id:n,title:u.trim(),priority:f,default_due_offset_days:_?parseInt(_):null,sort_order:((o==null?void 0:o.length)||0)+1}),p(""),b(""),fe.success("Template added")}catch{fe.error("Failed to add template")}},w=async C=>{try{await d.mutateAsync(C),fe.success("Template deleted")}catch{fe.error("Failed to delete template")}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-[560px]",children:[e.jsx(Ss,{children:e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(rP,{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(ve,{children:"Pipeline Stage"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:r.filter(C=>!C.is_won_stage&&!C.is_lost_stage).map(C=>e.jsx("button",{onClick:()=>a(C.id),className:Pt("px-3 py-1.5 rounded-full text-xs font-medium border transition-colors",n===C.id?"border-primary bg-primary/10 text-primary":"border-border hover:bg-muted"),children:C.name},C.id))})]}),e.jsx(Bi,{className:"max-h-[250px]",children:e.jsxs("div",{className:"space-y-1.5",children:[o==null?void 0:o.map((C,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:cgs[C.priority]}),e.jsx("span",{className:"text-sm flex-1 truncate",children:C.title}),C.default_due_offset_days&&e.jsxs(at,{variant:"outline",className:"text-[10px]",children:["+",C.default_due_offset_days,"d"]}),e.jsx("button",{onClick:()=>w(C.id),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",children:e.jsx(br,{className:"h-3.5 w-3.5 text-destructive"})})]},C.id)),(o==null?void 0:o.length)===0&&n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No templates for this stage yet"})]})}),n&&e.jsxs("div",{className:"space-y-3 border-t pt-3",children:[e.jsx(ve,{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:C=>p(C.target.value),className:"flex-1",onKeyDown:C=>C.key==="Enter"&&j()}),e.jsxs(tr,{value:f,onValueChange:C=>v(C),children:[e.jsx(Js,{className:"w-[100px]",children:e.jsx(sr,{})}),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(ve,{className:"text-xs",children:"Due offset (days from entering stage)"}),e.jsx(Re,{type:"number",placeholder:"e.g., 7",value:_,onChange:C=>b(C.target.value)})]}),e.jsxs(K,{onClick:j,disabled:!u.trim()||i.isPending,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function ugs(){const{data:t,isLoading:s}=Ffs(),{data:r}=Cce(),[n,a]=S.useState("list"),[o,l]=S.useState(""),[i,d]=S.useState("active"),[u,p]=S.useState("all"),[f,v]=S.useState("all"),[_,b]=S.useState(!1),[j,w]=S.useState(!1),N=S.useMemo(()=>{if(!t)return[];const I=new Map;return t.forEach(L=>{L.deal&&I.set(L.deal.id,L.deal.deal_name)}),Array.from(I,([L,R])=>({id:L,name:R}))},[t]),C=S.useMemo(()=>t?t.filter(I=>{var V,X,se,te;const L=o.toLowerCase(),R=!L||I.title.toLowerCase().includes(L)||((X=(V=I.deal)==null?void 0:V.deal_name)==null?void 0:X.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&&Xx(Ah(I.due_date))&&!$d(Ah(I.due_date)),q=u==="all"||I.priority===u,U=f==="all"||f==="no_deal"&&!I.deal_id||I.deal_id===f;return R&&$&&q&&U}):[],[t,o,i,u,f]),A=S.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&&Xx(Ah(L.due_date))&&!$d(Ah(L.due_date))).length,dueToday:I.filter(L=>L.due_date&&$d(Ah(L.due_date))).length,dueThisWeek:I.filter(L=>L.due_date&&l_t(Ah(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(K,{variant:"outline",size:"sm",onClick:()=>w(!0),children:[e.jsx(Hx,{className:"h-4 w-4 mr-1"}),"Templates"]}),e.jsxs(K,{size:"sm",onClick:()=>b(!0),children:[e.jsx(Zs,{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(Uh,{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(Th,{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(ld,{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(da,{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(fn,{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:p,children:[e.jsx(Js,{className:"w-[130px]",children:e.jsx(sr,{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:f,onValueChange:v,children:[e.jsx(Js,{className:"w-[160px]",children:e.jsx(sr,{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(Uh,{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(Wx,{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(ld,{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(rgs,{tasks:C}),n==="kanban"&&e.jsx(igs,{tasks:C}),n==="calendar"&&e.jsx(lgs,{tasks:C})]}),e.jsx(SJe,{open:_,onOpenChange:b}),e.jsx(dgs,{open:j,onOpenChange:w,stages:r||[]})]})})}const q0e=[{value:"video_intro",label:"Video Intro",icon:kn,description:"Add an intro video"},{value:"testimonials",label:"Testimonials",icon:gP,description:"Client testimonials carousel"},{value:"specialties",label:"Specialties",icon:Vh,description:"Tags for your specialties"},{value:"custom_links",label:"Custom Links",icon:Ho,description:"Custom CTA buttons"},{value:"social_media",label:"Social Media",icon:cd,description:"Links to your social profiles"}],hgs=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],mgs={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function CJe({cardId:t}){const{data:s,isLoading:r}=o0t(t),n=l0t(),a=c0t(),o=d0t(),[l,i]=S.useState(!1),[d,u]=S.useState(""),[p,f]=S.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:mgs[d]||{}},{onSuccess:()=>{i(!1),u("")}})},_=C=>{a.mutate({id:C.id,is_visible:!C.is_visible})},b=(C,A)=>{if(!s)return;const I=s.findIndex($=>$.id===C.id),L=A==="up"?I-1:I+1;if(L<0||L>=s.length)return;const R=s[L];a.mutate({id:C.id,sort_order:R.sort_order}),a.mutate({id:R.id,sort_order:C.sort_order})},j=C=>{confirm("Remove this block from this card?")&&o.mutate(C.id)},w=(C,A)=>{a.mutate({id:C.id,config:A},{onSuccess:()=>f(null)})},N=C=>q0e.find(A=>A.value===C);return e.jsxs("div",{className:"space-y-3",children:[!s||s.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted-foreground mb-4 text-sm",children:"No blocks yet. Add a block to customize this card."}),e.jsxs(K,{size:"sm",onClick:()=>i(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}):e.jsxs(e.Fragment,{children:[s.map((C,A)=>{const I=N(C.block_type),L=(I==null?void 0:I.icon)||Vh;return e.jsx(Ee,{className:C.is_visible?"":"opacity-50",children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fu,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx(L,{className:"h-4 w-4 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs",children:(I==null?void 0:I.label)||C.block_type}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:pgs(C)})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(C,"up"),disabled:A===0,children:e.jsx(Vd,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(C,"down"),disabled:A===s.length-1,children:e.jsx(eh,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(C),children:C.is_visible?e.jsx(ya,{className:"h-3 w-3"}):e.jsx(Em,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>f(C),children:"Edit"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>j(C),children:e.jsx(br,{className:"h-3 w-3"})})]})]})})},C.id)}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>i(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}),e.jsx(vs,{open:l,onOpenChange:i,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Add Block"})}),e.jsx("div",{className:"grid gap-3",children:q0e.map(C=>{const A=C.icon;return e.jsxs("button",{onClick:()=>u(C.value),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors ${d===C.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:C.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.description})]})]},C.value)})}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{onClick:v,disabled:!d||n.isPending,children:"Add Block"})]})]})}),p&&e.jsx(fgs,{block:p,onSave:C=>w(p,C),onClose:()=>f(null)})]})}function pgs(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 fgs({block:t,onSave:s,onClose:r}){const[n,a]=S.useState(t.config),o=q0e.find(l=>l.value===t.block_type);return e.jsx(vs,{open:!0,onOpenChange:r,children:e.jsxs(ys,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsxs(Ns,{children:["Edit ",o==null?void 0:o.label]})}),t.block_type==="video_intro"&&e.jsx(ggs,{config:n,onChange:a,cardId:t.card_id}),t.block_type==="testimonials"&&e.jsx(xgs,{config:n,onChange:a}),t.block_type==="specialties"&&e.jsx(ygs,{config:n,onChange:a}),t.block_type==="custom_links"&&e.jsx(vgs,{config:n,onChange:a}),t.block_type==="social_media"&&e.jsx(_gs,{config:n,onChange:a}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(K,{onClick:()=>s(n),children:"Save"})]})]})})}function ggs({config:t,onChange:s,cardId:r}){var _,b;const[n,a]=S.useState(""),[o,l]=S.useState((_=t.video_url)!=null&&_.includes("youtube")||(b=t.video_url)!=null&&b.includes("youtu.be")?"youtube":"library"),{data:i}=Ct({queryKey:["card-owner",r],queryFn:async()=>{const{data:j}=await G.from("agent_cards").select("user_id").eq("id",r).single();return j==null?void 0:j.user_id},enabled:!!r}),{data:d,isLoading:u}=Ct({queryKey:["agent-videos-library",i],queryFn:async()=>{const{data:j,error:w}=await G.from("agent_videos").select("id, title, bunny_video_id, thumbnail_url, playback_url, created_at").eq("owner_user_id",i).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(w)throw w;return j||[]},enabled:!!i}),p=(d==null?void 0:d.filter(j=>!n||(j.title||"").toLowerCase().includes(n.toLowerCase())))||[],f=t.bunny_video_id,v=j=>{var A;const w=(A=j.playback_url)==null?void 0:A.match(/\/(?:play|embed)\/(\d+)\//),C=`https://iframe.mediadelivery.net/embed/${w?w[1]:"570924"}/${j.bunny_video_id}?autoplay=false&responsive=true`;s({...t,video_url:C,bunny_video_id:j.bunny_video_id,video_source:"library"})};return e.jsx("div",{className:"space-y-4",children:e.jsxs(Na,{value:o,onValueChange:l,children:[e.jsxs(va,{className:"w-full",children:[e.jsx(ks,{value:"library",className:"flex-1",children:"Video Library"}),e.jsx(ks,{value:"youtube",className:"flex-1",children:"YouTube URL"})]}),e.jsxs(zs,{value:"library",className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(fn,{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:j=>a(j.target.value),className:"pl-9"})]}),e.jsx(Bi,{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"})]}):p.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:p.map(j=>e.jsxs("button",{onClick:()=>v(j),className:`w-full flex items-center gap-3 p-2 rounded-lg border text-left transition-colors ${f===j.bunny_video_id?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[j.thumbnail_url?e.jsx("img",{src:j.thumbnail_url,alt:"",className:"h-10 w-16 rounded object-cover flex-shrink-0 bg-muted",onError:w=>{var N;w.currentTarget.style.display="none",(N=w.currentTarget.nextElementSibling)==null||N.classList.remove("hidden")}}):null,e.jsx("div",{className:`h-10 w-16 rounded bg-muted flex items-center justify-center flex-shrink-0 ${j.thumbnail_url?"hidden":""}`,children:e.jsx(kn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:j.title||"Untitled Video"}),f===j.bunny_video_id&&e.jsx(ua,{className:"h-4 w-4 text-primary flex-shrink-0"})]},j.id))})})]}),e.jsx(zs,{value:"youtube",className:"space-y-3 mt-3",children:e.jsxs("div",{children:[e.jsx(ve,{children:"YouTube URL"}),e.jsx(Re,{placeholder:"https://www.youtube.com/watch?v=...",value:t.video_source==="youtube"&&t.video_url||"",onChange:j=>s({...t,video_url:j.target.value,bunny_video_id:null,video_source:"youtube"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Paste a YouTube video link"})]})})]})})}function xgs({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(Ee,{children:e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ve,{className:"text-xs font-medium",children:["Testimonial ",i+1]}),r.length>1&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>o(i),children:e.jsx(br,{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(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Testimonial"]})]})}function ygs({config:t,onChange:s}){const r=t.tags||[],[n,a]=S.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(ve,{className:"text-sm mb-2 block",children:"Preset Specialties"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:hgs.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(ve,{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(K,{variant:"outline",size:"sm",onClick:l,children:"Add"})]})]}),r.length>0&&e.jsxs("div",{children:[e.jsxs(ve,{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 vgs({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(K,{variant:"ghost",size:"icon",className:"h-8 w-8 mt-1 text-destructive",onClick:()=>o(i),children:e.jsx(br,{className:"h-3 w-3"})})]},i)),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Link"]})]})}const ELe=[{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 _gs({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 p=[...r];p[d]={...p[d],url:u},s({...t,platforms:p})},o=d=>{s({...t,platforms:r.filter((u,p)=>p!==d)})},l=ELe.filter(d=>!r.find(u=>u.platform===d.value)),i=d=>{const u=Tge[d],p=ELe.find(f=>f.value===d);return{label:(p==null?void 0:p.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 p=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:p.color+"30",backgroundColor:p.color+"10"},children:p.iconPath&&e.jsx("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:p.color,children:e.jsx("path",{d:p.iconPath})})}),e.jsx("div",{className:"flex-1",children:e.jsx(Re,{placeholder:`Your ${p.label} profile URL`,value:d.url,onChange:f=>a(u,f.target.value)})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive flex-shrink-0",onClick:()=>o(u),children:e.jsx(br,{className:"h-3.5 w-3.5"})})]},u)})}),l.length>0&&e.jsxs("div",{children:[e.jsx(ve,{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=Tge[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 bgs=Object.defineProperty,Eie=Object.getOwnPropertySymbols,MJe=Object.prototype.hasOwnProperty,TJe=Object.prototype.propertyIsEnumerable,PLe=(t,s,r)=>s in t?bgs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,U0e=(t,s)=>{for(var r in s||(s={}))MJe.call(s,r)&&PLe(t,r,s[r]);if(Eie)for(var r of Eie(s))TJe.call(s,r)&&PLe(t,r,s[r]);return t},V0e=(t,s)=>{var r={};for(var n in t)MJe.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Eie)for(var n of Eie(t))s.indexOf(n)<0&&TJe.call(t,n)&&(r[n]=t[n]);return r};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var KN;(t=>{const s=class no{constructor(d,u,p,f){if(this.version=d,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],dno.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=d*4+17;let v=[];for(let b=0;b7)throw new RangeError("Invalid value");let b,j;for(b=p;;b++){const A=no.getNumDataCodewords(b,u)*8,I=l.getTotalBits(d,b);if(I<=A){j=I;break}if(b>=f)throw new RangeError("Data too long")}for(const A of[no.Ecc.MEDIUM,no.Ecc.QUARTILE,no.Ecc.HIGH])_&&j<=no.getNumDataCodewords(b,A)*8&&(u=A);let w=[];for(const A of d){r(A.mode.modeBits,4,w),r(A.numChars,A.mode.numCharCountBits(b),w);for(const I of A.getData())w.push(I)}a(w.length==j);const N=no.getNumDataCodewords(b,u)*8;a(w.length<=N),r(0,Math.min(4,N-w.length),w),r(0,(8-w.length%8)%8,w),a(w.length%8==0);for(let A=236;w.lengthC[I>>>3]|=A<<7-(I&7)),new no(b,u,C,v)}getModule(d,u){return 0<=d&&d>>9)*1335;const f=(u<<10|p)^21522;a(f>>>15==0);for(let v=0;v<=5;v++)this.setFunctionModule(8,v,n(f,v));this.setFunctionModule(8,7,n(f,6)),this.setFunctionModule(8,8,n(f,7)),this.setFunctionModule(7,8,n(f,8));for(let v=9;v<15;v++)this.setFunctionModule(14-v,8,n(f,v));for(let v=0;v<8;v++)this.setFunctionModule(this.size-1-v,8,n(f,v));for(let v=8;v<15;v++)this.setFunctionModule(8,this.size-15+v,n(f,v));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let d=this.version;for(let p=0;p<12;p++)d=d<<1^(d>>>11)*7973;const u=this.version<<12|d;a(u>>>18==0);for(let p=0;p<18;p++){const f=n(u,p),v=this.size-11+p%3,_=Math.floor(p/3);this.setFunctionModule(v,_,f),this.setFunctionModule(_,v,f)}}drawFinderPattern(d,u){for(let p=-4;p<=4;p++)for(let f=-4;f<=4;f++){const v=Math.max(Math.abs(f),Math.abs(p)),_=d+f,b=u+p;0<=_&&_{(A!=j-v||L>=b)&&C.push(I[A])});return a(C.length==_),C}drawCodewords(d){if(d.length!=Math.floor(no.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let f=0;f>>3],7-(u&7)),u++)}}a(u==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,j),_||(d+=this.finderPenaltyCountPatterns(j)*no.PENALTY_N3),_=this.modules[v][w],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,j)*no.PENALTY_N3}for(let v=0;v5&&d++):(this.finderPenaltyAddHistory(b,j),_||(d+=this.finderPenaltyCountPatterns(j)*no.PENALTY_N3),_=this.modules[w][v],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,j)*no.PENALTY_N3}for(let v=0;v_+(b?1:0),u);const p=this.size*this.size,f=Math.ceil(Math.abs(u*20-p*10)/p)-1;return a(0<=f&&f<=9),d+=f*no.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 p=[6];for(let f=this.size-7;p.lengthno.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*d+128)*d+64;if(d>=2){const p=Math.floor(d/7)+2;u-=(25*p-10)*p-55,d>=7&&(u-=36)}return a(208<=u&&u<=29648),u}static getNumDataCodewords(d,u){return Math.floor(no.getNumRawDataModules(d)/8)-no.ECC_CODEWORDS_PER_BLOCK[u.ordinal][d]*no.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 f=0;f0);for(const f of d){const v=f^p.shift();p.push(0),u.forEach((_,b)=>p[b]^=no.reedSolomonMultiply(_,v))}return p}static reedSolomonMultiply(d,u){if(d>>>8||u>>>8)throw new RangeError("Byte out of range");let p=0;for(let f=7;f>=0;f--)p=p<<1^(p>>>7)*285,p^=(u>>>f&1)*d;return a(p>>>8==0),p}finderPenaltyCountPatterns(d){const u=d[1];a(u<=this.size*3);const p=u>0&&d[2]==u&&d[3]==u*3&&d[4]==u&&d[5]==u;return(p&&d[0]>=u*4&&d[6]>=u?1:0)+(p&&d[6]>=u*4&&d[0]>=u?1:0)}finderPenaltyTerminateAndCount(d,u,p){return d&&(this.finderPenaltyAddHistory(u,p),u=0),u+=this.size,this.finderPenaltyAddHistory(u,p),this.finderPenaltyCountPatterns(p)}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 p=d-1;p>=0;p--)u.push(i>>>p&1)}function n(i,d){return(i>>>d&1)!=0}function a(i){if(!i)throw new Error("Assertion error")}const o=class Lc{constructor(d,u,p){if(this.mode=d,this.numChars=u,this.bitData=p,u<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(d){let u=[];for(const p of d)r(p,8,u);return new Lc(Lc.Mode.BYTE,d.length,u)}static makeNumeric(d){if(!Lc.isNumeric(d))throw new RangeError("String contains non-numeric characters");let u=[];for(let p=0;p=1<{(s=>{const r=class{constructor(a,o){this.ordinal=a,this.formatBits=o}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(t.QrCode||(t.QrCode={}))})(KN||(KN={}));(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={}))})(KN||(KN={}));var K4=KN;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var wgs={L:K4.QrCode.Ecc.LOW,M:K4.QrCode.Ecc.MEDIUM,Q:K4.QrCode.Ecc.QUARTILE,H:K4.QrCode.Ecc.HIGH},AJe=128,EJe="L",PJe="#FFFFFF",IJe="#000000",LJe=!1,DJe=1,jgs=4,kgs=0,Ngs=.1;function OJe(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 RJe(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 Sgs(t,s,r,n){if(n==null)return null;const a=t.length+r*2,o=Math.floor(s*Ngs),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,p=n.y==null?t.length/2-d/2:n.y*l,f=n.opacity==null?1:n.opacity;let v=null;if(n.excavate){let b=Math.floor(u),j=Math.floor(p),w=Math.ceil(i+u-b),N=Math.ceil(d+p-j);v={x:b,y:j,w,h:N}}const _=n.crossOrigin;return{x:u,y:p,h:d,w:i,excavation:v,opacity:f,crossOrigin:_}}function Cgs(t,s){return s!=null?Math.max(Math.floor(s),0):t?jgs:kgs}function FJe({value:t,level:s,minVersion:r,includeMargin:n,marginSize:a,imageSettings:o,size:l,boostLevel:i}){let d=mt.useMemo(()=>{const b=(Array.isArray(t)?t:[t]).reduce((j,w)=>(j.push(...K4.QrSegment.makeSegments(w)),j),[]);return K4.QrCode.encodeSegments(b,wgs[s],r,void 0,void 0,i)},[t,s,r,i]);const{cells:u,margin:p,numCells:f,calculatedImageSettings:v}=mt.useMemo(()=>{let _=d.getModules();const b=Cgs(n,a),j=_.length+b*2,w=Sgs(_,l,b,o);return{cells:_,margin:b,numCells:j,calculatedImageSettings:w}},[d,l,o,n,a]);return{qrcode:d,margin:p,cells:u,numCells:f,calculatedImageSettings:v}}var Mgs=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Tgs=mt.forwardRef(function(s,r){const n=s,{value:a,size:o=AJe,level:l=EJe,bgColor:i=PJe,fgColor:d=IJe,includeMargin:u=LJe,minVersion:p=DJe,boostLevel:f,marginSize:v,imageSettings:_}=n,j=V0e(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:w}=j,N=V0e(j,["style"]),C=_==null?void 0:_.src,A=mt.useRef(null),I=mt.useRef(null),L=mt.useCallback(Y=>{A.current=Y,typeof r=="function"?r(Y):r&&(r.current=Y)},[r]),[R,$]=mt.useState(!1),{margin:q,cells:U,numCells:V,calculatedImageSettings:X}=FJe({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:v,imageSettings:_,size:o});mt.useEffect(()=>{if(A.current!=null){const Y=A.current,de=Y.getContext("2d");if(!de)return;let ie=U;const ae=I.current,le=X!=null&&ae!==null&&ae.complete&&ae.naturalHeight!==0&&ae.naturalWidth!==0;le&&X.excavation!=null&&(ie=RJe(U,X.excavation));const pe=window.devicePixelRatio||1;Y.height=Y.width=o*pe;const be=o/V*pe;de.scale(be,be),de.fillStyle=i,de.fillRect(0,0,V,V),de.fillStyle=d,Mgs?de.fill(new Path2D(OJe(ie,q))):U.forEach(function(ye,we){ye.forEach(function(ke,Ze){ke&&de.fillRect(Ze+q,we+q,1,1)})}),X&&(de.globalAlpha=X.opacity),le&&de.drawImage(ae,X.x+q,X.y+q,X.w,X.h)}}),mt.useEffect(()=>{$(!1)},[C]);const se=U0e({height:o,width:o},w);let te=null;return C!=null&&(te=mt.createElement("img",{src:C,key:C,style:{display:"none"},onLoad:()=>{$(!0)},ref:I,crossOrigin:X==null?void 0:X.crossOrigin})),mt.createElement(mt.Fragment,null,mt.createElement("canvas",U0e({style:se,height:o,width:o,ref:L,role:"img"},N)),te)});Tgs.displayName="QRCodeCanvas";var aD=mt.forwardRef(function(s,r){const n=s,{value:a,size:o=AJe,level:l=EJe,bgColor:i=PJe,fgColor:d=IJe,includeMargin:u=LJe,minVersion:p=DJe,boostLevel:f,title:v,marginSize:_,imageSettings:b}=n,j=V0e(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:w,cells:N,numCells:C,calculatedImageSettings:A}=FJe({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:_,imageSettings:b,size:o});let I=N,L=null;b!=null&&A!=null&&(A.excavation!=null&&(I=RJe(N,A.excavation)),L=mt.createElement("image",{href:b.src,height:A.h,width:A.w,x:A.x+w,y:A.y+w,preserveAspectRatio:"none",opacity:A.opacity,crossOrigin:A.crossOrigin}));const R=OJe(I,w);return mt.createElement("svg",U0e({height:o,width:o,viewBox:`0 0 ${C} ${C}`,ref:r,role:"img"},j),!!v&&mt.createElement("title",null,v),mt.createElement("path",{fill:i,d:`M0,0 h${C}v${C}H0z`,shapeRendering:"crispEdges"}),mt.createElement("path",{fill:d,d:R,shapeRendering:"crispEdges"}),L)});aD.displayName="QRCodeSVG";function Ags({slug:t,agentName:s}){const r=S.useRef(null),n=`https://cards.relevelup.com/${t}`,a=S.useCallback(()=>{var f;const o=(f=r.current)==null?void 0:f.querySelector("svg");if(!o)return;const l=document.createElement("canvas"),i=1024;l.width=i,l.height=i;const d=l.getContext("2d");if(!d)return;const u=new XMLSerializer().serializeToString(o),p=new Image;p.onload=()=>{d.fillStyle="#ffffff",d.fillRect(0,0,i,i),d.drawImage(p,0,0,i,i);const v=document.createElement("a");v.download=`${t}-qr-code.png`,v.href=l.toDataURL("image/png"),v.click(),fe.success("QR code downloaded!")},p.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(u)))},[t]);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{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(aD,{value:n,size:120,level:"H",bgColor:"#ffffff",fgColor:"#000000"})}),e.jsxs("div",{className:"space-y-2 min-w-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Download this QR code to use on business cards, flyers, signs, or any print materials. Scanning it opens your digital card instantly."}),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"gap-1.5",children:[e.jsx(xi,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function Cpe(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 Egs(){const{user:t}=Gs(),{data:s,isLoading:r}=n0t(t==null?void 0:t.id),n=PM(),[a,o]=S.useState(null),l=S.useMemo(()=>a||(s?Cpe(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(Igs,{userId:t==null?void 0:t.id})});const i=l||Cpe(s),d=u=>{o(p=>{const f=p||Cpe(s);return typeof u=="function"?u(f):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(Lgs,{card:s}),e.jsx(Fgs,{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(iN,{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(Pgs,{card:s,form:i})})]})})]})})}function Pgs({card:t,form:s}){const{data:r}=Ct({queryKey:["card-preview-profile",t.user_id],queryFn:async()=>{const{data:a}=await G.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 G.storage.from("avatars").list(`${t.user_id}`);if(l&&l.length>0){const{data:i}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${l[0].name}`);o=`${i.publicUrl}?t=${Date.now()}`}}return{...a,avatar_url:o}}}),n=S.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(H1e,{card:n})})}function Igs({userId:t}){var d;const[s,r]=S.useState(""),n=m9e(),{data:a}=Ct({queryKey:["my-profile-for-card",t],queryFn:async()=>{if(!t)return null;const{data:u}=await G.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){fe.error("Please enter a URL slug for your card");return}n.mutate({user_id:t,slug:u,is_published:!0},{onSuccess:()=>fe.success("Your digital card has been created!")})},i=[{icon:Pm,title:"Shareable Link",desc:"One link that works everywhere"},{icon:Dm,title:"Lead Capture",desc:"Collect leads automatically"},{icon:rh,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:Bl,title:"Fully Customizable",desc:"Themes, colors, and content blocks"}];return e.jsxs("div",{className:"max-w-2xl mx-auto p-4 animate-fade-in",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary/90 via-primary to-primary/80 p-8 md:p-12 mb-8 text-primary-foreground",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_30%_20%,rgba(255,255,255,0.15),transparent_50%)]"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_80%_80%,rgba(0,0,0,0.1),transparent_50%)]"}),e.jsxs("div",{className:"relative z-10",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full bg-white/20 backdrop-blur-sm text-sm font-medium mb-4",children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),"New Feature"]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-3 tracking-tight",children:"Your Digital Business Card"}),e.jsx("p",{className:"text-primary-foreground/80 text-lg max-w-md leading-relaxed",children:"Ditch the paper. Share a beautiful, interactive card that captures leads and makes a lasting impression."})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 mb-8",children:i.map(u=>e.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl border bg-card hover:shadow-md transition-shadow",children:[e.jsx("div",{className:"mt-0.5 p-2 rounded-lg bg-primary/10 shrink-0",children:e.jsx(u.icon,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:u.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u.desc})]})]},u.title))}),e.jsxs(Ee,{className:"shadow-lg border-2",children:[e.jsxs(Lt,{className:"text-center pb-2",children:[e.jsx(zt,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(yr,{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(ve,{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(K,{onClick:l,disabled:n.isPending,className:"w-full h-11 text-base font-semibold",size:"lg",children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function Lgs({card:t}){const r=`https://cards.relevelup.com/${t.slug}`,n=()=>{navigator.clipboard.writeText(r),fe.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(at,{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(Pm,{className:"h-3.5 w-3.5"}),"cards.relevelup.com/",t.slug]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[e.jsx(ni,{className:"h-3.5 w-3.5"})," Copy Link"]}),e.jsx(K,{size:"sm",asChild:!0,className:"gap-1.5",children:e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function Dgs({userId:t}){const s=ns(),r=S.useRef(null),[n,a]=S.useState(!1),[o,l]=S.useState(""),{data:i,isLoading:d}=Ct({queryKey:["card-editor-profile",t],queryFn:async()=>{const{data:X}=await G.from("profiles").select("name, email, phone, avatar_url").eq("id",t).single();let se=(X==null?void 0:X.avatar_url)||null;if(!se){const{data:te}=await G.storage.from("avatars").list(`${t}`);if(te&&te.length>0){const{data:Y}=G.storage.from("avatars").getPublicUrl(`${t}/${te[0].name}`);se=`${Y.publicUrl}?t=${Date.now()}`,await G.from("profiles").update({avatar_url:se}).eq("id",t)}}return{...X,avatar_url:se}}}),[u,p]=S.useState(null),[f,v]=S.useState(null),[_,b]=S.useState(null),[j,w]=S.useState(!1),N=u??(i==null?void 0:i.name)??"",C=f??(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(X=>X[0]).join("").toUpperCase().slice(0,2),R=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),$=Ot({mutationFn:async X=>{const{error:se}=await G.from("profiles").update(X).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"]}),fe.success("Profile updated!")},onError:()=>fe.error("Failed to update profile")}),q=()=>{const X={};if(u!==null&&u!==(i==null?void 0:i.name)&&(X.name=u),f!==null&&f!==(i==null?void 0:i.phone)&&(X.phone=f||null),_!==null&&_!==(i==null?void 0:i.email)&&(X.email=_),Object.keys(X).length===0){fe.info("No changes to save");return}$.mutate(X)},U=X=>{var Y;const se=(Y=X.target.files)==null?void 0:Y[0];if(!se)return;if(!se.type.startsWith("image/")){fe.error("Please select an image file");return}const te=new FileReader;te.onloadend=()=>{l(te.result),a(!0)},te.readAsDataURL(se),X.target.value=""},V=async X=>{w(!0);try{const{data:se}=await G.storage.from("avatars").list(`${t}`);se&&se.length>0&&await G.storage.from("avatars").remove(se.map(ae=>`${t}/${ae.name}`));const te=`${t}/avatar.jpg`,{error:Y}=await G.storage.from("avatars").upload(te,X,{upsert:!0,contentType:"image/jpeg"});if(Y)throw Y;const{data:de}=G.storage.from("avatars").getPublicUrl(te),ie=de.publicUrl+"?t="+Date.now();await G.from("profiles").update({avatar_url:ie}).eq("id",t),s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),fe.success("Photo updated!")}catch{fe.error("Failed to upload photo")}finally{w(!1)}};return d?e.jsx(gs,{className:"h-32 w-full rounded-xl"}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:R?"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(ve,{className:"text-sm font-semibold",children:"Profile Info"}),R&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400 font-medium",children:[e.jsx(Qo,{className:"h-3 w-3"}),"Missing info — complete below so your card looks great"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-3",children:"This info shows on your digital card and updates your profile everywhere."}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative group cursor-pointer",onClick:()=>{var X;return(X=r.current)==null?void 0:X.click()},children:[e.jsxs(gn,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx(Ea,{src:I||void 0,alt:N}),e.jsx(xn,{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(Og,{className:"h-5 w-5 text-white"})}),e.jsx("input",{ref:r,type:"file",accept:"image/*",className:"hidden",onChange:U})]}),e.jsxs("div",{className:"flex-1 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:j?"Uploading...":I?"Tap to change photo":"Add a profile photo"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This photo appears on your card, profile, and community posts"})]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Full Name"}),e.jsx(Re,{value:N,onChange:X=>p(X.target.value),placeholder:"Your full name",className:"h-10"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Phone Number"}),e.jsx(Re,{value:C,onChange:X=>v(X.target.value),placeholder:"(555) 123-4567",className:"h-10",type:"tel"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Email"}),e.jsx(Re,{value:A,onChange:X=>b(X.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:q,disabled:$.isPending,className:"w-full",children:$.isPending?"Saving...":"Update Profile Info"})]})}),e.jsx(Zbe,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:V,aspectRatio:1})]})}function Ogs({form:t,setForm:s,userId:r}){const[n,a]=S.useState(null),[o,l]=S.useState(t.brokerage_logo_url?"logo":"name"),[i,d]=S.useState(t.team_logo_url?"logo":"name"),u=_=>{l(_),s(_==="name"?b=>({...b,brokerage_logo_url:""}):b=>({...b,brokerage_display_name:""}))},p=_=>{d(_),s(_==="name"?b=>({...b,team_logo_url:""}):b=>({...b,team_name:""}))},f=async(_,b)=>{var w;const j=(w=_.target.files)==null?void 0:w[0];if(j){if(!j.type.startsWith("image/")){fe.error("Please select an image file");return}a(b);try{const N=j.name.split(".").pop()||"png",A=`${r}/${b==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${N}`,{error:I}=await G.storage.from("card-logos").upload(A,j,{upsert:!0});if(I)throw I;const{data:L}=G.storage.from("card-logos").getPublicUrl(A),R=L.publicUrl+"?t="+Date.now();s(b==="brokerage_logo_url"?$=>({...$,[b]:R,brokerage_display_name:""}):$=>({...$,[b]:R,team_name:""})),fe.success("Logo uploaded!")}catch{fe.error("Failed to upload logo")}finally{a(null),_.target.value=""}}},v=_=>{s(b=>({...b,[_]:""}))};return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(ve,{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(ve,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:o==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>u("name"),children:"Use Name"}),e.jsx(K,{type:"button",variant:o==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>u("logo"),children:"Use Logo"})]}),o==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{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(ve,{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(Og,{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:_=>f(_,"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(ve,{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(Pg,{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(ve,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:i==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>p("name"),children:"Use Name"}),e.jsx(K,{type:"button",variant:i==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>p("logo"),children:"Use Logo"})]}),i==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{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(ve,{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(Og,{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:_=>f(_,"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(ve,{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(Pg,{value:[t.team_logo_size||56],onValueChange:([_])=>s(b=>({...b,team_logo_size:_})),min:24,max:120,step:4})]})]})]})]})})}function Rgs({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(ve,{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(Bl,{className:"h-4 w-4"})," Brand Colors"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Customize colors to match your brand"})]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:o,children:"Reset to Default"})]}),e.jsx("div",{className:"grid gap-3",children:l.map(({key:i,label: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:p=>a(i,p.target.value),className:"sr-only"}),e.jsx("div",{className:"h-10 w-10 rounded-lg border-2 border-border cursor-pointer shadow-sm hover:scale-105 transition-transform",style:{backgroundColor:n[i]}})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:d}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u})]}),e.jsx(Re,{value:n[i],onChange:p=>{const f=p.target.value;/^#[0-9a-fA-F]{0,6}$/.test(f)&&a(i,f)},className:"w-24 h-8 text-xs font-mono",placeholder:"#ff5722"})]},i))}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Preview:"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.accent}}),e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.dark}}),e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.button}})]})]})]})}function Fgs({card:t,form:s,setForm:r}){var j;const n=p9e(),a=ns(),{data:o}=f9e(t.id),[l,i]=S.useState(t.slug),[d,u]=S.useState(!1),[p,f]=S.useState("idle"),v=S.useRef(JSON.stringify(s)),_=S.useRef(null);S.useEffect(()=>{const w=JSON.stringify(s);if(w!==v.current)return _.current&&clearTimeout(_.current),_.current=setTimeout(()=>{f("saving"),n.mutate({id:t.id,...s,is_published:!0,title:s.title||null,positioning_statement:s.positioning_statement||null,bio:s.bio||null,review_snippet:s.review_snippet||null,review_source_url:s.review_source_url||null,booking_url:s.booking_url||null,custom_cta_label:s.custom_cta_label||null,brokerage_display_name:s.brokerage_display_name||null,brokerage_logo_url:s.brokerage_logo_url||null,brokerage_logo_size:s.brokerage_logo_size,team_name:s.team_name||null,team_logo_url:s.team_logo_url||null,team_logo_size:s.team_logo_size,bold_theme_colors:s.bold_theme_colors||null,display_email:s.display_email||null},{onSuccess:()=>{v.current=w,f("saved"),setTimeout(()=>f("idle"),2e3)},onError:()=>f("idle")})},1500),()=>{_.current&&clearTimeout(_.current)}},[s]);const b=async()=>{const w=l.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!w){fe.error("Please enter a valid URL");return}if(w===t.slug){fe.info("No changes to save");return}u(!0);try{const{data:N}=await G.from("agent_cards").select("id").eq("slug",w).neq("id",t.id).maybeSingle();if(N){fe.error("This URL is already taken. Try another one.");return}const{error:C}=await G.from("agent_cards").update({slug:w}).eq("id",t.id);if(C)throw C;i(w),a.invalidateQueries({queryKey:["agent-card"]}),fe.success("Card address updated!")}catch{fe.error("Failed to update card address")}finally{u(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Na,{defaultValue:"content",children:[e.jsxs(va,{className:"w-full h-11 p-1",children:[e.jsxs(ks,{value:"content",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(uf,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Content"]}),e.jsxs(ks,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(ya,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),e.jsxs(ks,{value:"blocks",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Dm,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Blocks"]}),e.jsxs(ks,{value:"qrcode",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(L0,{className:"h-3.5 w-3.5 hidden sm:inline"}),"QR Code"]}),e.jsxs(ks,{value:"analytics",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(r_,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Analytics"]})]}),e.jsxs(zs,{value:"content",className:"mt-4 space-y-4",children:[e.jsx(Dgs,{userId:t.user_id}),e.jsx(Ogs,{form:s,setForm:r,userId:t.user_id}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx(ve,{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(Br,{checked:s.is_published,onCheckedChange:w=>r(N=>({...N,is_published:w}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{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:w=>i(w.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"your-name",className:"rounded-l-none h-10"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick: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(ve,{className:"text-sm font-medium",children:"Card Email (Override)"}),e.jsx(Re,{value:s.display_email,onChange:w=>r(N=>({...N,display_email:w.target.value})),placeholder:"you@yourbusiness.com",className:"h-11",type:"email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional — use a different email on your card instead of your sign-in email."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Theme"}),e.jsxs(tr,{value:s.theme,onValueChange:w=>r(N=>({...N,theme:w})),children:[e.jsx(Js,{className:"h-11",children:e.jsx(sr,{})}),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(Rgs,{form:s,setForm:r}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Title / Tagline"}),e.jsx(Re,{value:s.title,onChange:w=>r(N=>({...N,title:w.target.value})),placeholder:"e.g. Luxury Real Estate Specialist",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown below your name on the card"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Positioning Statement"}),e.jsx(Re,{value:s.positioning_statement,onChange:w=>r(N=>({...N,positioning_statement:w.target.value})),placeholder:"Your home journey, handled with care.",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Bio"}),e.jsx(Mr,{value:s.bio,onChange:w=>r(N=>({...N,bio:w.target.value})),placeholder:"A short intro about you and what makes you different...",rows:3})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Review Snippet"}),e.jsx(Re,{value:s.review_snippet,onChange:w=>r(N=>({...N,review_snippet:w.target.value})),placeholder:"Best agent we've ever worked with...",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Review Source URL"}),e.jsx(Re,{value:s.review_source_url,onChange:w=>r(N=>({...N,review_source_url:w.target.value})),placeholder:"https://g.page/your-business/review",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Booking URL"}),e.jsx(Re,{value:s.booking_url,onChange:w=>r(N=>({...N,booking_url:w.target.value})),placeholder:"https://calendly.com/your-link",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave empty to show a built-in lead form instead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Custom CTA Label"}),e.jsx(Re,{value:s.custom_cta_label,onChange:w=>r(N=>({...N,custom_cta_label:w.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),e.jsx(zs,{value:"sections",className:"mt-4",children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-5 divide-y",children:[{key:"show_photo",label:"Photo",desc:"Uses the photo from your Profile Info above"},{key:"show_bio",label:"Bio Section",desc:"Display your bio on the card"},{key:"show_credentials",label:"Credentials",desc:"Show star rating and reviews"},{key:"show_social_links",label:"Social Links",desc:"Display your social media links"},{key:"show_save_contact",label:"Save Contact",desc:"Let visitors save you as a contact"},{key:"show_leave_review",label:"Leave Review",desc:"Link to your review page"},{key:"show_refer_friend",label:"Refer a Friend",desc:"Enable referral submissions"}].map(({key:w,label:N,desc:C})=>e.jsxs("div",{className:"flex items-center justify-between py-4 first:pt-0 last:pb-0",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:N}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C})]}),e.jsx(Br,{checked:s[w],onCheckedChange:A=>r(I=>({...I,[w]:A}))})]},w))})})}),e.jsx(zs,{value:"blocks",className:"mt-4",children:e.jsx(CJe,{cardId:t.id})}),e.jsx(zs,{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:ya,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:r_,color:"text-amber-600 bg-amber-100 dark:text-amber-400 dark:bg-amber-900/30"},{label:"Leads",value:((j=o==null?void 0:o.leads)==null?void 0:j.length)??0,icon:xc,color:"text-emerald-600 bg-emerald-100 dark:text-emerald-400 dark:bg-emerald-900/30"}].map(w=>e.jsx(Ee,{className:"overflow-hidden",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`p-1.5 rounded-md ${w.color}`,children:e.jsx(w.icon,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:w.label})]}),e.jsx("div",{className:"text-2xl font-bold",children:w.value})]})},w.label))}),o&&o.leads.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(zt,{className:"text-base",children:"Recent Leads"})}),e.jsx(Oe,{className:"pt-0 space-y-2",children:o.leads.slice(0,5).map(w=>e.jsxs("div",{className:"flex items-center justify-between text-sm p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:w.name}),w.phone&&e.jsx("span",{className:"text-muted-foreground ml-2",children:w.phone})]}),w.intent&&e.jsx(at,{variant:"secondary",className:"text-xs",children:w.intent})]},w.id))})]}),(!o||o.leads.length===0)&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center",children:[e.jsx(r_,{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(zs,{value:"qrcode",className:"mt-4 space-y-4",children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6",children:e.jsx(Ags,{slug:t.slug})})})})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[p==="saving"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-400 animate-pulse"})," Saving..."]}),p==="saved"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"})," All changes saved"]}),p==="idle"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/30"})," Changes auto-save"]})]})]})}function zgs(){const t=ns(),[s,r]=S.useState(""),[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState(!1),[f,v]=S.useState(!1),[_,b]=S.useState(null),[j,w]=S.useState(null),[N,C]=S.useState(0),{data:A,isLoading:I}=Ct({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:te,error:Y}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(Y)throw Y;return te}}),L=Ot({mutationFn:async te=>{const{data:Y,error:de}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_token",api_token:te}});if(de)throw de;if(Y!=null&&Y.error)throw new Error(Y.error);return Y},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),r(""),fe.success("BoldTrail connected successfully!")},onError:te=>{fe.error(te.message||"Failed to connect BoldTrail")}}),R=Ot({mutationFn:async()=>{const{data:te,error:Y}=await G.functions.invoke("boldtrail-sync",{body:{action:"disconnect"}});if(Y)throw Y;return te},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),fe.success("BoldTrail disconnected")},onError:()=>fe.error("Failed to disconnect")}),$=Ot({mutationFn:async te=>{const{data:Y,error:de}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_direction",sync_direction:te}});if(de)throw de;if(Y!=null&&Y.error)throw new Error(Y.error);return Y},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),fe.success("Sync direction saved")},onError:te=>{fe.error(te.message||"Failed to save sync direction")}}),q=Ot({mutationFn:async()=>{const{data:te,error:Y}=await G.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=>{fe.error(te.message||"Failed to generate sync preview")}}),U=Ot({mutationFn:async()=>{w("Initializing sync..."),C(5);const{data:te,error:Y}=await G.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 de=te;let ie=de.sync_log_id,ae=de.next_phase,le=de.next_offset;const pe=de.push_total||0,be=de.pull_total||0,ye=pe+be;let we=0,ke=0;for(;ae!=="finalize";){ae==="push"?(w(`Pushing contacts to BoldTrail... (${we}/${pe})`),C(ye>0?we/ye*100:0)):ae==="pull"&&(w(`Pulling contacts from BoldTrail... (${ke}/${be})`),C(ye>0?(pe+ke)/ye*100:0));const{data:Ce,error:Te}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:ae,offset:le,sync_log_id:ie,sync_direction:se}});if(Te)throw Te;if(Ce!=null&&Ce.error)throw new Error(Ce.error);const Fe=Ce;we+=Fe.chunk_pushed||0,ke+=Fe.chunk_pulled||0,Fe.progress&&w(Fe.progress),ae==="pull"&&be>0?C(Math.min(95,ke/be*100)):ae==="push"&&pe>0&&C(Math.min(95,we/pe*100)),ae=Fe.next_phase,le=Fe.next_offset}w("Finalizing sync..."),C(95);const{data:Ze,error:_e}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:ie,sync_direction:se}});if(_e)throw _e;return C(100),Ze},onSuccess:te=>{w(null),C(0),a(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["contacts"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),fe.success(`Sync complete! Pushed ${te.contacts_pushed||0}, pulled ${te.contacts_pulled||0}, skipped ${te.contacts_skipped||0} duplicates.`)},onError:te=>{w(null),C(0),fe.error(te.message||"Sync failed")}}),V=A==null?void 0:A.connected,X=(A==null?void 0:A.sync_direction)||"bidirectional",se=_??X;return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Lt,{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(Hc,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["BoldTrail",V&&e.jsx(at,{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(ym,{className:"h-3.5 w-3.5"}),"Learn More"]})]}),e.jsx(yr,{children:"Sync contacts bidirectionally between Agent OS and your BoldTrail (kvCORE) CRM."})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Two-way contact sync with duplicate prevention"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Preview what will sync before executing"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Syncs name, email, phone, address, notes, and lead source"})]}),V?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsx("div",{className:"rounded-lg border p-3 space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"BoldTrail Connected"}),(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(at,{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(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect BoldTrail?"}),e.jsx(Dl,{children:"This will remove your API token. Previously synced contacts will remain in both systems."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>R.mutate(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]})}),e.jsx("div",{className:"rounded-lg border p-3",children:e.jsx(dye,{value:X,onChange:te=>$.mutate(te)})}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{onClick:()=>q.mutate(),disabled:q.isPending||U.isPending,variant:"outline",className:"gap-2",children:[q.isPending?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(ya,{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(K,{onClick:()=>L.mutate(s),disabled:!s||s.length<10||L.isPending,children:[L.isPending?e.jsx(Po,{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(vs,{open:n,onOpenChange:te=>{U.isPending||a(te)},children:e.jsxs(ys,{className:"sm:max-w-lg",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Hc,{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(dye,{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(Vd,{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(eh,{className:"h-3 w-3"})," Pull to Agent OS"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-muted-foreground",children:i.already_synced}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"})," Already synced"]})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["Agent OS: ",i.agent_os_total," contacts · BoldTrail: ",i.boldtrail_total," contacts"]}),U.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(Ti,{value:N||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:j||"Sync in progress..."})]}),te>0&&e.jsxs(mf,{open:u,onOpenChange:p,children:[e.jsx(pf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Vd,{className:"h-3 w-3 text-emerald-600"}),te," contacts to push to BoldTrail"]}),e.jsx(Vo,{className:`h-3 w-3 transition-transform ${u?"rotate-180":""}`})]})}),e.jsx(ff,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.push_preview.map((de,ie)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:de.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:de.email})]},ie)),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(mf,{open:f,onOpenChange:v,children:[e.jsx(pf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(eh,{className:"h-3 w-3 text-blue-600"}),Y," contacts to pull from BoldTrail"]}),e.jsx(Vo,{className:`h-3 w-3 transition-transform ${f?"rotate-180":""}`})]})}),e.jsx(ff,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.pull_preview.map((de,ie)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:de.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:de.email})]},ie)),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(K,{variant:"outline",onClick:()=>a(!1),disabled:U.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>U.mutate(),disabled:U.isPending||te===0&&Y===0,className:"gap-2",children:[U.isPending?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Hc,{className:"h-4 w-4"}),U.isPending?"Syncing...":"Sync Now"]})]})]})})()]})}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{className:"sm:max-w-2xl p-0 overflow-hidden",children:[e.jsx(Ss,{className:"p-6 pb-0",children:e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Hc,{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 Bgs(){const{isAdmin:t}=Gs(),s=ns(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(!1),{data:d,isLoading:u}=Ct({queryKey:["gmail-integration"],queryFn:async()=>{const{data:I,error:L}=await G.from("gmail_integrations").select("*").maybeSingle();if(L)throw L;return I}}),{data:p}=Ct({queryKey:["social-accounts"],queryFn:async()=>{const{data:{user:I}}=await G.auth.getUser();if(!I)return[];const{data:L,error:R}=await G.from("social_accounts").select("*").eq("user_id",I.id).order("created_at",{ascending:!1});if(R)throw R;return L}}),f=async()=>{n(!0);try{const{data:I,error:L}=await G.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),fe.error("Failed to start Gmail connection"),n(!1)}},v=async()=>{o(!0);try{const{data:I,error:L}=await G.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),fe.error("Failed to start connection. Make sure Meta App credentials are configured."),o(!1)}},_=async()=>{i(!0);try{const{data:I,error:L}=await G.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),fe.error("Failed to start LinkedIn connection. Please try again."),i(!1)}},b=Ot({mutationFn:async I=>{const{error:L}=await G.from("gmail_integrations").delete().eq("id",I);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["gmail-integration"]}),fe.success("Gmail disconnected")},onError:()=>{fe.error("Failed to disconnect Gmail")}}),j=Ot({mutationFn:async I=>{const{error:L}=await G.from("social_accounts").delete().eq("id",I);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["social-accounts"]}),fe.success("Account disconnected")},onError:()=>{fe.error("Failed to disconnect account")}}),w=!!(d!=null&&d.is_active),N=(p==null?void 0:p.filter(I=>I.platform==="facebook"))||[],C=(p==null?void 0:p.filter(I=>I.platform==="instagram"))||[],A=(p==null?void 0:p.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(Ee,{children:[e.jsx(Lt,{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(_r,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Gmail",w&&e.jsx(at,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),e.jsx(yr,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Send personalized emails from your Gmail account"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Automatically log emails as activity touchpoints"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Quick compose from any contact detail page"})]}),w?e.jsxs("div",{className:"flex items-center justify-between mt-4 p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:d.gmail_email}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Gmail account"})]}),e.jsxs(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect Gmail?"}),e.jsx(Dl,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>b.mutate(d.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:f,disabled:r||u,children:[r?e.jsx(Po,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(_r,{className:"h-4 w-4 mr-2"}),"Connect Gmail",e.jsx(Fi,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(Lt,{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(Hd,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Facebook",t?N.length>0?e.jsx(at,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(at,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(zu,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(yr,{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(gn,{className:"h-8 w-8",children:[e.jsx(Ea,{src:I.profile_picture_url||""}),e.jsx(xn,{children:e.jsx(Hd,{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(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect Facebook?"}),e.jsx(Dl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>j.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(K,{onClick:v,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),"Connect Facebook Page"]})]})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(Lt,{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(Wd,{className:"h-5 w-5 text-pink-600"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Instagram",t?C.length>0?e.jsx(at,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(at,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(zu,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(yr,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[C.length>0&&e.jsx("div",{className:"space-y-2",children:C.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(gn,{className:"h-8 w-8",children:[e.jsx(Ea,{src:I.profile_picture_url||""}),e.jsx(xn,{children:e.jsx(Wd,{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(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect Instagram?"}),e.jsx(Dl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>j.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(K,{onClick:v,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),"Connect Instagram Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Instagram Business accounts must be connected to a Facebook Page."})]})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(Lt,{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(Lm,{className:"h-5 w-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["LinkedIn",t?A.length>0?e.jsx(at,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(at,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(zu,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(yr,{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(gn,{className:"h-8 w-8",children:[e.jsx(Ea,{src:I.profile_picture_url||""}),e.jsx(xn,{children:e.jsx(Lm,{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(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect LinkedIn?"}),e.jsx(Dl,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>j.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(K,{onClick:_,disabled:l,variant:"outline",className:"gap-2",children:[l?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]}),e.jsx(zgs,{})]})})}function $gs(){const[t]=Ec(),s=Dr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Connecting your Gmail account...");return S.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),fe.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),fe.error("No authorization code received");return}try{const{data:f,error:v}=await G.functions.invoke("gmail-oauth",{body:{action:"exchange_code",code:i,state:p}});if(v)throw v;if(f!=null&&f.success)n("success"),o(f.message||"Gmail connected successfully!"),fe.success("Gmail connected!");else throw new Error((f==null?void 0:f.error)||"Unknown error")}catch(f){console.error("Gmail OAuth callback error:",f),n("error"),o(f instanceof Error?f.message:"Failed to connect Gmail"),fe.error("Failed to connect: "+(f instanceof Error?f.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(As,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(gi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(kc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(yr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"Back to Integrations":"Try Again"})})]})})}function qgs(){const t=Dr();return S.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 Ugs(){const[t]=Ec(),s=Dr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Processing your connection...");return S.useEffect(()=>{(async()=>{var f;const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),fe.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),fe.error("No authorization code received");return}try{const{data:v,error:_}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/mission-control/integrations/meta/callback"}});if(_)throw _;if(v!=null&&v.success)n("success"),o(`Successfully connected ${((f=v.accounts)==null?void 0:f.length)||0} account(s)!`),fe.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"),fe.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(Ee,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(As,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(gi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(kc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(yr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Integrations":"Try Again"})})]})})}const zJe=new Date().getFullYear(),Vgs=Array.from({length:5},(t,s)=>zJe-s);function Hgs(){const[t,s]=S.useState(zJe),r=Dr(),{data:n,isLoading:a}=H5t();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(sr,{})}),e.jsx(er,{children:Vgs.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(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Agents Tracking"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(n==null?void 0:n.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Xo,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(n==null?void 0:n.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with transactions"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Agents with Scorecards"}),e.jsx(yr,{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(Xo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents have added transactions yet"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:n.map(o=>e.jsxs(js,{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(K,{variant:"ghost",size:"sm",onClick:()=>r(`/admin/scorecard/${o.id}`),children:[e.jsx(ya,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const BJe=new Date().getFullYear(),Wgs=Array.from({length:10},(t,s)=>BJe-s);function ILe(){var b;const{userId:t}=Mo(),s=Dr(),n=vu().pathname.startsWith("/mission-control"),[a,o]=S.useState(BJe),{data:l,isLoading:i}=Ct({queryKey:["agent-profile",t],queryFn:async()=>{const{data:j,error:w}=await G.from("profiles").select("id, name, email").eq("id",t).single();if(w)throw w;return j},enabled:!!t}),{data:d,isLoading:u}=ibe(a,t),{yearStats:p,lifetimeStats:f,showCommission:v}=vVe(a,t),{data:_}=yVe(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(j=>e.jsx(gs,{className:"h-24"},j))})]})}):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(K,{variant:"ghost",size:"icon",onClick:()=>s(n?"/mission-control/scorecard":"/admin/scorecard"),children:e.jsx(Ua,{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:j=>o(Number(j)),children:[e.jsx(Js,{className:"w-[120px]",children:e.jsx(sr,{})}),e.jsx(er,{children:Wgs.map(j=>e.jsx(At,{value:String(j),children:j},j))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:p.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.totalTransactions," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[p.buyerCount,"/",p.sellerCount]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Kc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Tl(p.totalVolume,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Cc,{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:Tl(p.averagePrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{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=p.topLeadSource)==null?void 0:b.name)||"-"})]})})]}),_&&e.jsx(wZe,{goals:_,stats:p,year:a,showCommission:v}),e.jsxs(Na,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsx(ks,{value:"transactions",children:"Transactions"}),e.jsx(ks,{value:"charts",children:"Charts"}),e.jsxs(ks,{value:"map",children:[e.jsx(Ai,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(zs,{value:"transactions",children:e.jsx(kwe,{transactions:d||[],showCommission:v,isLoading:u})}),e.jsx(zs,{value:"charts",children:e.jsx(P2e,{stats:p,year:a})}),e.jsx(zs,{value:"map",children:e.jsx(I2e,{transactions:d||[],isLoading:u})})]})]})})}function Ggs(){const t=ns(),[s,r]=S.useState(""),[n,a]=S.useState("all");K9e();const{data:o,refetch:l}=Ct({queryKey:["listing-exchange-flag"],queryFn:async()=>{const{data:I}=await G.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").single();return(I==null?void 0:I.enabled)??!1}}),{data:i,isLoading:d}=Ct({queryKey:["admin-listings"],queryFn:async()=>{const{data:I,error:L}=await G.from("listings").select(` *, agent:profiles!listings_agent_id_fkey(id, name, email), photos:listing_photos(id, photo_url, is_primary) `).order("created_at",{ascending:!1});if(L)throw L;return I}}),{data:u}=Ct({queryKey:["admin-listing-stats"],queryFn:async()=>{const{data:I}=await G.from("listings").select("id, is_approved, status"),{data:L}=await G.from("listing_shares").select("id"),{data:R}=await G.from("listing_views").select("id");return{total:(I==null?void 0:I.length)||0,pending:(I==null?void 0:I.filter($=>!$.is_approved).length)||0,active:(I==null?void 0:I.filter($=>$.status==="active").length)||0,totalShares:(L==null?void 0:L.length)||0,totalViews:(R==null?void 0:R.length)||0}}}),p=async(I,L,R="submit_url")=>{try{const{data:{session:$}}=await G.auth.getSession();if(!$)return;const{data:q,error:U}=await G.functions.invoke("google-indexing",{body:{action:R,listing_id:I,listing_slug:L}});if(U)throw U;if((q==null?void 0:q.configured)===!1)return;q!=null&&q.success&&fe.success("Submitted to Google for indexing")}catch($){console.error("Google indexing submission failed:",$)}},f=Ot({mutationFn:async()=>{const{data:{session:I}}=await G.auth.getSession();if(!I)throw new Error("Not authenticated");const{data:L,error:R}=await G.functions.invoke("google-indexing",{body:{action:"submit_all"}});if(R)throw R;return L},onSuccess:I=>{if((I==null?void 0:I.configured)===!1){fe.error("Google Indexing API not configured. Add the GOOGLE_INDEXING_SERVICE_ACCOUNT secret.");return}fe.success(`Submitted ${(I==null?void 0:I.succeeded)||0} URLs to Google (${(I==null?void 0:I.failed)||0} failed)`)},onError:I=>{fe.error("Failed to submit to Google"),console.error(I)}}),v=Ot({mutationFn:async({id:I,approved:L,slug:R})=>{const{error:$}=await G.from("listings").update({is_approved:L}).eq("id",I);if($)throw $;return{id:I,approved:L,slug:R}},onSuccess:I=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),fe.success(I.approved?"Listing approved":"Listing unapproved"),I.approved?p(I.id,I.slug||null,"submit_url"):p(I.id,I.slug||null,"remove_url")}}),_=Ot({mutationFn:async({id:I,featured:L})=>{const{error:R}=await G.from("listings").update({is_featured:L}).eq("id",I);if(R)throw R},onSuccess:(I,{featured:L})=>{t.invalidateQueries({queryKey:["admin-listings"]}),fe.success(L?"Listing featured":"Listing unfeatured")}}),b=Ot({mutationFn:async I=>{const{error:L}=await G.from("listings").delete().eq("id",I);if(L)throw L},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),fe.success("Listing deleted")}}),j=Ot({mutationFn:async I=>{const{error:L}=await G.from("feature_flags").update({enabled:I}).eq("key","listing_exchange_enabled");if(L)throw L},onSuccess:()=>{l(),fe.success("Feature flag updated")}}),w=o??!1,N=i==null?void 0:i.filter(I=>{var $,q,U,V;const L=(($=I.city)==null?void 0:$.toLowerCase().includes(s.toLowerCase()))||((U=(q=I.agent)==null?void 0:q.name)==null?void 0:U.toLowerCase().includes(s.toLowerCase()))||((V=I.property_address)==null?void 0:V.toLowerCase().includes(s.toLowerCase())),R=n==="all"||n==="pending"&&!I.is_approved||n==="approved"&&I.is_approved;return L&&R}),C=I=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I),A=I=>{const L={active:"bg-green-500/10 text-green-600 border-green-200",coming_soon:"bg-blue-500/10 text-blue-600 border-blue-200",price_improvement:"bg-amber-500/10 text-amber-600 border-amber-200",under_contract:"bg-purple-500/10 text-purple-600 border-purple-200",sold:"bg-gray-500/10 text-gray-600 border-gray-200"};return L[I]||L.active};return e.jsx(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.jsxs(K,{variant:"outline",size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(Pm,{className:"h-4 w-4"}),"Submit All to Google"]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Feature visible to agents"}),e.jsx(Br,{checked:w,onCheckedChange:I=>j.mutate(I)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Aa,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Listings"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.total)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cc,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Active"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.active)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Pending Review"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.pending)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ya,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Views"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.totalViews)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cd,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Shares"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.totalShares)||0})]})})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(fn,{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:I=>r(I.target.value),className:"pl-9"})]}),e.jsx(Na,{value:n,onValueChange:I=>a(I),children:e.jsxs(va,{children:[e.jsx(ks,{value:"all",children:"All"}),e.jsx(ks,{value:"pending",children:"Pending"}),e.jsx(ks,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{children:["Listings (",(N==null?void 0:N.length)||0,")"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Property"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Price"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-center",children:"Approved"}),e.jsx(jt,{className:"text-center",children:"Featured"}),e.jsx(jt,{children:"Views"}),e.jsx(jt,{children:"Shares"}),e.jsx(jt,{children:"Date"}),e.jsx(jt,{})]})}),e.jsx(Pn,{children:d?e.jsx(js,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(N==null?void 0:N.length)===0?e.jsx(js,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):N==null?void 0:N.map(I=>{var L,R,$,q,U;return e.jsxs(js,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[(R=(L=I.photos)==null?void 0:L[0])!=null&&R.photo_url?e.jsx("img",{src:I.photos[0].photo_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(Aa,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.property_address||`${I.city}, ${I.state}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:($=I.property_type)==null?void 0:$.replace("_"," ")})]})]})}),e.jsx(lt,{children:e.jsx("p",{className:"text-sm",children:((q=I.agent)==null?void 0:q.name)||"Unknown"})}),e.jsx(lt,{className:"font-medium",children:C(I.price)}),e.jsx(lt,{children:e.jsx(at,{variant:"outline",className:A(I.status),children:(U=I.status)==null?void 0:U.replace("_"," ")})}),e.jsx(lt,{className:"text-center",children:e.jsx(Br,{checked:I.is_approved??!1,onCheckedChange:V=>v.mutate({id:I.id,approved:V,slug:I.slug})})}),e.jsx(lt,{className:"text-center",children:e.jsx(Br,{checked:I.is_featured??!1,onCheckedChange:V=>_.mutate({id:I.id,featured:V})})}),e.jsx(lt,{children:I.view_count||0}),e.jsx(lt,{children:I.share_count||0}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:ws(new Date(I.created_at),"MMM d, yyyy")}),e.jsx(lt,{children:e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(ef,{className:"h-4 w-4"})})}),e.jsxs(Td,{align:"end",children:[e.jsxs(Ta,{onClick:()=>window.open(`/mission-control/listings/${I.id}`,"_blank"),children:[e.jsx(ya,{className:"h-4 w-4 mr-2"}),"View Listing"]}),e.jsxs(Ta,{onClick:()=>_.mutate({id:I.id,featured:!I.is_featured}),children:[e.jsx(Gn,{className:"h-4 w-4 mr-2"}),I.is_featured?"Unfeature":"Feature"]}),e.jsxs(Ta,{className:"text-destructive",onClick:()=>{confirm("Are you sure you want to delete this listing?")&&b.mutate(I.id)},children:[e.jsx(Ur,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},I.id)})})]})})})]})]})})}const Kgs=()=>{var f,v;const[t,s]=S.useState(""),[r,n]=S.useState(null),{data:a,isLoading:o}=Ct({queryKey:["membership-reviews"],queryFn:async()=>{const{data:_,error:b}=await G.from("membership_reviews").select("*").order("created_at",{ascending:!1});if(b)throw b;const j=(_==null?void 0:_.map(C=>C.user_id))||[],{data:w}=await G.from("profiles").select("id, name, email").in("id",j);return _==null?void 0:_.map(C=>({...C,profiles:(w==null?void 0:w.find(A=>A.id===C.user_id))||null}))}}),l=a==null?void 0:a.filter(_=>{var j,w,N,C,A;const b=t.toLowerCase();return((w=(j=_.profiles)==null?void 0:j.name)==null?void 0:w.toLowerCase().includes(b))||((C=(N=_.profiles)==null?void 0:N.email)==null?void 0:C.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,p=_=>e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(b=>e.jsx(Gn,{className:Pt("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(_u,{title:"Membership Reviews",description:"View and manage feedback from LevelUp members"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"Total Reviews"}),e.jsx(zt,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"Average Rating"}),e.jsxs(zt,{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(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"5-Star Reviews"}),e.jsx(zt,{className:"text-3xl",children:(d==null?void 0:d[5])||0})]})}),e.jsx(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"Posted to Google"}),e.jsxs(zt,{className:"flex items-center gap-2 text-3xl",children:[u,e.jsx(sn,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(fn,{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(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Member"}),e.jsx(jt,{children:"Rating"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Review"}),e.jsx(jt,{children:"Google"}),e.jsx(jt,{children:"Date"})]})}),e.jsx(Pn,{children:o?e.jsx(js,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(js,{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,j;return e.jsxs(js,{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:(j=_.profiles)==null?void 0:j.email})]})}),e.jsx(lt,{children:p(_.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(at,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):e.jsx(at,{variant:"outline",children:"No"})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:ws(new Date(_.created_at),"MMM d, yyyy")})]},_.id)})})]})})}),e.jsx(vs,{open:!!r,onOpenChange:()=>n(null),children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Review Details"})}),r&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-4 p-4 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:((f=r.profiles)==null?void 0:f.name)||"Unknown Member"}),((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(_r,{className:"h-3 w-3"}),r.profiles.email]})]}),e.jsxs("div",{className:"text-right",children:[p(r.rating),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r.rating," out of 5 stars"]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Review"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:r.review_text||"No written review provided."})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(on,{className:"h-4 w-4"}),ws(new Date(r.created_at),"MMMM d, yyyy 'at' h:mm a")]}),r.posted_to_google?e.jsxs(at,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(sn,{className:"h-3 w-3 mr-1"}),"Posted to Google"]}):e.jsx(at,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},Zgs=[{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"}],Ygs=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 Xgs(){const t=ns(),{user:s}=Gs(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(!1),{data:d,isLoading:u}=Ct({queryKey:["weekly-digest-settings"],queryFn:async()=>{const{data:q,error:U}=await G.from("weekly_digest_settings").select("*").single();if(U)throw U;return q}}),{data:p,isLoading:f}=Ct({queryKey:["weekly-digest-logs"],queryFn:async()=>{const{data:q,error:U}=await G.from("weekly_digest_logs").select("*").order("sent_at",{ascending:!1}).limit(100);if(U)throw U;return q}}),{data:v}=Ct({queryKey:["digest-subscriber-count"],queryFn:async()=>{const{count:q,error:U}=await G.from("profiles").select("id",{count:"exact",head:!0}).eq("digest_opt_out",!1).not("email","is",null);if(U)throw U;return q||0}}),{data:_,refetch:b}=Ct({queryKey:["digest-queue-status"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const[U,V,X,se]=await Promise.all([G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","pending").gte("created_at",q.toISOString()),G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","processing").gte("created_at",q.toISOString()),G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","sent").gte("created_at",q.toISOString()),G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","failed").gte("created_at",q.toISOString())]);return{pending:U.count||0,processing:V.count||0,sent:X.count||0,failed:se.count||0,total:(U.count||0)+(V.count||0)+(X.count||0)+(se.count||0)}},refetchInterval:5e3});S.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:j=0}=Ct({queryKey:["digest-today-failed-count"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const{count:U,error:V}=await G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",q.toISOString());if(V)throw V;return U||0}}),w=Ot({mutationFn:async q=>{const{error:U}=await G.from("weekly_digest_settings").update(q).eq("id",d==null?void 0:d.id);if(U)throw U},onSuccess:()=>{t.invalidateQueries({queryKey:["weekly-digest-settings"]}),fe.success("Settings updated")},onError:q=>{fe.error("Failed to update settings: "+q.message)}}),N=async()=>{n(!0);try{const{data:q,error:U}=await G.functions.invoke("send-weekly-digest",{body:{manual:!0}});if(U)throw U;q.queued?fe.success(`${q.queued.toLocaleString()} emails queued! They'll be sent automatically (~80/minute).`):q.sent!==void 0&&fe.success(`Digest sent! ${q.sent} emails delivered, ${q.failed} failed`),b(),t.invalidateQueries({queryKey:["weekly-digest-logs"]})}catch(q){fe.error("Failed to send digest: "+q.message)}finally{n(!1)}},C=async()=>{var q,U,V,X,se,te;if(!(s!=null&&s.email)){fe.error("No email found for your account");return}o(!0);try{const{data:Y,error:de}=await G.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:s.email}});if(de)throw de;const ie=Y==null?void 0:Y.resendId,ae=Y==null?void 0:Y.resendDetails,le=ae==null?void 0:ae.status,pe=((q=ae==null?void 0:ae.body)==null?void 0:q.status)||((V=(U=ae==null?void 0:ae.body)==null?void 0:U.data)==null?void 0:V.status),be=((se=(X=ae==null?void 0:ae.body)==null?void 0:X.error)==null?void 0:se.message)||((te=ae==null?void 0:ae.body)==null?void 0:te.message);fe.success(ie?`Preview accepted by email provider (id: ${ie})${le?`, status check: ${le}`:""}${pe?`, provider: ${pe}`:""}${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){fe.error("Failed to send preview: "+Y.message)}finally{o(!1)}},A=async()=>{i(!0);try{const{data:q,error:U}=await G.functions.invoke("send-weekly-digest",{body:{retryFailed:!0}});if(U)throw U;q.queued===0||q.sent===0&&q.failed===0&&!q.queued?fe.info("No failed emails to retry"):q.queued?fe.success(`${q.queued} emails queued for retry!`):fe.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){fe.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:R}=Ct({queryKey:["digest-delivery-stats"],queryFn:async()=>{var te,Y;const q=new Date;q.setUTCHours(0,0,0,0);const[U,V,X,se]=await Promise.all([G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","sent").gte("sent_at",q.toISOString()),G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",q.toISOString()),G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("has_agent_os_activity",!0).gte("sent_at",q.toISOString()),G.from("weekly_digest_logs").select("sent_at").order("sent_at",{ascending:!1}).limit(1)]);return{totalSent:U.count||0,totalFailed:V.count||0,agentOsEngaged:X.count||0,lastSent:((Y=(te=se.data)==null?void 0:te[0])==null?void 0:Y.sent_at)||null}},refetchInterval:L?5e3:!1}),$={totalSent:(R==null?void 0:R.totalSent)||0,totalFailed:(R==null?void 0:R.totalFailed)||0,lastSent:R==null?void 0:R.lastSent,agentOsEngaged:(R==null?void 0:R.agentOsEngaged)||0};return u?e.jsx(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(Na,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(va,{children:[e.jsxs(ks,{value:"settings",className:"flex items-center gap-2",children:[e.jsx($l,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(ks,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-4 w-4"}),"Delivery Stats"]})]}),e.jsxs(zs,{value:"settings",className:"space-y-6",children:[L&&_&&e.jsx(Ee,{className:"border-primary/50 bg-primary/5",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx(As,{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(Ti,{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(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(hr,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:v}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscribers"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-emerald-500/10",children:e.jsx(da,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.totalSent}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Delivered"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-destructive/10",children:e.jsx(kc,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.totalFailed}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(Tn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.lastSent?ws(new Date($.lastSent),"MMM d"):"Never"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last Sent"})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(yr,{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(ve,{children:"Enable Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Send automated weekly emails to members"})]}),e.jsx(Br,{checked:d==null?void 0:d.is_enabled,onCheckedChange:q=>w.mutate({is_enabled:q})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Cron Frequency"}),e.jsxs(tr,{value:(d==null?void 0:d.cron_frequency)||"daily",onValueChange:q=>w.mutate({cron_frequency:q}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),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(ve,{children:"Day of Week"}),e.jsxs(tr,{value:String(d==null?void 0:d.send_day),onValueChange:q=>w.mutate({send_day:parseInt(q)}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:Zgs.map(q=>e.jsx(At,{value:q.value,children:q.label},q.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Time (UTC)"}),e.jsxs(tr,{value:String(d==null?void 0:d.send_hour),onValueChange:q=>w.mutate({send_hour:parseInt(q)}),disabled:(d==null?void 0:d.cron_frequency)==="daily",children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:Ygs.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(K,{onClick:C,disabled:a,variant:"outline",className:"flex-1",children:[e.jsx(ya,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(K,{onClick:N,disabled:r,className:"flex-1",children:[e.jsx(ka,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),j>0&&e.jsxs(K,{onClick:A,disabled:l,variant:"outline",className:"w-full",children:[e.jsx(Po,{className:`h-4 w-4 mr-2 ${l?"animate-spin":""}`}),l?"Retrying...":`Retry ${j} Failed`]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(yr,{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(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"New Resources"})]}),e.jsx(Br,{checked:d==null?void 0:d.include_new_resources,onCheckedChange:q=>w.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(hr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"Community Highlights"})]}),e.jsx(Br,{checked:d==null?void 0:d.include_community_posts,onCheckedChange:q=>w.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(Xo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"Agent OS Stats"})]}),e.jsx(Br,{checked:d==null?void 0:d.include_agent_os_stats,onCheckedChange:q=>w.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(on,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"Upcoming Events"})]}),e.jsx(Br,{checked:d==null?void 0:d.include_upcoming_events,onCheckedChange:q=>w.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(Hh,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"Goals Progress"})]}),e.jsx(Br,{checked:d==null?void 0:d.include_goals_progress,onCheckedChange:q=>w.mutate({include_goals_progress:q})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Custom Introduction"}),e.jsx(yr,{children:"Personalize the intro message (optional)"})]}),e.jsx(Oe,{children:e.jsx(Mr,{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=>w.mutate({custom_intro_text:q.target.value||null}),rows:3})})]})]}),e.jsx(zs,{value:"stats",children:e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(_r,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(yr,{children:"Recent digest emails sent to members"})]}),e.jsx(Oe,{children:f?e.jsx("div",{className:"animate-pulse space-y-2",children:[1,2,3,4,5].map(q=>e.jsx("div",{className:"h-12 bg-muted rounded"},q))}):p&&p.length>0?e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Sent At"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Resources"}),e.jsx(jt,{children:"Agent OS"})]})}),e.jsx(Pn,{children:p.map(q=>e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium",children:q.email_sent_to}),e.jsx(lt,{children:ws(new Date(q.sent_at),"MMM d, yyyy h:mm a")}),e.jsx(lt,{children:e.jsx(at,{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(at,{variant:"secondary",children:"Active"}):e.jsx(at,{variant:"outline",children:"Not Started"})})]},q.id))})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(_r,{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 Qgs={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 Jgs(){var we,ke,Ze;const t=ns(),[s,r]=S.useState(""),[n,a]=S.useState(null),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(""),[f,v]=S.useState(""),[_,b]=S.useState(!0),[j,w]=S.useState(!1),[N,C]=S.useState(""),[A,I]=S.useState(null),{data:L,isLoading:R}=Ct({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:_e,error:Ce}=await G.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Ce)throw Ce;const Te=(_e==null?void 0:_e.map(We=>We.user_id))||[],{data:Fe}=await G.from("profiles").select("id, name, email").in("id",Te),Ae=new Map((Fe==null?void 0:Fe.map(We=>[We.id,{name:We.name,email:We.email}]))||[]);return _e==null?void 0:_e.map(We=>({...We,profile:Ae.get(We.user_id)||null}))}}),{data:$}=Ct({queryKey:["all-profiles-for-points",L],queryFn:async()=>{const Ce=[];let Te=0;for(;;){const{data:Fe,error:Ae}=await G.from("profiles").select("id, name, email").order("name").range(Te,Te+1e3-1);if(Ae)throw Ae;if(Ce.push(...Fe),!Fe||Fe.length<1e3)break;Te+=1e3}return Ce}}),U=(($==null?void 0:$.filter(_e=>!(L!=null&&L.some(Ce=>Ce.user_id===_e.id))))||[]).filter(_e=>{var Te,Fe;if(!N)return!0;const Ce=N.toLowerCase();return((Te=_e.name)==null?void 0:Te.toLowerCase().includes(Ce))||((Fe=_e.email)==null?void 0:Fe.toLowerCase().includes(Ce))}),{data:V,isLoading:X}=Ct({queryKey:["agent-point-history",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:_e,error:Ce}=await G.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(Ce)throw Ce;return _e},enabled:!!(n!=null&&n.user_id)&&i}),{data:se}=Ct({queryKey:["agent-badges",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:_e,error:Ce}=await G.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(Ce)throw Ce;return _e},enabled:!!(n!=null&&n.user_id)}),te=Ot({mutationFn:async({userId:_e,points:Ce,reason:Te})=>{const{error:Fe}=await G.from("agent_points").insert({user_id:_e,points:Ce,reason:Te});if(Fe)throw Fe;const{data:Ae}=await G.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",_e).maybeSingle(),We=((Ae==null?void 0:Ae.total_points)||0)+Ce,ht=((Ae==null?void 0:Ae.spendable_points)||0)+Ce,{error:De}=await G.from("agent_attendance_stats").upsert({user_id:_e,total_points:Math.max(0,We),spendable_points:Math.max(0,ht),updated_at:new Date().toISOString()},{onConflict:"user_id"});if(De)throw De},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-agent-points"]}),t.invalidateQueries({queryKey:["agent-point-history"]}),l(!1),p(""),v(""),fe.success(_?"Points awarded successfully!":"Points deducted successfully!")},onError:_e=>{console.error("Error modifying points:",_e),fe.error("Failed to modify points")}}),Y=()=>{if(!n||!u||!f){fe.error("Please fill in all fields");return}const _e=parseInt(u);if(isNaN(_e)||_e<=0){fe.error("Please enter a valid positive number");return}te.mutate({userId:n.user_id,points:_?_e:-_e,reason:f})},de=()=>{if(!A||!u||!f){fe.error("Please fill in all fields");return}const _e=parseInt(u);if(isNaN(_e)||_e<=0){fe.error("Please enter a valid positive number");return}te.mutate({userId:A.id,points:_e,reason:f},{onSuccess:()=>{w(!1),I(null),C("")}})},ie=(_e,Ce)=>{a(_e),b(Ce),l(!0)},ae=_e=>{a(_e),d(!0)},le=L==null?void 0:L.filter(_e=>{var Ae,We,ht,De;const Ce=((We=(Ae=_e.profile)==null?void 0:Ae.name)==null?void 0:We.toLowerCase())||"",Te=((De=(ht=_e.profile)==null?void 0:ht.email)==null?void 0:De.toLowerCase())||"",Fe=s.toLowerCase();return Ce.includes(Fe)||Te.includes(Fe)}),pe=(L==null?void 0:L.reduce((_e,Ce)=>_e+Ce.total_points,0))||0,be=(L==null?void 0:L.length)||0,ye=be>0?Math.round(pe/be):0;return R?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(_e=>e.jsx(gs,{className:"h-24"},_e))}),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(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),e.jsx("p",{className:"text-2xl font-bold",children:be}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Ki,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Points"})]}),e.jsx("p",{className:"text-2xl font-bold",children:pe.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"awarded across all agents"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Cc,{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(fn,{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:_e=>r(_e.target.value),className:"pl-10"})]}),e.jsxs(K,{onClick:()=>w(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Agent Leaderboard"}),e.jsx(yr,{children:"All agents with their points, events, and streaks"})]}),e.jsx(Oe,{children:!le||le.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ki,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents with points yet"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-12",children:"#"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{className:"text-center",children:"Total Points"}),e.jsx(jt,{className:"text-center",children:"Spendable"}),e.jsx(jt,{className:"text-center",children:"Events"}),e.jsx(jt,{className:"text-center",children:"Streak"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:le.map((_e,Ce)=>{var Te,Fe,Ae,We;return e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium",children:Ce<3?e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center ${Ce===0?"bg-yellow-100 text-yellow-700":Ce===1?"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700"}`,children:Ce+1}):e.jsx("span",{className:"text-muted-foreground",children:Ce+1})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(gn,{className:"h-8 w-8",children:e.jsx(xn,{children:((Fe=(Te=_e.profile)==null?void 0:Te.name)==null?void 0:Fe.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Ae=_e.profile)==null?void 0:Ae.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(We=_e.profile)==null?void 0:We.email})]})]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(at,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),_e.total_points]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(at,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(io,{className:"h-3 w-3 mr-1"}),_e.spendable_points||0]})}),e.jsx(lt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(on,{className:"h-3 w-3 text-muted-foreground"}),_e.total_events_attended]})}),e.jsx(lt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx($h,{className:"h-3 w-3 text-orange-500"}),_e.current_streak]})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ie(_e,!0),title:"Award points",children:e.jsx(Zs,{className:"h-4 w-4 text-green-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ie(_e,!1),title:"Deduct points",children:e.jsx(P0,{className:"h-4 w-4 text-red-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ae(_e),title:"View history",children:e.jsx(u5,{className:"h-4 w-4"})})]})})]},_e.user_id)})})]})})]}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{children:_?"Award Points":"Deduct Points"}),e.jsxs(Kr,{children:[_?"Award":"Deduct"," points ",_?"to":"from"," ",((we=n==null?void 0:n.profile)==null?void 0:we.name)||"this agent"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"points",children:"Points Amount"}),e.jsx(Re,{id:"points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:_e=>p(_e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"reason",children:"Reason"}),e.jsx(Mr,{id:"reason",placeholder:"Enter reason for this adjustment...",value:f,onChange:_e=>v(_e.target.value)})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{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(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{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(Na,{defaultValue:"history",className:"w-full",children:[e.jsxs(va,{className:"grid w-full grid-cols-2",children:[e.jsx(ks,{value:"history",children:"Point History"}),e.jsx(ks,{value:"badges",children:"Badges"})]}),e.jsx(zs,{value:"history",className:"mt-4",children:X?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(_e=>e.jsx(gs,{className:"h-12"},_e))}):!V||V.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(u5,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No point history yet"})]}):e.jsx("div",{className:"max-h-80 overflow-y-auto space-y-2",children:V.map(_e=>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:_e.reason}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ws(new Date(_e.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(at,{variant:_e.points>=0?"default":"destructive",className:_e.points>=0?"bg-green-100 text-green-800":"",children:[_e.points>=0?"+":"",_e.points]})]},_e.id))})}),e.jsx(zs,{value:"badges",className:"mt-4",children:!se||se.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(rc,{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(_e=>e.jsxs("div",{className:`p-3 rounded-lg ${Qgs[_e.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rc,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:_e.badge_name})]}),_e.badge_description&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:_e.badge_description}),e.jsxs("p",{className:"text-xs mt-1 opacity-60",children:["Earned ",ws(new Date(_e.earned_at),"MMM d, yyyy")]})]},_e.id))})})]})]})}),e.jsx(vs,{open:j,onOpenChange:_e=>{w(_e),_e||(I(null),C(""),p(""),v(""))},children:e.jsxs(ys,{className:"max-w-md",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(gn,{className:"h-10 w-10",children:e.jsx(xn,{children:((Ze=A.name)==null?void 0:Ze.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(K,{variant:"ghost",size:"sm",onClick:()=>I(null),children:"Change"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"new-points",children:"Points Amount"}),e.jsx(Re,{id:"new-points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:_e=>p(_e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"new-reason",children:"Reason"}),e.jsx(Mr,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:f,onChange:_e=>v(_e.target.value)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Search Agent"}),e.jsxs("div",{className:"relative",children:[e.jsx(fn,{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:_e=>C(_e.target.value),className:"pl-10"})]})]}),e.jsx("div",{className:"max-h-60 overflow-y-auto border rounded-lg",children:U.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(hr,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:N?"No matching agents found":"All agents already have points"})]}):U.slice(0,20).map(_e=>{var Ce;return e.jsxs("button",{onClick:()=>I(_e),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(gn,{className:"h-8 w-8",children:e.jsx(xn,{children:((Ce=_e.name)==null?void 0:Ce.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:_e.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:_e.email})]})]},_e.id)})})]})}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),A&&e.jsxs(K,{onClick:de,disabled:te.isPending,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Award Points"]})]})]})})]})})}function exs(){const{data:t,isLoading:s}=r0t(),[r,n]=S.useState(null),[a,o]=S.useState(!1),[l,i]=S.useState(""),[d,u]=S.useState("all"),[p,f]=S.useState("newest"),[v,_]=S.useState("table"),b=S.useMemo(()=>(t==null?void 0:t.map(A=>A.user_id))||[],[t]),j=S.useMemo(()=>(t==null?void 0:t.map(A=>A.id))||[],[t]),{data:w}=Ct({queryKey:["card-profiles-lookup",b],queryFn:async()=>{if(b.length===0)return{};const{data:A}=await G.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}=Ct({queryKey:["card-stats-all",j],queryFn:async()=>{if(j.length===0)return{};const A={};j.forEach(R=>{A[R]={views:0,leads:0}});const{data:I}=await G.from("agent_card_interactions").select("card_id").in("card_id",j).eq("interaction_type","card_view");I==null||I.forEach(R=>{A[R.card_id]&&A[R.card_id].views++});const{data:L}=await G.from("agent_card_leads").select("card_id").in("card_id",j);return L==null||L.forEach(R=>{A[R.card_id]&&A[R.card_id].leads++}),A},enabled:j.length>0}),C=S.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 R=w==null?void 0:w[L.user_id];return L.slug.toLowerCase().includes(I)||(($=R==null?void 0:R.name)==null?void 0:$.toLowerCase().includes(I))||((q=R==null?void 0:R.email)==null?void 0:q.toLowerCase().includes(I))})}return p==="newest"?A.sort((I,L)=>new Date(L.created_at).getTime()-new Date(I.created_at).getTime()):p==="oldest"?A.sort((I,L)=>new Date(I.created_at).getTime()-new Date(L.created_at).getTime()):p==="name"?A.sort((I,L)=>{var R,$;return(((R=w==null?void 0:w[I.user_id])==null?void 0:R.name)||"").localeCompare((($=w==null?void 0:w[L.user_id])==null?void 0:$.name)||"")}):p==="slug"?A.sort((I,L)=>I.slug.localeCompare(L.slug)):p==="views_desc"?A.sort((I,L)=>{var R,$;return(((R=N==null?void 0:N[L.id])==null?void 0:R.views)||0)-((($=N==null?void 0:N[I.id])==null?void 0:$.views)||0)}):p==="views_asc"?A.sort((I,L)=>{var R,$;return(((R=N==null?void 0:N[I.id])==null?void 0:R.views)||0)-((($=N==null?void 0:N[L.id])==null?void 0:$.views)||0)}):p==="leads_desc"?A.sort((I,L)=>{var R,$;return(((R=N==null?void 0:N[L.id])==null?void 0:R.leads)||0)-((($=N==null?void 0:N[I.id])==null?void 0:$.leads)||0)}):p==="leads_asc"&&A.sort((I,L)=>{var R,$;return(((R=N==null?void 0:N[I.id])==null?void 0:R.leads)||0)-((($=N==null?void 0:N[L.id])==null?void 0:$.leads)||0)}),A},[t,d,l,p,w]);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(K,{onClick:()=>o(!0),children:[e.jsx(Zs,{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(fn,{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(sr,{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:p,onValueChange:f,children:[e.jsx(Js,{className:"w-full sm:w-44",children:e.jsx(sr,{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(K,{variant:v==="table"?"default":"ghost",size:"sm",onClick:()=>_("table"),className:"rounded-r-none",children:e.jsx(w5,{className:"h-4 w-4"})}),e.jsx(K,{variant:v==="grid"?"default":"ghost",size:"sm",onClick:()=>_("grid"),className:"rounded-l-none",children:e.jsx(mp,{className:"h-4 w-4"})})]})]}),!s&&t&&t.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",C.length," of ",t.length," cards"]}),s?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(A=>e.jsx(gs,{className:"h-48"},A))}):C.length>0?v==="table"?e.jsx(txs,{cards:C,cardProfiles:w,cardStats:N,onEdit:n,sortBy:p,setSortBy:f}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:C.map(A=>e.jsx(sxs,{card:A,onEdit:()=>n(A),stats:N==null?void 0:N[A.id]},A.id))}):t&&t.length>0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(fn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No matching cards"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Try adjusting your search or filters"})]})}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No cards yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"Create your first digital agent card"}),e.jsxs(K,{onClick:()=>o(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Card"]})]})})]}),e.jsx(rxs,{open:a,onOpenChange:o}),r&&e.jsx(nxs,{card:r,open:!!r,onOpenChange:A=>!A&&n(null)})]})}function txs({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(eh,{className:"h-3 w-3"}):a===`${d}_asc`?e.jsx(Vd,{className:"h-3 w-3"}):e.jsx(Hc,{className:"h-3 w-3 opacity-40"});return e.jsx(Ee,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"text-left p-3 font-medium",children:e.jsxs("button",{onClick:()=>{o(a==="name"?"newest":"name")},className:"flex items-center gap-1 hover:text-foreground text-muted-foreground",children:["Agent ",a==="name"&&e.jsx(Vd,{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],p=r==null?void 0:r[d.id],f=`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(at,{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:(p==null?void 0:p.views)??0}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.leads)??0}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>n(d),className:"h-8 w-8 p-0",children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{navigator.clipboard.writeText(f),fe.success("Link copied!")},children:e.jsx(ni,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",asChild:!0,children:e.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",children:e.jsx(sn,{className:"h-3.5 w-3.5"})})})]})})]},d.id)})})]})})})}function sxs({card:t,onEdit:s,stats:r}){const[n,a]=S.useState(null);S.useEffect(()=>{(async()=>{const{data:d}=await G.from("profiles").select("name").eq("id",t.user_id).single();let u=null;try{const{data:p}=await G.storage.from("avatars").list(`${t.user_id}`);if(p&&p.length>0){const{data:f}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${p[0].name}`);u=f.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),fe.success("Link copied!")};return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsxs(gn,{className:"h-10 w-10",children:[e.jsx(Ea,{src:(n==null?void 0:n.avatar_url)||void 0}),e.jsx(xn,{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(at,{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(ya,{className:"h-3.5 w-3.5"}),(r==null?void 0:r.views)??0," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hr,{className:"h-3.5 w-3.5"}),(r==null?void 0:r.leads)??0," leads"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:s,className:"flex-1",children:[e.jsx(Ra,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:l,children:e.jsx(ni,{className:"h-3 w-3"})}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:e.jsx(sn,{className:"h-3 w-3"})})})]})]})})}function rxs({open:t,onOpenChange:s}){const[r,n]=S.useState(""),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState(!1),p=m9e(),f=l.trim(),{data:v}=Ct({queryKey:["profiles-search-for-cards",f],queryFn:async()=>{let C=G.from("profiles").select("id, name, email").order("name").limit(50);f.length>=2&&(C=C.or(`name.ilike.%${f}%,email.ilike.%${f}%`));const{data:A}=await C;return A||[]},enabled:t}),[_,b]=S.useState(null),j=(v==null?void 0:v.find(C=>C.id===r))||_,w=()=>{if(!r||!a.trim()){fe.error("Select an agent and enter a slug");return}p.mutate({user_id:r,slug:a.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-"),is_published:!0},{onSuccess:()=>{s(!1),n(""),o(""),i("")}})},N=C=>{var I;n(C),u(!1);const A=v==null?void 0:v.find(L=>L.id===C);A&&(b(A),o(((I=A.name)==null?void 0:I.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||""))};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{children:"Agent"}),e.jsxs(So,{open:d,onOpenChange:u,children:[e.jsx(Co,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":d,className:"w-full justify-between font-normal",children:[j?`${j.name} (${j.email})`:"Search for an agent...",e.jsx(df,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(ko,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(wf,{shouldFilter:!1,children:[e.jsx(jf,{placeholder:"Search by name or email...",value:l,onValueChange:i}),e.jsxs(kf,{children:[e.jsx(Nf,{children:"No agents found."}),e.jsx(Sf,{children:(v||[]).map(C=>e.jsxs(Nm,{value:C.id,onSelect:N,children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",r===C.id?"opacity-100":"opacity-0")}),C.name," (",C.email,")"]},C.id))})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{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:C=>o(C.target.value),placeholder:"john-doe"})]})]}),e.jsx(K,{onClick:w,disabled:p.isPending,className:"w-full",children:p.isPending?"Creating...":"Create Card"})]})]})})}function nxs({card:t,open:s,onOpenChange:r}){const n=p9e(),{data:a}=f9e(t.id),o=ns(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,f]=S.useState(!1),[v,_]=S.useState(""),[b,j]=S.useState(t.slug),[w,N]=S.useState(!1),[C,A]=S.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});S.useEffect(()=>{s&&(async()=>{try{const{data:V}=await G.storage.from("avatars").list(`${t.user_id}`);if(V&&V.length>0){const{data:X}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${V[0].name}`);i(`${X.publicUrl}?t=${Date.now()}`)}}catch{}})()},[t.user_id,s]);const I=U=>{var se;const V=(se=U.target.files)==null?void 0:se[0];if(!V)return;if(!V.type.startsWith("image/")){fe.error("Please select an image file");return}if(V.size>5*1024*1024){fe.error("Image must be under 5MB");return}const X=new FileReader;X.onloadend=()=>{_(X.result),f(!0)},X.readAsDataURL(V),U.target.value=""},L=async U=>{u(!0);try{const{data:V}=await G.storage.from("avatars").list(`${t.user_id}`);V&&V.length>0&&await G.storage.from("avatars").remove(V.map(de=>`${t.user_id}/${de.name}`));const X=`${t.user_id}/avatar.jpg`,{error:se}=await G.storage.from("avatars").upload(X,U,{upsert:!0,contentType:"image/jpeg"});if(se)throw se;const{data:te}=G.storage.from("avatars").getPublicUrl(X),Y=`${te.publicUrl}?t=${Date.now()}`;i(Y),await G.from("profiles").update({avatar_url:Y}).eq("id",t.user_id),o.invalidateQueries({queryKey:["agent-card-public"]}),fe.success("Photo updated!")}catch(V){fe.error(V.message||"Upload failed")}finally{u(!1)}},R=async()=>{const U=b.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!U){fe.error("Please enter a valid URL");return}if(U===t.slug){fe.info("No changes to save");return}N(!0);try{const{data:V}=await G.from("agent_cards").select("id").eq("slug",U).neq("id",t.id).maybeSingle();if(V){fe.error("This URL is already taken. Try another one.");return}const{error:X}=await G.from("agent_cards").update({slug:U}).eq("id",t.id);if(X)throw X;j(U),o.invalidateQueries({queryKey:["agent-cards-admin"]}),fe.success("Card address updated!")}catch{fe.error("Failed to update card address")}finally{N(!1)}},$=async(U,V)=>{var se;const X=(se=U.target.files)==null?void 0:se[0];if(X){if(!X.type.startsWith("image/")){fe.error("Please select an image file");return}try{const te=X.name.split(".").pop()||"png",Y=V==="brokerage_logo_url"?"brokerage-logo":"team-logo",de=`${t.user_id}/${Y}.${te}`,{error:ie}=await G.storage.from("card-logos").upload(de,X,{upsert:!0});if(ie)throw ie;const{data:ae}=G.storage.from("card-logos").getPublicUrl(de),le=ae.publicUrl+"?t="+Date.now();A(V==="brokerage_logo_url"?pe=>({...pe,[V]:le,brokerage_display_name:""}):pe=>({...pe,[V]:le,team_name:""})),fe.success("Logo uploaded!")}catch{fe.error("Failed to upload logo")}finally{U.target.value=""}}},q=()=>{n.mutate({id:t.id,...C,title:C.title||null,positioning_statement:C.positioning_statement||null,bio:C.bio||null,review_snippet:C.review_snippet||null,review_source_url:C.review_source_url||null,booking_url:C.booking_url||null,custom_cta_label:C.custom_cta_label||null,custom_cta_url:C.custom_cta_url||null,brokerage_display_name:C.brokerage_display_name||null,brokerage_logo_url:C.brokerage_logo_url||null,brokerage_logo_size:C.brokerage_logo_size,team_name:C.team_name||null,team_logo_url:C.team_logo_url||null,team_logo_size:C.team_logo_size},{onSuccess:()=>r(!1)})};return e.jsxs(e.Fragment,{children:[e.jsx(vs,{open:s,onOpenChange:r,children:e.jsxs(ys,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{children:"Edit Agent Card"}),e.jsxs(Kr,{children:["/card/",t.slug]})]}),e.jsxs(Na,{defaultValue:"content",children:[e.jsxs(va,{className:"w-full",children:[e.jsx(ks,{value:"content",className:"flex-1",children:"Content"}),e.jsx(ks,{value:"sections",className:"flex-1",children:"Sections"}),e.jsx(ks,{value:"blocks",className:"flex-1",children:"Blocks"}),e.jsx(ks,{value:"analytics",className:"flex-1",children:"Analytics"})]}),e.jsxs(zs,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Published"}),e.jsx(Br,{checked:C.is_published,onCheckedChange:U=>A(V=>({...V,is_published:U}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[e.jsxs(gn,{className:"h-16 w-16",children:[e.jsx(Ea,{src:l||void 0}),e.jsx(xn,{children:"?"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:I,disabled:d}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:d,children:e.jsx("span",{children:d?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ya,{className:"h-3 w-3 mr-1"}),"Change Photo"]})})})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{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:U=>j(U.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"agent-name",className:"rounded-l-none"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:R,disabled:w||b===t.slug,className:"shrink-0",children:w?"Saving...":"Update"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Theme"}),e.jsxs(tr,{value:C.theme,onValueChange:U=>A(V=>({...V,theme:U})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),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(ve,{children:"Title / Tagline"}),e.jsx(Re,{value:C.title,onChange:U=>A(V=>({...V,title:U.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(ve,{children:"Positioning Statement"}),e.jsx(Re,{value:C.positioning_statement,onChange:U=>A(V=>({...V,positioning_statement:U.target.value})),placeholder:"Your home journey, handled with care."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Bio"}),e.jsx(Mr,{value:C.bio,onChange:U=>A(V=>({...V,bio:U.target.value})),placeholder:"Short about me...",rows:3})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Review Snippet"}),e.jsx(Re,{value:C.review_snippet,onChange:U=>A(V=>({...V,review_snippet:U.target.value})),placeholder:"Best agent we've ever worked with..."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Review Source URL"}),e.jsx(Re,{value:C.review_source_url,onChange:U=>A(V=>({...V,review_source_url:U.target.value})),placeholder:"https://g.page/your-business/review"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Booking URL (optional — if empty, shows lead form)"}),e.jsx(Re,{value:C.booking_url,onChange:U=>A(V=>({...V,booking_url:U.target.value})),placeholder:"https://calendly.com/your-link"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Custom CTA Label (optional)"}),e.jsx(Re,{value:C.custom_cta_label,onChange:U=>A(V=>({...V,custom_cta_label:U.target.value})),placeholder:"Book a Call"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Custom CTA URL (optional)"}),e.jsx(Re,{value:C.custom_cta_url,onChange:U=>A(V=>({...V,custom_cta_url:U.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(ve,{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:C.brokerage_display_name,onChange:U=>A(V=>({...V,brokerage_display_name:U.target.value,brokerage_logo_url:""})),placeholder:"Brokerage name (or upload logo below)",disabled:!!C.brokerage_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[C.brokerage_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:C.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${C.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>A(U=>({...U,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(Ya,{className:"h-3.5 w-3.5"}),C.brokerage_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:U=>$(U,"brokerage_logo_url")})]})]}),C.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[C.brokerage_logo_size||56,"px"]})]}),e.jsx(Pg,{value:[C.brokerage_logo_size||56],onValueChange:([U])=>A(V=>({...V,brokerage_logo_size:U})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(ve,{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:C.team_name,onChange:U=>A(V=>({...V,team_name:U.target.value,team_logo_url:""})),placeholder:"Team name (or upload logo below)",disabled:!!C.team_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[C.team_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:C.team_logo_url,alt:"Team logo",style:{height:`${C.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>A(U=>({...U,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(Ya,{className:"h-3.5 w-3.5"}),C.team_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:U=>$(U,"team_logo_url")})]})]}),C.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[C.team_logo_size||56,"px"]})]}),e.jsx(Pg,{value:[C.team_logo_size||56],onValueChange:([U])=>A(V=>({...V,team_logo_size:U})),min:24,max:120,step:4})]})]})]})]}),e.jsx(zs,{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:U,label:V,hint:X})=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx(ve,{children:V}),X&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[X," ",U==="show_photo"&&e.jsx("a",{href:"/profile",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:"Update Profile"})]})]}),e.jsx(Br,{checked:C[U],onCheckedChange:se=>A(te=>({...te,[U]:se}))})]},U))}),e.jsx(zs,{value:"blocks",className:"mt-4",children:e.jsx(CJe,{cardId:t.id})}),e.jsx(zs,{value:"analytics",className:"mt-4",children:a?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.views}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Views"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.clicks}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Clicks"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.leads.length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Leads"})]})})]}),a.leads.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Recent Leads"}),e.jsx("div",{className:"space-y-2",children:a.leads.slice(0,5).map(U=>e.jsxs("div",{className:"text-sm p-2 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"font-medium",children:U.name}),U.phone&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",U.phone]}),U.intent&&e.jsx(at,{variant:"secondary",className:"ml-2 text-xs",children:U.intent})]},U.id))})]})]}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No analytics data yet"})})]}),e.jsx(K,{onClick:q,disabled:n.isPending,className:"w-full mt-4",children:n.isPending?"Saving...":"Save Changes"})]})}),e.jsx(Zbe,{open:p,onClose:()=>f(!1),imageSrc:v,onCropComplete:L,aspectRatio:1})]})}const $5={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"},F2e={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 z2e(t=!0){return Ct({queryKey:["marketplace-categories",t],queryFn:async()=>{let s=G.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 axs(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.from("marketplace_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),fe.success("Category created successfully")},onError:s=>{fe.error("Failed to create category: "+s.message)}})}function ixs(){const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("marketplace_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),fe.success("Category updated successfully")},onError:s=>{fe.error("Failed to update category: "+s.message)}})}function oxs(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("marketplace_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),fe.success("Category deleted successfully")},onError:s=>{fe.error("Failed to delete category: "+s.message)}})}function $Je(t,s=!0){return Ct({queryKey:["marketplace-products",t,s],queryFn:async()=>{let r=G.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 lxs(t){return Ct({queryKey:["marketplace-product",t],queryFn:async()=>{const{data:s,error:r}=await G.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 cxs(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.from("marketplace_products").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),fe.success("Product created successfully")},onError:s=>{fe.error("Failed to create product: "+s.message)}})}function dxs(){const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.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]}),fe.success("Product updated successfully")},onError:s=>{fe.error("Failed to update product: "+s.message)}})}function uxs(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("marketplace_products").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),fe.success("Product deleted successfully")},onError:s=>{fe.error("Failed to delete product: "+s.message)}})}function hxs(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.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 mxs(){const t=ns();return Ot({mutationFn:async({id:s,productId:r})=>{const{error:n}=await G.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]}),fe.success("Image deleted successfully")},onError:s=>{fe.error("Failed to delete image: "+s.message)}})}function pxs(){const t=ns();return Ot({mutationFn:async({imageId:s,productId:r})=>{const{error:n}=await G.from("marketplace_product_images").update({is_primary:!1}).eq("product_id",r);if(n)throw n;const{error:a}=await G.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]}),fe.success("Primary image updated")},onError:s=>{fe.error("Failed to set primary image: "+s.message)}})}function fxs(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.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]}),fe.success("Variant added successfully")}})}function gxs(){const t=ns();return Ot({mutationFn:async({id:s,productId:r})=>{const{error:n}=await G.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]}),fe.success("Variant deleted successfully")}})}function xxs(){const t=ns();return Ot({mutationFn:async({productId:s,videoUrl:r})=>{await G.from("marketplace_product_videos").delete().eq("product_id",s);const{data:n,error:a}=await G.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]}),fe.success("Video updated successfully")}})}function yxs(t){const{isAdmin:s}=Gs();return Ct({queryKey:["marketplace-orders",t,s],queryFn:async()=>{let r=G.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 G.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 vxs(){const{user:t}=Gs();return Ct({queryKey:["my-marketplace-orders",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.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 _xs(t){return Ct({queryKey:["marketplace-order",t],queryFn:async()=>{const{data:s,error:r}=await G.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 bxs(){const t=ns(),{user:s}=Gs();return Ot({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 G.from("marketplace_orders").update(d).eq("id",r);if(u)throw u;const{error:p}=await G.from("marketplace_order_status_history").insert({order_id:r,status:n,notes:a,created_by:s==null?void 0:s.id});if(p)throw p;if(["shipped","in_production","processing","completed"].includes(n)&&n!==i)try{await G.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"]}),fe.success("Order status updated")},onError:r=>{fe.error("Failed to update order: "+r.message)}})}function wxs(){const t=ns();return Ot({mutationFn:async({itemId:s,proofUrl:r,proofNotes:n,orderId:a})=>{const{error:o}=await G.from("marketplace_order_items").update({proof_url:r,proof_notes:n,proof_status:"pending"}).eq("id",s);if(o)throw o;await G.from("marketplace_orders").update({status:"awaiting_proof_approval"}).eq("id",a);try{await G.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"]}),fe.success("Proof uploaded & customer notified")}})}function jxs(){const t=ns();return Ot({mutationFn:async({itemId:s,orderId:r})=>{const{error:n}=await G.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"]}),fe.success("Proof approved")}})}function kxs(){const t=ns();return Ot({mutationFn:async({itemId:s,orderId:r,reason:n})=>{const{error:a}=await G.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"]}),fe.success("Proof rejected - please upload a new proof")}})}function Nxs(){const{data:t,isLoading:s}=z2e(!1),r=axs(),n=ixs(),a=oxs(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),f=()=>{p({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),d(null)},v=j=>{d(j),p({name:j.name,description:j.description||"",image_url:j.image_url||"",sort_order:j.sort_order,is_active:j.is_active}),l(!0)},_=async j=>{j.preventDefault(),i?await n.mutateAsync({id:i.id,...u}):await r.mutateAsync(u),l(!1),f()},b=async j=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(j)};return s?e.jsxs(Ee,{children:[e.jsx(Lt,{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(j=>e.jsx(gs,{className:"h-12 w-full"},j))})})]}):e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"Categories"}),e.jsxs(vs,{open:o,onOpenChange:j=>{l(j),j||f()},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Category"]})}),e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{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(ve,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",value:u.name,onChange:j=>p({...u,name:j.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Mr,{id:"description",value:u.description,onChange:j=>p({...u,description:j.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"image_url",children:"Image URL"}),e.jsx(Re,{id:"image_url",value:u.image_url,onChange:j=>p({...u,image_url:j.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(Re,{id:"sort_order",type:"number",value:u.sort_order,onChange:j=>p({...u,sort_order:parseInt(j.target.value)||0})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"is_active",checked:u.is_active,onCheckedChange:j=>p({...u,is_active:j})}),e.jsx(ve,{htmlFor:"is_active",children:"Active"})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:r.isPending||n.isPending,children:i?"Update Category":"Create Category"})]})]})]})]}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Sort Order"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(j=>e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium",children:j.name}),e.jsx(lt,{className:"max-w-xs truncate",children:j.description}),e.jsx(lt,{children:j.sort_order}),e.jsx(lt,{children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${j.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:j.is_active?"Active":"Inactive"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>v(j),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(j.id),disabled:a.isPending,children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]})})]},j.id))})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first category to get started."})})]})}function Sxs(){var ye,we;const{data:t,isLoading:s}=$Je(void 0,!1),{data:r}=z2e(!1),n=cxs(),a=dxs(),o=uxs(),l=hxs(),i=mxs(),d=pxs(),u=fxs(),p=gxs(),f=xxs(),[v,_]=S.useState(!1),[b,j]=S.useState(!1),[w,N]=S.useState(!1),[C,A]=S.useState(null),[I,L]=S.useState(null),[R,$]=S.useState(!1),[q,U]=S.useState({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),[V,X]=S.useState({name:"",price_adjustment:0}),[se,te]=S.useState(""),Y=()=>{U({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)},de=ke=>{A(ke),U({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)},ie=async ke=>{ke.preventDefault();const Ze={...q,category_id:q.category_id||null};C?await a.mutateAsync({id:C.id,...Ze}):await n.mutateAsync(Ze),_(!1),Y()},ae=async ke=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(ke)},le=async ke=>{if(!I||!ke.target.files||ke.target.files.length===0)return;$(!0);const Ze=ke.target.files[0],_e=Ze.name.split(".").pop(),Ce=`products/${I.id}/${Date.now()}.${_e}`;try{const{error:Te}=await G.storage.from("marketplace").upload(Ce,Ze);if(Te)throw Te;const{data:{publicUrl:Fe}}=G.storage.from("marketplace").getPublicUrl(Ce);await l.mutateAsync({product_id:I.id,image_url:Fe,is_primary:!I.images||I.images.length===0}),fe.success("Image uploaded successfully")}catch(Te){fe.error("Failed to upload image: "+Te.message)}finally{$(!1)}},pe=async ke=>{ke.preventDefault(),I&&(await u.mutateAsync({product_id:I.id,name:V.name,price_adjustment:V.price_adjustment}),X({name:"",price_adjustment:0}))},be=async()=>{!I||!se||(await f.mutateAsync({productId:I.id,videoUrl:se}),te(""))};return s?e.jsxs(Ee,{children:[e.jsx(Lt,{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(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"Products"}),e.jsxs(vs,{open:v,onOpenChange:ke=>{_(ke),ke||Y()},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Product"]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:C?"Edit Product":"Add Product"})}),e.jsxs("form",{onSubmit:ie,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(ve,{htmlFor:"name",children:"Product Name"}),e.jsx(Re,{id:"name",value:q.name,onChange:ke=>U({...q,name:ke.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"category",children:"Category"}),e.jsxs(tr,{value:q.category_id,onValueChange:ke=>U({...q,category_id:ke}),children:[e.jsx(Js,{children:e.jsx(sr,{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(ve,{htmlFor:"description",children:"Description"}),e.jsx(Mr,{id:"description",value:q.description,onChange:ke=>U({...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(ve,{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=>U({...q,base_price:parseFloat(ke.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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=>U({...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(ve,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(Re,{id:"sort_order",type:"number",value:q.sort_order,onChange:ke=>U({...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(Br,{id:"allow_artwork_upload",checked:q.allow_artwork_upload,onCheckedChange:ke=>U({...q,allow_artwork_upload:ke})}),e.jsx(ve,{htmlFor:"allow_artwork_upload",children:"Allow customer to upload artwork"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"requires_proof_approval",checked:q.requires_proof_approval,onCheckedChange:ke=>U({...q,requires_proof_approval:ke})}),e.jsx(ve,{htmlFor:"requires_proof_approval",children:"Requires proof approval"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"is_active",checked:q.is_active,onCheckedChange:ke=>U({...q,is_active:ke})}),e.jsx(ve,{htmlFor:"is_active",children:"Active"})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:n.isPending||a.isPending,children:C?"Update Product":"Create Product"})]})]})]})]}),e.jsx(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 Ze,_e;return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[ke.images&&ke.images.length>0?e.jsx("img",{src:((Ze=ke.images.find(Ce=>Ce.is_primary))==null?void 0:Ze.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(at,{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:((_e=ke.category)==null?void 0:_e.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(at,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),ke.requires_proof_approval&&e.jsx(at,{variant:"outline",className:"text-xs",children:"Proof Required"}),ke.variants&&ke.variants.length>0&&e.jsxs(at,{variant:"outline",className:"text-xs",children:[ke.variants.length," Variants"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>de(ke),children:[e.jsx(Ra,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(ke),j(!0)},children:[e.jsx(T0,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(ke),N(!0)},children:[e.jsx(Vh,{className:"h-3 w-3 mr-1"}),"Variants"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ae(ke.id),children:e.jsx(br,{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(vs,{open:b,onOpenChange:j,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsx(Ss,{children:e.jsxs(Ns,{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(at,{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(K,{variant:"secondary",size:"icon",onClick:async()=>{var Ze;await d.mutateAsync({imageId:ke.id,productId:I.id}),L({...I,images:(Ze=I.images)==null?void 0:Ze.map(_e=>({..._e,is_primary:_e.id===ke.id}))})},disabled:d.isPending,title:"Set as primary",children:e.jsx(Gn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"destructive",size:"icon",onClick:async()=>{var _e;await i.mutateAsync({id:ke.id,productId:I.id});const Ze=t==null?void 0:t.find(Ce=>Ce.id===I.id);Ze&&L({...Ze,images:(_e=Ze.images)==null?void 0:_e.filter(Ce=>Ce.id!==ke.id)})},disabled:i.isPending,children:e.jsx(br,{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:le,className:"hidden",id:"image-upload",disabled:R}),e.jsxs("label",{htmlFor:"image-upload",className:"cursor-pointer",children:[e.jsx(T0,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:R?"Uploading...":"Click to upload an image"})]})]}),e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx(ve,{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(K,{onClick:be,disabled:!se,children:[e.jsx(kn,{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(vs,{open:w,onOpenChange:N,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsxs(Ns,{children:["Manage Variants - ",I==null?void 0:I.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:pe,className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Variant name (e.g., 500 count)",value:V.name,onChange:ke=>X({...V,name:ke.target.value}),required:!0}),e.jsx(Re,{type:"number",step:"0.01",placeholder:"Price adj.",value:V.price_adjustment,onChange:ke=>X({...V,price_adjustment:parseFloat(ke.target.value)||0}),className:"w-32"}),e.jsx(K,{type:"submit",children:"Add"})]}),e.jsxs("div",{className:"space-y-2",children:[(we=I==null?void 0:I.variants)==null?void 0:we.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(K,{variant:"ghost",size:"icon",onClick:()=>p.mutateAsync({id:ke.id,productId:I.id}),children:e.jsx(br,{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 Cxs=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function Mxs(){var j,w,N;const{data:t,isLoading:s}=yxs(),r=bxs(),n=wxs(),[a,o]=S.useState(null),[l,i]=S.useState(!1),[d,u]=S.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[p,f]=S.useState(!1),v=C=>{o(C),u({status:C.status,notes:"",trackingNumber:C.tracking_number||"",trackingUrl:C.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(C,A)=>{if(!a||!C.target.files||C.target.files.length===0)return;f(!0);const I=C.target.files[0],L=I.name.split(".").pop(),R=`proofs/${a.id}/${A}/${Date.now()}.${L}`;try{const{error:$}=await G.storage.from("marketplace").upload(R,I);if($)throw $;const{data:{publicUrl:q}}=G.storage.from("marketplace").getPublicUrl(R);await n.mutateAsync({itemId:A,proofUrl:q,orderId:a.id}),fe.success("Proof uploaded successfully")}catch($){fe.error("Failed to upload proof: "+$.message)}finally{f(!1)}};return s?e.jsxs(Ee,{children:[e.jsx(Lt,{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(C=>e.jsx(gs,{className:"h-16 w-full"},C))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Orders"})}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Order #"}),e.jsx(jt,{children:"Customer"}),e.jsx(jt,{children:"Date"}),e.jsx(jt,{children:"Total"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(C=>{var A,I;return e.jsxs(js,{children:[e.jsx(lt,{className:"font-mono",children:C.order_number}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((A=C.user)==null?void 0:A.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(I=C.user)==null?void 0:I.email})]})}),e.jsx(lt,{children:ws(new Date(C.created_at),"MMM d, yyyy")}),e.jsxs(lt,{className:"font-bold",children:["$",Number(C.total).toFixed(2)]}),e.jsx(lt,{children:e.jsx(at,{className:F2e[C.status],children:$5[C.status]})}),e.jsx(lt,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>v(C),children:[e.jsx(ya,{className:"h-4 w-4 mr-1"}),"View"]})})]},C.id)})})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No orders yet."})})]}),e.jsx(vs,{open:l,onOpenChange:i,children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsxs(Ns,{children:["Order ",a==null?void 0:a.order_number]})}),a&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Customer"}),e.jsx("p",{children:(j=a.user)==null?void 0:j.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(w=a.user)==null?void 0:w.email})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Shipping Address"}),e.jsx("p",{children:a.shipping_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.shipping_address,e.jsx("br",{}),a.shipping_city,", ",a.shipping_state," ",a.shipping_zip]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Order Items"}),e.jsx("div",{className:"space-y-3",children:(N=a.items)==null?void 0:N.map(C=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:C.product_name}),C.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.variant_name})]}),e.jsxs("p",{className:"font-bold",children:["$",Number(C.unit_price).toFixed(2)," x ",C.quantity]})]}),C.artwork_url&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Customer Artwork:"}),e.jsx("a",{href:C.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Artwork"})]}),e.jsx("div",{className:"mt-3 pt-3 border-t",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Proof Status: "}),e.jsx(at,{variant:C.proof_status==="approved"?"default":"secondary",children:C.proof_status||"No proof yet"})]}),C.proof_url?e.jsx("a",{href:C.proof_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Proof"}):e.jsxs("div",{children:[e.jsx("input",{type:"file",accept:"image/*,.pdf",onChange:A=>b(A,C.id),className:"hidden",id:`proof-${C.id}`,disabled:p}),e.jsx("label",{htmlFor:`proof-${C.id}`,children:e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("span",{children:[e.jsx(Ya,{className:"h-4 w-4 mr-1"}),p?"Uploading...":"Upload Proof"]})})})]})]})})]},C.id))})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Subtotal"}),e.jsxs("span",{children:["$",Number(a.subtotal).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",Number(a.shipping_total).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between font-bold text-lg mt-2",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",Number(a.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Update Order Status"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Status"}),e.jsxs(tr,{value:d.status,onValueChange:C=>u({...d,status:C}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:Cxs.map(C=>e.jsx(At,{value:C,children:$5[C]},C))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Tracking Number"}),e.jsx(Re,{value:d.trackingNumber,onChange:C=>u({...d,trackingNumber:C.target.value}),placeholder:"Enter tracking number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Tracking URL"}),e.jsx(Re,{value:d.trackingUrl,onChange:C=>u({...d,trackingUrl:C.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Notes (optional)"}),e.jsx(Mr,{value:d.notes,onChange:C=>u({...d,notes:C.target.value}),placeholder:"Add a note about this status change..."})]}),e.jsxs(K,{onClick:_,disabled:r.isPending,className:"w-full",children:[e.jsx(dl,{className:"h-4 w-4 mr-2"}),"Update Status"]})]})]}),a.status_history&&a.status_history.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Status History"}),e.jsx("div",{className:"space-y-2",children:a.status_history.map(C=>e.jsxs("div",{className:"flex justify-between text-sm p-2 bg-muted rounded",children:[e.jsxs("div",{children:[e.jsx(at,{variant:"outline",children:$5[C.status]}),C.notes&&e.jsx("p",{className:"text-muted-foreground mt-1",children:C.notes})]}),e.jsx("span",{className:"text-muted-foreground",children:ws(new Date(C.created_at),"MMM d, h:mm a")})]},C.id))})]})]})]})})]})}function Txs(){const[t,s]=S.useState("products"),r=Dr();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(K,{variant:"outline",onClick:()=>r("/marketplace"),children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),e.jsxs(Na,{value:t,onValueChange:s,children:[e.jsxs(va,{className:"grid w-full grid-cols-3",children:[e.jsxs(ks,{value:"products",className:"flex items-center gap-2",children:[e.jsx(dl,{className:"h-4 w-4"}),"Products"]}),e.jsxs(ks,{value:"categories",className:"flex items-center gap-2",children:[e.jsx(qh,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(ks,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(km,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx(zs,{value:"products",children:e.jsx(Sxs,{})}),e.jsx(zs,{value:"categories",children:e.jsx(Nxs,{})}),e.jsx(zs,{value:"orders",children:e.jsx(Mxs,{})})]})]})})}function qJe(){return Ct({queryKey:["reward-categories"],queryFn:async()=>{const{data:t,error:s}=await G.from("reward_store_categories").select("*").order("sort_order",{ascending:!0});if(s)throw s;return t}})}function Axs(t){return Ct({queryKey:["reward-items",t],queryFn:async()=>{let s=G.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 Exs(t){return Ct({queryKey:["active-reward-items",t],queryFn:async()=>{let s=G.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 Pxs(t){return Ct({queryKey:["user-purchases",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.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 Ixs(){return Ct({queryKey:["all-reward-purchases"],queryFn:async()=>{const{data:t,error:s}=await G.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 G.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 Lxs(t){return Ct({queryKey:["spendable-points",t],queryFn:async()=>{if(!t)return 0;const{data:s,error:r}=await G.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 Dxs(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.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 Oxs(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.from("reward_store_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function Rxs(){const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("reward_store_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function Fxs(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("reward_store_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function zxs(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.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 Bxs(){const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.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 $xs(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.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 qxs(t){const s=t.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return s?{bucket:s[1],path:s[2]}:null}async function Mpe(t,s){const r=qxs(t);if(r)try{const{data:n,error:a}=await G.storage.from(r.bucket).download(r.path);if(a){console.error("Error downloading file:",a),fe.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),fe.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),fe.error("Failed to download file")}}function UJe(){return Ct({queryKey:["point-reward-settings"],queryFn:async()=>{const{data:t,error:s}=await G.from("point_reward_settings").select("*").order("action_name");if(s)throw s;return t}})}function Uxs(){const t=ns();return Ot({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 G.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 Vxs(){const{user:t}=Gs(),[s,r]=S.useState("items"),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState(""),[u,p]=S.useState(""),[f,v]=S.useState(""),[_,b]=S.useState(null),[j,w]=S.useState(!1),[N,C]=S.useState(null),[A,I]=S.useState(""),[L,R]=S.useState(""),[$,q]=S.useState(null),[U,V]=S.useState(""),[X,se]=S.useState("file"),[te,Y]=S.useState(""),[de,ie]=S.useState(""),[ae,le]=S.useState(""),[pe,be]=S.useState(!0),[ye,we]=S.useState(null),[ke,Ze]=S.useState(!1),[_e,Ce]=S.useState(!1),Te=S.useRef(null),Fe=S.useRef(null),{data:Ae,isLoading:We}=qJe(),{data:ht,isLoading:De}=Axs(),{data:Dt,isLoading:he}=Ixs(),{data:Qe,isLoading:ot}=UJe(),rt=Oxs(),Ne=Rxs(),it=Fxs(),qe=zxs(),Xe=Bxs(),$e=$xs(),Ke=Uxs(),[ct,Ue]=S.useState({}),Ve=vt=>{vt?(l(vt),d(vt.name),p(vt.description||""),v(vt.icon||"")):(l(null),d(""),p(""),v("")),a(!0)},Je=async()=>{if(!i.trim()){fe.error("Please enter a category name");return}try{o?(await Ne.mutateAsync({id:o.id,name:i,description:u||null,icon:f||null}),fe.success("Category updated successfully")):(await rt.mutateAsync({name:i,description:u||null,icon:f||null,sort_order:((Ae==null?void 0:Ae.length)||0)+1}),fe.success("Category created successfully")),a(!1)}catch(vt){console.error("Error saving category:",vt),fe.error("Failed to save category")}},Rt=async()=>{if(_)try{await it.mutateAsync(_),fe.success("Category deleted successfully"),b(null)}catch(vt){console.error("Error deleting category:",vt),fe.error("Failed to delete category")}},$t=vt=>{var Cs;vt?(C(vt),I(vt.name),R(vt.description||""),q(vt.category_id),V(vt.points_cost.toString()),se(vt.item_type),Y(vt.file_url||""),ie(vt.preview_image_url||""),le(((Cs=vt.max_quantity)==null?void 0:Cs.toString())||""),be(vt.is_active)):(C(null),I(""),R(""),q(null),V(""),se("file"),Y(""),ie(""),le(""),be(!0)),w(!0)},ls=async(vt,Cs)=>{Cs==="file"?Ze(!0):Ce(!0);try{const or=vt.name.split(".").pop(),Ar=`${Date.now()}-${Math.random().toString(36).substring(7)}.${or}`,Wn=`${Cs==="file"?"items":"previews"}/${Ar}`,{error:ai}=await G.storage.from("reward-store").upload(Wn,vt);if(ai)throw ai;const{data:{publicUrl:bo}}=G.storage.from("reward-store").getPublicUrl(Wn);Cs==="file"?Y(bo):ie(bo),fe.success("File uploaded successfully")}catch(or){console.error("Error uploading file:",or),fe.error("Failed to upload file")}finally{Cs==="file"?Ze(!1):Ce(!1)}},Qt=async()=>{if(!A.trim()){fe.error("Please enter an item name");return}if(!U||parseInt(U)<0){fe.error("Please enter a valid points cost");return}try{const vt={name:A,description:L||null,category_id:$,points_cost:parseInt(U),item_type:X,file_url:te||null,preview_image_url:de||null,max_quantity:ae?parseInt(ae):null,current_quantity:ae?parseInt(ae):null,is_active:pe,created_by:t==null?void 0:t.id};N?(await Xe.mutateAsync({id:N.id,...vt,current_quantity:N.max_quantity!==(ae?parseInt(ae):null)?ae?parseInt(ae):null:N.current_quantity}),fe.success("Item updated successfully")):(await qe.mutateAsync(vt),fe.success("Item created successfully")),w(!1)}catch(vt){console.error("Error saving item:",vt),fe.error("Failed to save item")}},rs=async()=>{if(ye)try{await $e.mutateAsync(ye),fe.success("Item deleted successfully"),we(null)}catch(vt){console.error("Error deleting item:",vt),fe.error("Failed to delete item")}},as=async(vt,Cs)=>{const or=ct[vt];if(or===void 0||or===Cs.toString())return;const Ar=parseInt(or);if(isNaN(Ar)||Ar<0){fe.error("Please enter a valid positive number");return}try{await Ke.mutateAsync({id:vt,points:Ar}),fe.success("Points updated successfully"),Ue(Wn=>{const ai={...Wn};return delete ai[vt],ai})}catch(Wn){console.error("Error updating points:",Wn),fe.error("Failed to update points")}};return We||De||he||ot?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(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(dl,{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:(ht==null?void 0:ht.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(ht==null?void 0:ht.filter(vt=>vt.is_active).length)||0," active"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(qh,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Categories"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(Ae==null?void 0:Ae.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(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:[ht&&ht.length>0?Math.round(ht.reduce((vt,Cs)=>vt+Cs.points_cost,0)/ht.length):0," pts"]})]})})]}),e.jsxs(Na,{value:s,onValueChange:r,children:[e.jsxs(va,{children:[e.jsx(ks,{value:"items",children:"Items"}),e.jsx(ks,{value:"categories",children:"Categories"}),e.jsx(ks,{value:"purchases",children:"Purchases"}),e.jsx(ks,{value:"point-settings",children:"Point Settings"})]}),e.jsx(zs,{value:"items",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Store Items"}),e.jsx(yr,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(K,{onClick:()=>$t(),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),e.jsx(Oe,{children:!ht||ht.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(io,{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(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Item"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{className:"text-center",children:"Cost"}),e.jsx(jt,{className:"text-center",children:"Type"}),e.jsx(jt,{className:"text-center",children:"Quantity"}),e.jsx(jt,{className:"text-center",children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:ht.map(vt=>e.jsxs(js,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[vt.preview_image_url?e.jsx("img",{src:vt.preview_image_url,alt:vt.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(io,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:vt.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:vt.description||"No description"})]})]})}),e.jsx(lt,{children:vt.category?e.jsx(at,{variant:"outline",children:vt.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(lt,{className:"text-center",children:e.jsxs(at,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),vt.points_cost]})}),e.jsx(lt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[vt.item_type==="file"?e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Lo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:vt.item_type})]})}),e.jsx(lt,{className:"text-center",children:vt.max_quantity!==null?e.jsxs("span",{className:vt.current_quantity===0?"text-red-500":"",children:[vt.current_quantity,"/",vt.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(lt,{className:"text-center",children:e.jsx(at,{variant:vt.is_active?"default":"secondary",children:vt.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(K,{variant:"ghost",size:"sm",onClick:()=>$t(vt),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>we(vt.id),children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]})})]},vt.id))})]})})]})}),e.jsx(zs,{value:"categories",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Categories"}),e.jsx(yr,{children:"Organize your store items into categories"})]}),e.jsxs(K,{onClick:()=>Ve(),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Oe,{children:!Ae||Ae.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(qh,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No categories yet. Add your first category!"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{className:"text-center",children:"Items"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:Ae.map(vt=>e.jsxs(js,{children:[e.jsxs(lt,{className:"font-medium",children:[vt.icon&&e.jsx("span",{className:"mr-2",children:vt.icon}),vt.name]}),e.jsx(lt,{className:"text-muted-foreground",children:vt.description||"—"}),e.jsx(lt,{className:"text-center",children:(ht==null?void 0:ht.filter(Cs=>Cs.category_id===vt.id).length)||0}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Ve(vt),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(vt.id),children:e.jsx(br,{className:"h-4 w-4 text-destructive"})})]})})]},vt.id))})]})})]})}),e.jsx(zs,{value:"purchases",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(km,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(yr,{children:"View all reward redemptions by agents"})]}),e.jsx(Oe,{children:!Dt||Dt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(km,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No purchases yet."})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Date"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Item"}),e.jsx(jt,{className:"text-center",children:"Points Spent"})]})}),e.jsx(Pn,{children:Dt.map(vt=>{var Cs,or,Ar,Wn;return e.jsxs(js,{children:[e.jsx(lt,{className:"text-muted-foreground",children:ws(new Date(vt.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(Xi,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Cs=vt.user)==null?void 0:Cs.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((or=vt.user)==null?void 0:or.email)||"—"})]})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(Ar=vt.item)!=null&&Ar.preview_image_url?e.jsx("img",{src:vt.item.preview_image_url,alt:vt.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(io,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((Wn=vt.item)==null?void 0:Wn.name)||"Deleted item"})]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(at,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),vt.points_spent]})})]},vt.id)})})]})})]})})]})]}),e.jsx(vs,{open:n,onOpenChange:a,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{htmlFor:"categoryName",children:"Name"}),e.jsx(Re,{id:"categoryName",value:i,onChange:vt=>d(vt.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(Mr,{id:"categoryDescription",value:u,onChange:vt=>p(vt.target.value),placeholder:"Optional description..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),e.jsx(Re,{id:"categoryIcon",value:f,onChange:vt=>v(vt.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{onClick:Je,disabled:rt.isPending||Ne.isPending,children:rt.isPending||Ne.isPending?"Saving...":"Save"})]})]})}),e.jsx(vs,{open:j,onOpenChange:w,children:e.jsxs(ys,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{htmlFor:"itemName",children:"Name *"}),e.jsx(Re,{id:"itemName",value:A,onChange:vt=>I(vt.target.value),placeholder:"e.g., Premium Template Pack"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"itemDescription",children:"Description"}),e.jsx(Mr,{id:"itemDescription",value:L,onChange:vt=>R(vt.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(ve,{htmlFor:"itemCategory",children:"Category"}),e.jsxs(tr,{value:$||"none",onValueChange:vt=>q(vt==="none"?null:vt),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select category"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No category"}),Ae==null?void 0:Ae.map(vt=>e.jsxs(At,{value:vt.id,children:[vt.icon&&`${vt.icon} `,vt.name]},vt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"itemPointsCost",children:"Points Cost *"}),e.jsx(Re,{id:"itemPointsCost",type:"number",min:"0",value:U,onChange:vt=>V(vt.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(ve,{htmlFor:"itemType",children:"Type"}),e.jsxs(tr,{value:X,onValueChange:se,children:[e.jsx(Js,{children:e.jsx(sr,{})}),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(ve,{htmlFor:"itemMaxQuantity",children:"Max Quantity"}),e.jsx(Re,{id:"itemMaxQuantity",type:"number",min:"1",value:ae,onChange:vt=>le(vt.target.value),placeholder:"Leave empty for unlimited"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"File / Link URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:te,onChange:vt=>Y(vt.target.value),placeholder:X==="file"?"Upload a file or paste URL":"Paste external link"}),X==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var vt;return(vt=Te.current)==null?void 0:vt.click()},disabled:ke,children:e.jsx(Ya,{className:"h-4 w-4"})}),e.jsx("input",{ref:Te,type:"file",className:"hidden",onChange:vt=>{var or;const Cs=(or=vt.target.files)==null?void 0:or[0];Cs&&ls(Cs,"file")}})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Preview Image"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:de,onChange:vt=>ie(vt.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var vt;return(vt=Fe.current)==null?void 0:vt.click()},disabled:_e,children:e.jsx(Jo,{className:"h-4 w-4"})}),e.jsx("input",{ref:Fe,type:"file",accept:"image/*",className:"hidden",onChange:vt=>{var or;const Cs=(or=vt.target.files)==null?void 0:or[0];Cs&&ls(Cs,"preview")}})]}),de&&e.jsx("img",{src:de,alt:"Preview",className:"mt-2 h-24 rounded object-cover"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"itemIsActive",checked:pe,onCheckedChange:be}),e.jsx(ve,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(K,{onClick:Qt,disabled:qe.isPending||Xe.isPending,children:qe.isPending||Xe.isPending?"Saving...":"Save"})]})]})}),e.jsx(nc,{open:!!_,onOpenChange:()=>b(null),children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Category"}),e.jsx(Dl,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:Rt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(nc,{open:!!ye,onOpenChange:()=>we(null),children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Item"}),e.jsx(Dl,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:rs,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(Ee,{className:"mt-4",children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($l,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx(zt,{children:"Point Reward Settings"}),e.jsx(yr,{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($l,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No point settings configured."})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Action"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{className:"text-center w-32",children:"Points"}),e.jsx(jt,{className:"text-right w-24",children:"Save"})]})}),e.jsx(Pn,{children:Qe.map(vt=>e.jsxs(js,{children:[e.jsx(lt,{children:e.jsx("p",{className:"font-medium",children:vt.action_name})}),e.jsx(lt,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:vt.description})}),e.jsx(lt,{className:"text-center",children:e.jsx(Re,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:ct[vt.id]??vt.points.toString(),onChange:Cs=>Ue(or=>({...or,[vt.id]:Cs.target.value}))})}),e.jsx(lt,{className:"text-right",children:e.jsx(K,{size:"sm",variant:"outline",disabled:ct[vt.id]===void 0||ct[vt.id]===vt.points.toString()||Ke.isPending,onClick:()=>as(vt.id,vt.points),children:e.jsx(Bu,{className:"h-4 w-4"})})})]},vt.id))})]})})]})]})}const LLe=()=>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"})]}),DLe=[{value:"template",label:"Templates"},{value:"brand",label:"Brand Assets"},{value:"listing",label:"Listing Assets"},{value:"social",label:"Social Media"},{value:"general",label:"General"}];function Hxs(){const t=ns(),[s,r]=S.useState(!1),[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""}),{data:u,isLoading:p}=Ct({queryKey:["canva-integration"],queryFn:async()=>{const{data:C,error:A}=await G.from("canva_integration").select("*").eq("is_active",!0).maybeSingle();if(A)throw A;return C}}),{data:f}=Ct({queryKey:["brokerages-list"],queryFn:async()=>{const{data:C,error:A}=await G.from("brokerages").select("id, name").order("name");if(A)throw A;return C}}),{data:v}=Ct({queryKey:["canva-brokerage-folders"],queryFn:async()=>{const{data:C,error:A}=await G.from("canva_brokerage_folders").select("*, brokerages(name)").order("sort_order");if(A)throw A;return C}}),_=async()=>{var C;r(!0);try{const{data:A}=await G.auth.getSession(),I=(C=A==null?void 0:A.session)==null?void 0:C.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 U=window.open(q.authUrl,"canva-oauth","width=600,height=700,scrollbars=yes,resizable=yes");if(!U){fe.error("Popup was blocked. Please allow popups for this site and try again."),r(!1);return}const V=se=>{var te,Y;se.origin===window.location.origin&&(((te=se.data)==null?void 0:te.type)==="canva-oauth-success"?(window.removeEventListener("message",V),fe.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",V),fe.error("Canva connection failed: "+(se.data.error||"Unknown error")),r(!1)))};window.addEventListener("message",V);const X=setInterval(()=>{U.closed&&(clearInterval(X),window.removeEventListener("message",V),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1))},500)}else throw new Error("Failed to get authorization URL")}catch(A){console.error("Canva connect error:",A);const I=(A==null?void 0:A.message)||"";I.includes("CANVA_CLIENT_ID")?fe.error("Canva app credentials not configured yet."):fe.error(I||"Failed to start Canva connection"),r(!1)}},b=Ot({mutationFn:async C=>{var U;const{data:A}=await G.auth.getSession(),I=(U=A==null?void 0:A.session)==null?void 0:U.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:C})}),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"]}),fe.success("Canva disconnected")},onError:C=>{fe.error(C.message||"Failed to disconnect Canva")}}),j=Ot({mutationFn:async C=>{const{error:A}=await G.from("canva_brokerage_folders").insert({brokerage_id:C.brokerage_id,folder_id:C.folder_id.trim(),folder_name:C.folder_name.trim(),folder_type:C.folder_type,description:C.description.trim()||null,sort_order:(v==null?void 0:v.length)||0});if(A)throw A},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),fe.success("Folder added"),l(!1),d({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""})},onError:()=>fe.error("Failed to add folder")}),w=Ot({mutationFn:async C=>{const{error:A}=await G.from("canva_brokerage_folders").delete().eq("id",C);if(A)throw A},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),fe.success("Folder removed")},onError:()=>fe.error("Failed to remove folder")}),N=!!u;return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Lt,{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(LLe,{})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Canva Connect",N&&e.jsx(at,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(at,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(yr,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"OAuth 2.0 + PKCE for secure authorization"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"Map brokerage folders to auto-share with agents on connection"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"Multiple folders per brokerage (templates, brand assets, listings)"})]}),e.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-muted border border-dashed",children:[e.jsx("p",{className:"text-xs font-medium text-foreground mb-1",children:"Canva App Redirect URL"}),e.jsx("code",{className:"text-xs text-muted-foreground break-all select-all",children:"https://dashboard.relevelup.com/canva-callback.html"})]}),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(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect Canva?"}),e.jsx(Dl,{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(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{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(qh,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",v&&v.length>0&&e.jsx(at,{variant:"secondary",className:"text-xs",children:v.length})]}),n?e.jsx(Rg,{className:"h-4 w-4"}):e.jsx(Vo,{className:"h-4 w-4"})]}),n&&e.jsxs("div",{className:"border-t p-3 space-y-2",children:[v&&v.length>0?v.map(C=>{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:C.folder_name}),e.jsx(at,{variant:"outline",className:"text-xs shrink-0",children:((A=DLe.find(L=>L.value===C.folder_type))==null?void 0:A.label)||C.folder_type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(I=C.brokerages)==null?void 0:I.name," · ID: ",e.jsx("span",{className:"font-mono",children:C.folder_id})]})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive shrink-0 ml-2",onClick:()=>w.mutate(C.id),children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]},C.id)}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"No folders mapped yet"}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full gap-1.5 mt-1",onClick:()=>l(!0),children:[e.jsx(Zs,{className:"h-3.5 w-3.5"}),"Add Folder Mapping"]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:_,disabled:s||p,children:[s?e.jsx(Po,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx("div",{className:"mr-2",children:e.jsx(LLe,{})}),"Connect Canva",e.jsx(Fi,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{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(ve,{children:"Brokerage"}),e.jsxs(tr,{value:i.brokerage_id,onValueChange:C=>d(A=>({...A,brokerage_id:C})),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a brokerage…"})}),e.jsx(er,{children:f==null?void 0:f.map(C=>e.jsx(At,{value:C.id,children:C.name},C.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Canva Folder ID"}),e.jsx(Re,{placeholder:"e.g. FABCdef123456",value:i.folder_id,onChange:C=>d(A=>({...A,folder_id:C.target.value}))}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Found in the Canva folder URL: canva.com/folder/",e.jsx("strong",{children:"FOLDER_ID"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Folder Display Name"}),e.jsx(Re,{placeholder:"e.g. Brand Templates 2024",value:i.folder_name,onChange:C=>d(A=>({...A,folder_name:C.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Folder Type"}),e.jsxs(tr,{value:i.folder_type,onValueChange:C=>d(A=>({...A,folder_type:C})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:DLe.map(C=>e.jsx(At,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ve,{children:["Description ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(Re,{placeholder:"What's in this folder?",value:i.description,onChange:C=>d(A=>({...A,description:C.target.value}))})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>j.mutate(i),disabled:!i.brokerage_id||!i.folder_id||!i.folder_name||j.isPending,children:[j.isPending?e.jsx(Po,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function Wxs(){return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(_u,{title:"Integrations",description:"Manage platform-level service connections"}),e.jsx(Hxs,{})]})})}const Gxs={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 xE(t,s=18,r=10){return t.length<=s+r+3?t:`${t.slice(0,s)}…${t.slice(-r)}`}function Kxs(){var X,se,te,Y,de;const t=ns(),[s,r]=S.useState("Test Push"),[n,a]=S.useState("Testing web push notification"),[o,l]=S.useState("/community"),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[f,v]=S.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[_,b]=S.useState(null),[j,w]=S.useState(null),{data:N,isLoading:C}=Ct({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:ie,error:ae}=await G.from("push_notification_settings").select("*").order("setting_key");if(ae)throw ae;return ie}}),{data:A,isLoading:I}=Ct({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:ie,error:ae}=await G.from("push_subscriptions").select("*",{count:"exact",head:!0});if(ae)throw ae;return{totalSubscriptions:ie||0}}}),L=Ot({mutationFn:async({settingKey:ie,isEnabled:ae})=>{const{error:le}=await G.from("push_notification_settings").update({is_enabled:ae}).eq("setting_key",ie);if(le)throw le},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),fe.success("Notification setting updated")},onError:ie=>{fe.error("Failed to update setting: "+ie.message)}}),R=S.useMemo(()=>{var ie,ae;return f.isSupported?`perm=${f.permission??"unknown"} · controller=${f.controllerPresent?"yes":"no"} · sw=${((ie=f.serviceWorker)==null?void 0:ie.activeState)??"unknown"} · sub=${(ae=f.subscription)!=null&&ae.endpoint?"yes":"no"}`:"Push not supported in this browser."},[f]);S.useEffect(()=>{let ie=!0;const ae=async()=>{var ye,we,ke,Ze,_e,Ce,Te;const pe="serviceWorker"in navigator&&"PushManager"in window,be={isSupported:pe,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((ye=navigator.serviceWorker)!=null&&ye.controller)};if(!pe){ie&&v(be);return}try{const{data:Fe,error:Ae}=await G.functions.invoke("get-vapid-public-key",{body:{}});if(Ae)throw Ae;be.vapidPublicKey=Fe==null?void 0:Fe.vapidPublicKey;const ht=(await navigator.serviceWorker.getRegistrations()).find(De=>{var he,Qe,ot;return(((he=De.active)==null?void 0:he.scriptURL)||((Qe=De.waiting)==null?void 0:Qe.scriptURL)||((ot=De.installing)==null?void 0:ot.scriptURL)||"").includes("/sw.js")});if(ht){be.pushWorkerScriptUrl=((we=ht.active)==null?void 0:we.scriptURL)||((ke=ht.waiting)==null?void 0:ke.scriptURL)||((Ze=ht.installing)==null?void 0:Ze.scriptURL),be.serviceWorker={scope:ht.scope,activeState:(_e=ht.active)==null?void 0:_e.state};const De=await ht.pushManager.getSubscription();if(De){const Dt=De.toJSON();be.subscription={endpoint:Dt.endpoint,p256dh:(Ce=Dt.keys)==null?void 0:Ce.p256dh,auth:(Te=Dt.keys)==null?void 0:Te.auth}}}}catch(Fe){be.error=(Fe==null?void 0:Fe.message)||String(Fe)}ie&&v(be)};ae();const le=window.setInterval(ae,4e3);return()=>{ie=!1,window.clearInterval(le)}},[]);const $=async()=>{if(typeof Notification>"u"){fe.error("Notifications API not available in this browser.");return}try{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted"){fe.error("Notification permission not granted.");return}new Notification("Local notification test",{body:"If you see this, OS/browser notifications can display."}),fe.success("Triggered a local notification (not push).")}catch(ie){fe.error(`Local notification failed: ${(ie==null?void 0:ie.message)||String(ie)}`)}},q=async()=>{d(!0),b(null);try{const{data:ie,error:ae}=await G.functions.invoke("send-push-notification",{body:{title:s,body:n,url:o}});if(ae)throw ae;b({sent:ie==null?void 0:ie.sent,failed:ie==null?void 0:ie.failed,expiredCleaned:ie==null?void 0:ie.expiredCleaned,vapidPublicKey:ie==null?void 0:ie.vapidPublicKey}),(ie==null?void 0:ie.sent)>0?fe.success(`Test notification sent to ${ie.sent} subscriber(s)`):(ie==null?void 0:ie.failed)>0?fe.warning(`Notification failed for ${ie.failed} subscriber(s). ${ie.expired||0} expired subscriptions cleaned up.`):fe.info("No active subscriptions to send to")}catch(ie){console.error("Error sending test notification:",ie),b({error:(ie==null?void 0:ie.message)||String(ie)}),fe.error("Failed to send test notification: "+(ie.message||"Unknown error"))}finally{d(!1)}},U=async()=>{p(!0),w(null);try{const{data:ie,error:ae}=await G.functions.invoke("generate-vapid-keys",{body:{}});if(ae)throw ae;const le=ie==null?void 0:ie.publicKey,pe=ie==null?void 0:ie.privateKey;if(!le||!pe)throw new Error("generate-vapid-keys did not return keys");w({publicKey:le,privateKey:pe}),fe.success("Generated new VAPID keys. Update backend secrets, then clear + re-subscribe.")}catch(ie){console.error("Error generating VAPID keys:",ie),fe.error("Failed to generate VAPID keys: "+((ie==null?void 0:ie.message)||"Unknown error"))}finally{p(!1)}},V=Ot({mutationFn:async()=>{const{error:ie}=await G.from("push_subscriptions").delete().neq("id","00000000-0000-0000-0000-000000000000");if(ie)throw ie},onSuccess:()=>{fe.success("All subscriptions cleared. Users will need to re-enable notifications."),t.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:ie=>{fe.error("Failed to clear subscriptions: "+ie.message)}});return e.jsx(Ms,{title:"Notification Settings",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(yr,{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(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx($l,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(yr,{children:"Control which types of push notifications are sent to users"})]}),e.jsx(Oe,{children:C?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):e.jsx("div",{className:"space-y-4",children:N==null?void 0:N.map(ie=>{const ae=Gxs[ie.setting_key]||{label:ie.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:ae.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ae.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ie.description})]})]}),e.jsx(Br,{checked:ie.is_enabled,onCheckedChange:le=>L.mutate({settingKey:ie.setting_key,isEnabled:le}),disabled:L.isPending})]},ie.id)})})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(cf,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(yr,{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:R}),f.error&&e.jsx("div",{className:"mt-2 text-destructive",children:f.error}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Backend VAPID public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:f.vapidPublicKey?xE(f.vapidPublicKey):"(not loaded)"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Service worker"}),e.jsxs("div",{className:"rounded-md border bg-background p-2 font-mono text-xs",children:[e.jsxs("div",{children:["scope: ",(X=f.serviceWorker)!=null&&X.scope?xE(f.serviceWorker.scope,24,8):"none"]}),e.jsxs("div",{children:["active: ",((se=f.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=f.subscription)!=null&&te.endpoint?xE(f.subscription.endpoint,40,12):"none"]}),e.jsxs("div",{children:["p256dh: ",(Y=f.subscription)!=null&&Y.p256dh?xE(f.subscription.p256dh,22,10):"none"]}),e.jsxs("div",{children:["auth: ",(de=f.subscription)!=null&&de.auth?xE(f.subscription.auth,22,10):"none"]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(K,{variant:"outline",onClick:$,children:"Local notification test"}),e.jsx(K,{variant:"outline",onClick:()=>window.location.reload(),children:"Reload page"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"test-title",children:"Notification Title"}),e.jsx(Re,{id:"test-title",value:s,onChange:ie=>r(ie.target.value),placeholder:"Enter notification title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"test-body",children:"Notification Body"}),e.jsx(Mr,{id:"test-body",value:n,onChange:ie=>a(ie.target.value),placeholder:"Enter notification message",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"test-url",children:"Click URL (optional)"}),e.jsx(Re,{id:"test-url",value:o,onChange:ie=>l(ie.target.value),placeholder:"/community or full URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Where users will be taken when they click the notification"})]}),e.jsxs(K,{onClick:q,disabled:i||!s||!n,className:"w-full sm:w-auto",children:[e.jsx(ka,{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(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(br,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(yr,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"If you've recently updated the VAPID keys, existing subscriptions will no longer work. Use this to clear all subscriptions so users can re-subscribe with the new keys."}),e.jsxs(K,{variant:"destructive",onClick:()=>V.mutate(),disabled:V.isPending,children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),V.isPending?"Clearing...":"Clear All Subscriptions"]}),e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"VAPID key rotation helper"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:"If you suspect the backend public/private keys don’t match, generate a fresh pair, update backend secrets, then clear subscriptions and have users re-enable push."}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:e.jsx(K,{variant:"outline",onClick:U,disabled:u,children:u?"Generating…":"Generate VAPID keys"})}),j&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"text-muted-foreground",children:["Copy these into backend secrets ",e.jsx("span",{className:"font-mono",children:"VAPID_PUBLIC_KEY"})," and ",e.jsx("span",{className:"font-mono",children:"VAPID_PRIVATE_KEY"}),"."]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:j.publicKey})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Private key (keep secret)"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:j.privateKey})]})]})]})]})]})]})})}function Zxs(){const{toast:t}=Ia(),[s,r]=S.useState([]),[n,a]=S.useState({totalPresentations:0,totalViews:0,totalLeads:0,totalCtaClicks:0,agentsUsing:0}),[o,l]=S.useState(!0),{sortKey:i,sortDirection:d,handleSort:u,sortData:p}=UL("presentation_count","desc"),f=p(s,{name:b=>{var j;return((j=b.name)==null?void 0:j.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});S.useEffect(()=>{v()},[]);const v=async()=>{try{l(!0);const{data:b,error:j}=await G.rpc("get_admin_presentation_stats");if(j)throw j;if(!b||b.length===0){l(!1);return}const w=b.map(L=>L.owner_user_id),{data:N,error:C}=await G.from("profiles").select("id, name, email, avatar_url").in("id",w);if(C)throw C;const A=new Map((N==null?void 0:N.map(L=>[L.id,L]))||[]),I=b.map(L=>{const R=A.get(L.owner_user_id);return{owner_user_id:L.owner_user_id,name:(R==null?void 0:R.name)||"Unknown",email:(R==null?void 0:R.email)||"",avatar_url:(R==null?void 0:R.avatar_url)||null,presentation_count:Number(L.presentation_count),total_views:Number(L.total_views),total_leads:Number(L.total_leads),total_cta_clicks:Number(L.total_cta_clicks)}});r(I),r(I),a({totalPresentations:I.reduce((L,R)=>L+R.presentation_count,0),totalViews:I.reduce((L,R)=>L+R.total_views,0),totalLeads:I.reduce((L,R)=>L+R.total_leads,0),totalCtaClicks:I.reduce((L,R)=>L+R.total_cta_clicks,0),agentsUsing:I.length})}catch(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:hr,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:Bg,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:ya,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:xc,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:r_,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(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{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(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Cc,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((b,j)=>e.jsx(gs,{className:"h-12 w-full"},j))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No presentations created yet."}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(el,{sortKey:"name",currentSortKey:i,currentDirection:d,onSort:u,children:"Agent"}),e.jsx(el,{sortKey:"presentations",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Presentations"}),e.jsx(el,{sortKey:"views",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Views"}),e.jsx(el,{sortKey:"leads",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Leads"}),e.jsx(el,{sortKey:"cta_clicks",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"CTA Clicks"}),e.jsx(el,{sortKey:"conversion",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Conversion"})]})}),e.jsx(Pn,{children:f.map(b=>{var w,N;const j=b.total_views>0?(b.total_leads/b.total_views*100).toFixed(1):"0.0";return e.jsxs(js,{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=(w=b.name)==null?void 0:w.charAt(0))==null?void 0:N.toUpperCase())||"?"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children: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(at,{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(j)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[j,"%"]})})]},b.owner_user_id)})})]})})]})]})})}function Yxs(){const{toast:t}=Ia(),[s,r]=S.useState([]),[n,a]=S.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=S.useState(!0);S.useEffect(()=>{i()},[]);const i=async()=>{try{l(!0);const{data:u,error:p}=await G.rpc("get_admin_guest_book_stats");if(p)throw p;if(!u||u.length===0){l(!1);return}const f=u.map(w=>w.agent_id),{data:v,error:_}=await G.from("profiles").select("id, name, email, avatar_url").in("id",f);if(_)throw _;const b=new Map((v==null?void 0:v.map(w=>[w.id,w]))||[]),j=u.map(w=>{const N=b.get(w.agent_id);return{agent_id:w.agent_id,name:(N==null?void 0:N.name)||"Unknown",email:(N==null?void 0:N.email)||"",avatar_url:(N==null?void 0:N.avatar_url)||null,open_house_count:Number(w.open_house_count),total_visitors:Number(w.total_visitors),total_leads:Number(w.total_leads),active_count:Number(w.active_count)}});j.sort((w,N)=>N.total_visitors-w.total_visitors),r(j),a({totalOpenHouses:j.reduce((w,N)=>w+N.open_house_count,0),totalVisitors:j.reduce((w,N)=>w+N.total_visitors,0),totalLeads:j.reduce((w,N)=>w+N.total_leads,0),activeOpenHouses:j.reduce((w,N)=>w+N.active_count,0),agentsUsing:j.length})}catch(u){console.error("Error loading guest book stats:",u),t({title:"Error",description:"Failed to load guest book analytics",variant:"destructive"})}finally{l(!1)}},d=[{label:"Agents Using",value:n.agentsUsing,icon:hr,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:Un,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:gi,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:ya,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:xc,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(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:u.label}),e.jsx(u.icon,{className:`h-4 w-4 ${u.color}`})]}),e.jsx(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(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Cc,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((u,p)=>e.jsx(gs,{className:"h-12 w-full"},p))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No open houses created yet."}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Agent"}),e.jsx(jt,{className:"text-center",children:"Open Houses"}),e.jsx(jt,{className:"text-center",children:"Active"}),e.jsx(jt,{className:"text-center",children:"Visitors"}),e.jsx(jt,{className:"text-center",children:"Leads"}),e.jsx(jt,{className:"text-center",children:"Conversion"})]})}),e.jsx(Pn,{children:s.map(u=>{var f,v;const p=u.total_visitors>0?(u.total_leads/u.total_visitors*100).toFixed(1):"0.0";return e.jsxs(js,{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=(f=u.name)==null?void 0:f.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(at,{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(at,{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(p)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[p,"%"]})})]},u.agent_id)})})]})})]})]})})}function Xxs(){const[t]=Ec(),s=Dr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Processing connection...");return S.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),fe.error("Failed to connect: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),fe.error("Failed to connect: No authorization code");return}try{const{data:f,error:v}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p}});if(v)throw v;if(f!=null&&f.success)n("success"),o(f.message||"Accounts connected successfully!"),fe.success(f.message||"Social accounts connected!");else throw new Error((f==null?void 0:f.error)||"Failed to connect accounts")}catch(f){console.error("Callback error:",f),n("error"),o(f.message||"Failed to complete connection"),fe.error(f.message||"Failed to connect accounts")}})()},[t]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4",children:[r==="loading"&&e.jsx(As,{className:"h-12 w-12 animate-spin text-primary"}),r==="success"&&e.jsx(gi,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx(kc,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(zt,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(yr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/admin/integrations"),children:r==="success"?"View Integrations":"Back to Integrations"})})]})})}function Qxs(){const t=ns(),[s,r]=S.useState(""),[n,a]=S.useState(""),[o,l]=S.useState([]),i=S.useRef(null),{data:d,isLoading:u}=Ct({queryKey:["prospect-emails"],queryFn:async()=>{const{data:w,error:N}=await G.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(N)throw N;return w}}),p={total:(d==null?void 0:d.length)||0,sent:(d==null?void 0:d.filter(w=>w.status==="sent").length)||0,converted:(d==null?void 0:d.filter(w=>w.status==="converted").length)||0,conversionRate:d!=null&&d.length?Math.round(d.filter(w=>w.status==="converted").length/d.length*100):0},f=Ot({mutationFn:async w=>{const{data:N,error:C}=await G.functions.invoke("send-prospect-email",{body:{emails:w}});if(C)throw C;return N},onSuccess:w=>{t.invalidateQueries({queryKey:["prospect-emails"]}),fe.success(`${w.sent} email${w.sent>1?"s":""} sent successfully!`),r(""),a(""),l([])},onError:w=>{fe.error("Failed to send: "+w.message)}}),v=Ot({mutationFn:async()=>{var A,I;const{data:{user:w}}=await G.auth.getUser();if(!(w!=null&&w.email))throw new Error("Could not get your email");const{data:N,error:C}=await G.functions.invoke("send-prospect-email",{body:{emails:[{email:w.email,first_name:(I=(A=w.user_metadata)==null?void 0:A.name)==null?void 0:I.split(" ")[0]}],test_mode:!0}});if(C)throw C;return N},onSuccess:()=>{fe.success("Test email sent to your inbox!")},onError:w=>{fe.error("Failed to send test: "+w.message)}}),_=()=>{if(!s.trim()){fe.error("Please enter an email address");return}if(d==null?void 0:d.find(N=>N.email.toLowerCase()===s.trim().toLowerCase())){fe.error("This email has already been prospected");return}f.mutate([{email:s.trim(),first_name:n.trim()||void 0}])},b=w=>{var A;const N=(A=w.target.files)==null?void 0:A[0];if(!N)return;const C=new FileReader;C.onload=I=>{var U,V;const R=((U=I.target)==null?void 0:U.result).split(` `).filter(X=>X.trim()),$=[],q=(V=R[0])!=null&&V.toLowerCase().includes("email")?1:0;for(let X=q;Xde.trim().replace(/"/g,"")),te=se[0],Y=se[1];te&&te.includes("@")&&$.push({email:te,first_name:Y||void 0})}l($),fe.success(`${$.length} entries loaded from CSV`)},C.readAsText(N),i.current&&(i.current.value="")},j=()=>{if(o.length===0){fe.error("No entries to send");return}const w=new Set((d==null?void 0:d.map(C=>C.email.toLowerCase()))||[]),N=o.filter(C=>!w.has(C.email.toLowerCase()));if(N.length===0){fe.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(As,{className:"h-3 w-3 animate-spin"}):e.jsx(_r,{className:"h-3 w-3"}),"Send Test to Me"]})]})]}),e.jsx(Oe,{children:e.jsxs(Na,{defaultValue:"single",children:[e.jsxs(va,{className:"mb-4",children:[e.jsxs(ks,{value:"single",children:[e.jsx(ka,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(ks,{value:"bulk",children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Bulk CSV"]})]}),e.jsx(zs,{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(ve,{htmlFor:"prospect-email",className:"sr-only",children:"Email"}),e.jsx(Re,{id:"prospect-email",type:"email",placeholder:"agent@example.com",value:s,onChange:w=>r(w.target.value),onKeyDown:w=>w.key==="Enter"&&_()})]}),e.jsxs("div",{className:"w-full sm:w-48",children:[e.jsx(ve,{htmlFor:"prospect-name",className:"sr-only",children:"First Name"}),e.jsx(Re,{id:"prospect-name",placeholder:"First name (optional)",value:n,onChange:w=>a(w.target.value),onKeyDown:w=>w.key==="Enter"&&_()})]}),e.jsxs(K,{onClick:_,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(ka,{className:"h-4 w-4"}),"Send Invite"]})]})}),e.jsx(zs,{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(K,{variant:"outline",onClick:()=>{var w;return(w=i.current)==null?void 0:w.click()},className:"gap-2",children:[e.jsx(In,{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(at,{variant:"secondary",className:"gap-1",children:[e.jsx(hr,{className:"h-3 w-3"}),o.length," entries ready"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>l([]),children:[e.jsx(Ur,{className:"h-4 w-4"}),"Clear"]})]}),e.jsxs("div",{className:"max-h-40 overflow-y-auto border rounded-lg p-3 bg-muted/30 text-sm font-mono space-y-1",children:[o.slice(0,20).map((w,N)=>e.jsxs("div",{className:"text-muted-foreground",children:[w.email,w.first_name?` — ${w.first_name}`:""]},N)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(K,{onClick:j,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(ka,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(_r,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(yr,{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((w,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(w=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-3 px-4 text-sm font-medium text-foreground",children:w.email}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:w.first_name||"—"}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:ws(new Date(w.sent_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-3 px-4",children:w.status==="converted"?e.jsxs(at,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-0",children:[e.jsx(da,{className:"h-3 w-3 mr-1"}),"Converted"]}):e.jsxs(at,{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:w.converted_at?ws(new Date(w.converted_at),"MMM d, yyyy"):"—"})]},w.id))})]})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Hh,{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 Ace(t){const s=ns(),{toast:r}=Ia(),n=Ct({queryKey:["recruit-stages",t],queryFn:async()=>{if(!t)return[];const{data:d,error:u}=await G.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(u)throw u;return d},enabled:!!t}),a=Ct({queryKey:["recruit-prospects",t],queryFn:async()=>{if(!t)return[];const{data:d,error:u}=await G.from("recruit_prospects").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(u)throw u;return d},enabled:!!t}),o=Ot({mutationFn:async d=>{const{data:{user:u}}=await G.auth.getUser();if(!u)throw new Error("Not authenticated");const p={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:f,error:v}=await G.from("recruit_prospects").insert(p).select().single();if(v)throw v;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect added"})},onError:d=>r({title:"Error",description:d.message,variant:"destructive"})}),l=Ot({mutationFn:async({id:d,...u})=>{const{data:p,error:f}=await G.from("recruit_prospects").update({...u,updated_at:new Date().toISOString()}).eq("id",d).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]})},onError:d=>r({title:"Error",description:d.message,variant:"destructive"})}),i=Ot({mutationFn:async d=>{const{error:u}=await G.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 Jxs(t){const s=ns(),{toast:r}=Ia(),n=Ct({queryKey:["recruit-activities",t],queryFn:async()=>{if(!t)return[];const{data:o,error:l}=await G.from("recruit_activities").select("*").eq("prospect_id",t).order("created_at",{ascending:!1});if(l)throw l;return o},enabled:!!t}),a=Ot({mutationFn:async o=>{const{data:{user:l}}=await G.auth.getUser();if(!l)throw new Error("Not authenticated");const{data:i,error:d}=await G.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 OLe=(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 VJe({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=S.useState(OLe(n,r)),d=p=>f=>i(v=>({...v,[p]:f.target.value})),u=p=>{p.preventDefault(),a({...l,experience_years:l.experience_years?parseInt(l.experience_years):null,last_year_transactions:l.last_year_transactions?parseInt(l.last_year_transactions):null,stage_id:l.stage_id||null}),i(OLe(n,r)),s(!1)};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Add Recruit Prospect"})}),e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs(Na,{defaultValue:"basic",className:"w-full",children:[e.jsxs(va,{className:"grid w-full grid-cols-4",children:[e.jsx(ks,{value:"basic",children:"Basic Info"}),e.jsx(ks,{value:"production",children:"Production"}),e.jsx(ks,{value:"social",children:"Social & Web"}),e.jsx(ks,{value:"personal",children:"Personal"})]}),e.jsxs(zs,{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(ve,{children:"First Name *"}),e.jsx(Re,{required:!0,value:l.first_name,onChange:d("first_name")})]}),e.jsxs("div",{children:[e.jsx(ve,{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(ve,{children:"Email"}),e.jsx(Re,{type:"email",value:l.email,onChange:d("email")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Phone"}),e.jsx(Re,{value:l.phone,onChange:d("phone")})]})]}),e.jsxs("div",{children:[e.jsx(ve,{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(ve,{children:"License #"}),e.jsx(Re,{value:l.license_number,onChange:d("license_number")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Experience (years)"}),e.jsx(Re,{type:"number",min:"0",value:l.experience_years,onChange:d("experience_years")})]})]}),e.jsxs("div",{children:[e.jsx(ve,{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(ve,{children:"City"}),e.jsx(Re,{value:l.city,onChange:d("city")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"State"}),e.jsx(Re,{value:l.state,onChange:d("state")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Zip"}),e.jsx(Re,{value:l.zip_code,onChange:d("zip_code")})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Pipeline Stage"}),e.jsxs(tr,{value:l.stage_id,onValueChange:p=>i(f=>({...f,stage_id:p})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:r.map(p=>e.jsx(At,{value:p.id,children:p.name},p.id))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Referred By"}),e.jsx(Re,{placeholder:"Who referred this prospect?",value:l.referred_by,onChange:d("referred_by")})]})]}),e.jsxs(zs,{value:"production",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ve,{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(ve,{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(ve,{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(ve,{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(ve,{children:"Specialties / Niche"}),e.jsx(Re,{placeholder:"e.g. Luxury, First-time buyers, Investment",value:l.specialties,onChange:d("specialties")})]})]}),e.jsxs(zs,{value:"social",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ve,{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(ve,{children:"Website URL"}),e.jsx(Re,{type:"url",placeholder:"https://...",value:l.website_url,onChange:d("website_url")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Instagram Handle"}),e.jsx(Re,{placeholder:"@handle",value:l.instagram_handle,onChange:d("instagram_handle")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Facebook URL"}),e.jsx(Re,{type:"url",placeholder:"https://facebook.com/...",value:l.facebook_url,onChange:d("facebook_url")})]})]}),e.jsxs(zs,{value:"personal",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Birthday"}),e.jsx(Re,{type:"date",value:l.birthday,onChange:d("birthday")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Spouse / Partner Name"}),e.jsx(Re,{value:l.spouse_name,onChange:d("spouse_name")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Interests / Hobbies"}),e.jsx(Re,{placeholder:"Golf, travel, community events...",value:l.interests,onChange:d("interests")})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Notes"}),e.jsx(Mr,{value:l.notes,onChange:d("notes"),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:o,children:"Add Prospect"})]})]})]})})}const H0e=[{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 eys(t){return Ct({queryKey:["recruit-videos",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.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 tys(t){return Ct({queryKey:["recruit-videos-prospect",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.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 sys(){const t=ns(),{toast:s}=Ia();return Ot({mutationFn:async r=>{const{data:{user:n}}=await G.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await G.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 HJe(){const t=ns();return Ot({mutationFn:async({id:s,sent_via:r})=>{const{error:n}=await G.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 WJe(t){return Ct({queryKey:["recruit-video-scripts",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.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 rys(){const t=ns(),{toast:s}=Ia();return Ot({mutationFn:async r=>{const{data:{user:n}}=await G.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await G.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 nys(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("recruit_video_scripts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]})}})}function ays({prospectId:t,prospectName:s,brokerageId:r}){var U;const{data:n=[],isLoading:a}=tys(t),{data:o=[]}=WJe(r),l=sys(),i=iS(),d=HJe(),[u,p]=S.useState("idle"),[f,v]=S.useState(0),[_,b]=S.useState(0),[j,w]=S.useState(""),[N,C]=S.useState(""),[A,I]=S.useState(!1),L=((U=o.find(V=>V.id===j))==null?void 0:U.script_text)||"",R=()=>{p("idle"),v(0),b(0),w(""),C("")},$=S.useCallback(async(V,X)=>{p("uploading");try{const se=`Recruiting: ${s}`,{videoId:te,libraryId:Y}=await KL(se),{uploadUrl:de,apiKey:ie}=await ZL(te),ae=new XMLHttpRequest;ae.upload.onprogress=_e=>{_e.lengthComputable&&v(_e.loaded/_e.total*100)},await new Promise((_e,Ce)=>{ae.onload=()=>ae.status>=200&&ae.status<300?_e():Ce(new Error("Upload failed")),ae.onerror=()=>Ce(new Error("Upload failed")),ae.open("PUT",de),ae.setRequestHeader("AccessKey",ie),ae.send(V)}),p("processing");let le=0;const pe=Date.now(),be=9e4,ye=`https://iframe.mediadelivery.net/embed/${Y}/${te}`;for(;le<4&&(await new Promise(Ce=>setTimeout(Ce,3e3)),!(Date.now()-pe>be));){const _e=await M3(te);if(le=_e.status,b(_e.encodeProgress||0),le===5||le===6)throw new Error("Video processing failed")}const we=await M3(te),ke=(we.storageSize||V.size)/(1024*1024),Ze=await i.mutateAsync({bunny_video_id:te,playback_url:we.directPlayUrl||ye,thumbnail_url:we.thumbnailUrl,preview_url:we.previewUrl||null,duration_seconds:we.length||X,file_size_mb:ke,title:se,status:le>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:Ze.id,brokerage_id:r,message:N||void 0}),p("done"),fe.success("Video recorded and linked to prospect!"),setTimeout(()=>{I(!1),R()},1500)}catch(se){fe.error(se.message||"Failed to upload video"),p("record")}},[t,s,r,N,i,l]),q=V=>{V&&(navigator.clipboard.writeText(`${window.location.origin}/recruit-video/${V}`),fe.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(kn,{className:"h-4 w-4"})," Video Outreach"]}),e.jsxs(vs,{open:A,onOpenChange:V=>{!V&&(u==="uploading"||u==="processing")||(I(V),V||R())},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>p("script"),children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Record Video"]})}),e.jsxs(ys,{className:"max-w-2xl",children:[e.jsx(Ss,{children:e.jsxs(Ns,{children:["Record Video for ",s]})}),u==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Choose a Script (optional)"}),e.jsxs(tr,{value:j,onValueChange:w,children:[e.jsx(Js,{className:"mt-1",children:e.jsx(sr,{placeholder:"No script — speak freely"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No script"}),o.map(V=>{var X;return e.jsx(At,{value:V.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[V.title,e.jsx(at,{variant:"outline",className:"text-[9px] ml-1",children:(X=H0e.find(se=>se.value===V.category))==null?void 0:X.label})]})},V.id)})]})]}),L&&e.jsx("div",{className:"mt-2 p-3 bg-muted/50 rounded-md text-sm max-h-32 overflow-y-auto whitespace-pre-wrap",children:L})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Personal Message (shown on landing page)"}),e.jsx(Mr,{value:N,onChange:V=>C(V.target.value),placeholder:`Hi ${s.split(" ")[0]}, I'd love to chat about what we're building here...`,rows:3,className:"mt-1"})]}),e.jsxs(K,{onClick:()=>p("record"),className:"w-full",children:[e.jsx(kn,{className:"h-4 w-4 mr-2"})," Start Recording"]})]}),u==="record"&&e.jsx(Tce,{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(Ti,{value:f,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(f),"%"]})]}),u==="processing"&&e.jsxs("div",{className:"py-8 space-y-4 text-center",children:[e.jsx("p",{className:"font-medium",children:"Processing video…"}),e.jsx(Ti,{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(ul,{className:"h-6 w-6 text-emerald-600"})}),e.jsx("p",{className:"font-medium text-emerald-600",children:"Video ready!"})]})]})]})]}),a?e.jsx("div",{className:"text-center py-4",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent mx-auto"})}):n.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No videos sent yet"}):e.jsx("div",{className:"space-y-2",children:n.map(V=>{var X,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:(X=V.video)!=null&&X.thumbnail_url?e.jsx("img",{src:V.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(kn,{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=V.video)==null?void 0:se.title)||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[V.view_count>0?e.jsxs(at,{variant:"secondary",className:"text-[9px] h-4",children:[e.jsx(ya,{className:"h-2.5 w-2.5 mr-0.5"}),V.view_count]}):V.sent_at?e.jsxs(at,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(ka,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(at,{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:ws(new Date(V.created_at),"MMM d")})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>q(V.share_token),children:e.jsx(ni,{className:"h-3 w-3"})}),!V.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>d.mutate({id:V.id,sent_via:"email"}),children:e.jsx(ka,{className:"h-3 w-3"})})]})]},V.id)})})]})}const RLe=[{value:"call",label:"Phone Call",icon:Zn},{value:"email",label:"Email",icon:_r},{value:"text",label:"Text Message",icon:oo},{value:"meeting",label:"Meeting",icon:on},{value:"note",label:"Note",icon:In}];function Qm({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 MR({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(sn,{className:"h-3 w-3 opacity-50"})]}):null}function Zl({label:t,value:s,onChange:r,type:n="text",placeholder:a}){return e.jsxs("div",{children:[e.jsx(ve,{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 GJe({prospect:t,stages:s,brokerageId:r,open:n,onOpenChange:a,onUpdate:o,onDelete:l}){const{activities:i,addActivity:d}=Jxs((t==null?void 0:t.id)||null),[u,p]=S.useState({type:"note",title:"",description:""}),[f,v]=S.useState(!1),[_,b]=S.useState(!1),[j,w]=S.useState({});if(!t)return null;const N=()=>{var X,se;w({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:((X=t.experience_years)==null?void 0:X.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)},C=()=>{const X={id:t.id};for(const[se,te]of Object.entries(j))se==="experience_years"||se==="last_year_transactions"?X[se]=te?parseInt(te):null:X[se]=te||null;o(X),b(!1)},A=()=>b(!1),I=X=>se=>w(te=>({...te,[X]:se})),L=()=>{u.title.trim()&&(d.mutate({prospect_id:t.id,activity_type:u.type,title:u.title,description:u.description||null}),p({type:"note",title:"",description:""}),v(!1))},R=s.find(X=>X.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,U=t.linkedin_url||t.website_url||t.instagram_handle||t.facebook_url,V=t.birthday||t.spouse_name||t.interests||t.referred_by;return e.jsx(gM,{open:n,onOpenChange:X=>{X||b(!1),a(X)},children:e.jsx(rS,{className:"w-full sm:max-w-lg p-0",children:e.jsx(Bi,{className:"h-full",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsx(xM,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(yM,{className:"text-xl",children:[t.first_name," ",t.last_name]}),R&&e.jsx(at,{variant:"outline",style:{borderColor:R.color,color:R.color},className:"mt-1",children:R.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[_?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:A,children:e.jsx(Ur,{className:"h-4 w-4"})}),e.jsx(K,{variant:"default",size:"icon",onClick:C,children:e.jsx(Bu,{className:"h-4 w-4"})})]}):e.jsx(K,{variant:"ghost",size:"icon",onClick:N,title:"Edit prospect",children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsxs(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete prospect?"}),e.jsx(Dl,{children:"This will permanently remove this prospect and all their activity history."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{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(_r,{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(Zn,{className:"h-3.5 w-3.5"})," ",t.phone]}),$&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Ai,{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(ve,{className:"text-xs text-muted-foreground",children:"Move to Stage"}),e.jsxs(tr,{value:t.stage_id||"",onValueChange:X=>o({id:t.id,stage_id:X}),children:[e.jsx(Js,{className:"mt-1",children:e.jsx(sr,{})}),e.jsx(er,{children:s.map(X=>e.jsx(At,{value:X.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:X.color}}),X.name]})},X.id))})]})]}),e.jsxs(Na,{defaultValue:"details",className:"w-full",children:[e.jsxs(va,{className:"grid w-full grid-cols-4 h-8 text-xs",children:[e.jsx(ks,{value:"details",className:"text-xs",children:"Details"}),e.jsx(ks,{value:"production",className:"text-xs",children:"Production"}),e.jsx(ks,{value:"social",className:"text-xs",children:"Social"}),e.jsx(ks,{value:"personal",className:"text-xs",children:"Personal"})]}),_?e.jsxs(e.Fragment,{children:[e.jsxs(zs,{value:"details",className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Zl,{label:"First Name",value:j.first_name,onChange:I("first_name")}),e.jsx(Zl,{label:"Last Name",value:j.last_name,onChange:I("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Zl,{label:"Email",value:j.email,onChange:I("email"),type:"email"}),e.jsx(Zl,{label:"Phone",value:j.phone,onChange:I("phone")})]}),e.jsx(Zl,{label:"Current Brokerage",value:j.current_brokerage,onChange:I("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Zl,{label:"License #",value:j.license_number,onChange:I("license_number")}),e.jsx(Zl,{label:"Experience (years)",value:j.experience_years,onChange:I("experience_years"),type:"number"})]}),e.jsx(Zl,{label:"Address",value:j.address,onChange:I("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(Zl,{label:"City",value:j.city,onChange:I("city")}),e.jsx(Zl,{label:"State",value:j.state,onChange:I("state")}),e.jsx(Zl,{label:"Zip",value:j.zip_code,onChange:I("zip_code")})]}),e.jsx(Zl,{label:"Source",value:j.source,onChange:I("source")}),e.jsx(Zl,{label:"Referred By",value:j.referred_by,onChange:I("referred_by")}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Notes"}),e.jsx(Mr,{value:j.notes,onChange:X=>w(se=>({...se,notes:X.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs(zs,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(Zl,{label:"Annual Production",value:j.annual_production,onChange:I("annual_production"),placeholder:"e.g. $5M"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Zl,{label:"Last Year Volume",value:j.last_year_volume,onChange:I("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(Zl,{label:"Last Year Transactions",value:j.last_year_transactions,onChange:I("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(Zl,{label:"Avg Sale Price",value:j.avg_sale_price,onChange:I("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(Zl,{label:"Specialties / Niche",value:j.specialties,onChange:I("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs(zs,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(Zl,{label:"LinkedIn URL",value:j.linkedin_url,onChange:I("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(Zl,{label:"Website URL",value:j.website_url,onChange:I("website_url"),type:"url",placeholder:"https://..."}),e.jsx(Zl,{label:"Instagram Handle",value:j.instagram_handle,onChange:I("instagram_handle"),placeholder:"@handle"}),e.jsx(Zl,{label:"Facebook URL",value:j.facebook_url,onChange:I("facebook_url"),type:"url",placeholder:"https://facebook.com/..."})]}),e.jsxs(zs,{value:"personal",className:"mt-3 space-y-3",children:[e.jsx(Zl,{label:"Birthday",value:j.birthday,onChange:I("birthday"),type:"date"}),e.jsx(Zl,{label:"Spouse / Partner",value:j.spouse_name,onChange:I("spouse_name")}),e.jsx(Zl,{label:"Interests / Hobbies",value:j.interests,onChange:I("interests"),placeholder:"Golf, travel, community events..."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(zs,{value:"details",className:"mt-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Qm,{label:"Current Brokerage",value:t.current_brokerage}),e.jsx(Qm,{label:"License #",value:t.license_number}),e.jsx(Qm,{label:"Experience",value:t.experience_years!=null?`${t.experience_years} years`:null}),e.jsx(Qm,{label:"Referred By",value:t.referred_by}),e.jsx(Qm,{label:"Source",value:t.source})]}),t.notes&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Notes"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.notes})]})]}),e.jsx(zs,{value:"production",className:"mt-3",children:q?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Qm,{label:"Annual Production",value:t.annual_production}),e.jsx(Qm,{label:"Last Year Volume",value:t.last_year_volume}),e.jsx(Qm,{label:"Last Year Transactions",value:t.last_year_transactions}),e.jsx(Qm,{label:"Avg Sale Price",value:t.avg_sale_price}),e.jsx(Qm,{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(zs,{value:"social",className:"mt-3",children:U?e.jsxs("div",{className:"space-y-2",children:[e.jsx(MR,{label:"LinkedIn",url:t.linkedin_url,icon:Lm}),e.jsx(MR,{label:"Website",url:t.website_url,icon:Pm}),t.instagram_handle&&e.jsx(MR,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:Wd}),e.jsx(MR,{label:"Facebook",url:t.facebook_url,icon:Hd})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No social profiles added yet"})}),e.jsx(zs,{value:"personal",className:"mt-3",children:V?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Qm,{label:"Birthday",value:t.birthday?ws(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:io}),e.jsx(Qm,{label:"Spouse / Partner",value:t.spouse_name,icon:Si}),e.jsx("div",{className:"col-span-2",children:e.jsx(Qm,{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(ays,{prospectId:t.id,prospectName:`${t.first_name} ${t.last_name||""}`,brokerageId:r}),e.jsx(Rl,{}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-semibold text-sm",children:"Activity Log"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>v(!f),children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Log Activity"]})]}),f&&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:X=>p(se=>({...se,type:X})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:RLe.map(X=>e.jsx(At,{value:X.value,children:X.label},X.value))})]}),e.jsx(Re,{placeholder:"Subject / Title",value:u.title,onChange:X=>p(se=>({...se,title:X.target.value}))}),e.jsx(Mr,{placeholder:"Details (optional)",value:u.description,onChange:X=>p(se=>({...se,description:X.target.value})),rows:2}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>v(!1),children:"Cancel"}),e.jsx(K,{size:"sm",onClick: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(X=>{const se=RLe.find(Y=>Y.value===X.activity_type),te=(se==null?void 0:se.icon)||In;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:X.title}),X.description&&e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:X.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ws(new Date(X.created_at),"MMM d, yyyy h:mm a")})]})]},X.id)})]})]})]})})})})}const FLe=["first_name","last_name","email","phone","current_brokerage","license_number","experience_years","annual_production","notes"];function KJe({open:t,onOpenChange:s,brokerageId:r,stages:n}){var V;const{toast:a}=Ia(),o=ns(),l=S.useRef(null),[i,d]=S.useState([]),[u,p]=S.useState([]),[f,v]=S.useState({}),[_,b]=S.useState(((V=n[0])==null?void 0:V.id)||""),[j,w]=S.useState(!1),[N,C]=S.useState("upload"),[A,I]=S.useState(0),L=()=>{d([]),p([]),v({}),C("upload"),I(0)},R=X=>{var Y;const se=(Y=X.target.files)==null?void 0:Y[0];if(!se)return;const te=new FileReader;te.onload=de=>{var ye;const ae=((ye=de.target)==null?void 0:ye.result).split(/\r?\n/).filter(we=>we.trim());if(ae.length<2){a({title:"Invalid CSV",description:"File must have a header row and at least one data row",variant:"destructive"});return}const le=$(ae[0]);p(le);const pe={};le.forEach((we,ke)=>{const Ze=we.toLowerCase().replace(/[^a-z]/g,"_").replace(/_+/g,"_"),_e=FLe.find(Ce=>Ze.includes(Ce)||Ce.includes(Ze)||Ce==="first_name"&&(Ze.includes("first")||Ze==="name")||Ce==="last_name"&&Ze.includes("last")||Ce==="current_brokerage"&&(Ze.includes("brokerage")||Ze.includes("company"))||Ce==="license_number"&&Ze.includes("license")||Ce==="experience_years"&&(Ze.includes("experience")||Ze.includes("years"))||Ce==="annual_production"&&(Ze.includes("production")||Ze.includes("volume")));_e&&(pe[String(ke)]=_e)}),v(pe);const be=ae.slice(1).map(we=>{const ke=$(we),Ze={};return le.forEach((_e,Ce)=>{Ze[String(Ce)]=ke[Ce]||""}),Ze});d(be),C("map")},te.readAsText(se)},$=X=>{const se=[];let te="",Y=!1;for(const de of X)de==='"'?Y=!Y:de===","&&!Y?(se.push(te.trim()),te=""):te+=de;return se.push(te.trim()),se},q=async()=>{w(!0);try{const{data:{user:X}}=await G.auth.getUser();if(!X)throw new Error("Not authenticated");const se=i.map(Y=>{const de={brokerage_id:r,created_by:X.id,stage_id:_,source:"csv_import",first_name:"Unknown"};return Object.entries(f).forEach(([ie,ae])=>{var pe;const le=(pe=Y[ie])==null?void 0:pe.trim();le&&(ae==="experience_years"?de[ae]=parseInt(le)||null:de[ae]=le)}),de});let te=0;for(let Y=0;Y{const X=`first_name,last_name,email,phone,current_brokerage,license_number,experience_years,annual_production,notes Jane,Smith,jane@example.com,555-0100,ABC Realty,RE12345,8,$5M,Met at conference`,se=new Blob([X],{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(vs,{open:t,onOpenChange:X=>{X||L(),s(X)},children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{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(C0,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Upload a CSV file with prospect data"}),e.jsx("input",{ref:l,type:"file",accept:".csv",className:"hidden",onChange:R}),e.jsxs(K,{onClick:()=>{var X;return(X=l.current)==null?void 0:X.click()},children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"})," Choose File"]})]}),e.jsx(K,{variant:"link",className:"text-xs",onClick:U,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(sr,{})}),e.jsx(er,{children:n.map(X=>e.jsx(At,{value:X.id,children:X.name},X.id))})]})]})]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-[140px]",children:"CSV Column"}),e.jsx(jt,{className:"w-[160px]",children:"Map To"}),e.jsx(jt,{children:"Preview"})]})}),e.jsx(Pn,{children:u.map((X,se)=>{var te;return e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium text-xs",children:X}),e.jsx(lt,{children:e.jsxs(tr,{value:f[String(se)]||"skip",onValueChange:Y=>v(de=>({...de,[String(se)]:Y==="skip"?"":Y})),children:[e.jsx(Js,{className:"h-8 text-xs",children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"skip",children:"— Skip —"}),FLe.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(f).includes("first_name")&&e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-sm",children:[e.jsx(Qo,{className:"h-4 w-4"}),' Map at least "first name" to proceed']}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>{L()},children:"Back"}),e.jsx(K,{onClick:q,disabled:j||!Object.values(f).includes("first_name"),children:j?"Importing...":`Import ${i.length} Prospects`})]})]}),N==="done"&&e.jsxs("div",{className:"text-center py-6 space-y-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-green-500/10 flex items-center justify-center mx-auto",children:e.jsx(ua,{className:"h-6 w-6 text-green-600"})}),e.jsxs("p",{className:"font-semibold",children:[A," prospects imported successfully!"]}),e.jsx(K,{onClick:()=>{L(),s(!1)},children:"Close"})]})]})})}function iys({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=Ace(t),[i,d]=S.useState(!1),[u,p]=S.useState(),[f,v]=S.useState(null),[_,b]=S.useState(!1),[j,w]=S.useState(!1),[N,C]=S.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=U=>r.filter(V=>V.stage_id===U),I=(U,V)=>{C(V),U.dataTransfer.effectAllowed="move"},L=U=>{U.preventDefault(),U.dataTransfer.dropEffect="move"},R=(U,V)=>{U.preventDefault(),N&&(o.mutate({id:N,stage_id:V}),C(null))},$=U=>{p(U),d(!0)},q=U=>{v(U),b(!0)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.length," prospect",r.length!==1?"s":""]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>w(!0),children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>{p(void 0),d(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs(Bi,{className:"w-full",children:[e.jsx("div",{className:"flex gap-4 pb-4",style:{minWidth:s.length*300},children:s.map(U=>{const V=A(U.id);return e.jsxs("div",{className:"w-[280px] flex-shrink-0 flex flex-col",onDragOver:L,onDrop:X=>R(X,U.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:U.color}}),e.jsx("h3",{className:"font-semibold text-sm",children:U.name}),e.jsx(at,{variant:"secondary",className:"text-xs h-5 px-1.5",children:V.length})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>$(U.id),children:e.jsx(Zs,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"space-y-2 min-h-[200px] bg-muted/30 rounded-lg p-2",children:V.map(X=>e.jsx(Ee,{className:"p-3 cursor-pointer hover:shadow-md transition-shadow border-l-4 group",style:{borderLeftColor:U.color},draggable:!0,onDragStart:se=>I(se,X.id),onClick:()=>q(X),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Fu,{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(Xi,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"font-medium text-sm truncate",children:[X.first_name," ",X.last_name]})]}),X.current_brokerage&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Aa,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:X.current_brokerage})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[X.email&&e.jsx(_r,{className:"h-3 w-3 text-muted-foreground"}),X.phone&&e.jsx(Zn,{className:"h-3 w-3 text-muted-foreground"}),X.experience_years!=null&&e.jsxs(at,{variant:"secondary",className:"text-[10px] h-4 px-1",children:[X.experience_years,"yr"]})]})]})]})},X.id))})]},U.id)})}),e.jsx(Ioe,{orientation:"horizontal"})]}),e.jsx(VJe,{open:i,onOpenChange:d,stages:s,defaultStageId:u,onSubmit:U=>a.mutate(U),isSubmitting:a.isPending}),e.jsx(GJe,{prospect:f,stages:s,brokerageId:t,open:_,onOpenChange:b,onUpdate:U=>{o.mutate(U),v(V=>V?{...V,...U}:null)},onDelete:U=>l.mutate(U)}),e.jsx(KJe,{open:j,onOpenChange:w,brokerageId:t,stages:s})]})}function oys({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=Ace(t),[i,d]=S.useState(!1),[u,p]=S.useState(null),[f,v]=S.useState(!1),[_,b]=S.useState(!1),[j,w]=S.useState(""),[N,C]=S.useState("all"),[A,I]=S.useState(null),[L,R]=S.useState("asc"),$=X=>{A===X?R(se=>se==="asc"?"desc":"asc"):(I(X),R("asc"))},q=({column:X})=>A!==X?e.jsx(Hc,{className:"h-3.5 w-3.5 ml-1 text-muted-foreground/50"}):L==="asc"?e.jsx(Vd,{className:"h-3.5 w-3.5 ml-1 text-primary"}):e.jsx(eh,{className:"h-3.5 w-3.5 ml-1 text-primary"}),U=X=>s.find(se=>se.id===X),V=S.useMemo(()=>{let X=r.filter(se=>{var de,ie;const te=!j||`${se.first_name} ${se.last_name}`.toLowerCase().includes(j.toLowerCase())||((de=se.email)==null?void 0:de.toLowerCase().includes(j.toLowerCase()))||((ie=se.current_brokerage)==null?void 0:ie.toLowerCase().includes(j.toLowerCase())),Y=N==="all"||se.stage_id===N;return te&&Y});return A&&(X=[...X].sort((se,te)=>{var ae,le;let Y=null,de=null;switch(A){case"name":Y=`${se.first_name} ${se.last_name||""}`.toLowerCase(),de=`${te.first_name} ${te.last_name||""}`.toLowerCase();break;case"stage":Y=((ae=U(se.stage_id))==null?void 0:ae.sort_order)??999,de=((le=U(te.stage_id))==null?void 0:le.sort_order)??999;break;case"brokerage":Y=(se.current_brokerage||"").toLowerCase(),de=(te.current_brokerage||"").toLowerCase();break;case"experience":Y=se.experience_years??-1,de=te.experience_years??-1;break;case"production":Y=(se.annual_production||"").toLowerCase(),de=(te.annual_production||"").toLowerCase();break;case"source":Y=(se.source||"").toLowerCase(),de=(te.source||"").toLowerCase();break;default:return 0}if(Y===de)return 0;if(Y==null)return 1;if(de==null)return-1;const ie=Yw(X.target.value),className:"pl-8"})]}),e.jsxs(tr,{value:N,onValueChange:C,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{placeholder:"All stages"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All stages"}),s.map(X=>e.jsx(At,{value:X.id,children:X.name},X.id))]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>b(!0),children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>d(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{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(jt,{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(jt,{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(jt,{className:"hidden md:table-cell",children:"Contact"}),e.jsx(jt,{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(jt,{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(jt,{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(jt,{className:"w-[50px]"})]})}),e.jsx(Pn,{children:V.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:8,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):V.map(X=>{const se=U(X.stage_id);return e.jsxs(js,{className:"cursor-pointer",onClick:()=>{p(X),v(!0)},children:[e.jsxs(lt,{className:"font-medium",children:[X.first_name," ",X.last_name]}),e.jsx(lt,{children:se?e.jsxs(at,{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:X.current_brokerage?e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(Aa,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:X.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:[X.email&&e.jsx(_r,{className:"h-3.5 w-3.5 text-muted-foreground"}),X.phone&&e.jsx(Zn,{className:"h-3.5 w-3.5 text-muted-foreground"}),!X.email&&!X.phone&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]})}),e.jsx(lt,{className:"hidden lg:table-cell",children:X.experience_years!=null?`${X.experience_years} yr`:"—"}),e.jsx(lt,{className:"hidden lg:table-cell",children:X.annual_production||"—"}),e.jsx(lt,{className:"hidden lg:table-cell",children:X.source?e.jsx(at,{variant:"secondary",className:"text-xs",children:X.source}):"—"}),e.jsx(lt,{children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:te=>{te.stopPropagation(),l.mutate(X.id)},children:e.jsx(br,{className:"h-3.5 w-3.5"})})})]},X.id)})})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[V.length," of ",r.length," prospects"]}),e.jsx(VJe,{open:i,onOpenChange:d,stages:s,onSubmit:X=>a.mutate(X),isSubmitting:a.isPending}),e.jsx(GJe,{prospect:u,stages:s,brokerageId:t,open:f,onOpenChange:v,onUpdate:X=>{o.mutate(X),p(se=>se?{...se,...X}:null)},onDelete:X=>l.mutate(X)}),e.jsx(KJe,{open:_,onOpenChange:b,brokerageId:t,stages:s})]})}function lys({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=Ace(t),a=S.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",p=new Date,f=o>0?Math.round(r.reduce((N,C)=>N+Gg(p,new Date(C.created_at)),0)/o):0,v=s.map(N=>({...N,count:r.filter(C=>C.stage_id===N.id).length})),_={};r.forEach(N=>{const C=N.source||"unknown";_[C]=(_[C]||0)+1});const b=Object.entries(_).sort((N,C)=>C[1]-N[1]),j=new Date;j.setDate(j.getDate()-30);const w=r.filter(N=>new Date(N.created_at)>=j).length;return{total:o,signed:d,conversionRate:u,avgDays:f,byStage:v,bySrc:b,recentCount:w}},[s,r]);return n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(hr,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Prospects"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-500/10 flex items-center justify-center",children:e.jsx(Cc,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:[a.conversionRate,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Conversion Rate"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-amber-500/10 flex items-center justify-center",children:e.jsx(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(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-violet-500/10 flex items-center justify-center",children:e.jsx(Hh,{className:"h-5 w-5 text-violet-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.recentCount}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Added (30 days)"})]})]})})})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Pipeline Breakdown"})}),e.jsx(Oe,{className:"space-y-3",children:a.byStage.map(o=>{const l=a.total>0?o.count/a.total*100:0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:o.color}}),e.jsx("span",{children:o.name})]}),e.jsx("span",{className:"font-medium",children:o.count})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${l}%`,backgroundColor:o.color}})})]},o.id)})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(at,{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 zLe=[{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 cys({brokerageId:t}){const{toast:s}=Ia(),[r,n]=S.useState(null),[a,o]=S.useState(null),l=(d,u)=>{navigator.clipboard.writeText(d),n(u),s({title:"Copied to clipboard!"}),setTimeout(()=>n(null),2e3)},i=[...new Set(zLe.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(_r,{className:"h-4 w-4"})," ",d]}),zLe.filter(u=>u.category===d).map(u=>e.jsxs(Ee,{className:`cursor-pointer transition-all ${a===u.id?"ring-2 ring-primary/20":"hover:shadow-sm"}`,onClick:()=>o(a===u.id?null:u.id),children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{className:"text-sm",children:u.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Subject: ",u.subject]})]}),e.jsx(at,{variant:"secondary",className:"text-[10px]",children:u.category})]})}),a===u.id&&e.jsxs(Oe,{className:"pt-0 space-y-3",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Subject Line:"}),e.jsx("p",{className:"text-sm mb-3",children:u.subject}),e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Body:"}),e.jsx("pre",{className:"text-sm whitespace-pre-wrap font-sans",children:u.body})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:p=>{p.stopPropagation(),l(u.subject,u.id+"-subject")},children:[r===u.id+"-subject"?e.jsx(ua,{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(K,{size:"sm",onClick:p=>{p.stopPropagation(),l(u.body,u.id+"-body")},children:[r===u.id+"-body"?e.jsx(ua,{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 BLe={call:Zn,email:_r,text:oo,meeting:on,note:In};function dys({brokerageId:t}){const{data:s,isLoading:r}=Ct({queryKey:["recruit-activity-report",t],queryFn:async()=>{const{data:n,error:a}=await G.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 G.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 G.from("profiles").select("id, name, email").in("id",d),p=Object.fromEntries((u||[]).map(_=>[_.id,_])),f=sre(new Date,30);return{recruiters:d.map(_=>{var C,A;const b=(l||[]).filter(I=>I.created_by===_),j=b.filter(I=>new Date(I.created_at)>=f),w={};j.forEach(I=>{w[I.activity_type]=(w[I.activity_type]||0)+1});const N=n.filter(I=>I.created_by===_).length;return{id:_,name:((C=p[_])==null?void 0:C.name)||"Unknown",email:((A=p[_])==null?void 0:A.email)||"",totalActivities:b.length,recentActivities:j.length,byType:w,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(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(Xi,{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=BLe[o]||In;return e.jsxs(at,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(i,{className:"h-2.5 w-2.5"})," ",l," ",o,l!==1?"s":""]},o)})})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-lg font-bold",children:n.recentActivities}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"activities"})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-lg font-bold",children:n.prospectsCreated}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"prospects"})]})]},n.id))})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Recent Activity"})}),e.jsx(Oe,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=BLe[n.activity_type]||In;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:ws(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 uys({brokerageId:t}){const{toast:s}=Ia(),r=ns(),[n,a]=S.useState(!1),[o,l]=S.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),{data:i=[],isLoading:d}=Ct({queryKey:["recruit-referrals",t],queryFn:async()=>{const{data:w,error:N}=await G.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(N)throw N;return w}}),u=[...new Set(i.map(w=>w.referred_by))],{data:p=[]}=Ct({queryKey:["referral-profiles",u],queryFn:async()=>{if(!u.length)return[];const{data:w}=await G.from("profiles").select("id, name, email").in("id",u);return w||[]},enabled:u.length>0}),f=Object.fromEntries(p.map(w=>[w.id,w])),v=Ot({mutationFn:async w=>{const{data:{user:N}}=await G.auth.getUser();if(!N)throw new Error("Not authenticated");const{error:C}=await G.from("recruit_referrals").insert({brokerage_id:t,referred_by:N.id,referee_first_name:w.first_name,referee_last_name:w.last_name||null,referee_email:w.email||null,referee_phone:w.phone||null,referee_current_brokerage:w.current_brokerage||null,notes:w.notes||null});if(C)throw C},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-referrals",t]}),s({title:"Referral submitted!"}),l({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),a(!1)},onError:w=>s({title:"Error",description:w.message,variant:"destructive"})}),_=Ot({mutationFn:async({id:w,status:N,incentive_status:C})=>{const A={updated_at:new Date().toISOString()};N&&(A.status=N),C&&(A.incentive_status=C);const{error:I}=await G.from("recruit_referrals").update(A).eq("id",w);if(I)throw I},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-referrals",t]})}),b=w=>w==="approved"||w==="signed"?e.jsx(ua,{className:"h-3 w-3"}):w==="rejected"?e.jsx(kc,{className:"h-3 w-3"}):e.jsx(Tn,{className:"h-3 w-3"}),j=w=>w==="approved"||w==="signed"||w==="paid"?"bg-green-500/10 text-green-600 border-green-200":w==="rejected"?"bg-red-500/10 text-red-600 border-red-200":"bg-amber-500/10 text-amber-600 border-amber-200";return 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(K,{onClick:()=>a(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," Submit Referral"]})]}),i.length===0?e.jsxs(Ee,{className:"py-12 text-center",children:[e.jsx(xc,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No referrals yet. Agents can refer potential recruits here."})]}):e.jsx("div",{className:"space-y-3",children:i.map(w=>{var N;return e.jsx(Ee,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-medium",children:[w.referee_first_name," ",w.referee_last_name]}),e.jsxs(at,{variant:"outline",className:j(w.status),children:[b(w.status)," ",w.status]}),w.incentive_status&&e.jsxs(at,{variant:"outline",className:j(w.incentive_status),children:[e.jsx(io,{className:"h-3 w-3 mr-1"})," ",w.incentive_status]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[w.referee_email&&e.jsx("p",{children:w.referee_email}),w.referee_phone&&e.jsx("p",{children:w.referee_phone}),w.referee_current_brokerage&&e.jsxs("p",{children:["Currently at: ",w.referee_current_brokerage]}),e.jsxs("p",{children:["Referred by: ",((N=f[w.referred_by])==null?void 0:N.name)||"Unknown"," • ",ws(new Date(w.created_at),"MMM d, yyyy")]})]}),w.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 italic",children:w.notes})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(tr,{value:w.status,onValueChange:C=>_.mutate({id:w.id,status:C}),children:[e.jsx(Js,{className:"h-7 text-xs w-[110px]",children:e.jsx(sr,{})}),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:w.incentive_status||"pending",onValueChange:C=>_.mutate({id:w.id,incentive_status:C}),children:[e.jsx(Js,{className:"h-7 text-xs w-[100px]",children:e.jsx(sr,{})}),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"})]})]})]})]})},w.id)})}),e.jsx(vs,{open:n,onOpenChange:a,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Submit a Recruit Referral"})}),e.jsxs("form",{onSubmit:w=>{w.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(ve,{children:"First Name *"}),e.jsx(Re,{required:!0,value:o.first_name,onChange:w=>l(N=>({...N,first_name:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Last Name"}),e.jsx(Re,{value:o.last_name,onChange:w=>l(N=>({...N,last_name:w.target.value}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Email"}),e.jsx(Re,{type:"email",value:o.email,onChange:w=>l(N=>({...N,email:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Phone"}),e.jsx(Re,{value:o.phone,onChange:w=>l(N=>({...N,phone:w.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Current Brokerage"}),e.jsx(Re,{value:o.current_brokerage,onChange:w=>l(N=>({...N,current_brokerage:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Notes"}),e.jsx(Mr,{value:o.notes,onChange:w=>l(N=>({...N,notes:w.target.value})),rows:2})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:v.isPending,children:"Submit"})]})]})]})})]})}function hys({brokerageId:t}){const{toast:s}=Ia(),r=ns(),[n,a]=S.useState(!1),{data:o}=Ct({queryKey:["brokerage-recruit-form",t],queryFn:async()=>{const{data:v,error:_}=await G.from("brokerages").select("id, name, recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(_)throw _;return v}}),{data:l=[]}=Ct({queryKey:["recruit-interest-submissions",t],queryFn:async()=>{const{data:v,error:_}=await G.from("recruit_interest_submissions").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(_)throw _;return v}}),i=Ot({mutationFn:async v=>{const{error:_}=await G.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=Ot({mutationFn:async({id:v,status:_})=>{const{error:b}=await G.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)||""}`,p=()=>{navigator.clipboard.writeText(u),a(!0),s({title:"Link copied!"}),setTimeout(()=>a(!1),2e3)},f=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(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(ve,{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(Br,{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(K,{size:"sm",variant:"outline",onClick:p,children:n?e.jsx(ua,{className:"h-3.5 w-3.5"}):e.jsx(ni,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:e.jsx(sn,{className:"h-3.5 w-3.5"})})})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{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(xc,{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(at,{variant:"outline",className:f(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(_r,{className:"h-3 w-3"}),v.email]}),v.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Zn,{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:ws(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(sr,{})}),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 mys({brokerageId:t}){const{toast:s}=Ia(),r=ns(),[n,a]=S.useState(!1),[o,l]=S.useState({prospect_id:"",title:"",description:"",due_date:ws(ml(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,d]=S.useState("pending"),{data:u=[]}=Ct({queryKey:["recruit-prospects-list",t],queryFn:async()=>{const{data:L,error:R}=await G.from("recruit_prospects").select("id, first_name, last_name").eq("brokerage_id",t).order("first_name");if(R)throw R;return L}}),{data:p=[],isLoading:f}=Ct({queryKey:["recruit-follow-ups",t],queryFn:async()=>{const L=u.map(q=>q.id);if(!L.length)return[];const{data:R,error:$}=await G.from("recruit_follow_ups").select("*").in("prospect_id",L).order("due_date");if($)throw $;return R},enabled:u.length>0}),v=Object.fromEntries(u.map(L=>[L.id,L])),_=Ot({mutationFn:async L=>{const{data:{user:R}}=await G.auth.getUser();if(!R)throw new Error("Not authenticated");const{error:$}=await G.from("recruit_follow_ups").insert({prospect_id:L.prospect_id,assigned_to:R.id,title:L.title,description:L.description||null,due_date:new Date(L.due_date).toISOString()});if($)throw $},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-follow-ups",t]}),s({title:"Follow-up scheduled"}),l({prospect_id:"",title:"",description:"",due_date:ws(ml(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:L=>s({title:"Error",description:L.message,variant:"destructive"})}),b=Ot({mutationFn:async({id:L,completed:R})=>{const{error:$}=await G.from("recruit_follow_ups").update({completed_at:R?new Date().toISOString():null}).eq("id",L);if($)throw $},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-follow-ups",t]})}),j=p.filter(L=>i==="pending"?!L.completed_at:i==="completed"?!!L.completed_at:!0),w=j.filter(L=>!L.completed_at&&Xx(new Date(L.due_date))&&!$d(new Date(L.due_date))),N=j.filter(L=>!L.completed_at&&$d(new Date(L.due_date))),C=j.filter(L=>!L.completed_at&&!Xx(new Date(L.due_date))&&!$d(new Date(L.due_date))),A=j.filter(L=>!!L.completed_at),I=L=>{const R=v[L.prospect_id],$=!L.completed_at&&Xx(new Date(L.due_date))&&!$d(new Date(L.due_date));return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(zo,{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:[R&&e.jsxs(at,{variant:"secondary",className:"text-[10px]",children:[R.first_name," ",R.last_name]}),e.jsxs("span",{className:`flex items-center gap-1 ${$?"text-destructive font-medium":""}`,children:[$?e.jsx(Qo,{className:"h-3 w-3"}):e.jsx(on,{className:"h-3 w-3"}),ws(new Date(L.due_date),"MMM d, h:mm a")]}),L.is_automated&&e.jsx(at,{variant:"outline",className:"text-[10px]",children:"Auto"})]})]})]},L.id)};return f?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex gap-2",children:["pending","completed","all"].map(L=>e.jsxs(K,{size:"sm",variant:i===L?"default":"outline",onClick:()=>d(L),className:"capitalize text-xs",children:[L," ",L==="pending"&&w.length+N.length+C.length>0&&`(${w.length+N.length+C.length})`]},L))}),e.jsxs(K,{size:"sm",onClick:()=>a(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Follow-up"]})]}),i!=="completed"&&w.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-destructive flex items-center gap-1",children:[e.jsx(Qo,{className:"h-3.5 w-3.5"})," Overdue (",w.length,")"]}),w.map(I)]}),i!=="completed"&&N.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-600 flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"})," Today (",N.length,")"]}),N.map(I)]}),i!=="completed"&&C.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(on,{className:"h-3.5 w-3.5"})," Upcoming (",C.length,")"]}),C.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(ua,{className:"h-3.5 w-3.5"})," Completed (",A.length,")"]}),A.map(I)]}),j.length===0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-8",children:["No follow-ups ",i!=="all"?`(${i})`:""]}),e.jsx(vs,{open:n,onOpenChange:a,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Schedule Follow-up"})}),e.jsxs("form",{onSubmit:L=>{L.preventDefault(),_.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Prospect *"}),e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",required:!0,value:o.prospect_id,onChange:L=>l(R=>({...R,prospect_id:L.target.value})),children:[e.jsx("option",{value:"",children:"Select prospect..."}),u.map(L=>e.jsxs("option",{value:L.id,children:[L.first_name," ",L.last_name]},L.id))]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Task *"}),e.jsx(Re,{required:!0,value:o.title,onChange:L=>l(R=>({...R,title:L.target.value})),placeholder:"e.g. Follow-up call"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Details"}),e.jsx(Mr,{value:o.description,onChange:L=>l(R=>({...R,description:L.target.value})),rows:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Due Date *"}),e.jsx(Re,{type:"datetime-local",required:!0,value:o.due_date,onChange:L=>l(R=>({...R,due_date:L.target.value}))})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:_.isPending,children:"Schedule"})]})]})]})})]})}const pys=[{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 fys({brokerageId:t}){const{toast:s}=Ia(),r=ns(),[n,a]=S.useState(null),{data:o,isLoading:l}=Ct({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:w,error:N}=await G.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(N)throw N;return w}}),[i,d]=S.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:pys,testimonials:[],gallery_images:[]});S.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=Ot({mutationFn:async()=>{const w={brokerage_id:t,hero_headline:i.hero_headline,hero_subtext:i.hero_subtext,hero_image_url:i.hero_image_url,logo_url:i.logo_url,primary_color:i.primary_color,accent_color:i.accent_color,benefits:JSON.parse(JSON.stringify(i.benefits)),testimonials:JSON.parse(JSON.stringify(i.testimonials)),gallery_images:JSON.parse(JSON.stringify(i.gallery_images)),updated_at:new Date().toISOString()};if(i.id){const{error:N}=await G.from("recruit_landing_page_settings").update(w).eq("id",i.id);if(N)throw N}else{const{error:N}=await G.from("recruit_landing_page_settings").insert(w);if(N)throw N}},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-landing-settings",t]}),s({title:"Landing page saved!"})},onError:w=>s({title:"Error",description:w.message,variant:"destructive"})}),p=async(w,N)=>{const C=w.name.split(".").pop(),A=`${t}/${N}-${Date.now()}.${C}`,{error:I}=await G.storage.from("recruit-landing").upload(A,w);if(I)throw I;const{data:{publicUrl:L}}=G.storage.from("recruit-landing").getPublicUrl(A);return L},f=async(w,N)=>{var A;const C=(A=w.target.files)==null?void 0:A[0];if(C){a(N);try{const I=await p(C,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 w=>{var C;const N=(C=w.target.files)==null?void 0:C[0];if(N){a("gallery");try{const A=await p(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(w,N)=>{var A;const C=(A=w.target.files)==null?void 0:A[0];if(C){a(`testimonial-${N}`);try{const I=await p(C,`testimonial-${N}`);d(L=>{const R=[...L.testimonials];return R[N]={...R[N],photo_url:I},{...L,testimonials:R}})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},{data:b}=Ct({queryKey:["brokerage-slug-for-landing",t],queryFn:async()=>{const{data:w,error:N}=await G.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(N)throw N;return w}}),j=`${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:j}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:j,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(ve,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.logo_url&&e.jsx("img",{src:i.logo_url,alt:"Logo",className:"h-10 w-auto rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:n==="logo_url",children:e.jsxs("span",{children:[e.jsx(Ya,{className:"h-3.5 w-3.5 mr-1"}),n==="logo_url"?"Uploading...":"Upload Logo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:w=>f(w,"logo_url")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.primary_color,onChange:w=>d(N=>({...N,primary_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Re,{value:i.primary_color,onChange:w=>d(N=>({...N,primary_color:w.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.accent_color,onChange:w=>d(N=>({...N,accent_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Re,{value:i.accent_color,onChange:w=>d(N=>({...N,accent_color:w.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Hero Section"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Headline"}),e.jsx(Re,{value:i.hero_headline,onChange:w=>d(N=>({...N,hero_headline:w.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Subtext"}),e.jsx(Mr,{value:i.hero_subtext,onChange:w=>d(N=>({...N,hero_subtext:w.target.value})),rows:2,placeholder:"Take your career to the next level..."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Background Image"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.hero_image_url&&e.jsx("img",{src:i.hero_image_url,alt:"Hero",className:"h-16 w-28 object-cover rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:n==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(Ya,{className:"h-3.5 w-3.5 mr-1"}),n==="hero_image_url"?"Uploading...":"Upload Image"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:w=>f(w,"hero_image_url")})]}),i.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(w=>({...w,hero_image_url:null})),children:e.jsx(br,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>d(w=>({...w,benefits:[...w.benefits,{title:"",description:"",icon:"✨"}]})),children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Oe,{className:"space-y-3",children:[i.benefits.map((w,N)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Fu,{className:"h-4 w-4 mt-2 text-muted-foreground"}),e.jsx(Re,{value:w.icon,onChange:C=>{const A=[...i.benefits];A[N]={...w,icon:C.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:w.title,onChange:C=>{const A=[...i.benefits];A[N]={...w,title:C.target.value},d(I=>({...I,benefits:A}))},placeholder:"Benefit title"}),e.jsx(Re,{value:w.description,onChange:C=>{const A=[...i.benefits];A[N]={...w,description:C.target.value},d(I=>({...I,benefits:A}))},placeholder:"Short description"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(C=>({...C,benefits:C.benefits.filter((A,I)=>I!==N)})),children:e.jsx(br,{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(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:"Testimonials"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>d(w=>({...w,testimonials:[...w.testimonials,{name:"",role:"",quote:""}]})),children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Oe,{className:"space-y-3",children:[i.testimonials.map((w,N)=>{var C;return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[w.photo_url?e.jsx("img",{src:w.photo_url,alt:w.name,className:"h-10 w-10 rounded-full object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-muted flex items-center justify-center text-xs text-muted-foreground",children:((C=w.name)==null?void 0:C[0])||"?"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("span",{className:"text-[10px] text-primary hover:underline",children:n===`testimonial-${N}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange: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:w.name,onChange:A=>{const I=[...i.testimonials];I[N]={...w,name:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"Name"}),e.jsx(Re,{value:w.role,onChange:A=>{const I=[...i.testimonials];I[N]={...w,role:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"Role / Title"})]}),e.jsx(Mr,{value:w.quote,onChange:A=>{const I=[...i.testimonials];I[N]={...w,quote:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"What they say about working here...",rows:2})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(A=>({...A,testimonials:A.testimonials.filter((I,L)=>L!==N)})),children:e.jsx(br,{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(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:"Team & Culture Gallery"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{size:"sm",variant:"outline",asChild:!0,disabled:n==="gallery",children:e.jsxs("span",{children:[e.jsx(Jo,{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((w,N)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:w,alt:`Gallery ${N+1}`,className:"h-24 w-full object-cover rounded-lg"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(C=>({...C,gallery_images:C.gallery_images.filter((A,I)=>I!==N)})),children:e.jsx(br,{className:"h-3 w-3"})})]},N))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No gallery images added yet"})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:()=>u.mutate(),disabled:u.isPending,size:"lg",children:[e.jsx(Bu,{className:"h-4 w-4 mr-2"}),u.isPending?"Saving...":"Save Landing Page"]})})]})}function gys(t){if(!t)return"—";const s=Math.floor(t/60),r=t%60;return s>0?`${s}m ${r}s`:`${r}s`}function xys({video:t}){return t.cta_clicked_at?e.jsx(at,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-200",children:"CTA Clicked"}):t.view_count>0?e.jsxs(at,{className:"bg-blue-500/10 text-blue-600 border-blue-200",children:[e.jsx(ya,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(at,{variant:"secondary",children:[e.jsx(ka,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(at,{variant:"outline",children:[e.jsx(Tn,{className:"h-3 w-3 mr-1"}),"Draft"]})}function yys({brokerageId:t}){const{data:s=[],isLoading:r}=eys(t),{data:n=[]}=WJe(t),a=rys(),o=nys(),l=HJe(),[i,d]=S.useState(""),[u,p]=S.useState(!1),[f,v]=S.useState({title:"",script_text:"",category:"general"}),_=s.filter(C=>{var I,L,R,$;return i?`${((I=C.prospect)==null?void 0:I.first_name)||""} ${((L=C.prospect)==null?void 0:L.last_name)||""}`.toLowerCase().includes(i.toLowerCase())||(($=(R=C.video)==null?void 0:R.title)==null?void 0:$.toLowerCase().includes(i.toLowerCase())):!0}),b={total:s.length,sent:s.filter(C=>C.sent_at).length,viewed:s.filter(C=>C.view_count>0).length,ctaClicked:s.filter(C=>C.cta_clicked_at).length},j=S.useCallback(C=>{if(!C)return;const A=`${window.location.origin}/recruit-video/${C}`;navigator.clipboard.writeText(A),fe.success("Share link copied")},[]),w=S.useCallback((C,A)=>{l.mutate({id:C,sent_via:A})},[l]),N=()=>{!f.title.trim()||!f.script_text.trim()||a.mutate({brokerage_id:t,...f},{onSuccess:()=>{v({title:"",script_text:"",category:"general"}),p(!1)}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{label:"Total Videos",value:b.total,icon:kn,color:"text-primary"},{label:"Sent",value:b.sent,icon:ka,color:"text-blue-500"},{label:"Viewed",value:b.viewed,icon:ya,color:"text-amber-500"},{label:"CTA Clicked",value:b.ctaClicked,icon:da,color:"text-emerald-500"}].map(C=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:`h-10 w-10 rounded-lg bg-muted flex items-center justify-center ${C.color}`,children:e.jsx(C.icon,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:C.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.label})]})]})},C.label))}),e.jsxs(Na,{defaultValue:"videos",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsxs(ks,{value:"videos",children:[e.jsx(kn,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(ks,{value:"scripts",children:[e.jsx(In,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(ks,{value:"analytics",children:[e.jsx(Xo,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx(zs,{value:"videos",children:e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(fn,{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:C=>d(C.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(kn,{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(C=>{var A,I,L,R,$,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=C.video)!=null&&A.thumbnail_url?e.jsx("img",{src:C.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(kn,{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:gys(((I=C.video)==null?void 0:I.duration_seconds)??null)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"font-medium truncate",children:[(L=C.prospect)==null?void 0:L.first_name," ",(R=C.prospect)==null?void 0:R.last_name]}),e.jsx(xys,{video:C})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:(($=C.video)==null?void 0:$.title)||"Untitled video"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ws(new Date(C.created_at),"MMM d, yyyy"),((q=C.prospect)==null?void 0:q.current_brokerage)&&` · ${C.prospect.current_brokerage}`]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>j(C.share_token),title:"Copy share link",children:e.jsx(ni,{className:"h-4 w-4"})}),!C.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(C.id,"email"),title:"Mark as sent",children:e.jsx(ka,{className:"h-4 w-4"})}),C.share_token&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>window.open(`/recruit-video/${C.share_token}`,"_blank"),title:"Preview landing page",children:e.jsx(sn,{className:"h-4 w-4"})})]})]},C.id)})})})]})}),e.jsx(zs,{value:"scripts",children:e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-lg",children:"Recruiting Scripts"}),e.jsxs(vs,{open:u,onOpenChange:p,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1.5"}),"New Script"]})}),e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Create Recruiting Script"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title"}),e.jsx(Re,{value:f.title,onChange:C=>v(A=>({...A,title:C.target.value})),placeholder:"e.g., Why Switch to Our Brokerage"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Category"}),e.jsxs(tr,{value:f.category,onValueChange:C=>v(A=>({...A,category:C})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:H0e.map(C=>e.jsx(At,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Script"}),e.jsx(Mr,{value:f.script_text,onChange:C=>v(A=>({...A,script_text:C.target.value})),placeholder:"Hi [Name], I noticed you've been doing great work at [Brokerage]...",rows:8})]}),e.jsx(K,{onClick:N,disabled:!f.title.trim()||!f.script_text.trim(),className:"w-full",children:"Save Script"})]})]})]})]})}),e.jsx(Oe,{children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(In,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No scripts yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Create teleprompter scripts for common recruiting conversations"})]}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.map(C=>{var I;const A=((I=H0e.find(L=>L.value===C.category))==null?void 0:I.label)||C.category;return e.jsx(Ee,{className:"relative group",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(at,{variant:"outline",className:"text-[10px] mb-2",children:A}),e.jsx("h4",{className:"font-medium text-sm",children:C.title})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity text-destructive",onClick:()=>o.mutate(C.id),children:e.jsx(br,{className:"h-3.5 w-3.5"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-3",children:C.script_text}),C.is_global&&e.jsx(at,{variant:"secondary",className:"mt-2 text-[10px]",children:"Template"})]})},C.id)})})})]})}),e.jsx(zs,{value:"analytics",children:e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(C=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:C.label}),e.jsxs("span",{className:"font-medium",children:[C.count," (",C.pct,"%)"]})]}),e.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${C.color} rounded-full transition-all`,style:{width:`${C.pct}%`}})})]},C.label))}),s.filter(C=>C.view_count>0).length>0&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"Most Engaged Prospects"}),e.jsx("div",{className:"space-y-2",children:s.filter(C=>C.view_count>0).sort((C,A)=>A.view_count-C.view_count).slice(0,5).map(C=>{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=C.prospect)==null?void 0:A.first_name," ",(I=C.prospect)==null?void 0:I.last_name]}),e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ya,{className:"h-3.5 w-3.5"})," ",C.view_count]}),C.cta_clicked_at&&e.jsx(da,{className:"h-4 w-4 text-emerald-500"})]})]},C.id)})})]})]})]})})]})]})}function vys({brokerageId:t}){const{toast:s}=Ia(),r=ns(),{stages:n,prospects:a}=Ace(t),[o,l]=S.useState(!1),[i,d]=S.useState({title:"",target_count:"10",target_stage_id:"",period_start:ws(new Date,"yyyy-MM-dd"),period_end:ws(new Date(new Date().getFullYear(),new Date().getMonth()+3,0),"yyyy-MM-dd")}),{data:u=[],isLoading:p}=Ct({queryKey:["recruit-goals",t],queryFn:async()=>{const{data:b,error:j}=await G.from("recruit_goals").select("*").eq("brokerage_id",t).order("period_end",{ascending:!1});if(j)throw j;return b}}),f=Ot({mutationFn:async b=>{const{data:{user:j}}=await G.auth.getUser();if(!j)throw new Error("Not authenticated");const{error:w}=await G.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:j.id});if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal created"}),l(!1)},onError:b=>s({title:"Error",description:b.message,variant:"destructive"})}),v=Ot({mutationFn:async b=>{const{error:j}=await G.from("recruit_goals").delete().eq("id",b);if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal removed"})}}),_=b=>{const j=n.find(N=>N.id===b.target_stage_id);return{count:a.filter(N=>wg(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:j}};return p?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.length," goal",u.length!==1?"s":""]}),e.jsxs(K,{size:"sm",onClick:()=>l(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," New Goal"]})]}),u.length===0?e.jsxs(Ee,{className:"py-12 text-center",children:[e.jsx(Hh,{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:j,stage:w}=_(b),N=Math.min(100,j/b.target_count*100),C=wg(new Date,{start:new Date(b.period_start),end:new Date(b.period_end)});return e.jsxs(Ee,{className:C?"":"opacity-60",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{className:"text-sm",children:b.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ws(new Date(b.period_start),"MMM d")," – ",ws(new Date(b.period_end),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[C?e.jsx(at,{className:"text-[10px]",children:"Active"}):e.jsx(at,{variant:"secondary",className:"text-[10px]",children:"Ended"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground",onClick:()=>v.mutate(b.id),children:e.jsx(br,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[w&&e.jsxs(at,{variant:"outline",className:"text-[10px]",style:{borderColor:w.color,color:w.color},children:["Stage: ",w.name]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-bold text-lg",children:j}),e.jsxs("span",{className:"text-muted-foreground",children:["/ ",b.target_count]})]}),e.jsx(Ti,{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(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Create Recruiting Goal"})}),e.jsxs("form",{onSubmit:b=>{b.preventDefault(),f.mutate(i)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Goal Title *"}),e.jsx(Re,{required:!0,value:i.title,onChange:b=>d(j=>({...j,title:b.target.value})),placeholder:"e.g. Q2 Recruiting Target"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Target Count *"}),e.jsx(Re,{type:"number",min:"1",required:!0,value:i.target_count,onChange:b=>d(j=>({...j,target_count:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{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(j=>({...j,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(ve,{children:"Start Date"}),e.jsx(Re,{type:"date",required:!0,value:i.period_start,onChange:b=>d(j=>({...j,period_start:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"End Date"}),e.jsx(Re,{type:"date",required:!0,value:i.period_end,onChange:b=>d(j=>({...j,period_end:b.target.value}))})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:f.isPending,children:"Create Goal"})]})]})]})})]})}function _ys(){var i;const[t,s]=S.useState(""),[r,n]=S.useState("board"),{data:a=[],isLoading:o}=Ct({queryKey:["all-brokerages"],queryFn:async()=>{const{data:d,error:u}=await G.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(Aa,{className:"mr-2 h-4 w-4"}),e.jsx(sr,{placeholder:"Select brokerage"})]}),e.jsx(er,{children:a.map(d=>e.jsx(At,{value:d.id,children:d.name},d.id))})]})]}),l?e.jsxs(Na,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(va,{className:"flex-wrap h-auto gap-1",children:[e.jsx(ks,{value:"pipeline",children:"Pipeline"}),e.jsxs(ks,{value:"video-outreach",children:[e.jsx(kn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(ks,{value:"follow-ups",children:"Follow-ups"}),e.jsx(ks,{value:"referrals",children:"Referrals"}),e.jsx(ks,{value:"interest",children:"Interest Form"}),e.jsx(ks,{value:"landing-page",children:"Landing Page"}),e.jsx(ks,{value:"goals",children:"Goals"}),e.jsx(ks,{value:"metrics",children:"Metrics"}),e.jsx(ks,{value:"templates",children:"Email Templates"}),e.jsx(ks,{value:"activity",children:"Recruiter Activity"})]}),e.jsxs(zs,{value:"pipeline",children:[e.jsx("div",{className:"flex justify-end mb-3",children:e.jsxs("div",{className:"flex items-center rounded-md border bg-muted p-0.5",children:[e.jsxs(K,{variant:r==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("board"),children:[e.jsx(mp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(K,{variant:r==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("table"),children:[e.jsx(PP,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(iys,{brokerageId:l}):e.jsx(oys,{brokerageId:l})]}),e.jsx(zs,{value:"video-outreach",children:e.jsx(yys,{brokerageId:l})}),e.jsx(zs,{value:"follow-ups",children:e.jsx(mys,{brokerageId:l})}),e.jsx(zs,{value:"referrals",children:e.jsx(uys,{brokerageId:l})}),e.jsx(zs,{value:"interest",children:e.jsx(hys,{brokerageId:l})}),e.jsx(zs,{value:"landing-page",children:e.jsx(fys,{brokerageId:l})}),e.jsx(zs,{value:"goals",children:e.jsx(vys,{brokerageId:l})}),e.jsx(zs,{value:"metrics",children:e.jsx(lys,{brokerageId:l})}),e.jsx(zs,{value:"templates",children:e.jsx(cys,{brokerageId:l})}),e.jsx(zs,{value:"activity",children:e.jsx(dys,{brokerageId:l})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Aa,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found. Create a brokerage first."})]})]})})}function bys(){const[t,s]=S.useState(""),{data:r,isLoading:n}=Ct({queryKey:["admin-brokerage-content-activity"],queryFn:async()=>{const{data:i}=await G.from("brokerages").select("id, name");if(!i)return[];const{data:d}=await G.from("brokerage_content").select("id, brokerage_id, content_type, created_at"),{data:u}=await G.from("brokerage_content_categories").select("id, brokerage_id"),p=d||[],f=u||[],v=i.map(_=>{const b=p.filter(N=>N.brokerage_id===_.id),j=f.filter(N=>N.brokerage_id===_.id),w=b.length>0?b.reduce((N,C)=>C.created_at>N?C.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:w,categories:j.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(_u,{title:"Brokerage Content Activity",description:"See which brokerages are creating custom content for their agents"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Active Brokerages"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with content uploaded"})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Content Items"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"across all brokerages"})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{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(fn,{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(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Brokerage"}),e.jsx(jt,{className:"text-center",children:"Total"}),e.jsx(jt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(kn,{className:"h-3 w-3"})," Videos"]})}),e.jsx(jt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(In,{className:"h-3 w-3"})," PDFs"]})}),e.jsx(jt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Ho,{className:"h-3 w-3"})," Links"]})}),e.jsx(jt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(ld,{className:"h-3 w-3"})," Events"]})}),e.jsx(jt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Jo,{className:"h-3 w-3"})," Graphics"]})}),e.jsx(jt,{className:"text-center",children:"Categories"}),e.jsx(jt,{children:"Last Upload"})]})}),e.jsx(Pn,{children:n?e.jsx(js,{children:e.jsx(lt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):a.length===0?e.jsx(js,{children:e.jsx(lt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"No brokerages found"})}):a.map(i=>e.jsxs(js,{className:i.total_items===0?"opacity-50":"",children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Aa,{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(at,{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:ws(new Date(i.latest_item_date),"MMM d, yyyy")}):e.jsx("span",{className:"text-muted-foreground",children:"–"})})]},i.brokerage_id))})]})})})]})})}function wys(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 jys=(()=>{let t=0;const s=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${s()}${t}`)})();function __(t){const s=[];for(let r=0,n=t.length;rJm||t.height>Jm)&&(t.width>Jm&&t.height>Jm?t.width>t.height?(t.height*=Jm/t.width,t.width=Jm):(t.width*=Jm/t.height,t.height=Jm):t.width>Jm?(t.height*=Jm/t.width,t.width=Jm):(t.width*=Jm/t.height,t.height=Jm))}function Iie(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 Mys(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(s=>`data:image/svg+xml;charset=utf-8,${s}`)}async function Tys(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),Mys(a)}const Rm=(t,s)=>{if(t instanceof s)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===s.name||Rm(r,s)};function Ays(t){const s=t.getPropertyValue("content");return`${t.cssText} content: '${s.replace(/'|"/g,"")}';`}function Eys(t,s){return ZJe(s).map(r=>{const n=t.getPropertyValue(r),a=t.getPropertyPriority(r);return`${r}: ${n}${a?" !important":""};`}).join(" ")}function Pys(t,s,r,n){const a=`.${t}:${s}`,o=r.cssText?Ays(r):Eys(r,n);return document.createTextNode(`${a}{${o}}`)}function $Le(t,s,r,n){const a=window.getComputedStyle(t,r),o=a.getPropertyValue("content");if(o===""||o==="none")return;const l=jys();try{s.className=`${s.className} ${l}`}catch{return}const i=document.createElement("style");i.appendChild(Pys(l,r,a,n)),s.appendChild(i)}function Iys(t,s,r){$Le(t,s,":before",r),$Le(t,s,":after",r)}const qLe="application/font-woff",ULe="image/jpeg",Lys={woff:qLe,woff2:qLe,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:ULe,jpeg:ULe,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Dys(t){const s=/\.([^./]*?)$/g.exec(t);return s?s[1]:""}function B2e(t){const s=Dys(t).toLowerCase();return Lys[s]||""}function Oys(t){return t.split(/,/)[1]}function W0e(t){return t.search(/^(data:)/)!==-1}function Rys(t,s){return`data:${s};base64,${t}`}async function XJe(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 Tpe={};function Fys(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 $2e(t,s,r){const n=Fys(t,s,r.includeQueryParams);if(Tpe[n]!=null)return Tpe[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let a;try{const o=await XJe(t,r.fetchRequestInit,({res:l,result:i})=>(s||(s=l.headers.get("Content-Type")||""),Oys(i)));a=Rys(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 Tpe[n]=a,a}async function zys(t){const s=t.toDataURL();return s==="data:,"?t.cloneNode(!1):Iie(s)}async function Bys(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 Iie(i)}const r=t.poster,n=B2e(r),a=await $2e(r,n,s);return Iie(a)}async function $ys(t,s){var r;try{if(!((r=t==null?void 0:t.contentDocument)===null||r===void 0)&&r.body)return await Ece(t.contentDocument.body,s,!0)}catch{}return t.cloneNode(!1)}async function qys(t,s){return Rm(t,HTMLCanvasElement)?zys(t):Rm(t,HTMLVideoElement)?Bys(t,s):Rm(t,HTMLIFrameElement)?$ys(t,s):t.cloneNode(QJe(t))}const Uys=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",QJe=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function Vys(t,s,r){var n,a;if(QJe(s))return s;let o=[];return Uys(t)&&t.assignedNodes?o=__(t.assignedNodes()):Rm(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?o=__(t.contentDocument.body.childNodes):o=__(((a=t.shadowRoot)!==null&&a!==void 0?a:t).childNodes),o.length===0||Rm(t,HTMLVideoElement)||await o.reduce((l,i)=>l.then(()=>Ece(i,r)).then(d=>{d&&s.appendChild(d)}),Promise.resolve()),s}function Hys(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):ZJe(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`),Rm(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 Wys(t,s){Rm(t,HTMLTextAreaElement)&&(s.innerHTML=t.value),Rm(t,HTMLInputElement)&&s.setAttribute("value",t.value)}function Gys(t,s){if(Rm(t,HTMLSelectElement)){const r=s,n=Array.from(r.children).find(a=>t.value===a.getAttribute("value"));n&&n.setAttribute("selected","")}}function Kys(t,s,r){return Rm(s,Element)&&(Hys(t,s,r),Iys(t,s,r),Wys(t,s),Gys(t,s)),s}async function Zys(t,s){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let o=0;oqys(n,s)).then(n=>Vys(t,n,s)).then(n=>Kys(t,n,s)).then(n=>Zys(n,s))}const JJe=/url\((['"]?)([^'"]+?)\1\)/g,Yys=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Xys=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Qys(t){const s=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${s})(['"]?\\))`,"g")}function Jys(t){const s=[];return t.replace(JJe,(r,n,a)=>(s.push(a),r)),s.filter(r=>!W0e(r))}async function e0s(t,s,r,n,a){try{const o=r?wys(s,r):s,l=B2e(s);let i;return a||(i=await $2e(o,l,n)),t.replace(Qys(s),`$1${i}$3`)}catch{}return t}function t0s(t,{preferredFontFormat:s}){return s?t.replace(Xys,r=>{for(;;){const[n,,a]=Yys.exec(r)||[];if(!a)return"";if(a===s)return`src: ${n};`}}):t}function eet(t){return t.search(JJe)!==-1}async function tet(t,s,r){if(!eet(t))return t;const n=t0s(t,r);return Jys(n).reduce((o,l)=>o.then(i=>e0s(i,l,s,r)),Promise.resolve(n))}async function p4(t,s,r){var n;const a=(n=s.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(a){const o=await tet(a,null,r);return s.style.setProperty(t,o,s.style.getPropertyPriority(t)),!0}return!1}async function s0s(t,s){await p4("background",t,s)||await p4("background-image",t,s),await p4("mask",t,s)||await p4("-webkit-mask",t,s)||await p4("mask-image",t,s)||await p4("-webkit-mask-image",t,s)}async function r0s(t,s){const r=Rm(t,HTMLImageElement);if(!(r&&!W0e(t.src))&&!(Rm(t,SVGImageElement)&&!W0e(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,a=await $2e(n,B2e(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 n0s(t,s){const n=__(t.childNodes).map(a=>set(a,s));await Promise.all(n).then(()=>t)}async function set(t,s){Rm(t,Element)&&(await s0s(t,s),await r0s(t,s),await n0s(t,s))}function a0s(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 VLe={};async function HLe(t){let s=VLe[t];if(s!=null)return s;const n=await(await fetch(t)).text();return s={url:t,cssText:n},VLe[t]=s,s}async function WLe(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),XJe(i,s.fetchRequestInit,({result:d})=>(r=r.replace(l,`url(${d})`),[l,d]))});return Promise.all(o).then(()=>r)}function GLe(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 i0s(t,s){const r=[],n=[];return t.forEach(a=>{if("cssRules"in a)try{__(a.cssRules||[]).forEach((o,l)=>{if(o.type===CSSRule.IMPORT_RULE){let i=l+1;const d=o.href,u=HLe(d).then(p=>WLe(p,s)).then(p=>GLe(p).forEach(f=>{try{a.insertRule(f,f.startsWith("@import")?i+=1:a.cssRules.length)}catch(v){console.error("Error inserting rule from remote css",{rule:f,error:v})}})).catch(p=>{console.error("Error loading remote css",p.toString())});n.push(u)}})}catch(o){const l=t.find(i=>i.href==null)||document.styleSheets[0];a.href!=null&&n.push(HLe(a.href).then(i=>WLe(i,s)).then(i=>GLe(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{__(a.cssRules||[]).forEach(o=>{r.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${a.href}`,o)}}),r))}function o0s(t){return t.filter(s=>s.type===CSSRule.FONT_FACE_RULE).filter(s=>eet(s.style.getPropertyValue("src")))}async function l0s(t,s){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=__(t.ownerDocument.styleSheets),n=await i0s(r,s);return o0s(n)}function ret(t){return t.trim().replace(/["']/g,"")}function c0s(t){const s=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(o=>{s.add(ret(o))}),Array.from(n.children).forEach(o=>{o instanceof HTMLElement&&r(o)})}return r(t),s}async function d0s(t,s){const r=await l0s(t,s),n=c0s(t);return(await Promise.all(r.filter(o=>n.has(ret(o.style.fontFamily))).map(o=>{const l=o.parentStyleSheet?o.parentStyleSheet.href:null;return tet(o.cssText,l,s)}))).join(` `)}async function u0s(t,s){const r=s.fontEmbedCSS!=null?s.fontEmbedCSS:s.skipFonts?null:await d0s(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 h0s(t,s={}){const{width:r,height:n}=YJe(t,s),a=await Ece(t,s,!0);return await u0s(a,s),await set(a,s),a0s(a,s),await Tys(a,r,n)}async function m0s(t,s={}){const{width:r,height:n}=YJe(t,s),a=await h0s(t,s),o=await Iie(a),l=document.createElement("canvas"),i=l.getContext("2d"),d=s.pixelRatio||Sys(),u=s.canvasWidth||r,p=s.canvasHeight||n;return l.width=u*d,l.height=p*d,s.skipAutoScale||Cys(l),l.style.width=`${u}`,l.style.height=`${p}`,s.backgroundColor&&(i.fillStyle=s.backgroundColor,i.fillRect(0,0,l.width,l.height)),i.drawImage(o,0,0,l.width,l.height),l}async function p0s(t,s={}){return(await m0s(t,s)).toDataURL()}const J3=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),Pce={"just-listed":"JUST LISTED","just-sold":"JUST SOLD","open-house":"OPEN HOUSE","price-drop":"PRICE DROP"},TR={"instagram-square":{width:1080,height:1080},"instagram-story":{width:1080,height:1920},"facebook-post":{width:1200,height:630}},f0s=({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})]})]}),net=mt.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var f;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,d=(f=t.photos)==null?void 0:f[a],u=Pce[s],p=[t.bedrooms?`${t.bedrooms} Bed`:null,t.bathrooms?`${t.bathrooms} Bath`:null,t.sqft?`${t.sqft.toLocaleString()} Sq Ft`:null].filter(Boolean).join(" • ");return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Georgia', 'Times New Roman', serif",color:"#FFFFFF"},children:[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:J3(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.028,color:"#C9A84C",marginBottom:l.w*.01},children:["Sold for ",J3(t.soldPrice)]}),e.jsx("div",{style:{fontSize:l.w*.028,opacity:.9,marginBottom:l.w*.008},children:t.address}),e.jsxs("div",{style:{fontSize:l.w*.022,opacity:.7,marginBottom:l.w*.02},children:[t.city,", ",t.state," ",t.zip]}),e.jsx("div",{style:{display:"flex",gap:l.w*.015,fontSize:l.w*.022,letterSpacing:"0.05em",borderTop:"1px solid rgba(201,168,76,0.4)",paddingTop:l.w*.02},children:e.jsx("span",{children:p})}),s==="open-house"&&e.jsx("div",{style:{marginTop:l.w*.02,background:"rgba(201,168,76,0.15)",border:"1px solid rgba(201,168,76,0.4)",padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.024,letterSpacing:"0.1em",display:"inline-block"},children:"SAT & SUN • 1–4 PM"}),e.jsx(f0s,{branding:n,dim:l})]})]})]})});net.displayName="LuxuryDarkTemplate";const g0s=({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})]})]}),aet=mt.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=Pce[s],p=r==="instagram-story",f=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:f?"row":"column"},children:[e.jsxs("div",{style:{width:f?"55%":"100%",height:f?"100%":p?"50%":"52%",position:"relative",overflow:"hidden",flexShrink:0},children:[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*(f?.055:.065),fontWeight:800,lineHeight:1.1,color:v,marginBottom:l.w*.012},children:J3(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(g0s,{branding:n,dim:l,accentColor:v})]})]})});aet.displayName="ModernCleanTemplate";const x0s=({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})]})]}),iet=mt.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=Pce[s],p={"just-listed":"linear-gradient(135deg, #059669, #10B981)","just-sold":"linear-gradient(135deg, #7C3AED, #A855F7)","open-house":"linear-gradient(135deg, #2563EB, #3B82F6)","price-drop":"linear-gradient(135deg, #DC2626, #F43F5E)"},f=[t.bedrooms?`${t.bedrooms} BD`:null,t.bathrooms?`${t.bathrooms} BA`:null,t.sqft?`${t.sqft.toLocaleString()} SF`:null].filter(Boolean).join(" | ");return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Arial Black', 'Helvetica Neue', sans-serif",color:"#FFFFFF"},children:[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:p[s],padding:`${l.w*.025}px ${l.w*.04}px`,fontSize:l.w*.055,fontWeight:900,letterSpacing:"0.08em",alignSelf:"flex-start",borderRadius:l.w*.01,boxShadow:"0 8px 32px rgba(0,0,0,0.3)",transform:"rotate(-2deg)",marginBottom:l.w*.03},children:u}),e.jsx("div",{style:{flex:1}}),e.jsxs("div",{style:{background:"rgba(0,0,0,0.65)",backdropFilter:"blur(10px)",borderRadius:l.w*.015,padding:l.w*.04},children:[e.jsx("div",{style:{fontSize:l.w*.08,fontWeight:900,lineHeight:1,marginBottom:l.w*.01},children:J3(t.price)}),e.jsx("div",{style:{fontSize:l.w*.028,fontWeight:700,marginBottom:l.w*.005},children:t.address}),e.jsxs("div",{style:{fontSize:l.w*.022,opacity:.8,marginBottom:l.w*.015},children:[t.city,", ",t.state," ",t.zip]}),e.jsx("div",{style:{display:"inline-block",background:"rgba(255,255,255,0.15)",borderRadius:l.w*.008,padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.022,fontWeight:700,letterSpacing:"0.08em"},children:f}),s==="open-house"&&e.jsx("div",{style:{marginTop:l.w*.015,background:p["open-house"],borderRadius:l.w*.008,padding:`${l.w*.012}px ${l.w*.025}px`,fontSize:l.w*.024,fontWeight:800,display:"inline-block",marginLeft:l.w*.01},children:"SAT & SUN 1–4 PM"}),e.jsx(x0s,{branding:n,dim:l})]})]})]})});iet.displayName="BoldColorfulTemplate";const y0s=({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})]})]}),oet=mt.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var f;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,d=(f=t.photos)==null?void 0:f[a],u=Pce[s],p=r==="instagram-story";return e.jsx("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Georgia', 'Times New Roman', serif",color:"#1A1A1A",background:"#F5F0EB"},children:e.jsxs("div",{style:{display:"flex",flexDirection:p?"column":"row",height:"100%"},children:[e.jsxs("div",{style:{width:p?"100%":"42%",height:p?"40%":"100%",display:"flex",flexDirection:"column",justifyContent:"center",padding:l.w*.05,order:p?2:1},children:[e.jsx("div",{style:{fontSize:l.w*.016,letterSpacing:"0.3em",textTransform:"uppercase",color:"#8B7355",borderBottom:"2px solid #8B7355",paddingBottom:l.w*.01,marginBottom:l.w*.025,display:"inline-block",alignSelf:"flex-start"},children:u}),e.jsx("div",{style:{fontSize:l.w*(p?.06:.055),fontWeight:700,lineHeight:1.1,marginBottom:l.w*.015,fontStyle:"italic"},children:J3(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.02,color:"#8B7355",marginBottom:l.w*.01},children:["Sold: ",J3(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(y0s,{branding:n,dim:l})]}),e.jsxs("div",{style:{width:p?"100%":"58%",height:p?"60%":"100%",position:"relative",overflow:"hidden",order:p?1:2},children:[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"}})]})]})})});oet.displayName="EditorialTemplate";const v0s=[{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:"📉"}],KLe=[{value:"instagram-square",label:"Instagram Post",dimensions:"1080×1080",icon:e.jsx(Wd,{className:"h-4 w-4"})},{value:"instagram-story",label:"Instagram Story",dimensions:"1080×1920",icon:e.jsx(Wd,{className:"h-4 w-4"})},{value:"facebook-post",label:"Facebook Post",dimensions:"1200×630",icon:e.jsx(Hd,{className:"h-4 w-4"})}],_0s=[{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:"📰"}],ZLe=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),YLe={"luxury-dark":net,"modern-clean":aet,"bold-colorful":iet,editorial:oet};function b0s(){const[t,s]=S.useState(""),[r,n]=S.useState("address"),[a,o]=S.useState(!1),[l,i]=S.useState([]),[d,u]=S.useState(null),[p,f]=S.useState(0),[v,_]=S.useState("just-listed"),[b,j]=S.useState(["instagram-square"]),[w,N]=S.useState("luxury-dark"),[C,A]=S.useState(!1),[I,L]=S.useState(""),[R,$]=S.useState(""),[q,U]=S.useState(""),[V,X]=S.useState(!1),[se,te]=S.useState(!1),[Y,de]=S.useState([]),[ie,ae]=S.useState("search"),le=S.useRef({});S.useEffect(()=>{(async()=>{const{data:{user:Fe}}=await G.auth.getUser();if(!Fe)return;const{data:Ae}=await G.from("profiles").select("name, avatar_url, brokerages(name)").eq("id",Fe.id).single();if(Ae){L(Ae.name||""),U(Ae.avatar_url||"");const We=Ae.brokerages;$((We==null?void 0:We.name)||"")}})()},[]);const pe=async()=>{var Te;if(t.trim()){o(!0),i([]);try{const{data:Fe,error:Ae}=await G.functions.invoke("repliers-mls-search",{body:{searchType:r,query:t.trim()}});if(Ae)throw Ae;if(Fe.error)throw new Error(Fe.error);i(Fe.listings||[]),((Te=Fe.listings)==null?void 0:Te.length)===0&&fe.info("No listings found. Try a different search.")}catch(Fe){fe.error(Fe.message||"Search failed")}finally{o(!1)}}},be=Te=>{var Fe;u(Te),f(0),ae("customize"),Te.soldDate||(Fe=Te.status)!=null&&Fe.toLowerCase().includes("sold")?_("just-sold"):_("just-listed")},ye=Te=>{j(Fe=>Fe.includes(Te)?Fe.filter(Ae=>Ae!==Te):[...Fe,Te])},we=S.useCallback(async()=>{if(!(!d||b.length===0)){X(!0),de([]),ae("generate");try{await new Promise(Fe=>setTimeout(Fe,500));const Te=[];for(const Fe of b){const Ae=`${w}-${Fe}`,We=le.current[Ae];if(!We)continue;const ht=TR[Fe],De=await p0s(We,{width:ht.width,height:ht.height,pixelRatio:1,cacheBust:!0,style:{transform:"none",transformOrigin:"top left"}});Te.push({format:Fe,imageUrl:De})}de(Te),fe.success(`Generated ${Te.length} social post${Te.length>1?"s":""}!`)}catch(Te){fe.error(Te.message||"Generation failed")}finally{X(!1)}}},[d,b,w,p,C,I,R,q,v]),ke=async()=>{if(!(!d||b.length===0)){X(!0),de([]),ae("generate");try{const Te={...d,photos:d.photos.length>0?[d.photos[p]]:[]},Fe=[];for(const Ae of b){const{data:We,error:ht}=await G.functions.invoke("generate-listing-social-post",{body:{listing:Te,postType:v,format:Ae,branding:C?{enabled:!0,agentName:I,brokerage:R}:{enabled:!1}}});if(ht)throw ht;if(We.error)throw new Error(We.error);Fe.push({format:Ae,imageUrl:We.imageUrl})}de(Fe),fe.success(`Generated ${Fe.length} AI post${Fe.length>1?"s":""}!`)}catch(Te){fe.error(Te.message||"AI generation failed")}finally{X(!1)}}},Ze=()=>se?ke():we(),_e=(Te,Fe)=>{var We;const Ae=document.createElement("a");Ae.href=Te,Ae.download=`${((We=d==null?void 0:d.address)==null?void 0:We.replace(/\s+/g,"-"))||"listing"}-${v}-${Fe}.png`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae)},Ce=d?{listing:d,postType:v,format:"instagram-square",branding:C?{enabled:!0,agentName:I,brokerage:R,agentPhotoUrl:q||void 0}:{enabled:!1},selectedPhotoIndex:p}:null;return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(_u,{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:()=>ae("search"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${ie==="search"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"}`,children:[e.jsx(fn,{className:"h-3.5 w-3.5"})," 1. Find Listing"]}),e.jsx(Ha,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("button",{onClick:()=>d&&ae("customize"),disabled:!d,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${ie==="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(hn,{className:"h-3.5 w-3.5"})," 2. Customize"]}),e.jsx(Ha,{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 ${ie==="generate"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground/50"}`,children:[e.jsx(Jo,{className:"h-3.5 w-3.5"})," 3. Generate"]})]}),ie==="search"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-5 w-5 text-primary"})," Search MLS Listings ",e.jsx(mVe,{})]}),e.jsx(yr,{children:"Find a listing by MLS number or property address using Repliers.io"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Na,{value:r,onValueChange:Te=>n(Te),children:e.jsxs(va,{children:[e.jsxs(ks,{value:"address",children:[e.jsx(Ai,{className:"h-4 w-4 mr-1.5"})," Address"]}),e.jsxs(ks,{value:"mls",children:[e.jsx(Vh,{className:"h-4 w-4 mr-1.5"})," MLS #"]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:t,onChange:Te=>s(Te.target.value),placeholder:r==="mls"?"Enter MLS number...":"Enter property address...",className:"flex-1",onKeyDown:Te=>Te.key==="Enter"&&pe()}),e.jsxs(K,{onClick:pe,disabled:a||!t.trim(),children:[a?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(fn,{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((Te,Fe)=>{var Ae;return e.jsx(Ee,{className:"cursor-pointer hover:border-primary/50 hover:shadow-md transition-all group",onClick:()=>be(Te),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:(Ae=Te.photos)!=null&&Ae[0]?e.jsx("img",{src:Te.photos[0],alt:Te.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(Un,{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:ZLe(Te.price)}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:Te.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Te.city,", ",Te.state," ",Te.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[Te.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(XE,{className:"h-3 w-3"})," ",Te.bedrooms]}),Te.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Vx,{className:"h-3 w-3"})," ",Te.bathrooms]}),Te.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(hP,{className:"h-3 w-3"})," ",Te.sqft.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(at,{variant:"outline",className:"text-[10px]",children:Te.mlsNumber}),e.jsx(at,{variant:"outline",className:"text-[10px]",children:Te.status})]})]})]})})},Te.mlsNumber||Fe)})})]})]}),ie==="customize"&&d&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(Ee,{className:"lg:col-span-1",children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(zt,{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[p],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(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(Te=>Math.max(0,Te-1)),disabled:p===0,children:e.jsx(zl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p+1," of ",d.photos.length]}),e.jsx(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(Te=>Math.min(d.photos.length-1,Te+1)),disabled:p===d.photos.length-1,children:e.jsx(Ha,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg",children:ZLe(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(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{ae("search"),u(null)},children:[e.jsx(D0,{className:"h-3.5 w-3.5 mr-1.5"})," Choose Different Listing"]})]})]}),e.jsxs(Ee,{className:"lg:col-span-2",children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5 text-primary"})," Customize Your Post"]}),e.jsx(yr,{children:"Choose template, post type, format, and branding"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bl,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children: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(Br,{checked:se,onCheckedChange:te}),se&&e.jsx(u0,{className:"h-4 w-4 text-purple-500"})]})]}),!se&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Bl,{className:"h-4 w-4"})," Template Style"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:_0s.map(Te=>e.jsxs("button",{onClick:()=>N(Te.value),className:`flex flex-col items-center gap-1 px-3 py-3 rounded-lg border-2 transition-all text-center ${w===Te.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-2xl",children:Te.preview}),e.jsx("span",{className:"text-sm font-medium",children:Te.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:Te.description})]},Te.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Post Type"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:v0s.map(Te=>e.jsxs("button",{onClick:()=>_(Te.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm font-medium ${v===Te.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-lg",children:Te.icon})," ",Te.label]},Te.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Output Formats"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:KLe.map(Te=>e.jsxs("button",{onClick:()=>ye(Te.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm ${b.includes(Te.value)?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[Te.icon,e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium",children:Te.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:Te.dimensions})]})]},Te.value))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ve,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Xi,{className:"h-4 w-4"})," Agent Branding"]}),e.jsx(Br,{checked:C,onCheckedChange:A})]}),C&&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(ve,{className:"text-xs text-muted-foreground",children:"Agent Name"}),e.jsx(Re,{value:I,onChange:Te=>L(Te.target.value),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Brokerage (optional)"}),e.jsx(Re,{value:R,onChange:Te=>$(Te.target.value),placeholder:"XYZ Realty"})]})]})]})]}),!se&&Ce&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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*(TR[b[0]||"instagram-square"].height/TR[b[0]||"instagram-square"].width)},children:(()=>{const Te=YLe[w],Fe=b[0]||"instagram-square";return e.jsx(Te,{...Ce,format:Fe})})()})})]}),e.jsx(K,{onClick:Ze,disabled:b.length===0||V,size:"lg",className:"w-full gap-2",children:V?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-5 w-5 animate-spin"})," Generating ",b.length," post",b.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[se?e.jsx(u0,{className:"h-5 w-5"}):e.jsx(hn,{className:"h-5 w-5"}),"Generate ",b.length," Social Post",b.length>1?"s":"",se&&e.jsx(at,{variant:"outline",className:"ml-2 text-[10px]",children:"Uses Credits"})]})})]})]})]}),ie==="generate"&&e.jsxs("div",{className:"space-y-4",children:[V&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(As,{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(K,{variant:"outline",size:"sm",onClick:()=>ae("customize"),children:[e.jsx(D0,{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((Te,Fe)=>{const Ae=KLe.find(We=>We.value===Te.format);return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 p-1",children:e.jsx("img",{src:Te.imageUrl,alt:`${Te.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:[Ae==null?void 0:Ae.icon,e.jsx("span",{className:"text-sm font-medium",children:Ae==null?void 0:Ae.label})]}),e.jsx(at,{variant:"outline",className:"text-[10px]",children:Ae==null?void 0:Ae.dimensions})]}),e.jsxs(K,{size:"sm",className:"w-full gap-1.5",onClick:()=>_e(Te.imageUrl,Te.format),children:[e.jsx(xi,{className:"h-3.5 w-3.5"})," Download"]})]})]},Fe)})})]})]}),ie==="generate"&&!se&&d&&Ce&&e.jsx("div",{style:{position:"absolute",left:"-9999px",top:0},"aria-hidden":!0,children:b.map(Te=>{const Fe=YLe[w],Ae=TR[Te];return e.jsx("div",{style:{width:Ae.width,height:Ae.height},children:e.jsx(Fe,{ref:We=>{le.current[`${w}-${Te}`]=We},...Ce,format:Te})},`${w}-${Te}`)})})]})})}function w0s(){return Ct({queryKey:["lms-courses-admin"],queryFn:async()=>{const{data:t,error:s}=await G.from("lms_courses").select("*, modules:lms_modules(count), access:lms_course_access(*)").order("sort_order");if(s)throw s;return t}})}function j0s(t){return Ct({queryKey:["lms-course-admin",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.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 k0s(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.from("lms_courses").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function cet(){const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.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 N0s(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("lms_courses").delete().eq("id",s);if(r)throw r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function S0s(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.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 C0s(){const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.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 M0s(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("lms_modules").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function T0s(){const t=ns();return Ot({mutationFn:async s=>{const{data:r,error:n}=await G.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 A0s(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.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 E0s(){const t=ns();return Ot({mutationFn:async({courseId:s,accessRules:r})=>{const{error:n}=await G.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 G.from("lms_course_access").insert(a);if(o)throw o}},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-courses"]}),t.invalidateQueries({queryKey:["lms-course"]})}})}function P0s(){return Ct({queryKey:["lms-courses-agent"],queryFn:async()=>{const{data:t,error:s}=await G.from("lms_courses").select("*, modules:lms_modules(id)").eq("is_published",!0).order("sort_order");if(s)throw s;return t}})}function I0s(t){return Ct({queryKey:["lms-course-agent",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.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 det(t){return Ct({queryKey:["lms-progress",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("lms_progress").select("*").eq("course_id",t);if(r)throw r;return s},enabled:!!t})}function L0s(){const t=ns();return Ot({mutationFn:async({courseId:s,moduleId:r,userId:n})=>{const{data:a,error:o}=await G.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 D0s(){const{user:t}=Gs(),s=Dr(),{data:r,isLoading:n}=w0s(),a=k0s(),o=cet(),l=N0s(),[i,d]=S.useState(!1),[u,p]=S.useState(""),[f,v]=S.useState(""),[_,b]=S.useState(!0),j=async()=>{if(!(!u.trim()||!t))try{const C=await a.mutateAsync({title:u.trim(),description:f.trim()||void 0,is_sequential:_,created_by:t.id});fe.success("Course created"),d(!1),p(""),v(""),b(!0),s(`/admin/lms/${C.id}`)}catch{fe.error("Failed to create course")}},w=async C=>{try{await o.mutateAsync({id:C.id,is_published:!C.is_published}),fe.success(C.is_published?"Course unpublished":"Course published")}catch{fe.error("Failed to update course")}},N=async C=>{if(confirm("Delete this course and all its modules? This cannot be undone."))try{await l.mutateAsync(C),fe.success("Course deleted")}catch{fe.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(sh,{className:"h-7 w-7 text-primary"}),"LevelUp U — Course Manager"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Create and manage training courses for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>s("/admin/lms/stats"),children:[e.jsx(Xo,{className:"h-4 w-4 mr-2"}),"Analytics"]}),e.jsxs(K,{onClick:()=>d(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"New Course"]})]})]}),n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:[1,2,3].map(C=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Lt,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-2"})]})},C))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:r.map(C=>{var R,$;const A=(($=(R=C.modules)==null?void 0:R[0])==null?void 0:$.count)??0,I=C.access||[],L=I.length===0?"No access set":I.some(q=>q.access_type==="all")?"All agents":`${I.length} rule(s)`;return e.jsxs(Ee,{className:"group hover:shadow-md transition-all hover:border-primary/50 cursor-pointer",onClick:()=>s(`/admin/lms/${C.id}`),children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(zt,{className:"text-base truncate",children:C.title}),C.description&&e.jsx(yr,{className:"mt-1 line-clamp-2",children:C.description})]}),e.jsx(at,{variant:C.is_published?"default":"secondary",className:"ml-2 shrink-0",children:C.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(Ou,{className:"h-3.5 w-3.5"}),A," module",A!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[C.is_sequential?e.jsx(A0,{className:"h-3.5 w-3.5"}):e.jsx(cN,{className:"h-3.5 w-3.5"}),C.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hr,{className:"h-3.5 w-3.5"}),L]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsxs(K,{size:"sm",variant:"ghost",onClick:q=>{q.stopPropagation(),w(C)},children:[C.is_published?e.jsx(Em,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(ya,{className:"h-3.5 w-3.5 mr-1"}),C.is_published?"Unpublish":"Publish"]}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:q=>{q.stopPropagation(),N(C.id)},children:e.jsx(br,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"flex-1"}),e.jsx(Fi,{className:"h-4 w-4 text-muted-foreground"})]})]})]},C.id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(Ou,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-1",children:"No courses yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"Create your first training course to get started"}),e.jsxs(K,{onClick:()=>d(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Course"]})]})})]}),e.jsx(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{children:"Course Title"}),e.jsx(Re,{value:u,onChange:C=>p(C.target.value),placeholder:"e.g. LevelUp Onboarding"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Mr,{value:f,onChange:C=>v(C.target.value),placeholder:"What will agents learn?",rows:3})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order"})]}),e.jsx(Br,{checked:_,onCheckedChange:b})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{onClick:j,disabled:!u.trim()||a.isPending,children:a.isPending?"Creating...":"Create Course"})]})]})})]})}function O0s(){const{courseId:t}=Mo(),s=Dr(),{data:r,isLoading:n}=j0s(t),a=cet(),o=S0s(),l=C0s(),i=M0s(),d=T0s(),u=A0s(),p=E0s(),{data:f}=Ct({queryKey:["all-brokerages"],queryFn:async()=>{const{data:$e}=await G.from("brokerages").select("id, name").order("name");return $e||[]}}),[v,_]=S.useState(null),[b,j]=S.useState(!1),[w,N]=S.useState({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),[C,A]=S.useState(null),[I,L]=S.useState({title:"",resource_type:"link",url:""}),[R,$]=S.useState(new Set),[q,U]=S.useState(null),[V,X]=S.useState(0),[se,te]=S.useState(!1),Y=S.useRef(null),de=S.useRef(null),[ie,ae]=S.useState(!1),[le,pe]=S.useState(""),[be,ye]=S.useState(""),[we,ke]=S.useState(""),[Ze,_e]=S.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(K,{variant:"outline",className:"mt-4",onClick:()=>s("/admin/lms"),children:[e.jsx(Ua,{className:"h-4 w-4 mr-2"})," Back to Courses"]})]})});const Ce=r.modules||[],Te=r.access||[],Fe=Te.some($e=>$e.access_type==="all"),Ae=Te.filter($e=>$e.access_type==="brokerage").map($e=>$e.brokerage_id),We=(f||[]).filter($e=>$e.name.toLowerCase().includes(le.toLowerCase())),ht=$e=>{const Ke=new Set(R);Ke.has($e)?Ke.delete($e):Ke.add($e),$(Ke)},De=async()=>{if(!q)return null;te(!0),X(0);try{const{data:$e,error:Ke}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:q.name}});if(Ke)throw new Error(Ke.message);const{videoId:ct,libraryId:Ue}=$e,{data:Ve,error:Je}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:ct,libraryId:Ue}});if(Je)throw new Error(Je.message);const Rt=new XMLHttpRequest;return await new Promise(($t,ls)=>{Rt.upload.onprogress=Qt=>{Qt.lengthComputable&&X(Math.round(Qt.loaded/Qt.total*100))},Rt.onload=()=>Rt.status>=200&&Rt.status<300?$t():ls(new Error(`Upload failed: ${Rt.status}`)),Rt.onerror=()=>ls(new Error("Upload failed")),Rt.open("PUT",Ve.uploadUrl),Rt.setRequestHeader("AccessKey",Ve.apiKey),Rt.send(q)}),`https://iframe.mediadelivery.net/embed/${Ue}/${ct}`}catch($e){return console.error("Bunny upload error:",$e),fe.error("Video upload failed"),null}finally{te(!1),X(0)}},Dt=async()=>{if(w.title.trim())try{let $e=w.video_url.trim()||void 0;if(q){const Ke=await De();if(!Ke)return;$e=Ke}await o.mutateAsync({course_id:r.id,title:w.title.trim(),description:w.description.trim()||void 0,video_url:$e,text_content:w.text_content.trim()||void 0,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):void 0,sort_order:Ce.length}),fe.success("Module added"),j(!1),N({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),U(null)}catch{fe.error("Failed to add module")}},he=async()=>{if(v)try{let $e=w.video_url.trim()||null;if(q){const Ke=await De();if(!Ke)return;$e=Ke}await l.mutateAsync({id:v.id,title:w.title.trim(),description:w.description.trim()||null,video_url:$e,text_content:w.text_content.trim()||null,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):null}),fe.success("Module updated"),_(null),U(null)}catch{fe.error("Failed to update")}},Qe=async $e=>{if(confirm("Delete this module?"))try{await i.mutateAsync($e),fe.success("Module deleted")}catch{fe.error("Failed to delete")}},ot=async $e=>{if(I.title.trim())try{await d.mutateAsync({module_id:$e,title:I.title.trim(),resource_type:I.resource_type,url:I.url.trim()||void 0}),fe.success("Resource added"),A(null),L({title:"",resource_type:"link",url:""})}catch{fe.error("Failed to add resource")}},rt=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[{access_type:"all"}]}),fe.success("Access updated: All brokerages / all agents")}catch{fe.error("Failed to update access")}},Ne=async $e=>{const Ke=Te.filter(Je=>Je.access_type==="brokerage").map(Je=>Je.brokerage_id),ct=Ke.includes($e);let Ue;ct?Ue=Ke.filter(Je=>Je!==$e):Ue=[...Ke,$e];const Ve=Ue.map(Je=>({access_type:"brokerage",brokerage_id:Je}));try{await p.mutateAsync({courseId:r.id,accessRules:Ve}),fe.success(ct?"Brokerage removed":"Brokerage added")}catch{fe.error("Failed to update access")}},it=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[]}),fe.success("Access cleared")}catch{fe.error("Failed")}},qe=async($e,Ke)=>{const ct=Ke==="up"?$e-1:$e+1;if(!(ct<0||ct>=Ce.length))try{await Promise.all([l.mutateAsync({id:Ce[$e].id,sort_order:ct}),l.mutateAsync({id:Ce[ct].id,sort_order:$e})])}catch{fe.error("Failed to reorder")}},Xe=async()=>{try{await a.mutateAsync({id:r.id,title:be,description:we||null}),fe.success("Course updated"),_e(!1)}catch{fe.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(K,{variant:"ghost",size:"icon",onClick:()=>s("/admin/lms"),children:e.jsx(Ua,{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(at,{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(A0,{className:"h-3.5 w-3.5"}):e.jsx(cN,{className:"h-3.5 w-3.5"}),r.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{children:[Ce.length," module",Ce.length!==1?"s":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{ye(r.title),ke(r.description||""),_e(!0)},children:[e.jsx(Ra,{className:"h-3.5 w-3.5 mr-1"})," Edit"]}),e.jsxs(K,{variant:r.is_published?"secondary":"default",size:"sm",onClick:()=>a.mutateAsync({id:r.id,is_published:!r.is_published}).then(()=>fe.success(r.is_published?"Unpublished":"Published")),children:[r.is_published?e.jsx(Em,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(ya,{className:"h-3.5 w-3.5 mr-1"}),r.is_published?"Unpublish":"Publish"]})]})]}),e.jsxs(Na,{defaultValue:"modules",className:"w-full",children:[e.jsxs(va,{children:[e.jsx(ks,{value:"modules",children:"Modules"}),e.jsx(ks,{value:"access",children:"Access & Permissions"}),e.jsx(ks,{value:"settings",children:"Settings"})]}),e.jsxs(zs,{value:"modules",className:"mt-6 space-y-4",children:[Ce.map(($e,Ke)=>e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>ht($e.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:ct=>{ct.stopPropagation(),qe(Ke,"up")},disabled:Ke===0,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Rg,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:ct=>{ct.stopPropagation(),qe(Ke,"down")},disabled:Ke===Ce.length-1,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Vo,{className:"h-3.5 w-3.5"})})]})}),e.jsx(at,{variant:"outline",className:"shrink-0 font-mono text-xs",children:Ke+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:$e.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[$e.video_url&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(kn,{className:"h-3 w-3"})," Video"]}),$e.text_content&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(In,{className:"h-3 w-3"})," Text"]}),$e.duration_minutes&&e.jsxs("span",{children:[$e.duration_minutes," min"]}),$e.resources&&$e.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Ho,{className:"h-3 w-3"})," ",$e.resources.length," resource(s)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:ct=>{var Ue;ct.stopPropagation(),_($e),N({title:$e.title,description:$e.description||"",video_url:$e.video_url||"",text_content:$e.text_content||"",duration_minutes:((Ue=$e.duration_minutes)==null?void 0:Ue.toString())||""})},children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:ct=>{ct.stopPropagation(),Qe($e.id)},children:e.jsx(br,{className:"h-3.5 w-3.5"})})]})]}),R.has($e.id)&&e.jsxs("div",{className:"border-t bg-muted/30 p-4 space-y-3",children:[$e.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:$e.description}),$e.video_url&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Video: "}),e.jsx("a",{href:$e.video_url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:$e.video_url})]}),$e.text_content&&e.jsx("div",{className:"text-sm bg-background rounded-md p-3 border max-h-40 overflow-auto whitespace-pre-wrap",children:$e.text_content}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Resources"}),e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>{A($e.id),L({title:"",resource_type:"link",url:""})},children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add Resource"]})]}),$e.resources&&$e.resources.length>0?e.jsx("div",{className:"space-y-1",children:$e.resources.map(ct=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-background rounded p-2 border",children:[e.jsx(at,{variant:"outline",className:"text-[10px]",children:ct.resource_type}),e.jsx("span",{className:"flex-1 truncate",children:ct.title}),ct.url&&e.jsx("a",{href:ct.url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline text-xs",children:"Open"}),e.jsx(K,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive",onClick:()=>u.mutateAsync(ct.id),children:e.jsx(Ur,{className:"h-3 w-3"})})]},ct.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No resources yet"})]})]})]},$e.id)),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{j(!0),N({title:"",description:"",video_url:"",text_content:"",duration_minutes:""})},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," Add Module"]})]}),e.jsx(zs,{value:"access",className:"mt-6 space-y-4",children:e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Who can access this course?"})}),e.jsxs(Oe,{className:"space-y-5",children:[e.jsxs("div",{className:Pt("flex items-center gap-3 p-4 rounded-xl border-2 cursor-pointer transition-all",Fe?"border-primary bg-primary/5":"border-muted hover:border-muted-foreground/30"),onClick:rt,children:[e.jsx("div",{className:Pt("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(Pm,{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(Br,{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:Ae.length===0?"No brokerages selected — agents won't see this course":`${Ae.length} brokerage${Ae.length!==1?"s":""} selected`})]}),Ae.length>0&&e.jsx(K,{size:"sm",variant:"ghost",className:"text-xs text-muted-foreground",onClick:it,children:"Clear all"})]}),e.jsx(Re,{placeholder:"Search brokerages...",value:le,onChange:$e=>pe($e.target.value),className:"h-9"}),e.jsx("div",{className:"border rounded-lg divide-y max-h-[360px] overflow-auto",children:We.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No brokerages found"}):We.map($e=>{const Ke=Ae.includes($e.id);return e.jsxs("div",{className:Pt("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors",Ke?"bg-primary/5":"hover:bg-muted/50"),onClick:()=>Ne($e.id),children:[e.jsx("div",{className:Pt("h-5 w-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors",Ke?"bg-primary border-primary":"border-muted-foreground/30"),children:Ke&&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(Aa,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:$e.name}),Ke&&e.jsx(at,{variant:"secondary",className:"text-[10px] shrink-0",children:"Active"})]},$e.id)})})]})]})]})}),e.jsxs(zs,{value:"settings",className:"mt-6 space-y-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(()=>fe.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(Ur,{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(T0,{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:de,type:"file",accept:"image/*",className:"hidden",onChange:async $e=>{var ct;const Ke=(ct=$e.target.files)==null?void 0:ct[0];if(!(!Ke||!r)){ae(!0);try{const Ue=Ke.name.split(".").pop(),Ve=`${r.id}/thumbnail.${Ue}`,{error:Je}=await G.storage.from("lms-thumbnails").upload(Ve,Ke,{upsert:!0});if(Je)throw Je;const{data:Rt}=G.storage.from("lms-thumbnails").getPublicUrl(Ve),$t=`${Rt.publicUrl}?t=${Date.now()}`;await a.mutateAsync({id:r.id,thumbnail_url:$t}),fe.success("Thumbnail uploaded")}catch{fe.error("Failed to upload thumbnail")}finally{ae(!1),de.current&&(de.current.value="")}}}}),e.jsxs(K,{variant:"outline",size:"sm",disabled:ie,onClick:()=>{var $e;return($e=de.current)==null?void 0:$e.click()},children:[ie?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ya,{className:"h-4 w-4 mr-2"}),ie?"Uploading...":"Upload Thumbnail"]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(Br,{checked:r.is_sequential,onCheckedChange:$e=>a.mutateAsync({id:r.id,is_sequential:$e}).then(()=>fe.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(Br,{checked:r.is_published,onCheckedChange:$e=>a.mutateAsync({id:r.id,is_published:$e}).then(()=>fe.success("Updated"))})]})]})]})]})]})]}),e.jsx(vs,{open:b||!!v,onOpenChange:$e=>{$e||(j(!1),_(null))},children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{children:"Title"}),e.jsx(Re,{value:w.title,onChange:$e=>N(Ke=>({...Ke,title:$e.target.value})),placeholder:"Module title"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Mr,{value:w.description,onChange:$e=>N(Ke=>({...Ke,description:$e.target.value})),placeholder:"Brief description",rows:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Video"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:Pt("border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors hover:border-primary/50",q?"border-primary bg-primary/5":"border-muted-foreground/25"),onClick:()=>{var $e;return($e=Y.current)==null?void 0:$e.click()},children:[e.jsx("input",{ref:Y,type:"file",accept:"video/*",className:"hidden",onChange:$e=>{var ct;const Ke=(ct=$e.target.files)==null?void 0:ct[0];Ke&&(U(Ke),N(Ue=>({...Ue,video_url:""})))}}),q?e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm",children:[e.jsx(kn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-primary",children:q.name}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:$e=>{$e.stopPropagation(),U(null)},children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"flex flex-col items-center gap-1 text-muted-foreground",children:[e.jsx(Ya,{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(As,{className:"h-3.5 w-3.5 animate-spin"}),e.jsxs("span",{children:["Uploading to Bunny.net... ",V,"%"]})]}),e.jsx(Ti,{value:V,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:w.video_url,onChange:$e=>N(Ke=>({...Ke,video_url:$e.target.value})),placeholder:"YouTube, Vimeo, or Bunny.net URL"})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Text Content"}),e.jsx(Mr,{value:w.text_content,onChange:$e=>N(Ke=>({...Ke,text_content:$e.target.value})),placeholder:"Additional text content, instructions, notes...",rows:4})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Duration (minutes)"}),e.jsx(Re,{type:"number",value:w.duration_minutes,onChange:$e=>N(Ke=>({...Ke,duration_minutes:$e.target.value})),placeholder:"e.g. 15"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>{j(!1),_(null),U(null)},children:"Cancel"}),e.jsxs(K,{onClick:v?he:Dt,disabled:!w.title.trim()||se,children:[se?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Bu,{className:"h-4 w-4 mr-2"}),se?"Uploading...":v?"Save Changes":"Add Module"]})]})]})}),e.jsx(vs,{open:!!C,onOpenChange:$e=>{$e||A(null)},children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{children:"Title"}),e.jsx(Re,{value:I.title,onChange:$e=>L(Ke=>({...Ke,title:$e.target.value})),placeholder:"Resource title"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Type"}),e.jsxs(tr,{value:I.resource_type,onValueChange:$e=>L(Ke=>({...Ke,resource_type:$e})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),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(ve,{children:"URL"}),e.jsx(Re,{value:I.url,onChange:$e=>L(Ke=>({...Ke,url:$e.target.value})),placeholder:"https://..."})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>A(null),children:"Cancel"}),e.jsx(K,{onClick:()=>C&&ot(C),disabled:!I.title.trim(),children:"Add Resource"})]})]})}),e.jsx(vs,{open:Ze,onOpenChange:_e,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{children:"Title"}),e.jsx(Re,{value:be,onChange:$e=>ye($e.target.value)})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Mr,{value:we,onChange:$e=>ke($e.target.value),rows:3})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>_e(!1),children:"Cancel"}),e.jsx(K,{onClick:Xe,disabled:!be.trim(),children:"Save"})]})]})})]})}function R0s(){return Ct({queryKey:["lms-stats-overview"],queryFn:async()=>{const{data:t,error:s}=await G.rpc("get_lms_stats");if(s)throw s;return t}})}function F0s(){return Ct({queryKey:["lms-stats-courses"],queryFn:async()=>{const{data:t,error:s}=await G.rpc("get_lms_course_stats");if(s)throw s;return t||[]}})}function z0s(t){return Ct({queryKey:["lms-stats-agents",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.rpc("get_lms_agent_progress",{p_course_id:t});if(r)throw r;return s||[]},enabled:!!t})}function B0s(){const t=Dr(),{data:s,isLoading:r}=R0s(),{data:n,isLoading:a}=F0s(),[o,l]=S.useState(null),{data:i,isLoading:d}=z0s(o),[u,p]=S.useState(""),f=n==null?void 0:n.find(b=>b.course_id===o),v=i==null?void 0:i.filter(b=>{var j,w;return!u||((j=b.agent_name)==null?void 0:j.toLowerCase().includes(u.toLowerCase()))||((w=b.email)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))}),_=[{label:"Total Courses",value:(s==null?void 0:s.total_courses)??0,icon:Ou,color:"text-primary"},{label:"Published",value:(s==null?void 0:s.published_courses)??0,icon:da,color:"text-emerald-500"},{label:"Enrolled Agents",value:(s==null?void 0:s.total_enrollments)??0,icon:hr,color:"text-blue-500"},{label:"Modules Completed",value:(s==null?void 0:s.total_completions)??0,icon:Ki,color:"text-amber-500"},{label:"Active (30d)",value:(s==null?void 0:s.active_learners)??0,icon:Cc,color:"text-violet-500"},{label:"Total Modules",value:(s==null?void 0:s.total_modules)??0,icon:Xo,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(K,{variant:"ghost",size:"icon",onClick:()=>t("/admin/lms"),children:e.jsx(Ua,{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(sh,{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(Ee,{className:Pt("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:Pt("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(Xo,{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(Ee,{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 j=o===b.course_id;return e.jsx(Ee,{className:Pt("cursor-pointer transition-all hover:shadow-md",j?"border-primary ring-1 ring-primary/30 shadow-md":"hover:border-primary/40"),onClick:()=>l(j?null: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(at,{variant:b.is_published?"default":"secondary",className:"shrink-0 text-[10px] px-1.5 py-0",children:b.is_published?"Live":"Draft"})]})}),e.jsx(Ha,{className:Pt("h-4 w-4 text-muted-foreground transition-transform shrink-0 ml-2",j&&"rotate-90")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children: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(Ti,{value:b.avg_completion_pct,className:"h-2"})]})]})},b.course_id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"py-10 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"No courses created yet"})})})]}),e.jsxs("div",{className:"xl:col-span-3 space-y-3",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(l_,{className:"h-5 w-5 text-primary"}),f?`Agent Progress — ${f.course_title}`:"Agent Progress"]}),o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(fn,{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=>p(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(Ee,{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,j)=>{const w=b.completion_pct>=100;return e.jsx(Ee,{className:Pt("transition-all",w&&"border-emerald-200 bg-emerald-50/30 dark:border-emerald-900/40 dark:bg-emerald-950/10"),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:Pt("flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold shrink-0",j===0?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":j===1?"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400":j===2?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-muted text-muted-foreground"),children:j+1}),e.jsxs(gn,{className:"h-9 w-9 shrink-0",children:[e.jsx(Ea,{src:b.avatar_url||void 0}),e.jsx(xn,{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}),w&&e.jsxs(at,{variant:"default",className:"text-[10px] px-1.5 py-0 bg-emerald-500 hover:bg-emerald-600 shrink-0",children:[e.jsx(da,{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"}),ws(new Date(b.last_activity),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"text-right shrink-0 w-20",children:[e.jsxs("p",{className:Pt("text-sm font-bold",w?"text-emerald-600 dark:text-emerald-400":"text-foreground"),children:[b.completion_pct,"%"]}),e.jsx(Ti,{value:b.completion_pct,className:"h-1.5 mt-1"})]})]})})},b.user_id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"py-10 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:u?"No agents match your search":"No agents have started this course yet"})})})]}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"py-16 text-center",children:[e.jsx(hr,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Select a course to view agent progress"})]})})]})]})]})})}function $0s(){const{user:t}=Gs(),s=Dr(),{data:r,isLoading:n}=P0s();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(sh,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"LevelUp U"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Your training & development hub"})]})]})}),e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-primary/5 rounded-full -translate-y-1/2 translate-x-1/2"})]}),n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(a=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Oe,{className:"p-6",children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-3"})]})},a))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:r.map(a=>e.jsx(q0s,{course:a,userId:t==null?void 0:t.id,onClick:()=>s(`/levelup-u/${a.id}`)},a.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(Ou,{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 q0s({course:t,userId:s,onClick:r}){var i;const n=((i=t.modules)==null?void 0:i.length)??0,{data:a}=det(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(Ee,{className:"group cursor-pointer hover:shadow-lg transition-all hover:border-primary/50 overflow-hidden",onClick:r,children:[t.thumbnail_url?e.jsx("div",{className:"aspect-video bg-muted overflow-hidden",children:e.jsx("img",{src:t.thumbnail_url,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"})}):e.jsx("div",{className:"aspect-video bg-gradient-to-br from-primary/15 via-primary/5 to-muted flex items-center justify-center",children:e.jsx(sh,{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(Ou,{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(A0,{className:"h-3.5 w-3.5"}):e.jsx(cN,{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(Ti,{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(Ha,{className:"h-3.5 w-3.5"})]})})]})]})}function U0s(){const{courseId:t}=Mo(),s=Dr(),{user:r}=Gs(),{data:n,isLoading:a}=I0s(t),{data:o}=det(t),l=L0s(),[i,d]=S.useState(null),u=(n==null?void 0:n.modules)||[],p=new Set((o==null?void 0:o.filter(C=>C.completed).map(C=>C.module_id))||[]),f=p.size,v=u.length>0?Math.round(f/u.length*100):0;S.useEffect(()=>{if(u.length>0&&!i){const C=u.find(A=>!p.has(A.id));d((C==null?void 0:C.id)||u[0].id)}},[u,i,p]);const _=u.find(C=>C.id===i),b=u.findIndex(C=>C.id===i),j=(C,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}),fe.success("Module completed! 🎉"),b{const A=C.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=C.match(/vimeo\.com\/(\d+)/);if(I)return`https://player.vimeo.com/video/${I[1]}`;const L=C.match(/(?:iframe\.mediadelivery\.net|video\.bunnycdn\.com)\/(?:play|embed)\/(\d+)\/([a-f0-9-]+)/);return L?`https://iframe.mediadelivery.net/embed/${L[1]}/${L[2]}?responsive=true`:C};return a?e.jsx(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(K,{variant:"ghost",size:"icon",onClick:()=>s("/levelup-u"),children:e.jsx(Ua,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h1",{className:"text-xl font-bold text-foreground truncate",children:n.title}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("span",{children:[f,"/",u.length," completed"]}),e.jsxs("span",{children:[v,"%"]})]})]}),e.jsx("div",{className:"w-32",children:e.jsx(Ti,{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(Ee,{className:"lg:sticky lg:top-4",children:e.jsxs(Oe,{className:"p-0",children:[e.jsx("div",{className:"p-3 border-b",children:e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Modules"})}),e.jsx(Bi,{className:"max-h-[calc(100vh-280px)]",children:e.jsx("div",{className:"p-1",children:u.map((C,A)=>{const I=j(C,A),L=p.has(C.id),R=C.id===i;return e.jsxs("button",{disabled:I,onClick:()=>!I&&d(C.id),className:Pt("w-full flex items-center gap-3 p-3 rounded-lg text-left transition-all text-sm",R?"bg-primary/10 text-primary":"hover:bg-muted/50",I&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"shrink-0",children:I?e.jsx(zu,{className:"h-4 w-4 text-muted-foreground"}):L?e.jsx(da,{className:"h-4 w-4 text-green-500"}):e.jsx(Gc,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:Pt("font-medium truncate",R&&"text-primary"),children:[A+1,". ",C.title]}),C.duration_minutes&&e.jsxs("span",{className:"text-[11px] text-muted-foreground flex items-center gap-0.5 mt-0.5",children:[e.jsx(Tn,{className:"h-3 w-3"})," ",C.duration_minutes," min"]})]})]},C.id)})})})]})}),e.jsx("div",{className:"space-y-4",children:_?e.jsxs(e.Fragment,{children:[_.video_url&&e.jsx(Ee,{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(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:_.title}),_.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:_.description})]}),p.has(_.id)?e.jsxs(at,{className:"bg-green-500/15 text-green-600 border-green-500/30 shrink-0",children:[e.jsx(da,{className:"h-3.5 w-3.5 mr-1"})," Completed"]}):e.jsxs(K,{size:"sm",onClick:w,disabled:l.isPending,children:[e.jsx(da,{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(C=>e.jsxs("a",{href:C.url||C.file_url||"#",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-sm",children:[C.resource_type==="pdf"?e.jsx(In,{className:"h-4 w-4 text-red-500 shrink-0"}):C.resource_type==="template"?e.jsx(sh,{className:"h-4 w-4 text-purple-500 shrink-0"}):e.jsx(Ho,{className:"h-4 w-4 text-blue-500 shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:C.title}),e.jsx(sn,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]},C.id))})]}),e.jsxs("div",{className:"flex items-center justify-between border-t pt-4",children:[e.jsxs(K,{variant:"outline",size:"sm",disabled:b===0,onClick:()=>b>0&&d(u[b-1].id),children:[e.jsx(Ua,{className:"h-3.5 w-3.5 mr-1"})," Previous"]}),bd(u[b+1].id),children:["Next ",e.jsx(Ha,{className:"h-3.5 w-3.5 ml-1"})]}):v===100&&e.jsx(at,{className:"bg-green-500/15 text-green-600 border-green-500/30 text-sm px-3 py-1.5",children:"🎉 Course Complete!"})]})]})})]}):e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-16 text-muted-foreground",children:"Select a module to begin"})})})]})]})}):e.jsx(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(K,{variant:"outline",className:"mt-4",onClick:()=>s("/levelup-u"),children:[e.jsx(Ua,{className:"h-4 w-4 mr-2"})," Back"]})]})})}function V0s(){const{slug:t}=Mo(),{toast:s}=Ia(),[r,n]=S.useState(!1),[a,o]=S.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",experience_years:"",annual_production:"",license_number:"",why_interested:""}),{data:l,isLoading:i,error:d}=Ct({queryKey:["recruit-form-brokerage",t],queryFn:async()=>{const{data:A,error:I}=await G.from("brokerages").select("id, name, recruit_form_enabled").eq("recruit_form_slug",t).single();if(I)throw I;return A},enabled:!!t}),{data:u}=Ct({queryKey:["recruit-landing-public",l==null?void 0:l.id],queryFn:async()=>{const{data:A,error:I}=await G.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)}),p=Ot({mutationFn:async()=>{const{error:A}=await G.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(Aa,{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 f=u,v=(f==null?void 0:f.primary_color)||"#406E71",_=(f==null?void 0:f.accent_color)||"#2a4c64",b=(f==null?void 0:f.benefits)||[],j=(f==null?void 0:f.testimonials)||[],w=(f==null?void 0:f.gallery_images)||[],N=(f==null?void 0:f.hero_headline)||`Join ${l.name}`,C=(f==null?void 0:f.hero_subtext)||"Take your real estate career to the next level.";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(ua,{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:f!=null&&f.hero_image_url?`linear-gradient(135deg, ${v}dd, ${_}cc)`:`linear-gradient(135deg, ${v}, ${_})`},children:[(f==null?void 0:f.hero_image_url)&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center mix-blend-overlay opacity-40",style:{backgroundImage:`url(${f.hero_image_url})`}}),e.jsxs("div",{className:"relative z-10 text-center max-w-3xl mx-auto px-6 py-20",children:[(f==null?void 0:f.logo_url)&&e.jsx("img",{src:f.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:C}),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(Vo,{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))})]})}),w.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(hr,{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:w.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))})]})}),j.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(_5,{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:j.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(),p.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(ve,{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(ve,{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(ve,{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(ve,{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(ve,{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(ve,{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(ve,{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(ve,{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(ve,{className:"text-gray-700",children:"Why are you interested?"}),e.jsx(Mr,{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(K,{type:"submit",className:"w-full h-12 text-base font-semibold rounded-xl",style:{backgroundColor:v},disabled:p.isPending,children:p.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 H0s(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 W0s(){var v,_,b,j;const{shareToken:t}=Mo(),s=S.useRef(!1),{data:r,isLoading:n,error:a}=Ct({queryKey:["public-recruit-video",t],queryFn:async()=>{var L;if(!t)throw new Error("No token");const{data:w,error:N}=await G.from("recruit_videos").select(` *, prospect:recruit_prospects(first_name, last_name), video:agent_videos(id, title, playback_url, thumbnail_url, duration_seconds, owner_user_id) `).eq("share_token",t).single();if(N)throw N;const{data:C}=await G.from("profiles").select("name, avatar_url, title").eq("id",(L=w.video)==null?void 0:L.owner_user_id).single(),{data:A}=await G.from("brokerages").select("name").eq("id",w.brokerage_id).single(),{data:I}=await G.from("recruit_landing_page_settings").select("logo_url, primary_color, accent_color, hero_headline").eq("brokerage_id",w.brokerage_id).maybeSingle();return{rv:w,profile:C,brokerage:A,settings:I}},enabled:!!t});if(S.useEffect(()=>{var w;!((w=r==null?void 0:r.rv)!=null&&w.id)||s.current||(s.current=!0,G.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",p=((_=o.prospect)==null?void 0:_.first_name)||"there",f=(b=o.video)!=null&&b.playback_url?H0s(o.video.playback_url):null;return e.jsxs(e.Fragment,{children:[e.jsx(ah,{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 ",p,", ",l==null?void 0:l.name," has a message for you"]}),o.message&&e.jsx("p",{className:"text-muted-foreground max-w-xl mx-auto",children:o.message})]}),f&&e.jsx("div",{className:"rounded-xl overflow-hidden shadow-xl bg-black",children:e.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:e.jsx("iframe",{src:f,loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,width:"100%",height:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border p-6 flex items-center gap-4",children:[l!=null&&l.avatar_url?e.jsx("img",{src:l.avatar_url,alt:"",className:"h-14 w-14 rounded-full object-cover"}):e.jsx("div",{className:"h-14 w-14 rounded-full flex items-center justify-center text-white text-lg font-bold",style:{backgroundColor:u},children:((j=l==null?void 0:l.name)==null?void 0:j.charAt(0))||"?"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold",children:l==null?void 0:l.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(l==null?void 0:l.title)||"Recruiter"," · ",i==null?void 0:i.name]})]})]}),e.jsx("div",{className:"text-center",children:e.jsxs(K,{size:"lg",className:"text-white shadow-lg hover:shadow-xl transition-shadow px-8",style:{backgroundColor:u},onClick:()=>{G.from("recruit_videos").update({cta_clicked_at:new Date().toISOString()}).eq("id",o.id).then(()=>{})},children:[e.jsx(on,{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 G0s(){const t=Dr(),s=ns(),{isAdmin:r}=Gs(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState(null),{data:u,isLoading:p}=Ct({queryKey:["my-social-accounts"],queryFn:async()=>{const{data:{user:L},error:R}=await G.auth.getUser();if(R)throw R;if(!L)return[];const{data:$,error:q}=await G.from("social_accounts").select("*").eq("user_id",L.id).order("created_at",{ascending:!1});if(q)throw q;return $}}),f=Ot({mutationFn:async L=>{const{data:{user:R},error:$}=await G.auth.getUser();if($)throw $;if(!R)throw new Error("Not authenticated");const{error:q}=await G.from("social_accounts").delete().eq("id",L).eq("user_id",R.id);if(q)throw q},onSuccess:()=>{s.invalidateQueries({queryKey:["my-social-accounts"]}),s.invalidateQueries({queryKey:["social-accounts-for-post"]}),fe.success("Account disconnected successfully")},onError:()=>{fe.error("Failed to disconnect account")}}),v=async()=>{a(!0);try{const{data:L,error:R}=await G.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(R)throw R;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get authorization URL")}catch(L){console.error("Meta OAuth error:",L),fe.error("Failed to start connection. Please try again."),a(!1)}},_=async()=>{a(!0);try{const{data:L,error:R}=await G.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(R)throw R;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(L){console.error("LinkedIn OAuth error:",L),fe.error("Failed to start LinkedIn connection. Please try again."),a(!1)}},b=async()=>{a(!0);try{const{data:L,error:R}=await G.functions.invoke("google-business-oauth",{body:{action:"get_auth_url"}});if(R)throw R;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get Google authorization URL")}catch(L){console.error("Google OAuth error:",L),fe.error("Failed to start Google connection. Please try again."),a(!1)}},j=(u==null?void 0:u.filter(L=>L.platform==="facebook"))||[],w=(u==null?void 0:u.filter(L=>L.platform==="instagram"))||[],N=(u==null?void 0:u.filter(L=>L.platform==="linkedin"))||[],C=(u==null?void 0:u.filter(L=>L.platform==="google_business"))||[],A=((u==null?void 0:u.length)||0)>0,I=async(L,R)=>{l(L),d(null);try{const{data:$,error:q}=await G.functions.invoke("meta-api-test",{body:{testType:"all",accountId:L}});if(q)throw q;d($.results||[]),fe.success($.summary||"API tests completed")}catch($){console.error("Meta API test error:",$),fe.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(at,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(hn,{className:"h-3 w-3 mr-1"}),"Post directly from Social Swag"]})}),e.jsx("h1",{className:"text-2xl md:text-3xl font-bold mb-2",children:"Connect Your Social Accounts"}),e.jsx("p",{className:"text-white/90 max-w-xl",children:"Link your Facebook Pages and Instagram Business accounts to post content directly from Social Swag with one click."})]})]}),e.jsxs(K,{variant:"ghost",onClick:()=>t("/social-swag-2"),className:"gap-2",children:[e.jsx(Ua,{className:"h-4 w-4"}),"Back to Social Swag"]}),!r&&e.jsx(Ee,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-amber-100 dark:bg-amber-900/30 p-4 mb-4",children:e.jsx(Tn,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),e.jsx(at,{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(Ee,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:e.jsxs(Oe,{className:"flex items-center gap-4 p-4",children:[e.jsx("div",{className:"rounded-full bg-green-500 p-2",children:e.jsx(gi,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-green-800 dark:text-green-200",children:"You're all set!"}),e.jsx("p",{className:"text-sm text-green-600 dark:text-green-400",children:"You can now post directly to your connected accounts from Social Swag."})]})]})}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{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(Hd,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Facebook"}),e.jsx(yr,{children:"Connect your Facebook Pages"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Po,{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(gn,{className:"h-10 w-10",children:[e.jsx(Ea,{src:L.profile_picture_url||""}),e.jsx(xn,{children:e.jsx(Hd,{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(at,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect Facebook?"}),e.jsx(Dl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Facebook pages connected yet"}),e.jsxs(K,{onClick:v,disabled:n,className:"w-full gap-2",variant:j.length>0?"outline":"default",children:[n?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),j.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{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(Wd,{className:"h-6 w-6 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Instagram"}),e.jsx(yr,{children:"Connect Instagram Business accounts"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Po,{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(gn,{className:"h-10 w-10",children:[e.jsx(Ea,{src:L.profile_picture_url||""}),e.jsx(xn,{children:e.jsx(Wd,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["@",L.platform_username||"Instagram Account"]}),e.jsx(at,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect Instagram?"}),e.jsx(Dl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Instagram accounts connected yet"}),e.jsxs(K,{onClick:v,disabled:n,className:"w-full gap-2",variant:w.length>0?"outline":"default",children:[n?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),w.length>0?"Connect Another Account":"Connect Instagram"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Instagram Business accounts must be connected to a Facebook Page"})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{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(Lm,{className:"h-6 w-6 text-blue-700"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"LinkedIn"}),e.jsx(yr,{children:"Connect your LinkedIn profile"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Po,{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(gn,{className:"h-10 w-10",children:[e.jsx(Ea,{src:L.profile_picture_url||""}),e.jsx(xn,{children:e.jsx(Lm,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.platform_username||"LinkedIn Account"}),e.jsx(at,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect LinkedIn?"}),e.jsx(Dl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No LinkedIn account connected yet"}),e.jsxs(K,{onClick:_,disabled:n,className:"w-full gap-2",variant:N.length>0?"outline":"default",children:[n?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{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(Ee,{className:`relative overflow-hidden ${r?"":"opacity-75"}`,children:[!r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(at,{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(at,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Admin Testing"})}),e.jsx(Lt,{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(Ai,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Google Business"}),e.jsx(yr,{children:"Connect your Google Business Profile"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Po,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):C.length>0?e.jsx("div",{className:"space-y-3",children:C.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(gn,{className:"h-10 w-10",children:[e.jsx(Ea,{src:L.profile_picture_url||""}),e.jsx(xn,{children:e.jsx(Ai,{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(at,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(nc,{children:[e.jsx(Lh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect Google Business?"}),e.jsx(Dl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:r?"No Google Business account connected yet":"Google Business Profile integration is coming soon!"}),e.jsxs(K,{onClick:r?b:void 0,disabled:!r||n,className:"w-full gap-2",variant:C.length>0?"outline":"default",children:[n?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),C.length>0?"Reconnect Google Business":"Connect Google Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Post updates directly to your Google Business Profile"})]})]})]}),r&&(j.length>0||w.length>0)&&e.jsxs(Ee,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900",children:[e.jsx(Lt,{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(t_,{className:"h-6 w-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(yr,{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:[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(Hd,{className:"h-5 w-5 text-blue-600"}),e.jsx("span",{className:"font-medium",children:L.page_name||"Facebook Page"})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>I(L.id),disabled:o===L.id,children:o===L.id?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(t_,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${L.id}`)),w.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Wd,{className:"h-5 w-5 text-pink-600"}),e.jsxs("span",{className:"font-medium",children:["@",L.platform_username||"Instagram"]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>I(L.id),disabled:o===L.id,children:o===L.id?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(t_,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-ig-${L.id}`))]}),i&&i.length>0&&e.jsxs("div",{className:"mt-4 rounded-lg border bg-background p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Test Results"}),e.jsx("div",{className:"space-y-2",children:i.map((L,R)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[L.status==="success"?e.jsx(da,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):L.status==="pending"?e.jsx(As,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):e.jsx(kc,{className:"h-4 w-4 text-red-600 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-mono text-xs bg-muted px-1 rounded",children:L.test}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:L.details})]})]},R))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Note: Facebook posts are auto-deleted. Instagram posts will remain and should be manually deleted. Allow up to 24 hours for Meta to register the API calls."})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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 K0s(){const[t]=Ec(),s=Dr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Processing your connection...");return S.useEffect(()=>{(async()=>{var f;const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),fe.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),fe.error("No authorization code received");return}try{const{data:v,error:_}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/social-connections/callback"}});if(_)throw _;if(v!=null&&v.success)n("success"),o(`Successfully connected ${((f=v.accounts)==null?void 0:f.length)||0} account(s)!`),fe.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"),fe.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(Ee,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(As,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(gi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(kc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(yr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function Z0s(){const[t]=Ec(),s=Dr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Connecting your Google Business Profile...");return S.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),fe.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),fe.error("No authorization code received");return}try{const{data:f,error:v}=await G.functions.invoke("google-business-oauth",{body:{action:"exchange_code",code:i,state:p}});if(v)throw v;if(f!=null&&f.success)n("success"),o(f.message||"Successfully connected Google Business Profile!"),fe.success("Google Business Profile connected!");else throw new Error((f==null?void 0:f.error)||"Unknown error")}catch(f){console.error("Google OAuth callback error:",f),n("error"),o(f instanceof Error?f.message:"Failed to connect Google Business Profile"),fe.error("Failed to connect: "+(f instanceof Error?f.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(As,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(gi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(kc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(yr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/social-connections"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function Y0s(){const[t]=Ec(),s=Dr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Connecting your LinkedIn account...");return S.useEffect(()=>{(async()=>{var f;const i=t.get("code"),d=t.get("state"),u=t.get("error"),p=t.get("error_description");if(u){console.error("LinkedIn OAuth error:",u,p),n("error"),o(p||"Failed to connect LinkedIn account"),fe.error(p||"Failed to connect LinkedIn");return}if(!i){n("error"),o("No authorization code received"),fe.error("No authorization code received");return}try{const{data:v,error:_}=await G.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 ${((f=v.accounts)==null?void 0:f.length)||1} LinkedIn account`),fe.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"),fe.error("Failed to connect LinkedIn")}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center p-4 bg-background",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Lt,{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(As,{className:"h-8 w-8 animate-spin text-blue-600"}),r==="success"&&e.jsx(gi,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx(kc,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(zt,{className:"flex items-center justify-center gap-2",children:[e.jsx(Lm,{className:"h-5 w-5 text-blue-600"}),r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(yr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/social-connections"),disabled:r==="loading",children:r==="success"?"Continue":"Back to Connections"})})]})})}function X0s(){const t=Dr(),[s,r]=S.useState(null),{data:n,isLoading:a}=$Je(s||void 0,!0),{data:o,isLoading:l}=z2e(!0),{cartItems:i}=Voe(),d=i.reduce((p,f)=>p+f.quantity,0),u=p=>{t(`/marketplace/${p.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(p=>e.jsx(gs,{className:"h-10 w-24 flex-shrink-0"},p))}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:[1,2,3,4].map(p=>e.jsx(gs,{className:"h-72 w-full"},p))})]})}):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(K,{variant:"outline",onClick:()=>t("/marketplace/cart"),className:"relative",children:[e.jsx(km,{className:"h-4 w-4 mr-2"}),"Cart",d>0&&e.jsx(at,{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(K,{variant:s===null?"default":"outline",size:"sm",onClick:()=>r(null),children:"All"}),o.map(p=>e.jsx(K,{variant:s===p.id?"default":"outline",size:"sm",onClick:()=>r(p.id),children:p.name},p.id))]}),n&&n.length>0?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:n.map(p=>{var f;return e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>u(p),children:[e.jsxs("div",{className:"aspect-square bg-muted relative",children:[p.images&&p.images.length>0?e.jsx("img",{src:((f=p.images.find(v=>v.is_primary))==null?void 0:f.image_url)||p.images[0].image_url,alt:p.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(dl,{className:"h-12 w-12 text-muted-foreground"})}),p.category&&e.jsx(at,{className:"absolute top-2 left-2",variant:"secondary",children:p.category.name})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1 line-clamp-1",children:p.name}),p.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2 line-clamp-2",children:p.description}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-bold text-lg",children:["$",Number(p.base_price).toFixed(2)]}),p.variants&&p.variants.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.variants.length," options"]})]})]})]},p.id)})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(dl,{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 uet=S.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));uet.displayName="Breadcrumb";const het=S.forwardRef(({className:t,...s},r)=>e.jsx("ol",{ref:r,className:Pt("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...s}));het.displayName="BreadcrumbList";const jre=S.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:Pt("inline-flex items-center gap-1.5",t),...s}));jre.displayName="BreadcrumbItem";const G0e=S.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?Wve:"a";return e.jsx(a,{ref:n,className:Pt("transition-colors hover:text-foreground",s),...r})});G0e.displayName="BreadcrumbLink";const met=S.forwardRef(({className:t,...s},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:Pt("font-normal text-foreground",t),...s}));met.displayName="BreadcrumbPage";const K0e=({children:t,className:s,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Pt("[&>svg]:size-3.5",s),...r,children:t??e.jsx(Ha,{})});K0e.displayName="BreadcrumbSeparator";function Q0s(){var te,Y;const{productId:t}=Mo(),s=Dr(),{data:r,isLoading:n}=lxs(t||""),{addToCart:a,cartItems:o}=Voe(),[l,i]=S.useState(null),[d,u]=S.useState(1),[p,f]=S.useState(0),[v,_]=S.useState(null),[b,j]=S.useState(!1),[w,N]=S.useState(!1),C=(te=r==null?void 0:r.variants)==null?void 0:te.find(de=>de.id===l),A=((Y=r==null?void 0:r.variants)==null?void 0:Y.filter(de=>de.is_active))||[],I=Number((r==null?void 0:r.base_price)||0),L=C?Number(C.price_adjustment):0,R=I+L,$=Number((r==null?void 0:r.shipping_fee)||0),q=o.reduce((de,ie)=>de+ie.quantity,0),U=async de=>{if(!de.target.files||de.target.files.length===0)return;j(!0);const ie=de.target.files[0],ae=ie.name.split(".").pop(),le=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${ae}`;try{const{error:pe}=await G.storage.from("marketplace").upload(le,ie);if(pe)throw pe;const{data:{publicUrl:be}}=G.storage.from("marketplace").getPublicUrl(le);_(be),fe.success("Artwork uploaded successfully")}catch(pe){fe.error("Failed to upload artwork: "+pe.message)}finally{j(!1)}},V=()=>{if(r){if(A.length>0&&!l){fe.error("Please select an option");return}a(r,C||void 0,d,v||void 0),N(!0),fe.success("Added to cart!"),setTimeout(()=>N(!1),2e3)}},X=()=>{r!=null&&r.images&&f(de=>(de+1)%r.images.length)},se=()=>{r!=null&&r.images&&f(de=>(de-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(uet,{className:"mb-6",children:e.jsxs(het,{children:[e.jsx(jre,{children:e.jsx(G0e,{asChild:!0,children:e.jsx(vo,{to:"/marketplace",children:"Marketplace"})})}),r.category&&e.jsxs(e.Fragment,{children:[e.jsx(K0e,{}),e.jsx(jre,{children:e.jsx(G0e,{asChild:!0,children:e.jsx(vo,{to:`/marketplace?category=${r.category.id}`,children:r.category.name})})})]}),e.jsx(K0e,{}),e.jsx(jre,{children:e.jsx(met,{children:r.name})})]})}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"relative aspect-square bg-muted rounded-lg overflow-hidden flex items-center justify-center",children:r.images&&r.images.length>0?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:r.images[p].image_url,alt:r.name,className:"max-w-full max-h-full object-contain"}),r.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:se,children:e.jsx(zl,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:X,children:e.jsx(Ha,{className:"h-6 w-6"})})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(dl,{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((de,ie)=>e.jsx("button",{onClick:()=>f(ie),className:`w-16 h-16 flex-shrink-0 rounded-md overflow-hidden border-2 ${ie===p?"border-primary":"border-transparent"}`,children:e.jsx("img",{src:de.image_url,alt:"",className:"w-full h-full object-cover"})},de.id))}),r.video&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-2",children:"Product Video"}),e.jsx("div",{className:"aspect-video",children:e.jsx("iframe",{src:r.video.video_url,className:"w-full h-full rounded-lg",allowFullScreen:!0})})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[r.category&&e.jsx(at,{variant:"secondary",className:"mb-2",children:r.category.name}),e.jsx("h1",{className:"text-3xl font-bold mb-2",children:r.name}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-3xl font-bold",children:["$",R.toFixed(2)]}),$>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(ve,{children:"Select Option"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:A.map(de=>e.jsxs(K,{variant:l===de.id?"default":"outline",onClick:()=>i(de.id),children:[de.name,Number(de.price_adjustment)!==0&&e.jsxs("span",{className:"ml-1 opacity-70",children:["(",Number(de.price_adjustment)>0?"+":"","$",Number(de.price_adjustment).toFixed(2),")"]})]},de.id))})]}),r.allow_artwork_upload&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{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(K,{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:U,className:"hidden",id:"artwork-upload",disabled:b}),e.jsxs("label",{htmlFor:"artwork-upload",className:"flex flex-col items-center cursor-pointer",children:[e.jsx(Ya,{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(ve,{children:"Quantity"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(de=>Math.max(1,de-1)),children:"-"}),e.jsx(Re,{type:"number",value:d,onChange:de=>u(Math.max(1,parseInt(de.target.value)||1)),className:"w-20 text-center",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(de=>de+1),children:"+"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(K,{size:"lg",className:"flex-1",onClick:V,disabled:w,children:w?e.jsxs(e.Fragment,{children:[e.jsx(ua,{className:"h-5 w-5 mr-2"}),"Added!"]}):e.jsxs(e.Fragment,{children:[e.jsx(km,{className:"h-5 w-5 mr-2"}),"Add to Cart"]})}),e.jsxs(K,{variant:"outline",size:"lg",onClick:()=>s("/marketplace/cart"),className:"relative",children:[e.jsx(km,{className:"h-5 w-5"}),q>0&&e.jsx(at,{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(dl,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Product not found"}),e.jsx(K,{onClick:()=>s("/marketplace"),children:"Back to Marketplace"})]})})}function J0s(){const t=Dr(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:d}=Voe(),[u,p]=S.useState(!1),[f,v]=S.useState(""),_=async()=>{if(s.length===0){fe.error("Your cart is empty");return}p(!0);try{const{data:b,error:j}=await G.functions.invoke("marketplace-checkout",{body:{items:s.map(w=>{var N;return{product_id:w.product.id,variant_id:((N=w.variant)==null?void 0:N.id)||null,quantity:w.quantity,artwork_url:w.artworkUrl||null}}),notes:f.trim()||null}});if(j)throw j;if(b!=null&&b.url)d(),window.open(b.url,"_blank");else throw new Error("No checkout URL received")}catch(b){fe.error("Checkout failed: "+b.message)}finally{p(!1)}};return s.length===0?e.jsx(Ms,{title:"Shopping Cart",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Kx,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Your cart is empty"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Add some products to get started!"}),e.jsx(K,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(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 j,w;return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-24 h-24 flex-shrink-0 bg-muted rounded-lg overflow-hidden",children:b.product.images&&b.product.images.length>0?e.jsx("img",{src:((j=b.product.images.find(N=>N.is_primary))==null?void 0:j.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(Kx,{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(K,{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(br,{className:"h-4 w-4 text-destructive"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var N;return n(b.product.id,(N=b.variant)==null?void 0:N.id,b.quantity-1)},disabled:b.quantity<=1,children:e.jsx(P0,{className:"h-3 w-3"})}),e.jsx(Re,{type:"number",value:b.quantity,onChange:N=>{var C;return n(b.product.id,(C=b.variant)==null?void 0:C.id,parseInt(N.target.value)||1)},className:"w-14 h-8 text-center text-sm",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var N;return n(b.product.id,(N=b.variant)==null?void 0:N.id,b.quantity+1)},children:e.jsx(Zs,{className:"h-3 w-3"})})]})]})]})})},`${b.product.id}-${((w=b.variant)==null?void 0:w.id)||"base"}`)}),e.jsx(K,{variant:"ghost",className:"text-destructive",onClick:d,children:"Clear Cart"})]}),e.jsx("div",{children:e.jsxs(Ee,{className:"sticky top-4",children:[e.jsx(Lt,{children:e.jsx(zt,{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,j)=>b+j.quantity,0)," items)"]}),e.jsxs("span",{children:["$",o().toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",l().toFixed(2)]})]}),e.jsx(Rl,{}),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(Rl,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),e.jsx(Mr,{id:"orderNotes",placeholder:"Add any special instructions, design notes, or comments for your order...",value:f,onChange:b=>v(b.target.value),rows:3,className:"resize-none"})]}),e.jsx(K,{className:"w-full",size:"lg",onClick:_,disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Checkout",e.jsx(Fi,{className:"h-5 w-5 ml-2"})]})}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Secure checkout powered by Stripe"})]})]})})]})})}function evs(){const t=Dr(),{data:s,isLoading:r}=vxs();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(dl,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No orders yet"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Start shopping to see your orders here!"}),e.jsx(K,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Ms,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:s.map(n=>{var a,o,l;return e.jsx(Ee,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>t(`/marketplace/orders/${n.id}`),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:n.order_number}),e.jsx("span",{className:"text-muted-foreground text-sm ml-2",children:ws(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(at,{className:F2e[n.status],children:$5[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(K,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),window.open(n.tracking_url,"_blank")},children:[e.jsx(sn,{className:"h-4 w-4 mr-1"}),"Track"]}),e.jsx(Ha,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const XLe=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function tvs({currentStatus:t,statusHistory:s}){const r=XLe.indexOf(t);return e.jsx("div",{className:"space-y-3",children:XLe.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(da,{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:$5[n]}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ws(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function svs(){var N;const{orderId:t}=Mo(),s=Dr(),{data:r,isLoading:n,refetch:a}=_xs(t||""),o=jxs(),l=kxs(),[i,d]=S.useState(!1),[u,p]=S.useState(null),[f,v]=S.useState(""),[_,b]=S.useState(null),j=async C=>{b(C);try{await o.mutateAsync({orderId:t,itemId:C}),fe.success("Proof approved!"),a()}catch{fe.error("Failed to approve proof")}finally{b(null)}},w=async()=>{if(u){b(u);try{await l.mutateAsync({orderId:t,itemId:u,reason:f}),fe.success("Revision requested"),d(!1),v(""),p(null),a()}catch{fe.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(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"Order Status"}),e.jsx(at,{className:F2e[r.status],children:$5[r.status]})]}),e.jsx(Oe,{children:e.jsx(tvs,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Items"})}),e.jsx(Oe,{className:"space-y-4",children:(N=r.items)==null?void 0:N.map(C=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold",children:C.product_name}),C.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.variant_name}),e.jsxs("p",{className:"text-sm",children:["Qty: ",C.quantity," × $",Number(C.unit_price).toFixed(2)]})]}),e.jsxs("p",{className:"font-semibold",children:["$",(Number(C.unit_price)*C.quantity).toFixed(2)]})]}),C.artwork_url&&e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your Artwork:"}),e.jsxs("a",{href:C.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline",children:[e.jsx(e_,{className:"h-4 w-4"}),"View Artwork",e.jsx(sn,{className:"h-3 w-3"})]})]}),C.proof_url&&e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Proof Ready for Review"}),e.jsxs("a",{href:C.proof_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline mb-3",children:[e.jsx(e_,{className:"h-4 w-4"}),"View Proof",e.jsx(sn,{className:"h-3 w-3"})]}),C.proof_status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(K,{size:"sm",onClick:()=>j(C.id),disabled:_===C.id,children:[_===C.id?e.jsx(As,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(pu,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{p(C.id),d(!0)},disabled:_===C.id,children:[e.jsx(IP,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),C.proof_status==="approved"&&e.jsxs(at,{className:"bg-green-100 text-green-800",children:[e.jsx(da,{className:"h-3 w-3 mr-1"}),"Proof Approved"]}),C.proof_status==="rejected"&&C.proof_notes&&e.jsxs("div",{className:"mt-2",children:[e.jsx(at,{variant:"destructive",className:"mb-2",children:"Revision Requested"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:C.proof_notes})]})]})]},C.id))})]}),r.shipping_name&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(DP,{className:"h-5 w-5"}),"Shipping"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-medium",children:r.shipping_name}),e.jsxs("p",{className:"text-muted-foreground",children:[r.shipping_address,e.jsx("br",{}),r.shipping_city,", ",r.shipping_state," ",r.shipping_zip]}),r.tracking_number&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tracking Number:"}),e.jsx("p",{className:"font-mono font-medium",children:r.tracking_number}),r.tracking_url&&e.jsxs(K,{variant:"link",className:"p-0 h-auto mt-1",onClick:()=>window.open(r.tracking_url,"_blank"),children:["Track Package",e.jsx(sn,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),e.jsx("div",{children:e.jsxs(Ee,{className:"sticky top-4",children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Order Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",ws(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(Rl,{}),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(Rl,{}),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(Rl,{}),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(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{children:"Request Changes"}),e.jsx(Kr,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(Mr,{placeholder:"Describe the changes needed...",value:f,onChange:C=>v(C.target.value),rows:4}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{onClick:w,disabled:!f.trim()||_!==null,children:[_?e.jsx(As,{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(dl,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Order not found"}),e.jsx(K,{onClick:()=>s("/marketplace/orders"),children:"View All Orders"})]})})}function rvs(){const t=Dr(),[s]=Ec();return s.get("session_id"),S.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(Ee,{children:e.jsxs(Oe,{className:"pt-8 pb-6",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(da,{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(dl,{className:"h-4 w-4"}),"What happens next?"]}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("li",{children:"• We'll review your order and prepare it for production"}),e.jsx("li",{children:"• If your order requires a proof, you'll receive it for approval"}),e.jsx("li",{children:"• Once approved, we'll begin production and ship when ready"}),e.jsx("li",{children:"• You'll receive tracking info when your order ships"})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(K,{className:"flex-1",onClick:()=>t("/marketplace/orders"),children:["View My Orders",e.jsx(Fi,{className:"h-4 w-4 ml-2"})]}),e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function nvs(){const{user:t}=Gs(),[s,r]=S.useState("store"),[n,a]=S.useState(null),[o,l]=S.useState(null),[i,d]=S.useState(!1),[u,p]=S.useState(5),[f,v]=S.useState(""),[_,b]=S.useState(!1),[j,w]=S.useState(!1),[N,C]=S.useState(""),[A,I]=S.useState(null),[L,R]=S.useState(!1),{hasSubmittedReview:$,submitReview:q,markPostedToGoogle:U}=nqe(),{data:V}=UJe(),{data:X,isLoading:se}=qJe(),{data:te,isLoading:Y}=Exs(n),{data:de,isLoading:ie}=Pxs(t==null?void 0:t.id),{data:ae=0}=Lxs(t==null?void 0:t.id),le=Dxs(),pe=new Set((de==null?void 0:de.map(Ce=>Ce.item_id))||[]),be=async()=>{if(o)try{await le.mutateAsync(o.id),fe.success(`Successfully purchased "${o.name}"!`),l(null)}catch(Ce){fe.error(Ce.message||"Failed to purchase item")}},ye=async()=>{if(!f.trim()){fe.error("Please write a review");return}b(!0);const Ce=await q(u,f);b(!1),Ce.success?(fe.success("Thank you for your review! You earned 25 points!"),C(f),w(!0),v(""),p(5)):fe.error(Ce.error||"Failed to submit review")},we=()=>{navigator.clipboard.writeText(N),fe.success("Review copied to clipboard!")},ke=()=>{U(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},Ze=()=>{w(!1),d(!1),C("")};return se||Y||ie?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(Ce=>e.jsx(gs,{className:"h-64"},Ce))})]})}):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(Ee,{className:"bg-gradient-to-r from-primary/10 to-primary/5 border-primary/20",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(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:ae.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(Ki,{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($h,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{children:"Streak bonuses add extra points!"})]})]})]})})}),e.jsx(mf,{open:L,onOpenChange:R,children:e.jsxs(Ee,{className:"border-primary/20",children:[e.jsx(pf,{asChild:!0,children:e.jsx(Lt,{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(Ki,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-base",children:"How to Earn Points"}),e.jsx(yr,{children:"See all the ways you can earn spendable points"})]})]}),L?e.jsx(Rg,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(Vo,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(ff,{children:e.jsx(Oe,{className:"pt-0",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[V==null?void 0:V.filter(Ce=>Ce.is_active).map(Ce=>{const Te=Fe=>{switch(Fe){case"event_attendance":return e.jsx(on,{className:"h-5 w-5"});case"leave_review":return e.jsx(Gn,{className:"h-5 w-5"});case"add_listing":return e.jsx(Un,{className:"h-5 w-5"});case"first_contact":return e.jsx(hr,{className:"h-5 w-5"});case"first_video":return e.jsx(kn,{className:"h-5 w-5"});case"first_community_post":return e.jsx(oo,{className:"h-5 w-5"});default:return e.jsx(io,{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:Te(Ce.action_key)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:Ce.action_name}),Ce.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ce.description})]}),e.jsxs(at,{variant:"secondary",className:"font-bold shrink-0",children:["+",Ce.points]})]},Ce.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($h,{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(at,{variant:"outline",className:"font-bold shrink-0 border-orange-500/50 text-orange-600",children:"+Bonus"})]})]})})})]})}),!$&&e.jsx(Ee,{className:"bg-gradient-to-r from-yellow-500/10 to-orange-500/10 border-yellow-500/20",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-yellow-500/20 flex items-center justify-center",children:e.jsx(oo,{className:"h-6 w-6 text-yellow-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Earn 25 Free Points!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Leave a quick review and earn 25 spendable points"})]})]}),e.jsxs(K,{onClick:()=>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(Na,{value:s,onValueChange:r,children:[e.jsxs(va,{children:[e.jsxs(ks,{value:"store",className:"flex items-center gap-2",children:[e.jsx(Kx,{className:"h-4 w-4"}),"Store"]}),e.jsxs(ks,{value:"my-rewards",className:"flex items-center gap-2",children:[e.jsx(dl,{className:"h-4 w-4"}),"My Rewards",de&&de.length>0&&e.jsx(at,{variant:"secondary",className:"ml-1",children:de.length})]})]}),e.jsxs(zs,{value:"store",className:"mt-6",children:[X&&X.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx(K,{variant:n===null?"default":"outline",size:"sm",onClick:()=>a(null),children:"All"}),X.map(Ce=>e.jsxs(K,{variant:n===Ce.id?"default":"outline",size:"sm",onClick:()=>a(Ce.id),children:[Ce.icon&&`${Ce.icon} `,Ce.name]},Ce.id))]}),!te||te.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(io,{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(Ce=>{const Te=pe.has(Ce.id),Fe=Ce.max_quantity!==null&&Ce.current_quantity===0,Ae=ae>=Ce.points_cost;return e.jsxs(Ee,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-lg ${Te?"ring-2 ring-green-500/50 bg-green-500/5":""}`,onClick:()=>I(Ce),children:[Ce.preview_image_url?e.jsxs("div",{className:"aspect-video relative overflow-hidden bg-muted",children:[e.jsx("img",{src:Ce.preview_image_url,alt:Ce.name,className:"w-full h-full object-cover"}),Te&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(at,{className:"bg-green-500 text-white",children:[e.jsx(da,{className:"h-3 w-3 mr-1"}),"Owned"]})}),Fe&&!Te&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(at,{variant:"destructive",children:"Sold Out"})})]}):e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[e.jsx(io,{className:"h-12 w-12 text-muted-foreground/50"}),Te&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(at,{className:"bg-green-500 text-white",children:[e.jsx(da,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),e.jsxs(Lt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(zt,{className:"text-lg",children:Ce.name}),e.jsxs(at,{variant:"secondary",className:"font-bold shrink-0",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),Ce.points_cost]})]}),Ce.category&&e.jsxs(at,{variant:"outline",className:"w-fit",children:[Ce.category.icon&&`${Ce.category.icon} `,Ce.category.name]})]}),e.jsxs(Oe,{children:[e.jsx(yr,{className:"mb-4 line-clamp-2",children:Ce.description||"No description available"}),Ce.max_quantity!==null&&!Te&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[Ce.current_quantity," of ",Ce.max_quantity," remaining"]}),Te?e.jsx(K,{className:"w-full",onClick:We=>{We.stopPropagation(),Ce.file_url&&Mpe(Ce.file_url,Ce.name)},disabled:!Ce.file_url,children:Ce.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Access"]})}):e.jsx(K,{className:"w-full",onClick:We=>{We.stopPropagation(),l(Ce)},disabled:Fe||!Ae,children:Fe?"Sold Out":Ae?e.jsxs(e.Fragment,{children:[e.jsx(Kx,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${Ce.points_cost-ae} more pts`})]})]},Ce.id)})})]}),e.jsx(zs,{value:"my-rewards",className:"mt-6",children:!de||de.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(dl,{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:de.map(Ce=>{var Te,Fe,Ae,We,ht;return e.jsxs(Ee,{className:"overflow-hidden",children:[(Te=Ce.item)!=null&&Te.preview_image_url?e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted",children:e.jsx("img",{src:Ce.item.preview_image_url,alt:((Fe=Ce.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(io,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs(Lt,{className:"pb-2",children:[e.jsx(zt,{className:"text-lg",children:((Ae=Ce.item)==null?void 0:Ae.name)||"Unknown Item"}),e.jsxs(yr,{className:"text-xs",children:["Purchased for ",Ce.points_spent," points • ",new Date(Ce.purchased_at).toLocaleDateString()]})]}),e.jsx(Oe,{children:e.jsx(K,{className:"w-full",onClick:()=>{var De,Dt;(De=Ce.item)!=null&&De.file_url&&Mpe(Ce.item.file_url,(Dt=Ce.item)==null?void 0:Dt.name)},disabled:!((We=Ce.item)!=null&&We.file_url),children:((ht=Ce.item)==null?void 0:ht.item_type)==="file"?e.jsxs(e.Fragment,{children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},Ce.id)})})})]})]}),e.jsx(nc,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Confirm Purchase"}),e.jsxs(Dl,{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:[ae," points"]}),". After this purchase, you'll have"," ",e.jsxs("strong",{children:[ae-((o==null?void 0:o.points_cost)||0)," points"]})," remaining."]})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:be,disabled:le.isPending,children:le.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(vs,{open:i,onOpenChange:Ce=>{!Ce&&j?Ze():d(Ce)},children:e.jsx(ys,{children:j?e.jsxs(e.Fragment,{children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(da,{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(K,{variant:"outline",className:"w-full",onClick:we,children:[e.jsx(ni,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(On,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(K,{variant:"outline",onClick:Ze,children:"Maybe Later"}),e.jsxs(K,{onClick:ke,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(Ce=>e.jsx("button",{type:"button",onClick:()=>p(Ce),className:"focus:outline-none",children:e.jsx(Gn,{className:`h-8 w-8 transition-colors ${u>=Ce?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400"}`})},Ce))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Review"}),e.jsx(Mr,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:f,onChange:Ce=>v(Ce.target.value),rows:4})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{onClick:ye,disabled:_,className:"bg-yellow-600 hover:bg-yellow-700",children:_?"Submitting...":"Submit & Earn 25 Points"})]})]})})}),e.jsx(vs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[A==null?void 0:A.name,e.jsxs(at,{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(at,{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&&!pe.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(On,{children:A&&pe.has(A.id)?e.jsx(K,{className:"w-full",onClick:()=>{A.file_url&&Mpe(A.file_url,A.name)},disabled:!A.file_url,children:A.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Access"]})}):A&&e.jsx(K,{className:"w-full",onClick:()=>{I(null),l(A)},disabled:A.max_quantity!==null&&A.current_quantity===0||ae{const{user:t}=Gs(),s=ns(),r=Ct({queryKey:["smart-presentations",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:p}=await G.from("smart_presentations").select("*").eq("owner_user_id",t.id).neq("status","archived").order("created_at",{ascending:!1});if(p)throw p;return u||[]},enabled:!!t}),n=Ct({queryKey:["smart-presentation-templates",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:p}=await G.from("smart_presentation_templates").select("*").eq("is_active",!0).order("created_at",{ascending:!0});if(p)throw p;return u||[]},enabled:!!t}),a=Ot({mutationFn:async u=>{const{data:p,error:f}=await G.from("smart_presentations").insert({owner_user_id:t.id,...u}).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),o=Ot({mutationFn:async({id:u,...p})=>{const{data:f,error:v}=await G.from("smart_presentations").update(p).eq("id",u).select().single();if(v)throw v;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),l=Ot({mutationFn:async u=>{const{data:p,error:f}=await G.from("smart_presentations").update({status:"published",published_at:new Date().toISOString()}).eq("id",u).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),fe.success("Presentation published!")}}),i=Ot({mutationFn:async u=>{const{error:p}=await G.from("smart_presentations").update({status:"archived"}).eq("id",u);if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),fe.success("Presentation archived")}}),d=Ot({mutationFn:async u=>{const{error:p}=await G.from("smart_presentation_templates").insert({owner_user_id:t.id,name:u.title+" Template",description:"Created from "+u.title,template_type:"custom",icon:"📄",sections:u.sections,cta_config:{type:u.cta_type,label:u.cta_label},is_system:!1});if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentation-templates"]}),fe.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}},avs=()=>{const t=Dr(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=pet(),o=i=>i.status==="draft"?e.jsx(at,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?e.jsx(at,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?e.jsx(at,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):e.jsx(at,{variant:"secondary",className:"text-xs",children:"Not Opened"}),l=i=>{const d=`https://presentations.relevelup.com/${i}`;navigator.clipboard.writeText(d),fe.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(K,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(Zs,{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(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(Bg,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No presentations yet"}),e.jsx("p",{className:"text-muted-foreground mb-6 max-w-md",children:"Create your first Smart Presentation to impress clients with personalized, video-first content."}),e.jsxs(K,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Create Your First Presentation"]})]})}):e.jsx("div",{className:"space-y-3",children:s.map(i=>e.jsx(Ee,{className:"hover:shadow-sm transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(In,{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 ",ws(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ya,{className:"h-3 w-3"})," ",i.view_count," view",i.view_count!==1?"s":""]}),i.cta_clicked_count>0&&e.jsx("span",{className:"text-emerald-600 font-medium",children:"CTA clicked"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap sm:flex-nowrap sm:shrink-0",children:[i.status==="published"&&i.share_token&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>l(i.share_token),children:[e.jsx(ni,{className:"h-3.5 w-3.5 mr-1"}),"Copy Link"]}),i.status==="published"&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}?edit=true`),children:"Edit"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}`),children:i.status==="draft"?"Edit":"View"}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(Jp,{className:"h-4 w-4"})})}),e.jsxs(Td,{align:"end",children:[i.status==="published"&&i.share_token&&e.jsxs(Ta,{onClick:()=>window.open(`https://presentations.relevelup.com/${i.share_token}`,"_blank"),children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),e.jsxs(Ta,{onClick:()=>a.mutate(i),children:[e.jsx(In,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),e.jsxs(Ta,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[e.jsx(n5,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},QLe={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."}]},ivs=[{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 ovs(t){const s=QLe[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries(QLe))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return ivs}function lvs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=S.useState(!1),[o,l]=S.useState("script"),[i,d]=S.useState(0),[u,p]=S.useState(0),{canRecord:f}=vZe(),v=iS(),[_,b]=S.useState(""),[j,w]=S.useState(!1),[N,C]=S.useState(!0),[A,I]=S.useState(!1),[L,R]=S.useState(null),$=ovs(t),q=()=>{l("script"),d(0),p(0),b(""),w(!1),C(!0),I(!1),R(null)},U=Y=>{!Y&&(o==="uploading"||o==="processing")||(a(Y),Y||q())},V=Y=>{R(Y),b($[Y].text),w(!1)},X=()=>{l("record"),C(_.trim().length>0)},se=()=>{b(""),C(!1),l("record")},te=S.useCallback(async(Y,de)=>{l("uploading");try{const ie=t||"Presentation Video",{videoId:ae,uploadUrl:le,libraryId:pe}=await KL(ie),{apiKey:be}=await ZL(ae),ye=new XMLHttpRequest;ye.upload.onprogress=Ce=>{Ce.lengthComputable&&d(Ce.loaded/Ce.total*100)},await new Promise((Ce,Te)=>{ye.onload=()=>ye.status>=200&&ye.status<300?Ce():Te(new Error("Upload failed")),ye.onerror=()=>Te(new Error("Upload failed")),ye.open("PUT",le),ye.setRequestHeader("AccessKey",be),ye.send(Y)}),l("processing");let we=0;const ke=Date.now(),Ze=9e4;let _e=null;for(;we<4;){if(await new Promise(Te=>setTimeout(Te,3e3)),Date.now()-ke>Ze){const Te=Y.size/1048576,Fe=`https://iframe.mediadelivery.net/embed/${pe}/${ae}?responsive=true`;await v.mutateAsync({bunny_video_id:ae,playback_url:Fe,file_size_mb:Te,title:ie,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(Fe),fe.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const Ce=await M3(ae);if(we=Ce.status,p(Ce.encodeProgress||0),we===4)_e={playbackUrl:Ce.directPlayUrl,thumbnailUrl:Ce.thumbnailUrl,previewUrl:Ce.previewUrl||null,duration:Ce.length||de,fileSizeMb:(Ce.storageSize||Y.size)/(1024*1024)};else if(we===5||we===6)throw new Error("Video processing failed")}if(!_e)throw new Error("No video data");await v.mutateAsync({bunny_video_id:ae,contact_id:s||void 0,playback_url:_e.playbackUrl,thumbnail_url:_e.thumbnailUrl,preview_url:_e.previewUrl,duration_seconds:_e.duration,file_size_mb:_e.fileSizeMb,title:ie,status:"ready",touch_type:"presentation"}),r(_e.playbackUrl),fe.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(ie){console.error("Recording upload error:",ie),fe.error("Failed to process video. Please try again."),l("record")}},[t,s,r,v]);return e.jsxs(vs,{open:n,onOpenChange:U,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Record a video",children:[e.jsx(kn,{className:"h-3.5 w-3.5"}),"Record"]})}),e.jsxs(ys,{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(Ss,{children:e.jsxs(Ns,{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,de)=>e.jsxs("button",{onClick:()=>V(de),className:Pt("text-left p-3 rounded-lg border transition-all hover:bg-accent/50",L===de?"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(In,{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})]},de))})]}),_&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Your Script"}),!j&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>w(!0),className:"h-7 text-xs gap-1",children:[e.jsx(Ra,{className:"h-3 w-3"}),"Edit"]})]}),j?e.jsx(Mr,{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(Mr,{value:_,onChange:Y=>{b(Y.target.value),R(null)},rows:4,placeholder:"Type your own script here...",className:"text-sm"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:se,className:"text-muted-foreground",children:"Skip — no teleprompter"}),e.jsx(K,{onClick:X,disabled:!1,children:_.trim()?"Continue with Script":"Continue Without Script"})]})]}),!f&&o==="record"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-8 text-center",children:[e.jsx(Th,{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(K,{variant:"ghost",size:"sm",onClick:()=>C(!N),className:"h-7 text-xs gap-1",children:[N?e.jsx(Em,{className:"h-3 w-3"}):e.jsx(ya,{className:"h-3 w-3"}),N?"Hide Script":"Show Script"]})]}),e.jsx(Tce,{maxDurationSeconds:60,onRecordingComplete:te,onRecordingStateChange:I,onError:Y=>fe.error(Y),teleprompterContent:_.trim()?e.jsx(vJe,{text:_,isVisible:N,onToggleVisibility:()=>C(!N),isRecording:A,startCountdown:!1}):void 0}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>l("script"),className:"text-xs text-muted-foreground",children:"← Back to script"})]}):o==="uploading"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(As,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(Ti,{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(As,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(Ti,{value:u,className:"h-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Processing... ",Math.round(u),"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"This usually takes less than a minute"})]})]}):o==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[e.jsx(gi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Video attached!"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved to your video library"})]}):null]})]})}function cvs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState("idle"),[u,p]=S.useState(0),f=S.useRef(null),v=iS(),{data:_}=Ale(),b=(_==null?void 0:_.total_storage_mb)||0,w=((_==null?void 0:_.max_storage_mb)||1024)-b,N=()=>{l(null),d("idle"),p(0)},C=$=>{!$&&i!=="idle"&&i!=="done"||(a($),$||N())},A=$=>{var V;const q=(V=$.target.files)==null?void 0:V[0];if(!q)return;if(!q.type.startsWith("video/")){fe.error("Please select a video file");return}const U=q.size/(1024*1024);if(U>500){fe.error("Video file must be less than 500MB");return}if(U>w){fe.error(`Not enough storage. You have ${w.toFixed(1)} MB remaining.`);return}l(q)},I=S.useCallback(async()=>{if(o){d("creating"),p(0);try{const $=t||o.name,{data:q,error:U}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:$,isAgentVideo:!0}});if(U)throw new Error(U.message);const{videoId:V,libraryId:X}=q;d("uploading");const{data:se,error:te}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:V,isAgentVideo:!0}});if(te)throw new Error(te.message);await new Promise((ie,ae)=>{const le=new XMLHttpRequest;le.upload.addEventListener("progress",pe=>{pe.lengthComputable&&p(Math.round(pe.loaded/pe.total*100))}),le.addEventListener("load",()=>le.status>=200&&le.status<300?ie():ae(new Error(`Upload failed (${le.status})`))),le.addEventListener("error",()=>ae(new Error("Upload failed"))),le.open("PUT",se.uploadUrl),le.setRequestHeader("AccessKey",se.apiKey),le.send(o)}),d("processing");const Y=o.size/(1024*1024),de=`https://iframe.mediadelivery.net/embed/${X}/${V}`;await v.mutateAsync({bunny_video_id:V,playback_url:de,file_size_mb:Y,title:$,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(de),d("done"),fe.success("Video uploaded & attached to section!"),setTimeout(()=>a(!1),1200)}catch($){console.error("Upload error:",$),fe.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""}},R=i!=="idle"&&i!=="done";return e.jsxs(vs,{open:n,onOpenChange:C,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Upload a video file",children:[e.jsx(Ya,{className:"h-3.5 w-3.5"}),"Upload"]})}),e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsx(Ss,{children:e.jsxs(Ns,{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(kn,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(o.size/(1024*1024)).toFixed(1)," MB"]})]}),!R&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>{var $;return($=f.current)==null?void 0:$.click()},children:[e.jsx(Ya,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select a video file"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, MOV, WebM (max 500MB)"})]}),e.jsx("input",{ref:f,type:"file",accept:"video/*",className:"hidden",onChange:A,disabled:R}),R&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(As,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:L()})]}),e.jsx(Ti,{value:i==="uploading"?u:i==="processing"?100:10})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),disabled:R,children:"Cancel"}),e.jsx(K,{onClick:I,disabled:!o||R,children:R?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const JLe=[{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"}],eDe=()=>{const t=Dr(),{id:s}=Mo(),{user:r}=Gs(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=pet(),{isGmailConnected:d,gmailEmail:u}=gy(),[p,f]=S.useState(!1),[v,_]=S.useState("client"),[b,j]=S.useState(!1),[w,N]=S.useState(""),[C,A]=S.useState([]),[I,L]=S.useState(!1),[R,$]=S.useState(null),[q,U]=S.useState(!1),[V,X]=S.useState(""),[se,te]=S.useState(""),[Y,de]=S.useState(""),[ie,ae]=S.useState("buyer"),[le,pe]=S.useState(""),[be,ye]=S.useState(null),[we,ke]=S.useState(""),[Ze,_e]=S.useState([]),[Ce,Te]=S.useState("schedule_call"),[Fe,Ae]=S.useState("Schedule a Call"),[We,ht]=S.useState(""),[De,Dt]=S.useState(""),[he,Qe]=S.useState(null),[ot,rt]=S.useState(s||null),[Ne,it]=S.useState(null),[qe,Xe]=S.useState(!1),$e=async(vt,Cs)=>{if(!r)return;const or=5*1024*1024;if(vt.size>or){fe.error("Image must be under 5MB");return}if(!vt.type.startsWith("image/")){fe.error("Please upload an image file");return}Qe(Cs);try{const Ar=vt.name.split(".").pop()||"jpg",Wn=`${r.id}/${Date.now()}.${Ar}`,{error:ai}=await G.storage.from("listing-photos").upload(Wn,vt);if(ai)throw ai;const{data:{publicUrl:bo}}=G.storage.from("listing-photos").getPublicUrl(Wn);Rt(Cs,{image_url:bo}),fe.success("Image uploaded")}catch{fe.error("Failed to upload image")}finally{Qe(null)}};S.useEffect(()=>{s&&Ke(s)},[s]);const Ke=async vt=>{const{data:Cs,error:or}=await G.from("smart_presentations").select("*").eq("id",vt).single();if(or||!Cs)return;const Ar=Cs;if(j(!0),ke(Ar.title),X(Ar.client_name||""),pe(Ar.property_address||""),_e(Ar.sections||[]),Te(Ar.cta_type||"schedule_call"),Ae(Ar.cta_label||"Schedule a Call"),ht(Ar.cta_url||""),Dt(Ar.heading||""),it(Ar.share_token),Xe(Ar.status==="published"),rt(Ar.id),_("builder"),Ar.contact_id){const{data:Wn}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",Ar.contact_id).maybeSingle();Wn&&($(Wn),te(Wn.email||""),de(Wn.phone||""))}};S.useEffect(()=>{if(!r||w.length<1){A([]);return}const vt=setTimeout(async()=>{L(!0);const{data:Cs}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone, lead_source").eq("owner_user_id",r.id).or(`first_name.ilike.%${w}%,last_name.ilike.%${w}%,email.ilike.%${w}%`).limit(10);A(Cs||[]),L(!1)},300);return()=>clearTimeout(vt)},[w,r]);const ct=vt=>{$(vt),X(`${vt.first_name} ${vt.last_name||""}`.trim()),te(vt.email||""),de(vt.phone||""),U(!1)},Ue=async()=>{if(!V.trim()){fe.error("Client name is required");return}const vt=V.trim().split(" "),Cs=vt[0],or=vt.slice(1).join(" ")||null,{data:Ar,error:Wn}=await G.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:Cs,last_name:or,email:se||null,phone:Y||null,lead_source:"Smart Presentation"}).select().single();if(Wn){fe.error("Failed to create client");return}$(Ar),fe.success("Client created & saved to Agent OS"),_("template")},Ve=vt=>{ye(vt);const Cs=(vt.sections||[]).map(or=>({...or,is_visible:!0,video_url:"",text:""}));if(_e(Cs),ke(vt.name+(V?` for ${V}`:"")),vt.cta_config){const or=vt.cta_config;Te(or.type||"schedule_call"),Ae(or.label||"Schedule a Call")}_("builder")},Je=()=>{_e([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),ke(V?`Presentation for ${V}`:"New Presentation"),_("builder")},Rt=(vt,Cs)=>{_e(or=>or.map((Ar,Wn)=>Wn===vt?{...Ar,...Cs}:Ar))},$t=vt=>{Rt(vt,{is_visible:!Ze[vt].is_visible})},ls=()=>{_e(vt=>[...vt,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},Qt=vt=>{_e(Cs=>Cs.filter((or,Ar)=>Ar!==vt))},rs=async()=>{if(!we.trim()){fe.error("Title is required");return}try{if(ot){const vt=await l.mutateAsync({id:ot,title:we,sections:Ze,client_name:V,property_address:le||null,cta_type:Ce,cta_label:Fe,cta_url:We||null,heading:De||null});fe.success("Saved")}else{const vt=await o.mutateAsync({title:we,contact_id:(R==null?void 0:R.id)||void 0,client_name:V,property_address:le||void 0,template_id:(be==null?void 0:be.id)||void 0,sections:Ze,cta_type:Ce,cta_label:Fe,cta_url:We||void 0,heading:De||void 0});rt(vt.id),it(vt.share_token),fe.success("Presentation created!")}}catch(vt){console.error("Failed to save presentation:",vt);const Cs=(vt==null?void 0:vt.message)||(vt==null?void 0:vt.toString())||"Unknown error";fe.error(`Failed to save: ${Cs}`)}},as=async()=>{try{await rs();const vt=ot;if(vt){const Cs=await i.mutateAsync(vt);it(Cs.share_token),Xe(!0),_("share")}}catch(vt){console.error("Failed to publish presentation:",vt),fe.error(`Failed to publish: ${(vt==null?void 0:vt.message)||"Unknown error"}`)}},ir=Ne?`https://presentations.relevelup.com/${Ne}`:"";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(K,{variant:"ghost",size:"icon",onClick:()=>t("/mission-control/presentations"),children:e.jsx(Ua,{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((vt,Cs)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Pt("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",v===vt?"bg-primary text-primary-foreground":Cs<["client","template","builder","share"].indexOf(v)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:Cs<["client","template","builder","share"].indexOf(v)?e.jsx(ua,{className:"h-4 w-4"}):Cs+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:vt}),Cs<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},vt))}),v==="client"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>{$(null),X(""),te(""),de(""),U(!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(ka,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-semibold text-foreground text-sm",children:"Skip — Use as Lead Gen Tool"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No specific client. Share broadly to capture new leads."})]})]}),e.jsx(Fi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors shrink-0"})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(fn,{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(fn,{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:w,onChange:vt=>N(vt.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"}),C.map(vt=>e.jsxs("button",{onClick:()=>ct(vt),className:Pt("w-full text-left p-3 rounded-lg border transition-colors",(R==null?void 0:R.id)===vt.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[vt.first_name," ",vt.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:vt.email||vt.phone||"No contact info"})]},vt.id)),!w&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Start typing to search your contacts"}),w&&C.length===0&&!I&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No clients found"})]}),R&&e.jsxs(K,{onClick:()=>_("template"),className:"w-full gap-2",children:["Continue with ",R.first_name,e.jsx(Fi,{className:"h-4 w-4"})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(xc,{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(ve,{className:"text-xs",children:"Name *"}),e.jsx(Re,{value:V,onChange:vt=>{X(vt.target.value),U(!0),$(null)},placeholder:"Sarah & Mike Johnson"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Email"}),e.jsx(Re,{value:se,onChange:vt=>te(vt.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Phone"}),e.jsx(Re,{value:Y,onChange:vt=>de(vt.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Client Type"}),e.jsxs(tr,{value:ie,onValueChange:ae,children:[e.jsx(Js,{children:e.jsx(sr,{})}),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(ve,{className:"text-xs",children:"Property Address"}),e.jsx(Re,{value:le,onChange:vt=>pe(vt.target.value),placeholder:"Optional"})]})]}),q&&V&&e.jsxs(K,{onClick:Ue,className:"w-full gap-2",children:["Create Client & Continue",e.jsx(Fi,{className:"h-4 w-4"})]})]})]})]})]}),v==="template"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Na,{defaultValue:"system",children:[e.jsxs(va,{children:[e.jsx(ks,{value:"mine",children:"My Core Templates"}),e.jsx(ks,{value:"system",children:"LevelUp Smart Templates"}),e.jsx(ks,{value:"blank",children:"+ Start Blank"})]}),e.jsx(zs,{value:"mine",className:"mt-4",children:a?e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[1,2].map(vt=>e.jsx(gs,{className:"h-32"},vt))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(vt=>!vt.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(vt=>!vt.is_system).map(vt=>e.jsx(tDe,{template:vt,onSelect:Ve},vt.id))})}),e.jsx(zs,{value:"system",className:"mt-4",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(vt=>vt.is_system).map(vt=>e.jsx(tDe,{template:vt,onSelect:Ve},vt.id))})}),e.jsx(zs,{value:"blank",className:"mt-4",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start with a blank canvas and add your own sections."}),e.jsx(K,{onClick:Je,children:"Start from Scratch"})]})})})]}),e.jsxs(K,{variant:"outline",onClick:()=>_("client"),className:"gap-2",children:[e.jsx(Ua,{className:"h-4 w-4"}),"Back"]})]}),v==="builder"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Presentation Title"}),e.jsx(Re,{value:we,onChange:vt=>ke(vt.target.value)})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Page Heading"}),e.jsx(Re,{value:De,onChange:vt=>Dt(vt.target.value),placeholder:V?`Welcome, ${V}!`:"e.g. Welcome! or Your Custom Listing Plan"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:['The main heading visitors see. Leave blank for "Welcome, ',"",'!"']})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Client Name"}),e.jsx(Re,{value:V,onChange:vt=>X(vt.target.value)})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Property Address"}),e.jsx(Re,{value:le,onChange:vt=>pe(vt.target.value),placeholder:"Optional"})]})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sections"}),e.jsx(K,{variant:"outline",size:"sm",onClick:ls,children:"+ Add Section"})]}),e.jsx("div",{className:"space-y-3",children:Ze.map((vt,Cs)=>e.jsx(Ee,{className:Pt(!vt.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(Fu,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),e.jsx("span",{className:"text-lg",children:vt.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:vt.title,onChange:or=>Rt(Cs,{title:or.target.value}),className:"font-semibold border-none p-0 h-auto text-base focus-visible:ring-0 bg-transparent"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$t(Cs),children:vt.is_visible?e.jsx(ya,{className:"h-4 w-4"}):e.jsx(Em,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Qt(Cs),className:"text-destructive hover:text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})]})]}),e.jsx(Re,{value:vt.description||"",onChange:or=>Rt(Cs,{description:or.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(ve,{className:"text-xs",children:"Video URL"}),e.jsx(Re,{value:vt.video_url||"",onChange:or=>Rt(Cs,{video_url:or.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx(lvs,{sectionTitle:vt.title,contactId:R==null?void 0:R.id,onVideoReady:or=>Rt(Cs,{video_url:or})}),e.jsx(cvs,{sectionTitle:vt.title,contactId:R==null?void 0:R.id,onVideoReady:or=>Rt(Cs,{video_url:or})}),e.jsx(D2e,{userId:r==null?void 0:r.id,onSelect:or=>Rt(Cs,{video_url:or})})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),vt.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:vt.image_url,alt:"",className:"w-full max-h-40 object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>Rt(Cs,{image_url:""}),children:e.jsx(Ur,{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:[he===Cs?e.jsx(As,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(T0,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:he===Cs?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:he===Cs,onChange:or=>{var Wn;const Ar=(Wn=or.target.files)==null?void 0:Wn[0];Ar&&$e(Ar,Cs),or.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Text (optional)"}),e.jsx(Qg,{content:vt.text||"",onChange:or=>Rt(Cs,{text:or}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},Cs))})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Call to Action"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"CTA Type"}),e.jsxs(tr,{value:Ce,onValueChange:vt=>{Te(vt);const Cs=JLe.find(or=>or.value===vt);Cs&&Ae(Cs.label)},children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:JLe.map(vt=>e.jsx(At,{value:vt.value,children:vt.label},vt.value))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Button Label"}),e.jsx(Re,{value:Fe,onChange:vt=>Ae(vt.target.value)})]}),e.jsxs("div",{children:[e.jsxs(ve,{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:We,onChange:vt=>ht(vt.target.value),placeholder:"https://calendly.com/..."}),!We&&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(K,{variant:"outline",onClick:()=>_("template"),className:"gap-2",children:[e.jsx(Ua,{className:"h-4 w-4"}),"Back"]}),e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsx(K,{variant:"outline",onClick:rs,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(K,{onClick:as,disabled:i.isPending,className:"gap-2",children:[e.jsx(ka,{className:"h-4 w-4"}),qe?"Update & Reshare":"Publish & Share"]})]})]})]}),v==="share"&&Ne&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center py-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mb-4",children:e.jsx(ua,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Your Presentation is Live!"}),e.jsxs("p",{className:"text-muted-foreground mb-6 max-w-md",children:["Share this link with ",V||"your client",". You'll be notified when they view it."]}),e.jsxs("div",{className:"flex items-center gap-2 w-full max-w-lg",children:[e.jsx(Re,{value:ir,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(K,{onClick:()=>{navigator.clipboard.writeText(ir),fe.success("Link copied!")},children:e.jsx(ni,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-3 mt-6",children:[e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{const vt=`Hi ${V||""}! I put together something for you — check it out: ${ir}`;navigator.clipboard.writeText(vt),fe.success("Message copied!")},children:[e.jsx(oo,{className:"h-4 w-4"}),"Copy Text Message"]}),e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{d?f(!0):window.open(`mailto:${se||""}?subject=${encodeURIComponent(we)}&body=${encodeURIComponent(`Hi ${(R==null?void 0:R.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${ir} Looking forward to connecting!`)}`)},children:[e.jsx(_r,{className:"h-4 w-4"}),"Send Email"]})]}),d&&e.jsx(EM,{open:p,onOpenChange:f,contact:R?{id:R.id,first_name:R.first_name,last_name:R.last_name,email:se||R.email||""}:se?{id:"",first_name:(V==null?void 0:V.split(" ")[0])||"",last_name:(V==null?void 0:V.split(" ").slice(1).join(" "))||"",email:se}:void 0,defaultSubject:we,defaultBody:`Hi ${(R==null?void 0:R.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${ir} Looking forward to connecting!`,gmailEmail:u})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(K,{variant:"outline",onClick:()=>_("builder"),children:[e.jsx(Ua,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(K,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},tDe=({template:t,onSelect:s})=>e.jsx(Ee,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(Oe,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-2xl",children:t.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold",children:t.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(at,{variant:"outline",className:"text-xs capitalize",children:t.template_type}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(t.sections||[]).length," sections"]})]})]})]}),e.jsx(K,{className:"w-full mt-4",size:"sm",onClick:()=>s(t),children:"Use Template"})]})}),dvs=()=>{var j;const{shareToken:t}=Mo(),[s,r]=S.useState(null),[n,a]=S.useState(!0),[o,l]=S.useState(0),[i,d]=S.useState(!1);S.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),S.useEffect(()=>{t&&u()},[t]);const u=async()=>{const{data:w,error:N}=await G.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(N||!w){d(!0),a(!1);return}const{data:C}=await G.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",w.owner_user_id).single();let A;if(C!=null&&C.brokerage_id){const{data:L}=await G.from("brokerages").select("name").eq("id",C.brokerage_id).single();A=(L==null?void 0:L.name)||void 0}let I=null;if(w.contact_id){const{data:L}=await G.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",w.contact_id).single();I=L}r({...w,owner_name:C==null?void 0:C.name,owner_email:C==null?void 0:C.email,owner_phone:C==null?void 0:C.phone,owner_avatar:C==null?void 0:C.avatar_url,owner_title:(C==null?void 0:C.title)||void 0,brokerage_name: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 G.rpc("log_presentation_view",{p_presentation_id:w.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await G.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 f=s.sections.filter(w=>w.is_visible!==!1),v=f[o],_=w=>{const N=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(N)return`https://www.youtube.com/embed/${N[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const I=w.replace("/play/","/embed/"),L=I.includes("?")?"&":"?";return`${I}${L}responsive=true`}if(w.includes("iframe.mediadelivery.net")){if(w.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const L=w.includes("?")?"&":"?";return`${w}${L}responsive=true`}return""}const C=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(C)return`https://www.loom.com/embed/${C[1]}`;const A=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return A?`https://iframe.mediadelivery.net/embed/${A[1]}/${A[2]}?responsive=true`:w},b=!!((j=s.cta_url)!=null&&j.trim());return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})]})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[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:f.map((w,N)=>e.jsx("button",{onClick:()=>l(N),className:Pt("w-full text-left p-4 rounded-xl border transition-all",o===N?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(N+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:w.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:w.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:w.description})]})]})},N))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),b?e.jsxs(K,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(sn,{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(g9e,{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 uvs({openHouseId:t,enableSurvey:s,onToggleSurvey:r}){const{data:n,isLoading:a}=z0t(t),o=U0t(),l=V0t(),i=H0t(),d=W0t(),[u,p]=S.useState(""),[f,v]=S.useState("rating"),_=async N=>{r(N),N&&(!n||n.length===0)&&await d.mutateAsync(t)},b=async()=>{if(!u.trim())return;const N=(n==null?void 0:n.reduce((C,A)=>Math.max(C,A.sort_order),0))??0;await o.mutateAsync({open_house_id:t,question_type:f,question_text:u.trim(),sort_order:N+1}),p("")},j=async N=>{await l.mutateAsync({id:N.id,open_house_id:t,is_active:!N.is_active})},w=async N=>{await i.mutateAsync({id:N.id,open_house_id:t})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(ve,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(J1,{className:"h-4 w-4"}),"Property Feedback Survey"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show a quick feedback survey after visitors sign in"})]}),e.jsx(Br,{checked:s,onCheckedChange:_})]}),s&&e.jsx("div",{className:"space-y-3 pt-2 border-t border-border",children:a?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(As,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2",children:n==null?void 0:n.map(N=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-muted/20",children:[e.jsx(Fu,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm truncate",children:N.question_text}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:N.question_type.replace("_"," ")})]}),e.jsx(Br,{checked:N.is_active,onCheckedChange:()=>j(N),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>w(N),children:e.jsx(br,{className:"h-3.5 w-3.5"})})]},N.id))}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Add Question"}),e.jsx(Re,{value:u,onChange:N=>p(N.target.value),placeholder:"e.g. How did you hear about this listing?",className:"mt-1 h-9 text-sm",onKeyDown:N=>N.key==="Enter"&&b()})]}),e.jsxs(tr,{value:f,onValueChange:v,children:[e.jsx(Js,{className:"w-28 h-9 text-xs",children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"rating",children:"Rating"}),e.jsx(At,{value:"open_text",children:"Text"})]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:b,disabled:!u.trim()||o.isPending,className:"h-9",children:e.jsx(Zs,{className:"h-3.5 w-3.5"})})]})]})})]})}function hvs({open:t,onOpenChange:s,openHouse:r}){const n=y9e(),{user:a}=Gs(),o=S.useRef(null),[l,i]=S.useState(r.auto_forward_to_card??!1),[d,u]=S.useState(r.disclosure_pdf_url??""),[p,f]=S.useState(r.enable_survey??!1),[v,_]=S.useState(!1),[b,j]=S.useState(!1),w=async A=>{var q;const I=(q=A.target.files)==null?void 0:q[0];if(!I||!a)return;if(I.size>20*1024*1024){an({title:"File must be under 20MB",variant:"destructive"});return}if(I.type!=="application/pdf"){an({title:"Only PDF files are accepted",variant:"destructive"});return}_(!0);const L=`${a.id}/disclosures/${r.id}-${Date.now()}.pdf`,{error:R}=await G.storage.from("open-house-photos").upload(L,I,{upsert:!0});if(R){an({title:"Upload failed",description:R.message,variant:"destructive"}),_(!1);return}const{data:$}=G.storage.from("open-house-photos").getPublicUrl(L);u($.publicUrl),_(!1),an({title:"PDF uploaded!"})},N=()=>{u(""),o.current&&(o.current.value="")},C=async()=>{j(!0);try{await n.mutateAsync({id:r.id,auto_forward_to_card:l,disclosure_pdf_url:d||null,enable_survey:p}),an({title:"Settings saved!"}),s(!1)}catch{an({title:"Failed to save",variant:"destructive"})}finally{j(!1)}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(ve,{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(Br,{checked:l,onCheckedChange:i})]})}),!l&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Seller's Disclosures (PDF)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visitors can view or download this on the thank you screen after check-in"}),e.jsx("input",{ref:o,type:"file",accept:"application/pdf",onChange:w,className:"hidden"}),d?e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:[e.jsx(In,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm truncate flex-1",children:"Disclosure PDF uploaded"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:N,children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsx("button",{type:"button",onClick:()=>{var A;return(A=o.current)==null?void 0:A.click()},disabled:v,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:v?e.jsx(As,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Ya,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload PDF (max 20MB)"})]})})]}),e.jsx(uvs,{openHouseId:r.id,enableSurvey:p,onToggleSurvey:f}),e.jsx(K,{onClick:C,disabled:b,className:"w-full",children:b?"Saving...":"Save Settings"})]})]})})}const fet={5:"Excellent",4:"Good",3:"Neutral",2:"Bad",1:"Very Bad"};function mvs({question:t,responses:s}){const r=s.filter(l=>l.question_id===t.id&&l.rating_value!=null),n=r.length;if(n===0)return null;const a=r.reduce((l,i)=>l+(i.rating_value||0),0)/n,o=[5,4,3,2,1].map(l=>({val:l,count:r.filter(i=>i.rating_value===l).length,pct:Math.round(r.filter(i=>i.rating_value===l).length/n*100)}));return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:t.question_text}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[a.toFixed(1)," avg (",n," responses)"]})]}),e.jsx("div",{className:"space-y-1",children:o.map(l=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-16 text-muted-foreground text-right",children:fet[l.val]}),e.jsx("div",{className:"flex-1 h-4 bg-muted/30 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary/70 rounded-full transition-all",style:{width:`${l.pct}%`}})}),e.jsx("span",{className:"w-8 text-muted-foreground",children:l.count})]},l.val))})]})}function pvs({openHouseId:t}){const{data:s,isLoading:r}=q0t(t),{data:n}=x9e(t),a=S.useMemo(()=>{const f={};return n==null||n.forEach(v=>{f[v.id]=v}),f},[n]);if(r||!s)return null;const{questions:o,responses:l}=s;if(o.length===0)return null;const i=o.filter(f=>f.question_type==="rating"),d=o.filter(f=>f.question_type!=="rating"),u=[...new Set(l.map(f=>f.visitor_id))],p=u.length;return p===0?e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(J1,{className:"h-4 w-4"}),"Survey Results"]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No survey responses yet."})})]}):e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(J1,{className:"h-4 w-4"}),"Survey Results",e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-auto",children:[p," respondent",p!==1?"s":""]})]})}),e.jsx(Oe,{children:e.jsxs(Na,{defaultValue:"summary",children:[e.jsxs(va,{className:"mb-4",children:[e.jsxs(ks,{value:"summary",className:"text-xs gap-1",children:[e.jsx(Xo,{className:"h-3.5 w-3.5"})," Summary"]}),e.jsxs(ks,{value:"individual",className:"text-xs gap-1",children:[e.jsx(Xi,{className:"h-3.5 w-3.5"})," Per Visitor"]})]}),e.jsxs(zs,{value:"summary",className:"space-y-6",children:[i.map(f=>e.jsx(mvs,{question:f,responses:l},f.id)),d.map(f=>{const v=l.filter(_=>_.question_id===f.id&&_.text_value);return v.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-sm font-medium",children:f.question_text}),e.jsx("div",{className:"space-y-1.5 max-h-40 overflow-y-auto",children:v.map(_=>{const b=a[_.visitor_id];return e.jsxs("div",{className:"text-sm p-2 bg-muted/30 rounded-lg",children:[e.jsxs("span",{className:"text-muted-foreground text-xs",children:[b?`${b.first_name} ${b.last_name||""}`.trim():"Visitor",":"]}),e.jsx("p",{className:"mt-0.5",children:_.text_value})]},_.id)})})]},f.id)})]}),e.jsx(zs,{value:"individual",className:"space-y-4",children:u.map(f=>{const v=a[f],_=l.filter(b=>b.visitor_id===f);return e.jsxs("div",{className:"p-3 rounded-lg border border-border space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium",children:[v?`${v.first_name} ${v.last_name||""}`.trim():"Unknown Visitor",(v==null?void 0:v.email)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:v.email})]}),e.jsx("div",{className:"space-y-1",children:_.map(b=>{const j=o.find(w=>w.id===b.question_id);return j?e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:j.question_text}),e.jsx("span",{className:"font-medium",children:b.rating_value!=null?fet[b.rating_value]||b.rating_value:b.text_value})]},b.id):null})})]},f)})})]})})]})}const Z0e="guestbook.relevelup.com";function fvs(){const{data:t,isLoading:s}=D0t(),r=O0t(),n=y9e(),a=R0t(),[o,l]=S.useState(!1),[i,d]=S.useState(null),{user:u}=Gs(),p=ti(),[f,v]=S.useState(null),[_,b]=S.useState(null),[j,w]=S.useState(!1),N=S.useRef(null),[C,A]=S.useState({property_address:"",city:"",state:"",zip:"",event_date:ws(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),I=q=>{var V;const U=(V=q.target.files)==null?void 0:V[0];if(U){if(U.size>5*1024*1024){an({title:"Photo must be under 5MB",variant:"destructive"});return}v(U),b(URL.createObjectURL(U))}},L=()=>{v(null),b(null),N.current&&(N.current.value="")},R=async()=>{if(!C.property_address){an({title:C.event_type==="community"?"Event name is required":"Address is required",variant:"destructive"});return}let q;if(f&&u){w(!0);const U=f.name.split(".").pop(),V=`${p}/${Date.now()}.${U}`,{error:X}=await G.storage.from("open-house-photos").upload(V,f,{upsert:!0});if(X){an({title:"Photo upload failed",description:X.message,variant:"destructive"}),w(!1);return}const{data:se}=G.storage.from("open-house-photos").getPublicUrl(V);q=se.publicUrl,w(!1)}await r.mutateAsync({...C,photo_url:q}),l(!1),A({property_address:"",city:"",state:"",zip:"",event_date:ws(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),L()},$=q=>{navigator.clipboard.writeText(`https://${Z0e}/${q}`),an({title:"Link copied!"})};return e.jsxs(Ms,{title:"Guest Book",children:[e.jsx(ah,{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(vs,{open:o,onOpenChange:l,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"New Open House"]})}),e.jsxs(ys,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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:()=>A(q=>({...q,event_type:"property"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${C.event_type==="property"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Single Property"}),e.jsx("button",{type:"button",onClick:()=>A(q=>({...q,event_type:"community"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${C.event_type==="community"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Community Event"})]})}),e.jsxs("div",{children:[e.jsx(ve,{children:C.event_type==="community"?"Event Name *":"Property Address *"}),e.jsx(Re,{value:C.property_address,onChange:q=>A(U=>({...U,property_address:q.target.value})),placeholder:C.event_type==="community"?"Spring Festival at Riverside Estates":"123 Main Street"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"City"}),e.jsx(Re,{value:C.city,onChange:q=>A(U=>({...U,city:q.target.value})),placeholder:"Austin"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"State"}),e.jsx(Re,{value:C.state,onChange:q=>A(U=>({...U,state:q.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"ZIP"}),e.jsx(Re,{value:C.zip,onChange:q=>A(U=>({...U,zip:q.target.value})),placeholder:"78701"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Date"}),e.jsx(Re,{type:"date",value:C.event_date,onChange:q=>A(U=>({...U,event_date:q.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Start Time"}),e.jsx(Re,{type:"time",value:C.start_time,onChange:q=>A(U=>({...U,start_time:q.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"End Time"}),e.jsx(Re,{type:"time",value:C.end_time,onChange:q=>A(U=>({...U,end_time:q.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Welcome Message"}),e.jsx(Mr,{value:C.agent_greeting,onChange:q=>A(U=>({...U,agent_greeting:q.target.value})),placeholder:"Welcome! Please sign in below."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:C.event_type==="community"?"Event Photo":"Property Photo"}),e.jsx("input",{ref:N,type:"file",accept:"image/*",onChange:I,className:"hidden"}),_?e.jsxs("div",{className:"relative mt-1 rounded-xl overflow-hidden border border-border",children:[e.jsx("img",{src:_,alt:"Property preview",className:"w-full h-40 object-cover"}),e.jsx("button",{type:"button",onClick:L,className:"absolute top-2 right-2 bg-black/60 hover:bg-black/80 text-white rounded-full p-1 transition-colors",children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var q;return(q=N.current)==null?void 0:q.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(T0,{className:"h-6 w-6"}),e.jsxs("span",{className:"text-sm",children:["Add a ",C.event_type==="community"?"cover":"property"," photo"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Max 5MB"})]})]}),e.jsx(K,{onClick:R,disabled:r.isPending||j,className:"w-full",children:j?"Uploading photo...":r.isPending?"Creating...":C.event_type==="community"?"Create Community Event":"Create Open House"})]})]})]})]}),s?e.jsx("div",{className:"grid gap-4",children:[1,2].map(q=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Lt,{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"})]})},q))}):t!=null&&t.length?e.jsx("div",{className:"space-y-4",children:t.map(q=>e.jsx(gvs,{openHouse:q,isExpanded:i===q.id,onToggle:()=>d(i===q.id?null:q.id),onCopyLink:()=>$(q.slug||""),onToggleActive:()=>n.mutate({id:q.id,is_active:!q.is_active}),onDelete:()=>a.mutate(q.id)},q.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(L0,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No Open Houses Yet"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm mb-6",children:"Create your first open house to get a beautiful, mobile-friendly sign-in page with a shareable link and QR code."}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Your First Open House"]})]})})]})]})}function gvs({openHouse:t,isExpanded:s,onToggle:r,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=x9e(s?t.id:void 0),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[f,v]=S.useState(!1),_=S.useRef(null),b=`https://${Z0e}/${t.slug}`,j=I=>{if(!I)return"";const[L,R]=I.split(":"),$=parseInt(L),q=$>=12?"PM":"AM";return`${$>12?$-12:$||12}:${R} ${q}`},w=()=>{if(!(l!=null&&l.length))return;const I=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],L=l.map(V=>[V.first_name,V.last_name||"",V.email||"",V.phone||"",V.visitor_intent||"",V.wants_market_updates?"Yes":"No",(V.message||"").replace(/"/g,'""'),ws(new Date(V.created_at),"MM/dd/yyyy h:mm a")]),R=[I,...L].map(V=>V.map(X=>`"${X}"`).join(",")).join(` `),$=new Blob([R],{type:"text/csv"}),q=URL.createObjectURL($),U=document.createElement("a");U.href=q,U.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-visitors.csv`,U.click(),URL.revokeObjectURL(q)},N=S.useCallback(()=>{if(!_.current)return;const I=_.current.querySelector("svg");if(!I)return;const L=new XMLSerializer().serializeToString(I),R=document.createElement("canvas");R.width=1024,R.height=1024;const $=R.getContext("2d"),q=new Image;q.onload=()=>{$==null||$.drawImage(q,0,0,1024,1024);const U=document.createElement("a");U.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-qr.png`,U.href=R.toDataURL("image/png"),U.click()},q.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(L)))},[t.property_address]),C=S.useCallback(()=>{if(!_.current)return;const I=_.current.querySelector("svg");if(!I)return;const L=new XMLSerializer().serializeToString(I),R="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(L))),$=ws(new Date(t.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy"),q=t.start_time?`${j(t.start_time)}${t.end_time?" – "+j(t.end_time):""}`:"",U=[t.city,t.state].filter(Boolean).join(", "),V=t.agent_greeting||"Welcome! Please sign in below.",X=window.open("","_blank");X&&(X.document.write(` Open House – ${t.property_address}
${t.event_type==="community"?"Community Event":"Open House"}
${t.property_address}
${U?`
${U}${t.zip?" "+t.zip:""}
`:""}
Date
${$}
${q?`
Time
${q}
`:""}
${V}
QR Code
Scan to Sign In
Point your phone camera at the QR code
`),X.document.close(),setTimeout(()=>{X.focus(),X.print()},500))},[t,b]),A=async()=>{v(!0);try{const{error:I}=await G.functions.invoke("guestbook-email-link",{body:{openHouseId:t.id}});if(I)throw I;an({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(I){an({title:"Failed to send",description:I.message,variant:"destructive"})}finally{v(!1)}};return e.jsxs(Ee,{className:`transition-all ${t.is_active?"border-primary/30":"opacity-75"}`,children:[e.jsx(Lt,{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 flex-wrap",children:[e.jsx(zt,{className:"text-base truncate",children:t.property_address}),t.agent_name&&e.jsxs(at,{variant:"outline",className:"shrink-0 gap-1 text-xs bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300 border-blue-200 dark:border-blue-800",children:[e.jsx(Xi,{className:"h-3 w-3"}),t.agent_name]}),t.event_type==="community"&&e.jsxs(at,{variant:"outline",className:"shrink-0 gap-1",children:[e.jsx(Aa,{className:"h-3 w-3"}),"Community"]}),e.jsx(at,{variant:t.is_active?"default":"secondary",className:"shrink-0",children:t.is_active?"Active":"Inactive"})]}),e.jsxs(yr,{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(Ai,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ws(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"}),j(t.start_time),t.end_time?` - ${j(t.end_time)}`:""]}),e.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[e.jsx(hr,{className:"h-3 w-3"}),t.visitor_count," visitors"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:n,title:"Copy link",children:e.jsx(ni,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>d(!0),title:"QR Code",children:e.jsx(L0,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p(!0),title:"Settings",children:e.jsx($l,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(b,"_blank"),title:"Preview",children:e.jsx(sn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:a,title:t.is_active?"Deactivate":"Activate",children:t.is_active?e.jsx(Em,{className:"h-4 w-4"}):e.jsx(ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:o,title:"Delete",children:e.jsx(br,{className:"h-4 w-4 text-destructive"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:s?e.jsx(Rg,{className:"h-4 w-4"}):e.jsx(Vo,{className:"h-4 w-4"})})]})]})}),s&&e.jsxs(Oe,{className:"pt-0",children:[e.jsx(Rl,{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://",Z0e,"/",t.slug]})]}),l!=null&&l.length?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:[l.length," Visitor",l.length!==1?"s":""]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:w,className:"h-7 text-xs gap-1",children:[e.jsx(xi,{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(at,{variant:"outline",className:"text-xs capitalize",children:I.visitor_intent})}),e.jsx("td",{className:"p-2 text-xs text-muted-foreground",children:ws(new Date(I.created_at),"h:mm a")})]},I.id))})]})})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No visitors yet. Share the link to start collecting sign-ins!"}),t.enable_survey&&e.jsx("div",{className:"mt-4",children:e.jsx(pvs,{openHouseId:t.id})})]}),e.jsx(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{className:"sm:max-w-sm",children:[e.jsxs(Ss,{children:[e.jsx(Ns,{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(aD,{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(K,{variant:"outline",className:"flex-1",onClick:N,children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:C,children:[e.jsx(wP,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(K,{variant:"default",className:"w-full",onClick:A,disabled:f,children:[e.jsx(_r,{className:"h-4 w-4 mr-2"}),f?"Sending...":"Email Link to Me"]})]})]})}),e.jsx(hvs,{open:u,onOpenChange:p,openHouse:t})]})}function xvs(){const{slug:t}=Mo();return t?e.jsx(H9e,{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 get({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=Gs(),l=iS(),i=S.useRef(null),d=S.useRef(null),[u,p]=S.useState(!1),[f,v]=S.useState(!1),[_,b]=S.useState(0),j=async N=>{if(o){p(!0);try{const C=N.name.split(".").pop()||"jpg",A=`${o.id}/card-${Date.now()}.${C}`,{error:I}=await G.storage.from("listing-photos").upload(A,N);if(I)throw I;const{data:{publicUrl:L}}=G.storage.from("listing-photos").getPublicUrl(A);r(L),fe.success("Photo uploaded")}catch(C){fe.error(C.message||"Failed to upload photo")}finally{p(!1)}}},w=async N=>{if(o){if(N.size>500*1024*1024){fe.error("Video must be under 500MB");return}v(!0),b(0);try{const{videoId:C,libraryId:A}=await KL(`Card Video - ${Date.now()}`),{uploadUrl:I,apiKey:L}=await ZL(C);await new Promise((q,U)=>{const V=new XMLHttpRequest;V.upload.addEventListener("progress",X=>{X.lengthComputable&&b(Math.round(X.loaded/X.total*100))}),V.addEventListener("load",()=>{V.status>=200&&V.status<300?q():U(new Error("Upload failed"))}),V.addEventListener("error",()=>U(new Error("Upload failed"))),V.open("PUT",I),V.setRequestHeader("AccessKey",L),V.send(N)});const R=`https://iframe.mediadelivery.net/embed/${A}/${C}`;n(R);const $=parseFloat((N.size/(1024*1024)).toFixed(2));await l.mutateAsync({bunny_video_id:C,playback_url:`https://iframe.mediadelivery.net/play/${A}/${C}`,file_size_mb:$,title:"Card Video",status:"processing",touch_type:"video",contact_id:a||void 0}),fe.success("Video uploaded & added to your library")}catch(C){fe.error(C.message||"Failed to upload video")}finally{v(!1),b(0)}}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Media (optional)"}),e.jsxs(Na,{defaultValue:"photo",className:"w-full",children:[e.jsxs(va,{className:"grid w-full grid-cols-2",children:[e.jsxs(ks,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(Jo,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(ks,{value:"video",className:"gap-1.5 text-xs",children:[e.jsx(kn,{className:"h-3.5 w-3.5"}),"Video"]})]}),e.jsxs(zs,{value:"photo",className:"mt-3",children:[t?e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[e.jsx("img",{src:t,alt:"Card photo",className:"w-full h-40 object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>r(null),children:e.jsx(Ur,{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(As,{className:"h-6 w-6 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Og,{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 C=(A=N.target.files)==null?void 0:A[0];C&&j(C),N.target.value=""}})]}),e.jsxs(zs,{value:"video",className:"mt-3",children:[s?e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[e.jsx("iframe",{src:`${s}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>n(null),children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var N;return(N=d.current)==null?void 0:N.click()},disabled:f,className:"w-full h-32 border-2 border-dashed border-border rounded-lg flex flex-col items-center justify-center gap-2 text-muted-foreground hover:border-primary/40 hover:bg-accent/50 transition-colors",children:f?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(As,{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(Ya,{className:"h-6 w-6"}),e.jsx("span",{className:"text-xs",children:"Upload a video (max 500MB)"})]})}),!s&&!f&&e.jsx("div",{className:"mt-2",children:e.jsx(O2e,{contactId:a,onVideoReady:N=>n(N)})}),e.jsx("input",{ref:d,type:"file",accept:"video/*",className:"hidden",onChange:N=>{var A;const C=(A=N.target.files)==null?void 0:A[0];C&&w(C),N.target.value=""}}),e.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1.5 text-center",children:"Videos are also saved to your Video Library"})]})]})]})}const yvs=[{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 vvs({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:yvs.map((s,r)=>e.jsxs(wr.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 WM={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 sDe({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=Gs(),d=ns(),[u,p]=S.useState(!1),[f,v]=S.useState("type"),[_,b]=S.useState(""),[j,w]=S.useState(null),[N,C]=S.useState(!1),[A,I]=S.useState("home_anniversary"),[L,R]=S.useState(""),[$,q]=S.useState(""),[U,V]=S.useState(""),[X,se]=S.useState(""),[te,Y]=S.useState("elegant"),[de,ie]=S.useState(null),[ae,le]=S.useState(null),pe=S.useState(!1);!pe[0]&&t&&s&&(pe[1](!0),p(!0),I(s),r&&w(r),n&&R(n),a&&q(a),o&&V(o),v(n?"details":"contact"));const{data:be}=Ct({queryKey:["contacts-for-card",i==null?void 0:i.id,_],queryFn:async()=>{let We=G.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);_&&(We=We.or(`first_name.ilike.%${_}%,last_name.ilike.%${_}%`));const{data:ht,error:De}=await We;if(De)throw De;return ht},enabled:!!(i!=null&&i.id)&&u}),{data:ye}=Ct({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:We,error:ht}=await G.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(ht)throw ht;return We},enabled:!!(i!=null&&i.id)}),we=We=>{w(We.id),R(`${We.first_name}${We.last_name?" "+We.last_name:""}`),q([We.address,We.city,We.state].filter(Boolean).join(", ")),V(We.home_anniversary||""),v("details")},ke=We=>{I(We),v("contact")},Ze=async()=>{var We;if(!(!i||!ye)){C(!0);try{const ht={owner_user_id:i.id,contact_id:j,card_type:A,template:te,recipient_name:L,property_address:$||null,home_anniversary_date:U||null,custom_message:X||null,property_photo_url:de||null,video_url:ae||null,agent_name:ye.name||"Agent",agent_photo_url:ye.avatar_url,agent_phone:ye.phone,agent_email:ye.email,agent_brokerage:((We=ye.brokerage)==null?void 0:We.name)||null},{error:De}=await G.from("sendable_cards").insert(ht);if(De)throw De;fe.success("Card created! Copy the link to share it."),d.invalidateQueries({queryKey:["sendable-cards"]}),_e()}catch(ht){fe.error(ht.message||"Failed to create card")}finally{C(!1)}}},_e=()=>{p(!1),v("type"),I("home_anniversary"),b(""),w(null),R(""),q(""),V(""),se(""),Y("elegant"),ie(null),le(null)},Ce={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"},Te=WM[A],Fe=A==="home_anniversary",Ae=["home_anniversary","just_listed","just_sold"].includes(A);return e.jsxs(vs,{open:u,onOpenChange:We=>{We?p(!0):(_e(),l==null||l(!1))},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Create Card"]})}),e.jsxs(ys,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:f==="type"?"What type of card?":f==="contact"?`${Ce[A]} — Choose a Contact`:`${Ce[A]} — Customize`})}),f==="type"&&e.jsx(vvs,{onSelect:ke}),f==="contact"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>v("type"),children:[e.jsx(Ua,{className:"h-3.5 w-3.5"})," Back to card types"]}),e.jsxs("div",{className:"relative",children:[e.jsx(fn,{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:We=>b(We.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(We=>e.jsxs("button",{onClick:()=>we(We),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(Xi,{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:[We.first_name," ",We.last_name]}),We.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(Un,{className:"h-3 w-3"}),We.address]})]}),We.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"})]},We.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(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{v("details")},children:"Skip — enter details manually"})})]}),f==="details"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>v("contact"),children:[e.jsx(Ua,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Recipient Name"}),e.jsx(Re,{value:L,onChange:We=>R(We.target.value),placeholder:"John & Jane Smith"})]}),Ae&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Property Address"}),e.jsx(Re,{value:$,onChange:We=>q(We.target.value),placeholder:"123 Main St, Austin, TX"})]}),Fe&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Home Anniversary Date"}),e.jsx(Re,{type:"date",value:U,onChange:We=>V(We.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Personal Message (optional)"}),e.jsx(Mr,{value:X,onChange:We=>se(We.target.value),placeholder:Te.defaultMessage,rows:3})]}),e.jsx(get,{photoUrl:de,videoUrl:ae,onPhotoChange:ie,onVideoChange:le,contactId:j}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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:We,label:ht,gradient:De})=>e.jsxs("button",{onClick:()=>Y(We),className:`p-2 rounded-lg border-2 transition-all text-center ${te===We?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-10 rounded-md mb-1.5 ${De}`}),e.jsx("span",{className:"text-[10px] font-medium",children:ht})]},We))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>v("contact"),className:"flex-1",children:"Back"}),e.jsx(K,{onClick:Ze,disabled:!L||N,className:"flex-1 gap-2",children:N?"Creating...":"Create Card"})]})]})]})]})}const _vs={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 bvs({card:t}){const{user:s}=Gs(),{isGmailConnected:r}=gy(),n=ns(),[a,o]=S.useState(!1),[l,i]=S.useState("");S.useEffect(()=>{a&&t.contact_id&&!l&&G.from("innercircle_contacts").select("email").eq("id",t.contact_id).maybeSingle().then(({data:j})=>{j!=null&&j.email&&i(j.email)})},[a,t.contact_id]);const 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,p]=S.useState(d[t.card_type]||`A Special Card for ${t.recipient_name}!`),[f,v]=S.useState(""),_=`https://cardstudio.relevelup.com/c/${t.share_token}`,b=Ot({mutationFn:async()=>{var A;if(!l)throw new Error("Recipient email is required");const j=`
${f?`

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


`:""}

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

${t.property_address?`

${t.property_address}

`:""}
`,{data:w}=await G.auth.getSession(),N=(A=w==null?void 0:w.session)==null?void 0:A.access_token,C=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/gmail-send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({to:l,subject:u,body:j,contactId:t.contact_id||void 0})});if(!C.ok){const I=await C.json();throw new Error(I.error||"Failed to send")}return C.json()},onSuccess:async()=>{await G.from("sendable_cards").update({sent_at:new Date().toISOString(),sent_via:"gmail"}).eq("id",t.id),n.invalidateQueries({queryKey:["sendable-cards"]}),fe.success(`Card sent to ${l}!`),o(!1)},onError:j=>{fe.error(j.message||"Failed to send email")}});return r?e.jsxs(vs,{open:a,onOpenChange:o,children:[e.jsx(Ei,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(ka,{className:"h-3 w-3"})})}),e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Send Card via Gmail"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"To"}),e.jsx(Re,{type:"email",value:l,onChange:j=>i(j.target.value),placeholder:"recipient@email.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Subject"}),e.jsx(Re,{value:u,onChange:j=>p(j.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Personal Note (optional)"}),e.jsx(Mr,{value:f,onChange:j=>v(j.target.value),placeholder:"Add a warm personal note before the card link...",rows:3})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 text-xs text-muted-foreground",children:["The email will include a beautiful button linking to your card at:",e.jsx("br",{}),e.jsx("span",{className:"font-mono text-foreground",children:_})]}),e.jsx(K,{onClick:()=>b.mutate(),disabled:!l||b.isPending,className:"w-full gap-2",children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ka,{className:"h-4 w-4"})," Send Card"]})})]})]})]}):e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs opacity-50 cursor-not-allowed",title:"Connect Gmail in Settings to send cards via email",disabled:!0,children:e.jsx(ka,{className:"h-3 w-3"})})}function wvs({card:t}){const s=ns(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(t.recipient_name),[d,u]=S.useState(t.property_address||""),[p,f]=S.useState(t.home_anniversary_date||""),[v,_]=S.useState(t.custom_message||""),[b,j]=S.useState(t.template),[w,N]=S.useState(t.property_photo_url),[C,A]=S.useState(t.video_url||null),I=R=>{R&&(i(t.recipient_name),u(t.property_address||""),f(t.home_anniversary_date||""),_(t.custom_message||""),j(t.template),N(t.property_photo_url),A(t.video_url||null)),n(R)},L=async()=>{if(!l.trim()){fe.error("Recipient name is required");return}o(!0);try{const{error:R}=await G.from("sendable_cards").update({recipient_name:l.trim(),property_address:d.trim()||null,home_anniversary_date:p||null,custom_message:v.trim()||null,template:b,property_photo_url:w||null,video_url:C||null}).eq("id",t.id);if(R)throw R;s.invalidateQueries({queryKey:["sendable-cards"]}),fe.success("Card updated"),n(!1)}catch(R){fe.error(R.message||"Failed to update card")}finally{o(!1)}};return e.jsxs(vs,{open:r,onOpenChange:I,children:[e.jsx(Ei,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Ra,{className:"h-3 w-3"})})}),e.jsxs(ys,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Edit Card"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Recipient Name"}),e.jsx(Re,{value:l,onChange:R=>i(R.target.value),placeholder:"John & Jane Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Property Address"}),e.jsx(Re,{value:d,onChange:R=>u(R.target.value),placeholder:"123 Main St, Austin, TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Home Anniversary Date"}),e.jsx(Re,{type:"date",value:p,onChange:R=>f(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Personal Message (optional)"}),e.jsx(Mr,{value:v,onChange:R=>_(R.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(get,{photoUrl:w,videoUrl:C,onPhotoChange:N,onVideoChange:A,contactId:t.contact_id}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["elegant","bold","warm"].map(R=>e.jsxs("button",{onClick:()=>j(R),className:`p-3 rounded-lg border-2 transition-all text-center ${b===R?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-12 rounded-md mb-2 ${R==="elegant"?"bg-gradient-to-br from-slate-100 to-slate-200 dark:from-slate-800 dark:to-slate-700":R==="bold"?"bg-gradient-to-br from-violet-500 to-fuchsia-500":"bg-gradient-to-br from-amber-200 to-orange-300"}`}),e.jsx("span",{className:"text-xs font-medium capitalize",children:R})]},R))})]}),e.jsx(K,{onClick:L,disabled:!l.trim()||a,className:"w-full gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function jvs(){const{user:t}=Gs(),s=ns(),[r,n]=S.useState(""),[a,o]=Ec(),l=a.get("cardType"),i=a.get("contactId"),d=a.get("name"),u=a.get("address"),p=a.get("date"),f=!!l,{data:v,isLoading:_}=Ct({queryKey:["sendable-cards",t==null?void 0:t.id],queryFn:async()=>{const{data:A,error:I}=await G.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=Ot({mutationFn:async A=>{const{error:I}=await G.from("sendable_cards").delete().eq("id",A);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["sendable-cards"]}),fe.success("Card deleted")}}),j=A=>{const I=`https://cardstudio.relevelup.com/c/${A}`;navigator.clipboard.writeText(I),fe.success("Share link copied!")},w=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"},C={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"};return e.jsx(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(sDe,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(fn,{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(Ee,{className:"animate-pulse",children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"h-40 bg-muted rounded-lg mb-3"}),e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]})},A))}):w!=null&&w.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w.map(A=>e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-shadow",children:[e.jsxs("div",{className:`aspect-[16/10] flex items-center justify-center relative overflow-hidden ${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:C[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(at,{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(ya,{className:"h-3 w-3"}),A.view_count," views"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Cd(new Date(A.created_at),{addSuffix:!0})})]}),A.sent_at&&e.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",ws(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(K,{variant:"outline",size:"sm",className:"flex-1 gap-1 text-xs",onClick:()=>j(A.share_token),children:[e.jsx(ni,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(wvs,{card:A}),e.jsx(bvs,{card:A}),e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${A.share_token}`,"_blank"),children:e.jsx(sn,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive gap-1 text-xs",onClick:()=>b.mutate(A.id),children:e.jsx(br,{className:"h-3 w-3"})})]})]})]},A.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(_r,{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(sDe,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]})})]})})}function yE({delay:t,x:s,y:r,size:n}){return e.jsx(wr.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 kvs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:v}=t,_=WM[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(wr.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(wr.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(yE,{delay:0,x:"15%",y:"20%",size:8}),e.jsx(yE,{delay:1,x:"80%",y:"30%",size:6}),e.jsx(yE,{delay:2,x:"60%",y:"70%",size:10}),e.jsx(yE,{delay:.5,x:"25%",y:"80%",size:7}),e.jsx(yE,{delay:1.5,x:"70%",y:"15%",size:5})]}),e.jsxs(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.div,{className:"h-px bg-gradient-to-r from-transparent via-slate-300 dark:via-slate-600 to-transparent mx-auto mb-6",initial:{width:0},animate:{width:"80%"},transition:{duration:.8,delay:1.1},style:{margin:"0 auto 1.5rem"}}),f&&e.jsx(wr.div,{className:"mb-6 rounded-xl overflow-hidden shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.15,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),v&&e.jsx(wr.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(wr.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(wr.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(wr.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-slate-200 dark:ring-slate-700 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-full bg-gradient-to-br from-slate-200 to-blue-100 dark:from-slate-700 dark:to-slate-600 flex items-center justify-center shadow-md",children:e.jsx("span",{className:"text-sm font-semibold text-slate-600 dark:text-slate-300",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 dark:text-slate-200",children:l}),p&&e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-4",children:[d&&e.jsxs(wr.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(Zn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(wr.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(_r,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(wr.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 Ape({delay:t,x:s,y:r,color:n,size:a}){return e.jsx(wr.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 vE({delay:t,x:s,y:r}){return e.jsx(wr.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 rDe={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 Nvs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:v}=t,_=WM[s],b=rDe[s]||rDe.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(Ape,{delay:0,x:"10%",y:"10%",color:b.orbs[0],size:200}),e.jsx(Ape,{delay:1,x:"70%",y:"60%",color:b.orbs[1],size:180}),e.jsx(Ape,{delay:2,x:"50%",y:"20%",color:b.orbs[2],size:150}),e.jsx(vE,{delay:0,x:"20%",y:"25%"}),e.jsx(vE,{delay:.8,x:"75%",y:"15%"}),e.jsx(vE,{delay:1.6,x:"85%",y:"65%"}),e.jsx(vE,{delay:2.4,x:"10%",y:"75%"}),e.jsx(vE,{delay:.4,x:"45%",y:"85%"}),e.jsxs(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(Un,{className:"h-3.5 w-3.5"}),n]})]}),f&&e.jsx(wr.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10 shadow-lg",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),v&&e.jsx(wr.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(wr.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(wr.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(wr.img,{src:i,alt:l,className:"h-12 w-12 rounded-xl object-cover ring-2 ring-violet-500/40 shadow-lg",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-xl bg-gradient-to-br from-violet-500 to-fuchsia-500 flex items-center justify-center shadow-lg",children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-bold text-white",children:l}),p&&e.jsx("p",{className:"text-xs text-violet-300/60",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-5",children:[d&&e.jsxs(wr.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(Zn,{className:"h-3.5 w-3.5"})," Call Me"]}),u&&e.jsxs(wr.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(_r,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(wr.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 Svs({emoji:t,delay:s,x:r,duration:n}){return e.jsx(wr.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 nDe={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 Cvs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:v}=t,_=WM[s],b=nDe[s]||nDe.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((j,w)=>e.jsx(Svs,{emoji:j,delay:w*1.2,x:`${15+w*14}%`,duration:5+w%3},w)),e.jsx(wr.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(wr.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(wr.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(wr.div,{className:`h-28 bg-gradient-to-r ${b.header} relative overflow-hidden`,children:[e.jsx(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(Ai,{className:"h-3 w-3"}),n]})]}),f&&e.jsx(wr.div,{className:"mb-5 rounded-2xl overflow-hidden border border-amber-200 shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),v&&e.jsx(wr.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(wr.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(wr.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(wr.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}),p&&e.jsx("p",{className:`text-xs ${b.text} opacity-60`,children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[d&&e.jsxs(wr.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(Zn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(wr.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(_r,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(wr.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 AR({delay:t,x:s,y:r,size:n,color:a}){return e.jsx(wr.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 Epe({delay:t,x:s,y:r,size:n}){return e.jsx(wr.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 aDe={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 Mvs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:v}=t,_=WM[s],b=aDe[s]||aDe.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(AR,{delay:0,x:"5%",y:"10%",size:300,color:b.mesh[0]}),e.jsx(AR,{delay:2,x:"60%",y:"50%",size:250,color:b.mesh[1]}),e.jsx(AR,{delay:4,x:"30%",y:"70%",size:200,color:b.mesh[2]}),e.jsx(AR,{delay:1,x:"80%",y:"15%",size:180,color:b.mesh[0]}),e.jsx(Epe,{delay:0,x:"15%",y:"20%",size:100}),e.jsx(Epe,{delay:3,x:"70%",y:"60%",size:140}),e.jsx(Epe,{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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(wr.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(Ai,{className:"h-3 w-3"})," ",n]})]}),e.jsx(wr.div,{className:"h-px bg-gradient-to-r from-transparent via-white/15 to-transparent mx-auto mb-6",initial:{width:0},animate:{width:"70%"},transition:{duration:1,delay:1.1},style:{margin:"0 auto 1.5rem"}}),f&&e.jsx(wr.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.15,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),v&&e.jsx(wr.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(wr.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(wr.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(wr.img,{src:i,alt:l,className:"h-12 w-12 rounded-2xl object-cover ring-1 ring-white/10",whileHover:{scale:1.08}}):e.jsx("div",{className:"h-12 w-12 rounded-2xl bg-white/[0.08] border border-white/[0.1] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-semibold text-white/60",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-white/80",children:l}),p&&e.jsx("p",{className:"text-xs text-white/30",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[d&&e.jsxs(wr.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(Zn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(wr.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(_r,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(wr.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 Ppe({delay:t,x:s,angle:r,color:n}){return e.jsx(wr.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 ER({delay:t,x:s}){return e.jsx(wr.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 iDe={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 Tvs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:v}=t,_=WM[s],b=iDe[s]||iDe.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(Ppe,{delay:0,x:"20%",angle:15,color:b.stripe}),e.jsx(Ppe,{delay:2,x:"75%",angle:-12,color:b.stripe}),e.jsx(Ppe,{delay:4,x:"50%",angle:5,color:b.stripe}),e.jsx(ER,{delay:0,x:"30%"}),e.jsx(ER,{delay:1.5,x:"60%"}),e.jsx(ER,{delay:3,x:"45%"}),e.jsx(ER,{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(wr.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0},animate:{opacity:1},transition:{duration:1.2},children:[e.jsx(wr.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(wr.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(wr.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(wr.div,{className:"mb-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:.7},children:[e.jsx(wr.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(wr.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(wr.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(wr.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(Ai,{className:"h-3 w-3"})," ",n]})]}),e.jsxs(wr.div,{className:"flex items-center justify-center gap-3 my-8",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2},children:[e.jsx(wr.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(wr.span,{className:"text-white/10 text-xs",animate:{rotate:[0,360]},transition:{duration:20,repeat:1/0,ease:"linear"},children:"✦"}),e.jsx(wr.div,{className:"h-px flex-1 max-w-[60px] bg-gradient-to-l from-transparent to-white/15",initial:{scaleX:0},animate:{scaleX:1},transition:{delay:1.3,duration:.8},style:{transformOrigin:"left"}})]}),f&&e.jsxs(wr.div,{className:"mb-8 rounded-2xl overflow-hidden ring-1 ring-white/5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.3,duration:.6},children:[e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-950/30 to-transparent pointer-events-none"})]}),v&&e.jsx(wr.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(wr.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(wr.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(wr.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}),p&&e.jsx("p",{className:"text-[11px] text-white/25",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[d&&e.jsxs(wr.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(Zn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(wr.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(_r,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})}),e.jsx(wr.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 xet(){const{shareToken:t}=Mo(),{data:s,isLoading:r,error:n}=Ct({queryKey:["public-sendable-card",t],queryFn:async()=>{const{data:l,error:i}=await G.from("sendable_cards").select("*").eq("share_token",t).single();if(i)throw i;return l},enabled:!!t});if(S.useEffect(()=>{t&&G.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()-fl(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(Nvs,{...o});case"warm":return e.jsx(Cvs,{...o});case"glass":return e.jsx(Mvs,{...o});case"cinematic":return e.jsx(Tvs,{...o});case"elegant":default:return e.jsx(kvs,{...o})}}function Avs(){const t=ti();return Ct({queryKey:["drip-settings",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("drip_settings").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function Evs(){const t=ti(),s=ns();return Ot({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n}=await G.from("drip_settings").select("id").eq("user_id",t).maybeSingle();if(n){const{data:a,error:o}=await G.from("drip_settings").update(r).eq("user_id",t).select().single();if(o)throw o;return a}else{const{data:a,error:o}=await G.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 Pvs(){const t=Dr(),{isGmailConnected:s,gmailEmail:r}=gy(),{data:n,isLoading:a}=Avs(),o=Evs(),[l,i]=S.useState(!1),[d,u]=S.useState(!0),[p,f]=S.useState(!1);S.useEffect(()=>{n&&(i(n.is_globally_enabled),u(n.append_signature))},[n]);const v=async b=>{if(b&&!s){fe.error("Connect your Gmail account first before enabling Smart Drips");return}i(b);try{await o.mutateAsync({is_globally_enabled:b}),fe.success(b?"Smart Drips enabled globally":"Smart Drips paused globally")}catch{i(!b),fe.error("Failed to update settings")}},_=async b=>{u(b);try{await o.mutateAsync({append_signature:b}),fe.success(b?"Signature will be appended to drip emails":"Signature disabled for drip emails")}catch{u(!b),fe.error("Failed to update settings")}};return e.jsxs(vs,{open:p,onOpenChange:f,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx($l,{className:"h-3.5 w-3.5"}),"Settings"]})}),e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx($l,{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(_r,{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(at,{variant:"outline",className:"gap-1 text-emerald-600 border-emerald-200 bg-emerald-500/10 text-[10px]",children:[e.jsx(da,{className:"h-3 w-3"}),"Active"]}):e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs gap-1",onClick:()=>{f(!1),t("/mission-control/integrations")},children:[e.jsx(sn,{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(Rl,{}),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(bP,{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(Br,{checked:l,onCheckedChange:v,disabled:a||o.isPending})]}),e.jsx(Rl,{}),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(Ix,{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(Br,{checked:d,onCheckedChange:_,disabled:a||o.isPending})]}),d&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>{f(!1),t("/profile")},children:[e.jsx(Ix,{className:"h-3 w-3 mr-1"}),"Edit your email signature in Profile settings"]})]})]})]})}function Ivs(){const t=ti();return Ct({queryKey:["drip-templates",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.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 Lvs(){const t=ti();return Ct({queryKey:["drip-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function Dvs(){const t=ti(),s=ns();return Ot({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.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 Ovs(){const t=ns();return Ot({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("drip_templates").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function Rvs(){const t=ns();return Ot({mutationFn:async s=>{const{error:r}=await G.from("drip_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function Fvs(){const t=ti(),s=ns();return Ot({mutationFn:async({templateId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await G.from("drip_templates").select("*").eq("id",r).single();if(o)throw o;const{data:l,error:i}=await G.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 zvs=[{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 Bvs(){const t=ti(),{data:s,isLoading:r}=Ivs(),{data:n,isLoading:a}=Lvs(),o=Dvs(),l=Ovs(),i=Rvs(),d=Fvs(),[u,p]=S.useState(null),[f,v]=S.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))||[],j=L=>_.filter(R=>R.stage_id===L),w=async L=>{try{await l.mutateAsync({id:L.id,is_enabled:!L.is_enabled}),fe.success(L.is_enabled?"Drip disabled":"Drip enabled")}catch{fe.error("Failed to update")}},N=async L=>{try{const R=n==null?void 0:n.find($=>$.id===L);await o.mutateAsync({stage_id:L,title:`${(R==null?void 0:R.name)||"Stage"} follow-up`,subject:"",body:"",channel:"email",delay_type:"instant",delay_minutes:0}),p(L),fe.success("Drip template created")}catch{fe.error("Failed to create template")}},C=async L=>{try{await i.mutateAsync(L),fe.success("Template deleted")}catch{fe.error("Failed to delete")}},A=async L=>{if(!n||n.length===0){fe.error("No pipeline stages found");return}const R=n[0].id;try{await d.mutateAsync({templateId:L,stageId:R}),fe.success("Template copied to your drips!")}catch{fe.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(Dm,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Smart Drips"}),e.jsx(at,{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(Pvs,{})]}),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(cP,{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(Na,{defaultValue:"my-drips",children:[e.jsxs(va,{className:"grid grid-cols-2 w-full max-w-xs mb-6",children:[e.jsx(ks,{value:"my-drips",children:"My Drips"}),e.jsxs(ks,{value:"starters",children:["Starter Templates",b.length>0&&e.jsx(at,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",children:b.length})]})]}),e.jsx(zs,{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(Dm,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No Pipeline Stages"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create pipeline stages first to set up drip automations."})]}):e.jsxs("div",{className:"space-y-2",children:[n.filter(L=>!L.is_won_stage&&!L.is_lost_stage).map(L=>{const R=j(L.id),$=u===L.id,q=R.some(U=>U.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>p($?null:L.id),className:"w-full flex items-center gap-3 p-4 hover:bg-muted/30 transition-colors text-left",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:L.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:L.name}),R.length>0&&e.jsxs(at,{variant:"outline",className:`text-[10px] ${q?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[R.length," drip",R.length!==1?"s":"",q&&" · Active"]}),$?e.jsx(Vo,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Ha,{className:"h-4 w-4 text-muted-foreground"})]}),$&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:R.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No drip set for this stage"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>N(L.id),disabled:o.isPending,children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1.5"}),"Create Drip"]})]}):e.jsxs(e.Fragment,{children:[R.map(U=>e.jsx(oDe,{template:U,isEditing:f===U.id,onToggleEdit:()=>v(f===U.id?null:U.id),onToggleEnabled:()=>w(U),onUpdate:V=>l.mutateAsync({id:U.id,...V}),onDelete:()=>C(U.id),userId:t||""},U.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>N(L.id),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},L.id)}),n.filter(L=>L.is_won_stage||L.is_lost_stage).length>0&&e.jsxs("div",{className:"pt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-medium mb-2 px-1",children:"Closing Stages"}),n.filter(L=>L.is_won_stage||L.is_lost_stage).map(L=>{const R=j(L.id),$=u===L.id,q=R.some(U=>U.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden mb-2",children:[e.jsxs("button",{onClick:()=>p($?null:L.id),className:"w-full flex items-center gap-3 p-4 hover:bg-muted/30 transition-colors text-left",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:L.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:L.name}),R.length>0&&e.jsxs(at,{variant:"outline",className:`text-[10px] ${q?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[R.length," drip",R.length!==1?"s":"",q&&" · Active"]}),$?e.jsx(Vo,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Ha,{className:"h-4 w-4 text-muted-foreground"})]}),$&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:R.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No drip set for this stage"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>N(L.id),disabled:o.isPending,children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1.5"})," Create Drip"]})]}):e.jsxs(e.Fragment,{children:[R.map(U=>e.jsx(oDe,{template:U,isEditing:f===U.id,onToggleEdit:()=>v(f===U.id?null:U.id),onToggleEnabled:()=>w(U),onUpdate:V=>l.mutateAsync({id:U.id,...V}),onDelete:()=>C(U.id),userId:t||""},U.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>N(L.id),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},L.id)})]})]})}),e.jsx(zs,{value:"starters",children:b.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(hn,{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($vs,{template:L,onCopy:()=>A(L.id),isCopying:d.isPending},L.id))})})]})]})})}function oDe({template:t,isEditing:s,onToggleEdit:r,onToggleEnabled:n,onUpdate:a,onDelete:o,userId:l}){const[i,d]=S.useState(t.title),[u,p]=S.useState(t.subject),[f,v]=S.useState(t.body),[_,b]=S.useState(t.video_url||""),[j,w]=S.useState(t.channel),[N,C]=S.useState(t.delay_type),[A,I]=S.useState(t.delay_minutes),[L,R]=S.useState(!1),$=async()=>{R(!0);try{await a({title:i,subject:u,body:f,video_url:_||null,channel:j,delay_type:N,delay_minutes:A}),fe.success("Drip saved"),r()}catch{fe.error("Failed to save")}finally{R(!1)}},q=U=>{v(V=>V+U)};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(oo,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(_r,{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(kn,{className:"h-3 w-3 text-primary"})]})]}),e.jsx(Br,{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(ve,{className:"text-xs font-medium",children:"Title (internal)"}),e.jsx(Re,{value:i,onChange:U=>d(U.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(ve,{className:"text-xs font-medium",children:"Channel"}),e.jsx("div",{className:"flex gap-1 mt-1",children:["email","sms"].map(U=>e.jsxs("button",{onClick:()=>w(U),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${j===U?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[U==="sms"?e.jsx(oo,{className:"h-3 w-3"}):e.jsx(_r,{className:"h-3 w-3"}),U==="sms"?"SMS":"Email"]},U))})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ve,{className:"text-xs font-medium",children:"Timing"}),e.jsxs("div",{className:"flex gap-1 mt-1",children:[e.jsx("button",{onClick:()=>C("instant"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${N==="instant"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:"Instant"}),e.jsxs("button",{onClick:()=>C("scheduled"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${N==="scheduled"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[e.jsx(Tn,{className:"h-3 w-3 mr-1 inline"}),"Delay"]})]})]})]}),N==="scheduled"&&e.jsxs("div",{children:[e.jsx(ve,{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:U=>{const V=parseInt(U.target.value)||0;I(A>=60?V*60:V)},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(U=>e.jsx("button",{className:`px-2 py-1 rounded text-xs border transition-colors ${U.label==="Minutes"&&A<60||U.label==="Hours"&&A>=60&&A<1440||U.label==="Days"&&A>=1440?"bg-primary/10 text-primary border-primary/30":"text-muted-foreground border-input"}`,onClick:()=>{U.label==="Minutes"?I(30):U.label==="Hours"?I(60):I(1440)},children:U.label},U.label))})]})]}),j==="email"&&e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs font-medium",children:"Subject Line"}),e.jsx(Re,{value:u,onChange:U=>p(U.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(ve,{className:"text-xs font-medium",children:j==="sms"?"Message":"Email Body"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Insert:"}),e.jsxs("select",{className:"text-[10px] border rounded px-1 py-0.5 bg-background text-muted-foreground",value:"",onChange:U=>{U.target.value&&q(U.target.value),U.target.value=""},children:[e.jsx("option",{value:"",children:"Merge variable..."}),zvs.map(U=>e.jsx("option",{value:U.key,children:U.label},U.key))]})]})]}),e.jsx("textarea",{value:f,onChange:U=>v(U.target.value),placeholder:j==="sms"?"Hey {{client_first_name}}, great talking with you today! Here's a quick video about what's next...":`Hi {{client_first_name}}, It was great meeting with you! Here's a video about what to expect next...`,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[100px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),e.jsxs("div",{children:[e.jsx(ve,{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(kn,{className:"h-3 w-3 inline mr-1 text-primary"}),_.length>50?_.slice(0,50)+"...":_]}),e.jsx(K,{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(O2e,{onVideoReady:U=>b(U)}),e.jsx(D2e,{userId:l,onSelect:U=>b(U),triggerSize:"sm",triggerClassName:"gap-1.5 flex-1"}),e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const U=prompt("Paste a YouTube or Loom URL:");U&&b(U)},children:[e.jsx(Lo,{className:"h-3 w-3"})," Paste URL"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive",onClick:o,children:[e.jsx(br,{className:"h-3 w-3 mr-1"})," Delete"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",className:"text-xs",onClick:r,children:"Cancel"}),e.jsx(K,{size:"sm",className:"text-xs",onClick:$,disabled:L,children:L?"Saving...":"Save Drip"})]})]})]})]})}function $vs({template:t,onCopy:s,isCopying:r}){const[n,a]=S.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(at,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:l}),e.jsxs(at,{variant:"outline",className:"text-[10px] gap-1",children:[t.channel==="sms"?e.jsx(oo,{className:"h-3 w-3"}):e.jsx(_r,{className:"h-3 w-3"}),t.channel==="sms"?"SMS":"Email"]}),e.jsxs(at,{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(Vo,{className:"h-4 w-4 text-muted-foreground ml-1"}):e.jsx(Ha,{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(K,{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 yet=()=>{const t=vu();return S.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 qvs(){return S.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs(NFe,{children:[e.jsx(Vs,{path:"/c/:shareToken",element:e.jsx(xet,{})}),e.jsx(Vs,{path:"*",element:e.jsx(yet,{})})]})}const Ipe={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function vet({slugOverride:t}){const s=Mo(),r=t||s.slug,[n,a]=S.useState("types"),[o,l]=S.useState(null),[i,d]=S.useState(null),[u,p]=S.useState(null),[f,v]=S.useState(new Date),[_,b]=S.useState({name:"",email:"",phone:"",message:""}),[j,w]=S.useState(!1),{data:N,isLoading:C}=Ct({queryKey:["public-booking-settings",r],queryFn:async()=>{const{data:Y,error:de}=await G.from("agent_booking_settings").select("*").eq("slug",r).eq("is_active",!0).single();if(de)throw de;return Y},enabled:!!r}),{data:A}=Ct({queryKey:["public-booking-profile",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Y,error:de}=await G.from("profiles").select("name, avatar_url, email, phone, title, bio").eq("id",N.user_id).single();if(de)throw de;return Y},enabled:!!(N!=null&&N.user_id)}),{data:I=[]}=Ct({queryKey:["public-booking-types",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Y,error:de}=await G.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(de)throw de;return Y},enabled:!!(N!=null&&N.user_id)}),{data:L=[]}=Ct({queryKey:["public-availability",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Y,error:de}=await G.from("agent_availability_slots").select("day_of_week, start_time, end_time").eq("user_id",N.user_id).eq("is_active",!0);if(de)throw de;return Y},enabled:!!(N!=null&&N.user_id)}),{data:R=[]}=Ct({queryKey:["public-blocked-dates",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Y,error:de}=await G.from("agent_blocked_dates").select("blocked_date").eq("user_id",N.user_id);if(de)throw de;return Y.map(ie=>ie.blocked_date)},enabled:!!(N!=null&&N.user_id)}),{data:$=[]}=Ct({queryKey:["public-existing-bookings",N==null?void 0:N.user_id,i],queryFn:async()=>{if(!i)return[];const Y=ws(i,"yyyy-MM-dd"),{data:de,error:ie}=await G.from("bookings").select("start_time, end_time").eq("agent_user_id",N.user_id).eq("booking_date",Y).eq("status","confirmed");if(ie)throw ie;return de},enabled:!!(N!=null&&N.user_id)&&!!i}),q=S.useMemo(()=>[...new Set(L.map(Y=>Y.day_of_week))],[L]),U=Y=>{const de=Gh(new Date),ie=ml(de,(N==null?void 0:N.max_advance_days)||30),ae=ml(de,0);return IN(Y,ae)||PN(Y,ie)||R.includes(ws(Y,"yyyy-MM-dd"))?!1:q.includes(Y.getDay())},V=S.useMemo(()=>{if(!i||!o||!N)return[];const Y=L.filter(be=>be.day_of_week===i.getDay()),de=o.duration_minutes,ie=N.buffer_minutes||0,ae=[],le=new Date,pe=(N.min_notice_hours||2)*60*60*1e3;for(const be of Y){const[ye,we]=be.start_time.split(":").map(Number),[ke,Ze]=be.end_time.split(":").map(Number);let _e=HP(VP(i,ye),we);const Ce=HP(VP(i,ke),Ze);for(;R4(_e,de)<=Ce;){const Te=ws(_e,"HH:mm"),Fe=ws(R4(_e,de),"HH:mm");_e.getTime()-le.getTime()>=pe&&($.some(We=>{const ht=We.start_time.slice(0,5),De=We.end_time.slice(0,5);return Teht})||ae.push(Te)),_e=R4(_e,de+ie)}}return ae},[i,o,L,N,$]),X=S.useMemo(()=>{const Y=f.getFullYear(),de=f.getMonth(),ie=new Date(Y,de,1),ae=new Date(Y,de+1,0),le=ie.getDay(),pe=[];for(let be=0;be{if(!(!o||!i||!u||!_.name||!N)){w(!0);try{const Y=ws(R4(HP(VP(new Date,parseInt(u.split(":")[0])),parseInt(u.split(":")[1])),o.duration_minutes),"HH:mm"),{error:de}=await G.from("bookings").insert({agent_user_id:N.user_id,booking_type_id:o.id,booking_date:ws(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(de)throw de;G.functions.invoke("booking-notify",{body:{agentUserId:N.user_id,guestName:_.name,guestEmail:_.email||null,guestPhone:_.phone||null,guestMessage:_.message||null,bookingTypeName:o.name,bookingDate:ws(i,"yyyy-MM-dd"),startTime:u,endTime:Y,durationMinutes:o.duration_minutes,meetingLink:N.meeting_link||null}}).catch(ie=>console.error("Booking notify error:",ie)),a("confirmed")}catch(Y){fe.error("Failed to book: "+Y.message)}finally{w(!1)}}},te=Y=>{const[de,ie]=Y.split(":").map(Number),ae=de>=12?"PM":"AM";return`${de%12||12}:${ie.toString().padStart(2,"0")} ${ae}`};return C?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8] flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-[#406E71] border-t-transparent"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading booking page..."})]})}):N?e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8]",children:[e.jsx("div",{className:"h-1.5 bg-gradient-to-r from-[#406E71] via-[#5a9a9d] to-[#2a4c64]"}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-6 sm:py-10",children:[e.jsxs("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden mb-6",children:[e.jsx("div",{className:"relative bg-gradient-to-r from-[#406E71] to-[#2a4c64] px-6 pt-6 pb-12",children:e.jsxs("div",{className:"absolute inset-0 opacity-10",children:[e.jsx("div",{className:"absolute top-2 right-8 w-20 h-20 rounded-full border-2 border-white/30"}),e.jsx("div",{className:"absolute bottom-4 left-12 w-10 h-10 rounded-full border border-white/20"})]})}),e.jsx("div",{className:"relative -mt-10 px-6",children:e.jsxs("div",{className:"flex items-end gap-4",children:[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(Xi,{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(Zn,{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(_r,{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:Ipe[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),p(null)},className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(Ua,{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:Ipe[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:ws(f,"MMMM yyyy")}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{className:"h-8 w-8 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100 hover:text-slate-800 transition-colors",onClick:()=>v(new Date(f.getFullYear(),f.getMonth()-1)),children:e.jsx(zl,{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(f.getFullYear(),f.getMonth()+1)),children:e.jsx(Ha,{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)),X.map((Y,de)=>{if(!Y)return e.jsx("div",{},`pad-${de}`);const ie=U(Y),ae=i&&cl(Y,i),le=cl(Y,new Date);return e.jsx("button",{disabled:!ie,onClick:()=>{d(Y),p(null)},className:`h-10 w-10 mx-auto rounded-xl text-sm font-medium transition-all duration-150 ${ae?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-105":ie?"hover:bg-[#406E71]/10 text-slate-700 hover:text-[#406E71]":"text-slate-200 cursor-not-allowed"} ${le&&!ae?"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(ld,{className:"h-4 w-4 text-[#406E71]"}),e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:ws(i,"EEEE, MMMM d")})]}),V.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:V.map(Y=>{const de=u===Y;return e.jsx("button",{onClick:()=>p(Y),className:`px-3 py-2.5 rounded-xl text-sm font-medium transition-all duration-150 ${de?"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(K,{className:"w-full h-12 rounded-xl bg-[#406E71] hover:bg-[#365c5e] text-white font-semibold shadow-md shadow-[#406E71]/20 transition-all hover:shadow-lg",onClick:()=>a("form"),children:"Continue to Details"})]})]}),n==="form"&&o&&i&&u&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>a("date"),className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(Ua,{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:Ipe[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(ld,{className:"h-3.5 w-3.5 text-[#406E71]"}),ws(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(ve,{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(ve,{className:"text-xs font-semibold text-slate-700",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(_r,{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(ve,{className:"text-xs font-semibold text-slate-700",children:"Phone"}),e.jsxs("div",{className:"relative",children:[e.jsx(Zn,{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(ve,{className:"text-xs font-semibold text-slate-700",children:"Message (optional)"}),e.jsx(Mr,{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(K,{className:"w-full h-12 rounded-xl bg-[#406E71] hover:bg-[#365c5e] text-white font-semibold shadow-md shadow-[#406E71]/20 transition-all hover:shadow-lg disabled:opacity-60",onClick:se,disabled:!_.name||j,children:j?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}),"Booking..."]}):"Confirm Booking"})]}),n==="confirmed"&&e.jsxs("div",{className:"text-center space-y-5 py-6",children:[e.jsxs("div",{className:"relative mx-auto w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-emerald-100 animate-ping opacity-30"}),e.jsx("div",{className:"relative w-20 h-20 rounded-full bg-gradient-to-br from-emerald-400 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-200",children:e.jsx(da,{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&&ws(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(Zn,{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(_r,{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(ld,{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 Uvs(){const s=vu().pathname.slice(1).split("/")[0];return S.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(vet,{slugOverride:s}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100 dark:from-slate-950 dark:to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"LevelUp Scheduler"}),e.jsx("p",{className:"text-muted-foreground",children:"Visit a specific agent's booking URL to schedule a meeting."})]})})}function Vvs(){const s=vu().pathname.slice(1);return S.useEffect(()=>{document.body.classList.add("connect-page");const r=()=>{['[id*="lc_text_widget"]','[id*="lc_text-widget"]','[class*="lc-text-widget"]','[class*="lc_text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("connect-page"),n.forEach(clearTimeout)}},[]),!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-slate-100 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Connect"}),e.jsx("p",{className:"text-slate-500",children:"Stay connected with your real estate professional."}),e.jsx("p",{className:"text-slate-400 text-sm mt-2",children:"Visit a specific agent link to get started."})]})}):e.jsx(KUe,{slugOverride:s})}function _et({slugOverride:t}){const{slug:s}=Mo(),r=t||s,[n,a]=S.useState(!1),[o,l]=S.useState({}),[i,d]=S.useState(0),[u,p]=S.useState(!1),{data:f,isLoading:v}=Ct({queryKey:["public-landing-page",r],queryFn:async()=>{const{data:$,error:q}=await G.from("landing_pages").select("*").eq("slug",r).eq("is_published",!0).single();if(q)throw q;return $},enabled:!!r}),{data:_=[]}=Ct({queryKey:["public-landing-page-fields",f==null?void 0:f.id],queryFn:async()=>{const{data:$,error:q}=await G.from("landing_page_fields").select("*").eq("page_id",f.id).order("sort_order");if(q)throw q;return $},enabled:!!(f!=null&&f.id)});S.useEffect(()=>{f!=null&&f.id&&G.from("landing_pages").update({view_count:(f.view_count||0)+1}).eq("id",f.id).then(()=>{})},[f==null?void 0:f.id]);const b=Ot({mutationFn:async()=>{const $=_.find(X=>X.field_type==="text"&&X.label.toLowerCase().includes("name")),q=_.find(X=>X.field_type==="email"),U=_.find(X=>X.field_type==="phone"),{error:V}=await G.from("landing_page_submissions").insert([{page_id:f.id,answers:JSON.parse(JSON.stringify(o)),contact_name:$?String(o[$.label]||""):null,contact_email:q?String(o[q.label]||""):null,contact_phone:U?String(o[U.label]||""):null,referrer:document.referrer||null,user_agent:navigator.userAgent,utm_source:new URLSearchParams(window.location.search).get("utm_source"),utm_medium:new URLSearchParams(window.location.search).get("utm_medium"),utm_campaign:new URLSearchParams(window.location.search).get("utm_campaign")}]);if(V)throw V},onSuccess:()=>a(!0)}),j=$=>{$.preventDefault(),!(_.filter(U=>U.is_required&&!o[U.label]).length>0)&&b.mutate()};if(v)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-gray-400 border-t-transparent"})});if(!f)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-700",children:"Page Not Found"}),e.jsx("p",{className:"text-gray-500 mt-2",children:"This page doesn't exist or is no longer available."})]})});const w=f.primary_color||"#406E71",N=f.accent_color||"#2a4c64",C=f,A=f.page_type==="lead_magnet",I=f.page_type==="just_listed"||f.page_type==="just_sold",L=Array.isArray(C.property_photos)?C.property_photos:[],R=C.lead_magnet_file_url||C.lead_magnet_external_url;if(n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:`linear-gradient(135deg, ${w}, ${N})`},children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl p-8 max-w-md mx-4 text-center",children:[e.jsx(da,{className:"h-16 w-16 mx-auto mb-4",style:{color:w}}),e.jsx("h2",{className:"text-2xl font-bold mb-2",children:A?"Your download is ready!":"Submitted!"}),e.jsx("p",{className:"text-gray-600",children:f.success_message}),A&&R&&e.jsxs("a",{href:R,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 mt-6 px-6 py-3 rounded-lg text-white font-semibold transition-transform hover:scale-105",style:{backgroundColor:w},children:[e.jsx(xi,{className:"h-5 w-5"}),"Download ",C.lead_magnet_file_name||"Your File"]}),f.agent_name&&e.jsxs("div",{className:"mt-6 pt-4 border-t",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Contact"}),e.jsx("p",{className:"font-semibold",children:f.agent_name}),f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:w},children:[e.jsx(Zn,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:w},children:[e.jsx(_r,{className:"h-3 w-3"})," ",f.agent_email]})]})]})});if(I){const $=q=>{const U=parseFloat(q.replace(/[^0-9.]/g,""));return isNaN(U)?q:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(U)};return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[u&&L.length>0&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/95 flex items-center justify-center",onClick:()=>p(!1),children:[e.jsx("button",{onClick:()=>p(!1),className:"absolute top-4 right-4 text-white/80 hover:text-white z-10",children:e.jsx(Ur,{className:"h-8 w-8"})}),e.jsx("button",{onClick:q=>{q.stopPropagation(),d(U=>U===0?L.length-1:U-1)},className:"absolute left-4 top-1/2 -translate-y-1/2 bg-white/10 hover:bg-white/20 text-white rounded-full p-3 transition-colors z-10",children:e.jsx(zl,{className:"h-6 w-6"})}),e.jsx("img",{src:L[i],alt:`Property photo ${i+1}`,className:"max-h-[90vh] max-w-[90vw] object-contain rounded-lg",onClick:q=>q.stopPropagation()}),e.jsx("button",{onClick:q=>{q.stopPropagation(),d(U=>U===L.length-1?0:U+1)},className:"absolute right-4 top-1/2 -translate-y-1/2 bg-white/10 hover:bg-white/20 text-white rounded-full p-3 transition-colors z-10",children:e.jsx(Ha,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 text-white/70 text-sm",children:[i+1," / ",L.length]})]}),L.length>0&&e.jsxs("div",{className:"relative max-w-6xl mx-auto px-4 pt-6",children:[e.jsx("div",{className:"absolute top-10 left-8 z-10 px-4 py-1.5 rounded-full text-white font-bold text-sm uppercase tracking-wider shadow-lg",style:{backgroundColor:C.property_status==="just_sold"?"#e74c3c":w},children:C.property_status==="just_sold"?"🎉 Just Sold":"🏡 Just Listed"}),L.length===1?e.jsxs("div",{className:"rounded-2xl overflow-hidden cursor-pointer group",onClick:()=>{d(0),p(!0)},children:[e.jsx("img",{src:L[0],alt:"Property",className:"w-full h-[50vh] object-cover group-hover:scale-105 transition-transform duration-500"}),e.jsxs("div",{className:"absolute bottom-4 right-4 bg-black/60 text-white px-3 py-1.5 rounded-lg text-sm flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(c_,{className:"h-4 w-4"})," View"]})]}):L.length===2?e.jsx("div",{className:"grid grid-cols-2 gap-2 rounded-2xl overflow-hidden",children:L.slice(0,2).map((q,U)=>e.jsx("div",{className:"cursor-pointer group relative",onClick:()=>{d(U),p(!0)},children:e.jsx("img",{src:q,alt:`Property ${U+1}`,className:"w-full h-[45vh] object-cover group-hover:scale-105 transition-transform duration-500"})},U))}):e.jsxs("div",{className:"grid grid-cols-4 gap-2 rounded-2xl overflow-hidden",style:{height:"55vh"},children:[e.jsx("div",{className:"col-span-2 row-span-2 cursor-pointer group relative",onClick:()=>{d(0),p(!0)},children:e.jsx("img",{src:L[0],alt:"Property main",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),L.slice(1,5).map((q,U)=>e.jsxs("div",{className:"cursor-pointer group relative",onClick:()=>{d(U+1),p(!0)},children:[e.jsx("img",{src:q,alt:`Property ${U+2}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}),U===3&&L.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center text-white font-bold text-lg",children:["+",L.length-5," more"]})]},U))]}),L.length>2&&e.jsxs("button",{onClick:()=>{d(0),p(!0)},className:"absolute bottom-4 right-8 bg-white shadow-lg hover:shadow-xl text-gray-800 px-4 py-2 rounded-lg text-sm font-medium flex items-center gap-2 transition-shadow",children:[e.jsx(c_,{className:"h-4 w-4"})," View all ",L.length," photos"]})]}),L.length===0&&e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${w}, ${N})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[f.logo_url&&e.jsx("img",{src:f.logo_url,alt:"Logo",className:"h-12 w-auto mx-auto mb-6"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold",children:f.hero_headline}),f.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:f.hero_subtext})]})}),e.jsx("div",{className:"max-w-4xl mx-auto px-4 py-8",children:e.jsxs("div",{className:"grid md:grid-cols-5 gap-6",children:[e.jsx("div",{className:"md:col-span-3 space-y-6",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 md:p-8",children:[C.property_price&&e.jsx("p",{className:"text-3xl md:text-4xl font-bold mb-2",style:{color:w},children:$(C.property_price)}),C.property_address&&e.jsxs("p",{className:"text-gray-600 flex items-center gap-1.5 mb-5 text-lg",children:[e.jsx(Ai,{className:"h-5 w-5 shrink-0"})," ",C.property_address]}),e.jsxs("div",{className:"flex gap-6 mb-5 py-4 border-y border-gray-100",children:[C.property_beds&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(N0,{className:"h-5 w-5",style:{color:w}})," ",C.property_beds]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bedrooms"})]}),C.property_baths&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(Vx,{className:"h-5 w-5",style:{color:w}})," ",C.property_baths]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bathrooms"})]}),C.property_sqft&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(SP,{className:"h-5 w-5",style:{color:w}})," ",Number(C.property_sqft).toLocaleString()]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Sq Ft"})]})]}),C.property_description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-800 mb-2",children:"About This Property"}),e.jsx("p",{className:"text-gray-600 leading-relaxed whitespace-pre-line",children:C.property_description})]})]})}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 sticky top-6",children:[e.jsx("h2",{className:"text-lg font-bold mb-1",style:{color:w},children:C.property_status==="just_sold"?"Want results like this?":"Interested in this property?"}),e.jsx("p",{className:"text-gray-500 text-sm mb-4",children:"Fill out the form and I'll be in touch!"}),f.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-5 pb-4 border-b",children:[f.agent_photo_url&&e.jsx("img",{src:f.agent_photo_url,alt:f.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:f.agent_name}),e.jsxs("div",{className:"flex flex-col gap-0.5 text-xs text-gray-500",children:[f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Zn,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(_r,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:j,className:"space-y-3",children:[_.map(q=>e.jsxs("div",{children:[e.jsxs(ve,{className:"text-xs font-medium",children:[q.label,q.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),lDe(q,o,l)]},q.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},disabled:b.isPending,children:b.isPending?"Submitting...":"Submit"}),b.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${w}, ${N})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[f.logo_url&&e.jsx("img",{src:f.logo_url,alt:"Logo",className:"h-12 w-auto mx-auto mb-6"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold",children:f.hero_headline}),f.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:f.hero_subtext}),A&&C.lead_magnet_file_name&&e.jsxs("div",{className:"mt-6 inline-flex items-center gap-2 bg-white/20 backdrop-blur px-4 py-2 rounded-full text-sm",children:[e.jsx(xi,{className:"h-4 w-4"}),"Free Download: ",C.lead_magnet_file_name]})]})}),e.jsx("div",{className:"max-w-2xl mx-auto px-4 -mt-8",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 md:p-8",children:[A&&e.jsx("p",{className:"text-sm text-gray-500 mb-4 text-center",children:"Fill out the form below to get your free download!"}),f.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-6 pb-4 border-b",children:[f.agent_photo_url&&e.jsx("img",{src:f.agent_photo_url,alt:f.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:f.agent_name}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-500",children:[f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Zn,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(_r,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[_.map($=>e.jsxs("div",{children:[e.jsxs(ve,{className:"text-sm font-medium",children:[$.label,$.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),lDe($,o,l)]},$.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},disabled:b.isPending,children:b.isPending?"Submitting...":A?"Get My Free Download":"Submit"}),b.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}function lDe(t,s,r,n){const a=s[t.label]||"",o=Array.isArray(t.options)?t.options:[];switch(t.field_type){case"text":case"email":case"phone":return e.jsx(Re,{type:t.field_type==="email"?"email":t.field_type==="phone"?"tel":"text",value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),placeholder:t.placeholder||"",className:"mt-1"});case"textarea":return e.jsx(Mr,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),placeholder:t.placeholder||"",rows:3,className:"mt-1"});case"select":return e.jsxs(tr,{value:String(a),onValueChange:l=>r(i=>({...i,[t.label]:l})),children:[e.jsx(Js,{className:"mt-1",children:e.jsx(sr,{placeholder:"Select..."})}),e.jsx(er,{children:o.map(l=>e.jsx(At,{value:l,children:l},l))})]});case"multiselect":return e.jsx("div",{className:"mt-1 space-y-2",children:o.map(l=>{const i=Array.isArray(a)?a:[];return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(zo,{checked:i.includes(l),onCheckedChange:d=>{const u=d?[...i,l]:i.filter(p=>p!==l);r(p=>({...p,[t.label]:u}))}}),e.jsx("span",{className:"text-sm",children:l})]},l)})});case"toggle":return e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsx(Br,{checked:!!a,onCheckedChange:l=>r(i=>({...i,[t.label]:l?"Yes":"No"}))}),e.jsx("span",{className:"text-sm text-gray-600",children:a?"Yes":"No"})]});default:return e.jsx(Re,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),className:"mt-1"})}}function Hvs(){const s=vu().pathname.slice(1).split("/")[0];return S.useEffect(()=>{document.body.classList.add("landing-page-public");const r=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("landing-page-public"),n.forEach(clearTimeout)}},[]),s?e.jsx(_et,{slugOverride:s}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"LevelUp Pages"}),e.jsx("p",{className:"text-gray-500",children:"Visit a specific page URL to view content."})]})})}const Wvs=({team:t,onSelect:s})=>{const{data:r}=Ct({queryKey:["team-card-info",t.id],queryFn:async()=>{const{data:n}=await G.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 G.from("profiles").select("name, avatar_url").eq("id",o.user_id).single();l=i}return{count:a,leaderProfile:l}}});return e.jsxs(Ee,{className:"cursor-pointer hover:shadow-md transition-shadow group",onClick:s,children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(zt,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(yr,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(at,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(hr,{className:"h-3 w-3 mr-1"}),(r==null?void 0:r.count)??"…"]})]})}),e.jsxs(Oe,{className:"space-y-3",children:[(r==null?void 0:r.leaderProfile)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(gn,{className:"h-6 w-6",children:[e.jsx(Ea,{src:r.leaderProfile.avatar_url||""}),e.jsx(xn,{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(Bh,{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(rh,{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(at,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),t.shared_assets_enabled&&e.jsx(at,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),t.shared_videos_enabled&&e.jsx(at,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},Gvs=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=Gs(),l=o||(a.length>0?a[0].id:n),i=s?void 0:l||void 0,{teams:d,isLoading:u,createTeam:p,updateTeam:f,deleteTeam:v,addMember:_,removeMember:b,updateMemberRole:j}=aS(i),[w,N]=S.useState(!1),[C,A]=S.useState(null),{data:I}=Ct({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:$,error:q}=await G.from("brokerages").select("id, name").order("name");if(q)throw q;return $||[]},enabled:s}),{data:L}=Ct({queryKey:["brokerage-agents-for-teams",l],queryFn:async()=>{const{data:$,error:q}=await G.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",l).order("name");if(q)throw q;return $||[]},enabled:!!l}),R=async $=>{const q=$.brokerage_id||l||null,U=await p.mutateAsync({name:$.name,brokerage_id:q,description:$.description});if($.leaderId&&$.leaderId!=="none"&&await _.mutateAsync({team_id:U.id,user_id:$.leaderId,role:"team_leader"}),$.memberIds)for(const V of $.memberIds)await _.mutateAsync({team_id:U.id,user_id:V,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(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-muted-foreground",children:"You need brokerage manager access to manage teams."})]})}):e.jsx(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(K,{onClick:()=>N(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(_Ke,{open:w,onOpenChange:N,onCreateTeam:R,isCreating:p.isPending,brokerageAgents:L||[],isAdmin:s,allBrokerages:I,activeBrokerageId:l}),u&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map($=>e.jsx(Ee,{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&&!C&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first team to organize agents and share resources."}),e.jsxs(K,{onClick:()=>N(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Your First Team"]})]})}),!u&&d.length>0&&!C&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:d.map($=>e.jsx(Wvs,{team:$,onSelect:()=>A($)},$.id))}),C&&e.jsx(vKe,{team:C,brokerageAgents:L||[],onBack:()=>A(null),onUpdate:$=>f.mutateAsync({id:C.id,...$}).then(q=>A(q)),onAddMember:($,q)=>_.mutateAsync({team_id:C.id,user_id:$,role:q}),onRemoveMember:$=>b.mutateAsync({team_id:C.id,member_id:$}),onUpdateRole:($,q)=>j.mutateAsync({team_id:C.id,member_id:$,role:q}),onDeleteTeam:()=>v.mutate(C.id),isUpdating:f.isPending,isAddingMember:_.isPending})]})})},Kvs=()=>{const{data:t,isLoading:s}=Mf(),{useTeamMembers:r}=aS(),{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(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Team Yet"}),e.jsx("p",{className:"text-muted-foreground",children:"You haven't been assigned to a team. Ask your brokerage manager to add you."})]})})});const o=t.team;return e.jsx(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(at,{variant:t.role==="team_leader"?"default":"secondary",className:"capitalize",children:t.role==="team_leader"?e.jsxs(e.Fragment,{children:[e.jsx(Bh,{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(Na,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(va,{className:"flex-wrap",children:[e.jsx(ks,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(ks,{value:"contacts",children:[e.jsx(tN,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(ks,{value:"lead-pond",children:[e.jsx(Fg,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(ks,{value:"shared-assets",children:[e.jsx(qh,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]})]}),e.jsx(zs,{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,p;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsxs(gn,{className:"h-10 w-10",children:[e.jsx(Ea,{src:((i=l.profile)==null?void 0:i.avatar_url)||""}),e.jsx(xn,{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:(p=l.profile)==null?void 0:p.email})]}),l.role==="team_leader"?e.jsxs(at,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[e.jsx(Bh,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(at,{variant:"secondary",className:"ml-auto",children:"Member"})]})},l.id)})}),o.contact_visibility!=="private"&&e.jsx(zs,{value:"contacts",className:"space-y-4",children:e.jsx(cwe,{})}),o.lead_pond_enabled&&e.jsx(zs,{value:"lead-pond",className:"space-y-4",children:e.jsx(dwe,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx(zs,{value:"shared-assets",className:"space-y-4",children:e.jsx(yKe,{teamId:t.teamId})})]})]})})};function Zvs(){const{user:t}=Gs(),s=ns(),r=Ct({queryKey:["booking-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await G.from("agent_booking_settings").select("*").eq("user_id",t.id).maybeSingle();if(N)throw N;return w},enabled:!!t}),n=Ct({queryKey:["booking-types",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await G.from("agent_booking_types").select("*").eq("user_id",t.id).order("sort_order");if(N)throw N;return w},enabled:!!t}),a=Ct({queryKey:["availability-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await G.from("agent_availability_slots").select("*").eq("user_id",t.id).order("day_of_week").order("start_time");if(N)throw N;return w},enabled:!!t}),o=Ct({queryKey:["blocked-dates",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await G.from("agent_blocked_dates").select("*").eq("user_id",t.id).order("blocked_date");if(N)throw N;return w},enabled:!!t}),l=Ct({queryKey:["bookings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await G.from("bookings").select("*, booking_type:agent_booking_types(*)").eq("agent_user_id",t.id).order("booking_date",{ascending:!1});if(N)throw N;return w},enabled:!!t}),i=Ot({mutationFn:async()=>{const{data:w,error:N}=await G.from("agent_booking_settings").insert({user_id:t.id,slug:""}).select().single();if(N)throw N;const C=[{name:"Listing Consultation",description:"Get a comprehensive market analysis and listing strategy for your home",duration_minutes:60,color:"#10B981",icon:"Home",sort_order:0},{name:"Buyer Consultation",description:"Discuss your home search criteria, budget, and buying process",duration_minutes:45,color:"#3B82F6",icon:"Search",sort_order:1},{name:"Home Valuation",description:"Find out what your home is worth in today's market",duration_minutes:30,color:"#F59E0B",icon:"DollarSign",sort_order:2},{name:"General Meeting",description:"Coffee chat, check-in, or quick real estate question",duration_minutes:30,color:"#8B5CF6",icon:"Coffee",sort_order:3}],{error:A}=await G.from("agent_booking_types").insert(C.map(R=>({...R,user_id:t.id})));if(A)throw A;const I=[1,2,3,4,5].map(R=>({user_id:t.id,day_of_week:R,start_time:"09:00",end_time:"17:00"})),{error:L}=await G.from("agent_availability_slots").insert(I);if(L)throw L;return w},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),s.invalidateQueries({queryKey:["booking-types"]}),s.invalidateQueries({queryKey:["availability-slots"]}),fe.success("Scheduler set up successfully!")},onError:w=>fe.error(w.message)}),d=Ot({mutationFn:async w=>{const{error:N}=await G.from("agent_booking_settings").update(w).eq("user_id",t.id);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),fe.success("Settings updated")},onError:w=>fe.error(w.message)}),u=Ot({mutationFn:async w=>{const N={...w,user_id:t.id};if(w.id){const{error:C}=await G.from("agent_booking_types").update(N).eq("id",w.id);if(C)throw C}else{const{error:C}=await G.from("agent_booking_types").insert(N);if(C)throw C}},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),fe.success("Booking type saved")},onError:w=>fe.error(w.message)}),p=Ot({mutationFn:async w=>{const{error:N}=await G.from("agent_booking_types").delete().eq("id",w);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),fe.success("Booking type deleted")},onError:w=>fe.error(w.message)}),f=Ot({mutationFn:async w=>{const N={...w,user_id:t.id};if(w.id){const{error:C}=await G.from("agent_availability_slots").update(N).eq("id",w.id);if(C)throw C}else{const{error:C}=await G.from("agent_availability_slots").insert(N);if(C)throw C}},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>fe.error(w.message)}),v=Ot({mutationFn:async w=>{const{error:N}=await G.from("agent_availability_slots").delete().eq("id",w);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>fe.error(w.message)}),_=Ot({mutationFn:async w=>{const{error:N}=await G.from("agent_blocked_dates").insert({...w,user_id:t.id});if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]}),fe.success("Date blocked")},onError:w=>fe.error(w.message)}),b=Ot({mutationFn:async w=>{const{error:N}=await G.from("agent_blocked_dates").delete().eq("id",w);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]})},onError:w=>fe.error(w.message)}),j=Ot({mutationFn:async({id:w,reason:N})=>{const{error:C}=await G.from("bookings").update({status:"cancelled",cancelled_at:new Date().toISOString(),cancel_reason:N}).eq("id",w);if(C)throw C},onSuccess:()=>{s.invalidateQueries({queryKey:["bookings"]}),fe.success("Booking cancelled")},onError:w=>fe.error(w.message)});return{settings:r.data,bookingTypes:n.data??[],availability:a.data??[],blockedDates:o.data??[],bookings:l.data??[],isLoading:r.isLoading,initializeSettings:i,updateSettings:d,upsertBookingType:u,deleteBookingType:p,upsertAvailability:f,deleteAvailability:v,addBlockedDate:_,removeBlockedDate:b,cancelBooking:j}}const cDe={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function Yvs({types:t,onSave:s,onDelete:r}){const[n,a]=S.useState(null),[o,l]=S.useState(!1),i=()=>{a({name:"",description:"",duration_minutes:30,color:"#3B82F6",icon:"Calendar",is_active:!0,qualification_enabled:!1}),l(!0)},d=p=>{a({...p}),l(!0)},u=()=>{n!=null&&n.name&&(s(n),l(!1),a(null))};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Booking Types"}),e.jsx(yr,{children:"The meeting types prospects can book with you"})]}),e.jsxs(K,{onClick:i,size:"sm",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Type"]})]}),e.jsx(Oe,{children:t.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No booking types yet. Add one to get started."}):e.jsx("div",{className:"grid gap-3",children:t.map(p=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-lg",style:{backgroundColor:p.color+"20"},children:cDe[p.icon]||"📅"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:p.name}),!p.is_active&&e.jsx(at,{variant:"secondary",className:"text-xs",children:"Inactive"}),p.qualification_enabled&&e.jsxs(at,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(fP,{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"}),p.duration_minutes," min",p.description&&e.jsxs("span",{children:["· ",p.description.slice(0,60),p.description.length>60?"...":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(p),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>r(p.id),className:"text-destructive hover:text-destructive",children:e.jsx(br,{className:"h-4 w-4"})})]})]},p.id))})})]}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsxs(Ns,{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(ve,{children:"Name"}),e.jsx(Re,{value:n.name||"",onChange:p=>a({...n,name:p.target.value}),placeholder:"e.g. Listing Consultation"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Mr,{value:n.description||"",onChange:p=>a({...n,description:p.target.value}),placeholder:"Brief description for prospects",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Duration (minutes)"}),e.jsx(Re,{type:"number",min:15,max:180,step:15,value:n.duration_minutes||30,onChange:p=>a({...n,duration_minutes:parseInt(p.target.value)||30})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:n.color||"#3B82F6",onChange:p=>a({...n,color:p.target.value}),className:"h-10 w-10 rounded border cursor-pointer"}),e.jsx(Re,{value:n.color||"#3B82F6",onChange:p=>a({...n,color:p.target.value}),className:"flex-1"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Icon"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(cDe).map(([p,f])=>e.jsx("button",{onClick:()=>a({...n,icon:p}),className:`w-10 h-10 rounded-lg text-lg flex items-center justify-center border transition-colors ${n.icon===p?"border-primary bg-primary/10":"hover:bg-muted"}`,children:f},p))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Meeting Link Override (optional)"}),e.jsx(Re,{value:n.meeting_link_override||"",onChange:p=>a({...n,meeting_link_override:p.target.value||null}),placeholder:"Use a different link for this type"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Pre-Qualification Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask qualifying questions before booking"})]}),e.jsx(Br,{checked:n.qualification_enabled||!1,onCheckedChange:p=>a({...n,qualification_enabled:p})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Active"}),e.jsx(Br,{checked:n.is_active??!0,onCheckedChange:p=>a({...n,is_active:p})})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:u,children:"Save"})]})]})})]})}const dDe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Xvs({slots:t,onSave:s,onDelete:r}){const[n,a]=S.useState(null),[o,l]=S.useState("09:00"),[i,d]=S.useState("17:00"),u=dDe.map((f,v)=>t.filter(_=>_.day_of_week===v)),p=()=>{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(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5"}),"Weekly Availability"]}),e.jsx(yr,{children:"Set your available hours for each day"})]}),e.jsx(Oe,{className:"space-y-2",children:dDe.map((f,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:f})}),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 j,w;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(j=b.start_time)==null?void 0:j.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:(w=b.end_time)==null?void 0:w.slice(0,5),onBlur:N=>s({id:b.id,end_time:N.target.value})}),e.jsx(Br,{checked:b.is_active,onCheckedChange:N=>s({id:b.id,is_active:N})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>r(b.id),children:e.jsx(br,{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(K,{size:"sm",className:"h-8",onClick:p,children:"Add"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8",onClick:()=>a(null),children:"Cancel"})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground",onClick:()=>a(v),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add hours"]})]})]},f)})})]})}const Qvs={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 Jvs({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(Xi,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:o.guest_name}),e.jsx(at,{className:`text-xs ${Qvs[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(ld,{className:"h-3.5 w-3.5"}),ws(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(_r,{className:"h-3 w-3"}),o.guest_email]}),o.guest_phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Zn,{className:"h-3 w-3"}),o.guest_phone]})]}),o.booking_type&&e.jsx(at,{variant:"outline",className:"text-xs mt-1",children:o.booking_type.name}),o.guest_message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 italic",children:['"',o.guest_message,'"']})]}),l&&o.status==="confirmed"&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s(o.id),className:"text-destructive hover:text-destructive",children:[e.jsx(kc,{className:"h-4 w-4 mr-1"})," Cancel"]})]},o.id)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Upcoming Bookings"}),e.jsxs(yr,{children:[r.length," upcoming appointment",r.length!==1?"s":""]})]}),e.jsx(Oe,{children:r.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No upcoming bookings"}):e.jsx("div",{className:"space-y-3",children:r.map(o=>a(o,!0))})})]}),n.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Past & Cancelled"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:n.slice(0,20).map(o=>a(o))})})]})]})}function e1s({blockedDates:t,onAdd:s,onRemove:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(""),[i,d]=S.useState(""),u=()=>{o&&(s({blocked_date:o,reason:i||void 0}),a(!1),l(""),d(""))};return e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(tP,{className:"h-5 w-5"}),"Blocked Dates"]}),e.jsx(yr,{children:"Block specific dates (vacations, holidays, etc.)"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>a(!0),children:[e.jsx(Zs,{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:p=>l(p.target.value),className:"w-40"}),e.jsx(Re,{placeholder:"Reason (optional)",value:i,onChange:p=>d(p.target.value),className:"flex-1"}),e.jsx(K,{size:"sm",onClick:u,children:"Add"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>a(!1),children:"Cancel"})]}),t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No blocked dates"}):e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(p=>e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full border bg-muted/50 text-sm",children:[e.jsx("span",{children:ws(new Date(p.blocked_date+"T00:00:00"),"MMM d, yyyy")}),p.reason&&e.jsxs("span",{className:"text-muted-foreground",children:["(",p.reason,")"]}),e.jsx("button",{onClick:()=>r(p.id),className:"ml-1 text-muted-foreground hover:text-destructive",children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]},p.id))})]})]})}function t1s(){const{settings:t,bookingTypes:s,availability:r,blockedDates:n,bookings:a,isLoading:o,initializeSettings:l,updateSettings:i,upsertBookingType:d,deleteBookingType:u,upsertAvailability:p,deleteAvailability:f,addBlockedDate:v,removeBlockedDate:_,cancelBooking:b}=Zvs(),[j,w]=S.useState(""),[N,C]=S.useState(15);j||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(ld,{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(K,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(A),fe.success("Booking link copied!")},children:[e.jsx(ni,{className:"h-4 w-4 mr-1"})," Copy Link"]}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:A,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{className:"h-4 w-4 mr-1"})," Preview"]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{htmlFor:"scheduler-active",className:"text-sm",children:"Active"}),e.jsx(Br,{id:"scheduler-active",checked:t.is_active,onCheckedChange:I=>i.mutate({is_active:I})})]})]})]}),e.jsxs(Na,{defaultValue:"types",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsx(ks,{value:"types",children:"Booking Types"}),e.jsx(ks,{value:"availability",children:"Availability"}),e.jsx(ks,{value:"settings",children:"Settings"}),e.jsxs(ks,{value:"bookings",children:["Bookings",a.filter(I=>I.status==="confirmed").length>0&&e.jsx(at,{variant:"secondary",className:"ml-1.5 text-xs",children:a.filter(I=>I.status==="confirmed").length})]})]}),e.jsx(zs,{value:"types",children:e.jsx(Yvs,{types:s,onSave:I=>d.mutate(I),onDelete:I=>u.mutate(I)})}),e.jsx(zs,{value:"availability",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Xvs,{slots:r,onSave:I=>p.mutate(I),onDelete:I=>f.mutate(I)}),e.jsx(e1s,{blockedDates:n,onAdd:I=>v.mutate(I),onRemove:I=>_.mutate(I)})]})}),e.jsx(zs,{value:"settings",children:e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(MP,{className:"h-5 w-5"}),"General Settings"]}),e.jsx(yr,{children:"Configure your booking page defaults"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{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(K,{variant:"outline",size:"sm",onClick:()=>{A&&(navigator.clipboard.writeText(A),fe.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(ve,{htmlFor:"meeting-link",children:[e.jsx(Ho,{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(ve,{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(ve,{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(ve,{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(zs,{value:"bookings",children:e.jsx(Jvs,{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(ld,{className:"h-8 w-8 text-primary"})}),e.jsx("h1",{className:"text-3xl font-bold",children:"LevelUp Scheduler"}),e.jsx("p",{className:"text-muted-foreground text-lg max-w-md mx-auto",children:"Your own booking page — built for real estate. Prospects book with you, get auto-added to your CRM, and you never miss a lead."})]}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[{icon:"🏠",title:"Listing Consultation",desc:"60 min"},{icon:"🔍",title:"Buyer Consultation",desc:"45 min"},{icon:"💰",title:"Home Valuation",desc:"30 min"},{icon:"☕",title:"General Meeting",desc:"30 min"}].map(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(Rl,{}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:"✅ Auto-creates CRM contacts from every booking"}),e.jsx("p",{children:"✅ Optional pre-qualification questions per booking type"}),e.jsx("p",{children:"✅ Embeds on your Smart Card — replaces TidyCal"}),e.jsx("p",{children:"✅ Standalone shareable booking page"})]}),e.jsxs(K,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",size:"lg",children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),l.isPending?"Setting up...":"Activate Scheduler"]})]})})]})})}const uDe=[{id:"event_registration",label:"Event Registration",description:"Capture RSVPs for open houses, expos, seminars"},{id:"buyer_consultation",label:"Buyer Consultation",description:"Pre-qualify buyers with targeted questions"},{id:"home_valuation",label:"Home Valuation Request",description:`"What's your home worth?" lead capture`},{id:"lead_capture",label:"General Lead Capture",description:"Flexible form for any lead gen purpose"},{id:"lead_magnet",label:"Lead Magnet / Giveaway",description:"Offer a free download (PDF, guide, checklist) in exchange for contact info"},{id:"just_listed",label:"Just Listed",description:"Showcase a new listing with photos & details + contact CTA"},{id:"just_sold",label:"Just Sold",description:'Celebrate a sale & capture "Want results like this?" leads'}];function s1s(){const{user:t}=Gs(),s=ti(),{toast:r}=Ia(),n=Dr(),a=ns(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState(null),[f,v]=S.useState({title:"",description:"",page_type:"lead_capture"}),{data:_=[],isLoading:b}=Ct({queryKey:["landing-pages",s],queryFn:async()=>{const{data:C,error:A}=await G.from("landing_pages").select("*").eq("user_id",s).order("created_at",{ascending:!1});if(A)throw A;return C},enabled:!!s}),j=Ot({mutationFn:async()=>{const C=f.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")+"-"+Date.now().toString(36),{data:A}=await G.from("profiles").select("name, phone, avatar_url, email").eq("id",s).single(),I=f.page_type==="just_listed"||f.page_type==="just_sold",{data:L,error:R}=await G.from("landing_pages").insert({user_id:s,title:f.title,description:f.description||null,page_type:f.page_type,slug:C,hero_headline:I?f.page_type==="just_listed"?"🏡 Just Listed":"🎉 Just Sold":f.page_type==="lead_magnet"?"📥 Free Download":f.title,agent_name:(A==null?void 0:A.name)||null,agent_phone:(A==null?void 0:A.phone)||null,agent_email:(A==null?void 0:A.email)||t.email||null,agent_photo_url:(A==null?void 0:A.avatar_url)||null,property_status:I?f.page_type.replace("just_",""):null}).select().single();if(R)throw R;const $=r1s(f.page_type);if($.length>0){const{error:q}=await G.from("landing_page_fields").insert($.map((U,V)=>({...U,page_id:L.id,sort_order:V})));if(q)throw q}return L},onSuccess:C=>{a.invalidateQueries({queryKey:["landing-pages"]}),l(!1),v({title:"",description:"",page_type:"lead_capture"}),r({title:"Landing page created!"}),n(`/mission-control/landing-pages/${C.id}`)},onError:C=>r({title:"Error",description:C.message,variant:"destructive"})}),w=Ot({mutationFn:async C=>{const{error:A}=await G.from("landing_pages").delete().eq("id",C);if(A)throw A},onSuccess:()=>{a.invalidateQueries({queryKey:["landing-pages"]}),d(null),r({title:"Landing page deleted"})}}),N=C=>`https://pages.relevelup.com/${C}`;return e.jsxs(Ms,{title:"Landing Pages",children:[e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Landing Pages"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Create branded lead capture pages for events, consultations, and more"})]}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," New Page"]})]}),b?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"})}):_.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(In,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No landing pages yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1 mb-4",children:"Create your first page to start capturing leads"}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," Create Landing Page"]})]})}):e.jsx("div",{className:"grid gap-4",children:_.map(C=>{var A;return e.jsx(Ee,{className:"hover:shadow-md transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>n(`/mission-control/landing-pages/${C.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:C.title}),e.jsx(at,{variant:C.is_published?"default":"secondary",className:"text-[10px]",children:C.is_published?"Published":"Draft"}),e.jsx(at,{variant:"outline",className:"text-[10px]",children:((A=uDe.find(I=>I.id===C.page_type))==null?void 0:A.label)||C.page_type})]}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:C.description}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ya,{className:"h-3 w-3"})," ",C.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-3 w-3"})," ",C.submission_count," submissions"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[C.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>p(N(C.slug)),children:e.jsx(L0,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(N(C.slug)),r({title:"Link copied!"})},children:e.jsx(ni,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:N(C.slug),target:"_blank",rel:"noopener noreferrer",children:e.jsx(sn,{className:"h-3.5 w-3.5"})})})]}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{size:"sm",variant:"ghost",children:e.jsx(Jp,{className:"h-4 w-4"})})}),e.jsxs(Td,{align:"end",children:[e.jsxs(Ta,{onClick:()=>n(`/mission-control/landing-pages/${C.id}`),children:[e.jsx(Ra,{className:"h-3.5 w-3.5 mr-2"})," Edit"]}),e.jsxs(Ta,{onClick:()=>d(C.id),className:"text-destructive",children:[e.jsx(br,{className:"h-3.5 w-3.5 mr-2"})," Delete"]})]})]})]})]})})},C.id)})})]}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"Create Landing Page"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Page Title"}),e.jsx(Re,{value:f.title,onChange:C=>v(A=>({...A,title:C.target.value})),placeholder:"e.g. Veterans Home & Land Expo"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description (optional)"}),e.jsx(Mr,{value:f.description,onChange:C=>v(A=>({...A,description:C.target.value})),placeholder:"Brief internal description...",rows:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Page Template"}),e.jsxs(tr,{value:f.page_type,onValueChange:C=>v(A=>({...A,page_type:C})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:uDe.map(C=>e.jsx(At,{value:C.id,children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:C.label}),e.jsx("div",{className:"text-xs text-muted-foreground",children:C.description})]})},C.id))})]})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>j.mutate(),disabled:!f.title.trim()||j.isPending,children:j.isPending?"Creating...":"Create Page"})]})]})}),e.jsx(nc,{open:!!i,onOpenChange:()=>d(null),children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Landing Page?"}),e.jsx(Dl,{children:"This will permanently delete this page and all its submissions."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>i&&w.mutate(i),children:"Delete"})]})]})}),e.jsx(vs,{open:!!u,onOpenChange:()=>p(null),children:e.jsxs(ys,{className:"max-w-sm",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[u&&e.jsx(aD,{value:u,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:u}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{u&&(navigator.clipboard.writeText(u),r({title:"URL copied!"}))},children:[e.jsx(ni,{className:"h-3.5 w-3.5 mr-1"})," Copy URL"]})]})]})})]})}function r1s(t){const s=[{field_type:"text",label:"Full Name",placeholder:"Your name",is_required:!0},{field_type:"email",label:"Email",placeholder:"your@email.com",is_required:!0},{field_type:"phone",label:"Phone",placeholder:"(555) 123-4567",is_required:!1}];switch(t){case"event_registration":return[...s,{field_type:"select",label:"How did you hear about this event?",options:JSON.stringify(["Social Media","Friend/Referral","Email","Flyer/Sign","Other"]),is_required:!1},{field_type:"textarea",label:"Any questions or special needs?",placeholder:"Let us know...",is_required:!1}];case"buyer_consultation":return[...s,{field_type:"select",label:"Interested in",options:JSON.stringify(["Buying","Selling","Both"]),is_required:!0},{field_type:"select",label:"Timeline",options:JSON.stringify(["0-3 months","3-6 months","6-12 months","Just exploring"]),is_required:!1},{field_type:"toggle",label:"Already working with a Realtor?",is_required:!1},{field_type:"toggle",label:"Do you have property to sell?",is_required:!1},{field_type:"textarea",label:"Anything else we should know?",placeholder:"Tell us about your situation...",is_required:!1}];case"home_valuation":return[...s,{field_type:"text",label:"Property Address",placeholder:"123 Main St, City, State",is_required:!0},{field_type:"select",label:"Reason for Valuation",options:JSON.stringify(["Thinking of selling","Refinancing","Curiosity","Estate planning","Other"]),is_required:!1},{field_type:"select",label:"Timeline to Sell",options:JSON.stringify(["ASAP","1-3 months","3-6 months","6+ months","Not sure"]),is_required:!1}];case"lead_magnet":return[...s,{field_type:"select",label:"Are you currently working with a Realtor?",options:JSON.stringify(["Yes","No","Not yet"]),is_required:!1}];case"just_listed":return[...s,{field_type:"select",label:"I am interested in",options:JSON.stringify(["Scheduling a showing","Getting more details","Similar properties","Selling my home"]),is_required:!0},{field_type:"textarea",label:"Message",placeholder:"Tell me more about this property...",is_required:!1}];case"just_sold":return[...s,{field_type:"select",label:"I am looking to",options:JSON.stringify(["Sell my home","Buy a home","Both","Just curious"]),is_required:!0},{field_type:"text",label:"My Property Address",placeholder:"123 Main St, City, State",is_required:!1}];default:return[...s,{field_type:"textarea",label:"Message",placeholder:"How can we help you?",is_required:!1}]}}const n1s=[{value:"text",label:"Short Text"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"textarea",label:"Long Text"},{value:"select",label:"Dropdown"},{value:"multiselect",label:"Multi-Select"},{value:"toggle",label:"Yes / No Toggle"}];function a1s(){const{pageId:t}=Mo(),s=Dr(),{user:r}=Gs(),n=ti(),{toast:a}=Ia(),o=ns(),[l,i]=S.useState(null),[d,u]=S.useState(!1),{data:p,isLoading:f}=Ct({queryKey:["landing-page",t],queryFn:async()=>{const{data:ie,error:ae}=await G.from("landing_pages").select("*").eq("id",t).single();if(ae)throw ae;return ie},enabled:!!t}),{data:v=[],isLoading:_}=Ct({queryKey:["landing-page-fields",t],queryFn:async()=>{const{data:ie,error:ae}=await G.from("landing_page_fields").select("*").eq("page_id",t).order("sort_order");if(ae)throw ae;return ie},enabled:!!t}),{data:b=[]}=Ct({queryKey:["landing-page-submissions",t],queryFn:async()=>{const{data:ie,error:ae}=await G.from("landing_page_submissions").select("*").eq("page_id",t).order("created_at",{ascending:!1});if(ae)throw ae;return ie},enabled:!!t}),{data:j=[]}=Ct({queryKey:["my-listings-for-pages",n],queryFn:async()=>{const{data:ie,error:ae}=await G.from("listings").select("id, property_address, city, state, price, bedrooms, bathrooms, square_footage, description, status").eq("agent_id",n).order("created_at",{ascending:!1});if(ae)throw ae;return ie},enabled:!!r&&((p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold")}),[w,N]=S.useState({title:"",hero_headline:"",hero_subtext:"",hero_image_url:null,logo_url:null,primary_color:"#406E71",accent_color:"#2a4c64",agent_name:"",agent_phone:"",agent_email:"",agent_photo_url:null,success_message:"Thank you! We'll be in touch soon.",is_published:!1,description:"",lead_magnet_file_url:null,lead_magnet_file_name:null,lead_magnet_external_url:null,listing_id:null,property_address:"",property_price:"",property_beds:"",property_baths:"",property_sqft:"",property_description:"",property_photos:[],property_status:"just_listed"}),[C,A]=S.useState([]);S.useEffect(()=>{p&&N({title:p.title,hero_headline:p.hero_headline,hero_subtext:p.hero_subtext||"",hero_image_url:p.hero_image_url,logo_url:p.logo_url,primary_color:p.primary_color,accent_color:p.accent_color,agent_name:p.agent_name||"",agent_phone:p.agent_phone||"",agent_email:p.agent_email||"",agent_photo_url:p.agent_photo_url,success_message:p.success_message||"Thank you! We'll be in touch soon.",is_published:p.is_published,description:p.description||"",lead_magnet_file_url:p.lead_magnet_file_url||null,lead_magnet_file_name:p.lead_magnet_file_name||null,lead_magnet_external_url:p.lead_magnet_external_url||null,listing_id:p.listing_id||null,property_address:p.property_address||"",property_price:p.property_price||"",property_beds:p.property_beds||"",property_baths:p.property_baths||"",property_sqft:p.property_sqft||"",property_description:p.property_description||"",property_photos:Array.isArray(p.property_photos)?p.property_photos:[],property_status:p.property_status||"just_listed"})},[p]),S.useEffect(()=>{v.length>0&&A(v.map(ie=>({id:ie.id,field_type:ie.field_type,label:ie.label,placeholder:ie.placeholder,is_required:ie.is_required,options:typeof ie.options=="string"?ie.options:ie.options?JSON.stringify(ie.options):null,sort_order:ie.sort_order})))},[v]);const I=Ot({mutationFn:async()=>{const{error:ie}=await G.from("landing_pages").update({title:w.title,hero_headline:w.hero_headline,hero_subtext:w.hero_subtext||null,hero_image_url:w.hero_image_url,logo_url:w.logo_url,primary_color:w.primary_color,accent_color:w.accent_color,agent_name:w.agent_name||null,agent_phone:w.agent_phone||null,agent_email:w.agent_email||null,agent_photo_url:w.agent_photo_url,success_message:w.success_message,is_published:w.is_published,description:w.description||null,lead_magnet_file_url:w.lead_magnet_file_url,lead_magnet_file_name:w.lead_magnet_file_name,lead_magnet_external_url:w.lead_magnet_external_url,listing_id:w.listing_id,property_address:w.property_address||null,property_price:w.property_price||null,property_beds:w.property_beds||null,property_baths:w.property_baths||null,property_sqft:w.property_sqft||null,property_description:w.property_description||null,property_photos:w.property_photos,property_status:w.property_status,updated_at:new Date().toISOString()}).eq("id",t);if(ie)throw ie;if(await G.from("landing_page_fields").delete().eq("page_id",t),C.length>0){const{error:ae}=await G.from("landing_page_fields").insert(C.map((le,pe)=>({page_id:t,field_type:le.field_type,label:le.label,placeholder:le.placeholder||null,is_required:le.is_required,options:le.options?JSON.parse(le.options):null,sort_order:pe})));if(ae)throw ae}},onSuccess:()=>{o.invalidateQueries({queryKey:["landing-page",t]}),o.invalidateQueries({queryKey:["landing-page-fields",t]}),a({title:"Page saved!"})},onError:ie=>a({title:"Error",description:ie.message,variant:"destructive"})}),L=async(ie,ae)=>{const le=ie.name.split(".").pop(),pe=`landing-pages/${r.id}/${ae}-${Date.now()}.${le}`,{error:be}=await G.storage.from("recruit-landing").upload(pe,ie);if(be)throw be;const{data:{publicUrl:ye}}=G.storage.from("recruit-landing").getPublicUrl(pe);return ye},R=async(ie,ae)=>{var pe;const le=(pe=ie.target.files)==null?void 0:pe[0];if(le){i(ae);try{const be=await L(le,ae);N(ye=>({...ye,[ae]:be})),a({title:"Image uploaded!"})}catch(be){a({title:"Upload failed",description:be.message,variant:"destructive"})}finally{i(null)}}},$=async ie=>{var le;const ae=(le=ie.target.files)==null?void 0:le[0];if(ae){i("lead_magnet");try{const pe=await L(ae,"lead-magnet");N(be=>({...be,lead_magnet_file_url:pe,lead_magnet_file_name:ae.name})),a({title:"File uploaded!"})}catch(pe){a({title:"Upload failed",description:pe.message,variant:"destructive"})}finally{i(null)}}},q=async ie=>{const ae=ie.target.files;if(!(!ae||ae.length===0)){i("property_photos");try{const le=[];for(const pe of Array.from(ae)){const be=await L(pe,"property-photo");le.push(be)}N(pe=>({...pe,property_photos:[...pe.property_photos,...le]})),a({title:`${le.length} photo(s) uploaded!`})}catch(le){a({title:"Upload failed",description:le.message,variant:"destructive"})}finally{i(null)}}},U=async ie=>{const ae=j.find(pe=>pe.id===ie);if(!ae)return;const{data:le}=await G.from("listing_photos").select("photo_url").eq("listing_id",ie).order("sort_order");N(pe=>({...pe,listing_id:ie,property_address:ae.property_address||`${ae.city}, ${ae.state}`,property_price:ae.price?`$${ae.price.toLocaleString()}`:"",property_beds:ae.bedrooms?String(ae.bedrooms):"",property_baths:ae.bathrooms?String(ae.bathrooms):"",property_sqft:ae.square_footage?ae.square_footage.toLocaleString():"",property_description:ae.description||"",property_photos:(le==null?void 0:le.map(be=>be.photo_url))||pe.property_photos})),a({title:"Listing data imported!"})},V=()=>{A(ie=>[...ie,{field_type:"text",label:"",placeholder:"",is_required:!1,options:null,sort_order:ie.length}])},X=(ie,ae)=>{A(le=>le.map((pe,be)=>be===ie?{...pe,...ae}:pe))},se=ie=>{A(ae=>ae.filter((le,pe)=>pe!==ie))},te=p?`https://pages.relevelup.com/${p.slug}`:"",Y=(p==null?void 0:p.page_type)==="lead_magnet",de=(p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold";return f||_?e.jsx(Ms,{title:"Loading...",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):p?e.jsxs(Ms,{title:w.title||"Edit Page",children:[e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/landing-pages"),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:w.title||"Untitled Page"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(at,{variant:w.is_published?"default":"secondary",className:"text-[10px]",children:w.is_published?"Published":"Draft"}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ya,{className:"h-3 w-3"})," ",p.view_count," views"]}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"})," ",b.length," submissions"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[w.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>u(!0),children:e.jsx(L0,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(te),a({title:"Link copied!"})},children:[e.jsx(ni,{className:"h-3.5 w-3.5 mr-1"})," Copy Link"]}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:te,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(K,{onClick:()=>I.mutate(),disabled:I.isPending,children:[e.jsx(Bu,{className:"h-4 w-4 mr-2"}),I.isPending?"Saving...":"Save"]})]})]}),e.jsxs(Na,{defaultValue:"design",children:[e.jsxs(va,{children:[e.jsx(ks,{value:"design",children:"Design"}),Y&&e.jsx(ks,{value:"lead_magnet",children:"Lead Magnet"}),de&&e.jsx(ks,{value:"property",children:"Property Details"}),e.jsxs(ks,{value:"fields",children:["Form Fields (",C.length,")"]}),e.jsxs(ks,{value:"submissions",children:["Submissions (",b.length,")"]}),e.jsx(ks,{value:"settings",children:"Settings"})]}),e.jsxs(zs,{value:"design",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Page Details"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Page Title (internal)"}),e.jsx(Re,{value:w.title,onChange:ie=>N(ae=>({...ae,title:ie.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description (internal)"}),e.jsx(Re,{value:w.description,onChange:ie=>N(ae=>({...ae,description:ie.target.value}))})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Hero Section"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Headline"}),e.jsx(Re,{value:w.hero_headline,onChange:ie=>N(ae=>({...ae,hero_headline:ie.target.value})),placeholder:"Join us for..."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Subtext"}),e.jsx(Mr,{value:w.hero_subtext,onChange:ie=>N(ae=>({...ae,hero_subtext:ie.target.value})),rows:2,placeholder:"A brief description..."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Background Image"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.hero_image_url&&e.jsx("img",{src:w.hero_image_url,alt:"Hero",className:"h-16 w-28 object-cover rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(Ya,{className:"h-3.5 w-3.5 mr-1"}),l==="hero_image_url"?"Uploading...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ie=>R(ie,"hero_image_url")})]}),w.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N(ie=>({...ie,hero_image_url:null})),children:e.jsx(br,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Branding"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.logo_url&&e.jsx("img",{src:w.logo_url,alt:"Logo",className:"h-10 w-auto rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="logo_url",children:e.jsxs("span",{children:[e.jsx(Ya,{className:"h-3.5 w-3.5 mr-1"}),l==="logo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ie=>R(ie,"logo_url")})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.agent_photo_url&&e.jsx("img",{src:w.agent_photo_url,alt:"Agent",className:"h-10 w-10 rounded-full object-cover"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="agent_photo_url",children:e.jsxs("span",{children:[e.jsx(Ya,{className:"h-3.5 w-3.5 mr-1"}),l==="agent_photo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ie=>R(ie,"agent_photo_url")})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:w.primary_color,onChange:ie=>N(ae=>({...ae,primary_color:ie.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Re,{value:w.primary_color,onChange:ie=>N(ae=>({...ae,primary_color:ie.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:w.accent_color,onChange:ie=>N(ae=>({...ae,accent_color:ie.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Re,{value:w.accent_color,onChange:ie=>N(ae=>({...ae,accent_color:ie.target.value})),className:"font-mono text-xs"})]})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Agent Info (shown on page)"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Name"}),e.jsx(Re,{value:w.agent_name,onChange:ie=>N(ae=>({...ae,agent_name:ie.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Phone"}),e.jsx(Re,{value:w.agent_phone,onChange:ie=>N(ae=>({...ae,agent_phone:ie.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Email"}),e.jsx(Re,{value:w.agent_email,onChange:ie=>N(ae=>({...ae,agent_email:ie.target.value}))})]})]})})]})]}),Y&&e.jsx(zs,{value:"lead_magnet",className:"space-y-4 mt-4",children:e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(xi,{className:"h-4 w-4"})," Giveaway File"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a file or provide an external URL. Visitors will receive the download link after submitting the form."}),e.jsxs("div",{children:[e.jsx(ve,{children:"Upload File (PDF, guide, checklist, etc.)"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.lead_magnet_file_name&&e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(xi,{className:"h-3 w-3"})," ",w.lead_magnet_file_name]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="lead_magnet",children:e.jsxs("span",{children:[e.jsx(Ya,{className:"h-3.5 w-3.5 mr-1"}),l==="lead_magnet"?"Uploading...":"Upload File"]})}),e.jsx("input",{type:"file",className:"hidden",onChange:$})]}),w.lead_magnet_file_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N(ie=>({...ie,lead_magnet_file_url:null,lead_magnet_file_name:null})),children:e.jsx(br,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"flex-1 border-t"}),e.jsx("span",{children:"OR"}),e.jsx("div",{className:"flex-1 border-t"})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1",children:[e.jsx(Ho,{className:"h-3.5 w-3.5"})," External URL"]}),e.jsx(Re,{value:w.lead_magnet_external_url||"",onChange:ie=>N(ae=>({...ae,lead_magnet_external_url:ie.target.value||null})),placeholder:"https://drive.google.com/... or https://dropbox.com/...",className:"mt-1"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Link to a file on Google Drive, Dropbox, or any URL"})]})]})]})}),de&&e.jsxs(zs,{value:"property",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Un,{className:"h-4 w-4"})," Import from Listing Exchange"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pull property details and photos directly from one of your listings, or enter them manually below."}),e.jsxs(tr,{value:w.listing_id||"",onValueChange:ie=>U(ie),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a listing to import..."})}),e.jsx(er,{children:j.map(ie=>{var ae;return e.jsxs(At,{value:ie.id,children:[ie.property_address||`${ie.city}, ${ie.state}`," — $",(ae=ie.price)==null?void 0:ae.toLocaleString()]},ie.id)})})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Property Information"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Property Address"}),e.jsx(Re,{value:w.property_address,onChange:ie=>N(ae=>({...ae,property_address:ie.target.value})),placeholder:"123 Main St, City, State"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Price"}),e.jsx(Re,{value:w.property_price,onChange:ie=>N(ae=>({...ae,property_price:ie.target.value})),placeholder:"$450,000"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Beds"}),e.jsx(Re,{value:w.property_beds,onChange:ie=>N(ae=>({...ae,property_beds:ie.target.value})),placeholder:"4"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Baths"}),e.jsx(Re,{value:w.property_baths,onChange:ie=>N(ae=>({...ae,property_baths:ie.target.value})),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Sq Ft"}),e.jsx(Re,{value:w.property_sqft,onChange:ie=>N(ae=>({...ae,property_sqft:ie.target.value})),placeholder:"2,400"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Mr,{value:w.property_description,onChange:ie=>N(ae=>({...ae,property_description:ie.target.value})),rows:3,placeholder:"Beautiful home in a great neighborhood..."})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Property Photos"})}),e.jsxs(Oe,{className:"space-y-4",children:[w.property_photos.length>0&&e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:w.property_photos.map((ie,ae)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:ie,alt:`Property ${ae+1}`,className:"h-24 w-full object-cover rounded"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>N(le=>({...le,property_photos:le.property_photos.filter((pe,be)=>be!==ae)})),children:e.jsx(br,{className:"h-3 w-3"})})]},ae))}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="property_photos",children:e.jsxs("span",{children:[e.jsx(Ya,{className:"h-3.5 w-3.5 mr-1"}),l==="property_photos"?"Uploading...":"Add Photos"]})}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:q})]})]})]})]}),e.jsxs(zs,{value:"fields",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure the form fields visitors will fill out"}),e.jsxs(K,{size:"sm",onClick:V,children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Add Field"]})]}),C.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No fields yet. Add fields to build your form."})}):e.jsx("div",{className:"space-y-3",children:C.map((ie,ae)=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Fu,{className:"h-4 w-4 mt-2 text-muted-foreground cursor-grab"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Field Type"}),e.jsxs(tr,{value:ie.field_type,onValueChange:le=>X(ae,{field_type:le}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:n1s.map(le=>e.jsx(At,{value:le.value,children:le.label},le.value))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Label"}),e.jsx(Re,{value:ie.label,onChange:le=>X(ae,{label:le.target.value}),placeholder:"e.g. Full Name"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Placeholder"}),e.jsx(Re,{value:ie.placeholder||"",onChange:le=>X(ae,{placeholder:le.target.value}),placeholder:"Optional hint text"})]})]}),(ie.field_type==="select"||ie.field_type==="multiselect")&&e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Options (comma-separated)"}),e.jsx(Re,{value:ie.options?(typeof ie.options=="string"?JSON.parse(ie.options):ie.options).join(", "):"",onChange:le=>X(ae,{options:JSON.stringify(le.target.value.split(",").map(pe=>pe.trim()).filter(Boolean))}),placeholder:"Option 1, Option 2, Option 3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:ie.is_required,onCheckedChange:le=>X(ae,{is_required:le})}),e.jsx(ve,{className:"text-xs",children:"Required"})]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>se(ae),children:e.jsx(br,{className:"h-3.5 w-3.5 text-destructive"})})]})})},ae))})]}),e.jsx(zs,{value:"submissions",className:"mt-4",children:b.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12 text-center text-muted-foreground",children:"No submissions yet. Share your page to start collecting leads!"})}):e.jsx("div",{className:"space-y-3",children:b.map(ie=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:ie.contact_name||"Anonymous"}),ie.synced_to_crm&&e.jsx(at,{variant:"outline",className:"text-[10px]",children:"Synced"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground mt-0.5",children:[ie.contact_email&&e.jsx("span",{className:"mr-3",children:ie.contact_email}),ie.contact_phone&&e.jsx("span",{children:ie.contact_phone})]}),ie.answers&&typeof ie.answers=="object"&&e.jsx("div",{className:"mt-2 text-sm space-y-1",children:Object.entries(ie.answers).map(([ae,le])=>e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-muted-foreground",children:[ae,":"]})," ",e.jsx("span",{children:String(le)})]},ae))})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(ie.created_at).toLocaleDateString()})]})})},ie.id))})}),e.jsxs(zs,{value:"settings",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Publishing"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this page publicly accessible"})]}),e.jsx(Br,{checked:w.is_published,onCheckedChange:ie=>N(ae=>({...ae,is_published:ie}))})]}),w.is_published&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Public URL:"}),e.jsx("code",{className:"text-xs ml-2 break-all",children:te})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Thank You Message"})}),e.jsx(Oe,{children:e.jsx(Mr,{value:w.success_message,onChange:ie=>N(ae=>({...ae,success_message:ie.target.value})),rows:2,placeholder:"Message shown after form submission"})})]})]})]})]}),e.jsx(vs,{open:d,onOpenChange:u,children:e.jsxs(ys,{className:"max-w-sm",children:[e.jsx(Ss,{children:e.jsx(Ns,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx(aD,{value:te,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:te})]})]})})]}):e.jsx(Ms,{title:"Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Page not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/mission-control/landing-pages"),children:"Go back"})]})})}function hDe({value:t}){return t>0?e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600 dark:text-emerald-400",children:[e.jsx(YE,{className:"h-3 w-3"}),t,"%"]}):t<0?e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-red-600 dark:text-red-400",children:[e.jsx(ZE,{className:"h-3 w-3"}),Math.abs(t),"%"]}):e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[e.jsx(P0,{className:"h-3 w-3"}),"0%"]})}const i1s={Phone:Zn,MessageSquare:oo,Mail:_r,Gift:io,PenTool:n_,Video:kn},mDe=["bg-primary","bg-emerald-500","bg-amber-500","bg-sky-500","bg-purple-500","bg-orange-500","bg-pink-500","bg-teal-500"];function o1s(){const t=Dr(),{contactsWithScores:s,stats:r}=Joe(),{data:n}=LL(365),{data:a}=obe(),{data:o}=IL(),l=nbe(),i=S.useMemo(()=>{if(!n)return{touchesThisMonth:0,touchesLastMonth:0,touchTrend:0};const A=new Date,I=mc(A),L=Kp(A),R=mc(Mk(A,1)),$=Kp(Mk(A,1)),q=n.filter(X=>wg(new Date(X.completed_at),{start:I,end:L})).length,U=n.filter(X=>wg(new Date(X.completed_at),{start:R,end:$})).length,V=U>0?Math.round((q-U)/U*100):q>0?100:0;return{touchesThisMonth:q,touchesLastMonth:U,touchTrend:V}},[n]),d=S.useMemo(()=>{if(!n)return 0;const A=new Date,I=mc(A),L=Kp(A);return new Set(n.filter(R=>wg(new Date(R.completed_at),{start:I,end:L})).map(R=>R.contact_id)).size},[n]),u=S.useMemo(()=>{if(!a)return{closedThisMonth:0,totalGCI:0};const A=new Date,I=mc(A),L=Kp(A),R=a.filter($=>$.close_date&&wg(fl($.close_date),{start:I,end:L}));return{closedThisMonth:R.length,totalGCI:R.reduce(($,q)=>$+(Number(q.commission_amount)||0),0)}},[a]),p=S.useMemo(()=>{if(!s.length)return{newThisMonth:0,newLastMonth:0,trend:0};const A=new Date,I=mc(A),L=mc(Mk(A,1)),R=Kp(Mk(A,1)),$=s.filter(V=>new Date(V.created_at)>=I).length,q=s.filter(V=>wg(new Date(V.created_at),{start:L,end:R})).length,U=q>0?Math.round(($-q)/q*100):$>0?100:0;return{newThisMonth:$,newLastMonth:q,trend:U}},[s]),f=S.useMemo(()=>{if(!n||!o)return[];const A=new Date,I=mc(A),L=Kp(A),R=n.filter(U=>wg(new Date(U.completed_at),{start:I,end:L})),$={};R.forEach(U=>{const V=U.action_type_id;$[V]=($[V]||0)+1});const q=R.length||1;return o.filter(U=>$[U.id]).map(U=>({id:U.id,name:U.name,icon:U.icon,count:$[U.id]||0,percent:Math.round(($[U.id]||0)/q*100)})).sort((U,V)=>V.count-U.count)},[n,o]),v=S.useMemo(()=>[...s].filter(A=>A.relationshipScore.status==="at-risk"||A.relationshipScore.status==="cooling").sort((A,I)=>{const L=A.relationshipScore.daysSinceTouch??9999;return(I.relationshipScore.daysSinceTouch??9999)-L}).slice(0,5),[s]),_=S.useMemo(()=>{if(!n)return[];const A=new Date,I=mc(A),L=Kp(A),R=new Set(n.filter($=>wg(new Date($.completed_at),{start:I,end:L})).map($=>$.contact_id));return s.filter($=>$.relationshipScore.status==="warm"&&R.has($.id)&&$.relationshipScore.touchCountLast12Months>=2).sort(($,q)=>q.relationshipScore.score-$.relationshipScore.score).slice(0,5)},[s,n]),b=S.useMemo(()=>{if(!n)return{currentStreak:0,longestStreak:0};const A=new Set(n.map(V=>{const X=new Date(V.completed_at);return`${X.getFullYear()}-${X.getMonth()}-${X.getDate()}`})),I=new Date;I.setHours(0,0,0,0);let L=0,R=new Date(I);for(;A.has(`${R.getFullYear()}-${R.getMonth()}-${R.getDate()}`);)L++,R.setDate(R.getDate()-1);let $=0,q=0;if(Array.from(A).sort().length>0){const V=n.map(X=>{const se=new Date(X.completed_at);return se.setHours(0,0,0,0),se.getTime()}).filter((X,se,te)=>te.indexOf(X)===se).sort((X,se)=>X-se);q=1;for(let X=1;X[...s].sort((A,I)=>A.relationshipScore.score-I.relationshipScore.score),[s]),w=j.filter(A=>A.relationshipScore.status==="warm"),N=j.filter(A=>A.relationshipScore.status==="cooling"),C=j.filter(A=>A.relationshipScore.status==="at-risk");return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Relationship Scorecard"}),e.jsxs("p",{className:"text-muted-foreground",children:[ws(new Date,"MMMM yyyy")," — Your monthly relationship health report"]})]}),b.currentStreak>0&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-full bg-orange-500/10 border border-orange-500/20",children:[e.jsx($h,{className:"h-5 w-5 text-orange-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-orange-600 dark:text-orange-400",children:b.currentStreak}),e.jsx("span",{className:"text-sm text-muted-foreground ml-1",children:"day streak"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Si,{className:"h-4 w-4"}),"Avg Score"]}),e.jsx("div",{className:"text-3xl font-bold",children:r.averageScore}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"out of 100"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Am,{className:"h-4 w-4"}),"Touches"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-3xl font-bold",children:i.touchesThisMonth}),e.jsx(hDe,{value:i.touchTrend})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["vs ",i.touchesLastMonth," last month"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),"Reached"]}),e.jsx("div",{className:"text-3xl font-bold",children:d}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["of ",r.total," contacts"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Cc,{className:"h-4 w-4"}),"New Contacts"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-3xl font-bold",children:p.newThisMonth}),e.jsx(hDe,{value:p.trend})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"added this month"})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Hh,{className:"h-4 w-4 text-primary"}),"Weekly Goal"]})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[l.actionsThisWeek," of ",l.weeklyGoal," touches"]}),e.jsxs("span",{className:"text-sm font-medium",children:[Math.round(l.progress),"%"]})]}),e.jsx(Ti,{value:l.progress,className:"h-3"}),l.progress>=100&&e.jsxs("p",{className:"text-xs text-emerald-600 dark:text-emerald-400 mt-2 flex items-center gap-1",children:[e.jsx(Ki,{className:"h-3 w-3"}),"Goal reached! 🎉"]}),l.progress<100&&l.progress>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[l.weeklyGoal-l.actionsThisWeek," more to hit your goal"]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx($h,{className:"h-4 w-4 text-orange-500"}),"Momentum"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Current Streak"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xl font-bold",children:b.currentStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"}),b.currentStreak>=7&&e.jsx("span",{className:"ml-1",children:"🔥"}),b.currentStreak>=30&&e.jsx("span",{children:"🏆"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Longest Streak"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xl font-bold",children:b.longestStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"})]})]}),b.currentStreak===0&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 italic",children:"Log a touch today to start your streak!"})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Am,{className:"h-4 w-4"}),"How You're Reaching Out"]})}),e.jsx(Oe,{children:f.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No touches logged this month yet."}):e.jsx("div",{className:"space-y-2.5",children:f.slice(0,5).map((A,I)=>{const L=i1s[A.icon||""]||Am;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:A.name})]}),e.jsxs("span",{className:"text-muted-foreground",children:[A.count," (",A.percent,"%)"]})]}),e.jsx(Ti,{value:A.percent,className:Pt("h-1.5 bg-muted [&>div]:",mDe[I%mDe.length])})]},A.id)})})})]})]}),v.length>0&&e.jsxs(Ee,{className:"border-l-4 border-l-primary",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Zn,{className:"h-5 w-5 text-primary"}),"Who to Reach Out to Today"]}),e.jsxs(at,{variant:"secondary",children:[v.length," contacts"]})]}),e.jsx(yr,{children:"These relationships need attention the most"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:v.map(A=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card hover:bg-accent/50 cursor-pointer transition-colors",onClick:()=>t(`/mission-control/contacts/${A.id}`),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(mI,{score:A.relationshipScore,showScore:!0,size:"sm",showTooltip:!1}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[A.first_name," ",A.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:A.relationshipScore.daysSinceTouch===null?"Never contacted":`Last touch ${A.relationshipScore.daysSinceTouch}d ago`})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[A.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`tel:${A.phone}`)},children:e.jsx(Zn,{className:"h-4 w-4"})}),A.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`mailto:${A.email}`)},children:e.jsx(_r,{className:"h-4 w-4"})}),e.jsx(Ha,{className:"h-4 w-4 text-muted-foreground"})]})]},A.id))})})]}),_.length>0&&e.jsxs(Ee,{className:"border-l-4 border-l-emerald-500",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(rc,{className:"h-5 w-5 text-emerald-500"}),"Biggest Wins This Month"]}),e.jsx(yr,{children:"Relationships you've successfully warmed up"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:_.map(A=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-full bg-emerald-500/10 border border-emerald-500/20 cursor-pointer hover:bg-emerald-500/20 transition-colors",onClick:()=>t(`/mission-control/contacts/${A.id}`),children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),e.jsxs("span",{className:"text-sm font-medium",children:[A.first_name," ",A.last_name]}),e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400 font-bold",children:A.relationshipScore.score})]},A.id))})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ee,{className:"border-l-4 border-l-emerald-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Warm"}),e.jsx("p",{className:"text-3xl font-bold text-emerald-600 dark:text-emerald-400",children:r.warm})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🟢"})})]}),e.jsx(Ti,{value:r.total?r.warm/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-emerald-500"})]})}),e.jsx(Ee,{className:"border-l-4 border-l-amber-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Cooling Off"}),e.jsx("p",{className:"text-3xl font-bold text-amber-600 dark:text-amber-400",children:r.cooling})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🟡"})})]}),e.jsx(Ti,{value:r.total?r.cooling/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-amber-500"})]})}),e.jsx(Ee,{className:"border-l-4 border-l-red-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"At Risk"}),e.jsx("p",{className:"text-3xl font-bold text-red-600 dark:text-red-400",children:r.atRisk})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-red-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🔴"})})]}),e.jsx(Ti,{value:r.total?r.atRisk/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-red-500"})]})})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(aP,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Deals Closed This Month"}),e.jsx("p",{className:"text-2xl font-bold",children:u.closedThisMonth})]})]}),u.totalGCI>0&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"GCI This Month"}),e.jsxs("p",{className:"text-2xl font-bold text-emerald-600 dark:text-emerald-400",children:["$",u.totalGCI.toLocaleString()]})]})]})})}),e.jsxs(Na,{defaultValue:"at-risk",children:[e.jsxs(va,{children:[e.jsxs(ks,{value:"at-risk",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),"At Risk (",r.atRisk,")"]}),e.jsxs(ks,{value:"cooling",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-500"}),"Cooling (",r.cooling,")"]}),e.jsxs(ks,{value:"warm",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),"Warm (",r.warm,")"]})]}),[{key:"at-risk",contacts:C},{key:"cooling",contacts:N},{key:"warm",contacts:w}].map(({key:A,contacts:I})=>e.jsx(zs,{value:A,children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:I.length===0?e.jsx("p",{className:"p-6 text-center text-muted-foreground",children:"No contacts in this category"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Contact"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Last Touch"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Touches (12mo)"}),e.jsx(jt,{children:"Score"}),e.jsx(jt,{className:"w-10"})]})}),e.jsx(Pn,{children:I.slice(0,20).map(L=>e.jsxs(js,{className:"cursor-pointer",onClick:()=>t(`/mission-control/contacts/${L.id}`),children:[e.jsxs(lt,{className:"font-medium",children:[L.first_name," ",L.last_name]}),e.jsx(lt,{className:"hidden md:table-cell text-muted-foreground",children:L.relationshipScore.daysSinceTouch===null?"Never":L.relationshipScore.daysSinceTouch===0?"Today":`${L.relationshipScore.daysSinceTouch}d ago`}),e.jsx(lt,{className:"hidden md:table-cell",children:L.relationshipScore.touchCountLast12Months}),e.jsx(lt,{children:e.jsx(mI,{score:L.relationshipScore,showScore:!0})}),e.jsx(lt,{children:e.jsx(Ha,{className:"h-4 w-4 text-muted-foreground"})})]},L.id))})]})})})},A))]})]})})}function bet(){const{user:t}=Gs(),s=ns(),{data:r,isLoading:n}=Ct({queryKey:["contact-intake-page",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:u,error:p}=await G.from("contact_intake_pages").select("*").eq("user_id",t.id).maybeSingle();if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),a=Ot({mutationFn:async u=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:p,error:f}=await G.from("contact_intake_pages").insert({user_id:t.id,slug:u.toLowerCase().replace(/[^a-z0-9-]/g,"-")}).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),fe.success("Connect page created!")},onError:u=>{var p;(p=u.message)!=null&&p.includes("duplicate")?fe.error("That slug is already taken. Try another."):fe.error("Failed to create page")}}),o=Ot({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page");const{error:p}=await G.from("contact_intake_pages").update({...u,updated_at:new Date().toISOString()}).eq("id",r.id);if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),fe.success("Page updated!")},onError:()=>fe.error("Failed to update page")}),{data:l=[],isLoading:i}=Ct({queryKey:["contact-intake-submissions",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:u,error:p}=await G.from("contact_intake_submissions").select("*").eq("agent_user_id",t.id).order("created_at",{ascending:!1}).limit(100);if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),d=Ot({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page. Create your Connect page first.");const{data:p,error:f}=await G.from("contact_intake_tokens").insert({contact_id:u,intake_page_id:r.id}).select("token").single();if(f)throw f;return`${window.location.origin}/connect/${r.slug}?t=${p.token}`}});return{intakePage:r,isLoading:n,createPage:a,updatePage:o,submissions:l,loadingSubmissions:i,generateUpdateLink:d}}function l1s(){const{user:t}=Gs();return Ct({queryKey:["bulk-email-sends",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:s,error:r}=await G.from("bulk_email_sends").select("contact_id, sent_at, subject").eq("user_id",t.id).order("sent_at",{ascending:!1});if(r)throw r;return s}})}function c1s(t,s){if(!t)return null;const r=t.find(n=>n.contact_id===s);return(r==null?void 0:r.sent_at)||null}const OE=[{key:"email",label:"Missing Email",icon:_r,description:"No email — can't send drips or market updates",check:t=>!t.email,color:"text-red-500",fieldKey:"email",fieldType:"email",placeholder:"email@example.com"},{key:"phone",label:"Missing Phone",icon:Zn,description:"No phone number — can't call or text",check:t=>!t.phone,color:"text-orange-500",fieldKey:"phone",fieldType:"tel",placeholder:"(555) 123-4567"},{key:"address",label:"Missing Address",icon:Ai,description:"No address — can't send postcards or popbys",check:t=>!t.address,color:"text-amber-500",fieldKey:"address",fieldType:"text",placeholder:"123 Main St, City, ST 12345"},{key:"birthday",label:"Missing Birthday",icon:Ru,description:"No birthday — missing a key personal touch",check:t=>!t.birthday,color:"text-purple-500",fieldKey:"birthday",fieldType:"date"},{key:"home_anniversary",label:"Missing Home Anniversary",icon:Un,description:"No home anniversary — missing annual outreach opportunity",check:t=>!t.home_anniversary,color:"text-blue-500",fieldKey:"home_anniversary",fieldType:"date"},{key:"tags",label:"No Tags",icon:Vh,description:"Untagged — won't appear in filtered lists or plans",check:t=>!t.tags||t.tags.length===0,color:"text-slate-500"}];function k4(t){const s=[!!t.email,!!t.phone,!!t.address,!!t.birthday,!!t.home_anniversary,!!(t.tags&&t.tags.length>0)];return Math.round(s.filter(Boolean).length/s.length*100)}function d1s({contact:t,onClose:s}){const r=tbe(),[n,a]=S.useState({email:t.email||"",phone:t.phone||"",address:t.address||"",birthday:t.birthday||"",home_anniversary:t.home_anniversary||""}),o=async()=>{r.mutate({id:t.id,...n},{onSuccess:()=>s()})},l=OE.filter(i=>i.fieldKey&&i.check(t));return e.jsx(gM,{open:!0,onOpenChange:()=>s(),children:e.jsxs(rS,{className:"sm:max-w-md overflow-y-auto",children:[e.jsxs(xM,{children:[e.jsxs(yM,{children:["Quick Edit — ",t.first_name," ",t.last_name]}),e.jsxs(Y9e,{children:["Fill in missing fields to improve this contact's completeness (",k4(t),"%)"]})]}),e.jsxs("div",{className:"space-y-5 mt-6",children:[l.length>0&&e.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400 mb-1",children:"Missing Fields"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:l.map(i=>{const d=i.icon;return e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(d,{className:"h-3 w-3"}),i.label.replace("Missing ","")]},i.key)})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(_r,{className:"h-3.5 w-3.5"})," Email"]}),e.jsx(Re,{type:"email",placeholder:"email@example.com",value:n.email,onChange:i=>a(d=>({...d,email:i.target.value})),className:Pt(!t.email&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Zn,{className:"h-3.5 w-3.5"})," Phone"]}),e.jsx(Re,{type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:i=>a(d=>({...d,phone:i.target.value})),className:Pt(!t.phone&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Ai,{className:"h-3.5 w-3.5"})," Address"]}),e.jsx(Re,{placeholder:"123 Main St, City, ST 12345",value:n.address,onChange:i=>a(d=>({...d,address:i.target.value})),className:Pt(!t.address&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Ru,{className:"h-3.5 w-3.5"})," Birthday"]}),e.jsx(Re,{type:"date",value:n.birthday,onChange:i=>a(d=>({...d,birthday:i.target.value})),className:Pt(!t.birthday&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Home Anniversary"]}),e.jsx(Re,{type:"date",value:n.home_anniversary,onChange:i=>a(d=>({...d,home_anniversary:i.target.value})),className:Pt(!t.home_anniversary&&"border-amber-500/50")})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{className:"flex-1",onClick:o,disabled:r.isPending,children:[e.jsx(Bu,{className:"h-4 w-4 mr-1.5"}),r.isPending?"Saving...":"Save Changes"]}),e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"})]})]})]})})}const Lpe="Quick favor — can you update your info? 🙏",pDe=`Hi {{first_name}}, Hope you're doing well! I'm making sure I have the most up-to-date info for all my important contacts. Could you take 30 seconds to update your details? Just click the link below: {{update_link}} It's super quick — and it helps me make sure I'm reaching you at the right place with anything useful (market updates, birthday wishes, you name it 😊). Thanks so much!`;function u1s(){const t=Dr(),{data:s,isLoading:r}=Jh(),{data:n}=Ef(),{intakePage:a}=bet(),{isGmailConnected:o,gmailEmail:l}=gy(),{data:i}=l1s(),[d,u]=S.useState("blocked"),[p,f]=S.useState("all"),[v,_]=S.useState(null),[b,j]=S.useState(!1),[w,N]=S.useState(!1),[C,A]=S.useState(null),[I,L]=S.useState([]),[R,$]=S.useState(""),[q,U]=S.useState(""),V=S.useMemo(()=>s?p==="all"?s:s.filter(_e=>{var Ce;return(Ce=_e.tags)==null?void 0:Ce.some(Te=>Te.relationship_type_id===p)}):[],[s,p]),X=S.useMemo(()=>V.filter(_e=>!_e.email&&!_e.phone),[V]),se=S.useMemo(()=>{if(!V.length)return{overallCompleteness:0,fullyComplete:0,contactsByGap:{}};const _e={};_e.blocked=X,OE.forEach(Ae=>{_e[Ae.key]=V.filter(Ae.check)});const Ce=V.map(k4),Te=V.length>0?Math.round(Ce.reduce((Ae,We)=>Ae+We,0)/V.length):0,Fe=Ce.filter(Ae=>Ae===100).length;return{contactsByGap:_e,overallCompleteness:Te,fullyComplete:Fe}},[V,X]),te=S.useMemo(()=>{if(!s||s.length===0)return null;const _e=mc(Mk(new Date,1)),Ce=s.filter(We=>new Date(We.created_at)<_e);if(Ce.length===0)return null;const Te=Math.round(Ce.map(k4).reduce((We,ht)=>We+ht,0)/Ce.length),Fe=se.overallCompleteness,Ae=Fe-Te;return{oldCompleteness:Te,currentCompleteness:Fe,diff:Ae,oldCount:Ce.length}},[s,se.overallCompleteness]),Y=V.length,de=S.useCallback(()=>{var Dt;const _e=se.contactsByGap[d];if(!(_e!=null&&_e.length))return;const Ce=d==="blocked"?"Outreach Blocked":((Dt=OE.find(he=>he.key===d))==null?void 0:Dt.label)||d,Te=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Completeness %"],Fe=_e.map(he=>[he.first_name,he.last_name||"",he.email||"",he.phone||"",he.address||"",he.birthday||"",he.home_anniversary||"",k4(he).toString()]),Ae=[Te.join(","),...Fe.map(he=>he.map(Qe=>`"${Qe.replace(/"/g,'""')}"`).join(","))].join(` `),We=new Blob([Ae],{type:"text/csv"}),ht=URL.createObjectURL(We),De=document.createElement("a");De.href=ht,De.download=`sphere-gaps-${Ce.toLowerCase().replace(/\s+/g,"-")}-${ws(new Date,"yyyy-MM-dd")}.csv`,De.click(),URL.revokeObjectURL(ht),an({title:`Exported ${_e.length} contacts to CSV`})},[se.contactsByGap,d]),ie=S.useCallback(async _e=>{if(!a)return null;try{const{data:Ce,error:Te}=await G.from("contact_intake_tokens").insert({contact_id:_e,intake_page_id:a.id}).select("token").single();if(Te)throw Te;return Ce.token}catch{return null}},[a]),ae=S.useCallback(_e=>a?`https://contacts.relevelup.com/${a.slug}?t=${_e}`:"",[a]),le=S.useCallback(async _e=>{if(!a){fe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const Ce=await ie(_e);Ce?(await navigator.clipboard.writeText(ae(Ce)),fe.success("Update link copied!")):fe.error("Failed to generate link")},[a,ie,ae,t]),pe=S.useCallback(async _e=>{if(!a){fe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}if(!_e.email){fe.error("This contact has no email address");return}const Ce=await ie(_e.id);if(!Ce){fe.error("Failed to generate link");return}const Te=ae(Ce),Fe=pDe.replace("{{update_link}}",Te).replace(/\{\{first_name\}\}/g,_e.first_name).replace(/\{\{last_name\}\}/g,_e.last_name||""),Ae=Lpe.replace(/\{\{first_name\}\}/g,_e.first_name).replace(/\{\{last_name\}\}/g,_e.last_name||"");if(o)A({id:_e.id,first_name:_e.first_name,last_name:_e.last_name,email:_e.email}),L([]),$(Ae),U(Fe),N(!0);else{const We=encodeURIComponent(Lpe.replace("{{first_name}}",_e.first_name)),ht=encodeURIComponent(Fe.replace(/\{\{first_name\}\}/g,_e.first_name));window.location.href=`mailto:${_e.email}?subject=${We}&body=${ht}`}},[a,ie,ae,o,t]),be=S.useCallback(async _e=>{if(!a){fe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const Ce=_e.filter(Te=>Te.email);if(!Ce.length){fe.error("No contacts with email addresses in this group");return}if(!o){fe.error("Connect Gmail in Settings to send bulk emails");return}j(!0);try{const{data:Te,error:Fe}=await G.functions.invoke("process-intake-submissions",{body:{action:"generate_tokens",contact_ids:Ce.map(he=>he.id),intake_page_id:a.id}});if(Fe)throw Fe;const Ae=typeof Te=="string"?JSON.parse(Te):Te,We=Array.isArray(Ae)?Ae:Array.isArray(Ae==null?void 0:Ae.tokens)?Ae.tokens:[],ht=new Map(We.filter(he=>(he==null?void 0:he.contact_id)&&(he==null?void 0:he.token)).map(he=>[he.contact_id,he.token]));if(ht.size===0&&(await Promise.all(Ce.map(async Qe=>({contactId:Qe.id,token:await ie(Qe.id)})))).forEach(({contactId:Qe,token:ot})=>{ot&&ht.set(Qe,ot)}),ht.size===0){fe.error("Failed to generate update links. Please try again.");return}const De=Ce.filter(he=>ht.has(he.id)).map(he=>({id:he.id,first_name:he.first_name,last_name:he.last_name,email:he.email,updateLink:ae(ht.get(he.id))})),Dt=pDe;A(null),L(De),$(Lpe),U(Dt),N(!0),fe.success(`Ready to email ${De.length} contacts`)}catch{fe.error("Failed to generate links")}finally{j(!1)}},[a,o,ae,ie,t]),we=[{key:"blocked",label:"Outreach Blocked",icon:o0,color:"text-destructive",description:"Missing BOTH email AND phone — completely unreachable"},...OE].find(_e=>_e.key===d),ke=se.contactsByGap[d]||[],Ze=ke.filter(_e=>_e.email).length;return e.jsxs(Ms,{children:[e.jsxs("div",{className:"space-y-6 p-4 md:p-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Sphere Gaps Analyzer"}),e.jsx("p",{className:"text-muted-foreground",children:"Find missing info in your database to maximize your outreach potential"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hx,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(tr,{value:p,onValueChange:f,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{placeholder:"Filter by tag"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Contacts"}),n==null?void 0:n.map(_e=>e.jsx(At,{value:_e.id,children:_e.name},_e.id))]})]})]})]}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Database Completeness",p!=="all"&&e.jsx("span",{className:"ml-1 text-primary",children:"(filtered)"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("p",{className:"text-4xl font-bold",children:[se.overallCompleteness,"%"]}),te&&te.diff!==0&&p==="all"&&e.jsxs("div",{className:Pt("flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",te.diff>0?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-red-500/10 text-red-600 dark:text-red-400"),children:[te.diff>0?"↑":"↓"," ",Math.abs(te.diff),"% vs older contacts"]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Fully Complete"}),e.jsxs("p",{className:"text-2xl font-bold text-emerald-600 dark:text-emerald-400",children:[se.fullyComplete," ",e.jsxs("span",{className:"text-base font-normal text-muted-foreground",children:["/ ",Y]})]})]})]}),e.jsx(Ti,{value:se.overallCompleteness,className:"h-3"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:se.overallCompleteness>=80?"🎉 Great job! Your database is well maintained.":se.overallCompleteness>=50?"⚡ Good start — fill in the gaps below to unlock more outreach channels.":"🔍 Your database needs attention. Start with emails and phone numbers."})]})}),X.length>0&&e.jsx(Ee,{className:Pt("border-l-4 border-l-destructive cursor-pointer transition-all hover:shadow-md",d==="blocked"&&"ring-2 ring-primary"),onClick:()=>u("blocked"),children:e.jsx(Oe,{className:"pt-5 pb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(o0,{className:"h-6 w-6 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Outreach Blocked"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Missing both email AND phone — completely unreachable"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-3xl font-bold text-destructive",children:X.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"contacts"})]})]})})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:OE.map(_e=>{var We;const Ce=((We=se.contactsByGap[_e.key])==null?void 0:We.length)||0,Te=Y>0?Math.round(Ce/Y*100):0,Fe=_e.icon,Ae=d===_e.key;return e.jsx(Ee,{className:Pt("cursor-pointer transition-all hover:shadow-md",Ae&&"ring-2 ring-primary"),onClick:()=>u(_e.key),children:e.jsxs(Oe,{className:"pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Fe,{className:Pt("h-5 w-5",_e.color)}),e.jsx("span",{className:"text-sm font-medium",children:_e.label})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-2xl font-bold",children:Ce}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Te,"% of contacts"]})]}),e.jsx(Ti,{value:100-Te,className:"mt-2 h-1.5"})]})},_e.key)})}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg",children:[(we==null?void 0:we.label)||"Contacts"," — Contacts to Fix"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(at,{variant:"secondary",children:[ke.length," contacts"]}),ke.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:de,className:"gap-1.5",children:[e.jsx(xi,{className:"h-3.5 w-3.5"}),"Export"]}),Ze>0&&a&&e.jsxs(K,{size:"sm",onClick:()=>be(ke),disabled:b,className:"gap-1.5",children:[b?e.jsx(As,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ka,{className:"h-3.5 w-3.5"}),"Email ",Ze," Update Links"]})]})]})]}),e.jsx(yr,{children:we==null?void 0:we.description})]}),e.jsx(Oe,{className:"p-0",children:ke.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(da,{className:"h-10 w-10 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:d==="blocked"?"All contacts have at least an email or phone!":"All contacts have this field filled in!"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Contact"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Email"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Phone"}),e.jsx(jt,{children:"Completeness"}),e.jsx(jt,{className:"w-28",children:"Actions"})]})}),e.jsx(Pn,{children:ke.map(_e=>{const Ce=c1s(i,_e.id);return e.jsxs(js,{children:[e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"cursor-pointer hover:underline",onClick:()=>t(`/mission-control/contacts/${_e.id}`),children:[_e.first_name," ",_e.last_name]}),!_e.email&&!_e.phone&&d!=="blocked"&&e.jsx(at,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"Blocked"}),Ce&&e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsxs(at,{variant:"outline",className:"text-[10px] px-1.5 py-0 gap-1 text-muted-foreground border-muted",children:[e.jsx(_r,{className:"h-2.5 w-2.5"}),Cd(new Date(Ce),{addSuffix:!0})]})}),e.jsxs(Wc,{children:["Last bulk emailed ",ws(new Date(Ce),"MMM d, yyyy h:mm a")]})]})]})}),e.jsx(lt,{className:"hidden md:table-cell text-muted-foreground",children:_e.email||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(lt,{className:"hidden md:table-cell text-muted-foreground",children:_e.phone||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ti,{value:k4(_e),className:"h-2 w-16"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[k4(_e),"%"]})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>_(_e),children:e.jsx(c0,{className:"h-3.5 w-3.5"})})}),e.jsx(Wc,{children:"Quick edit"})]}),(_e.email||_e.phone)&&a&&e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>le(_e.id),children:e.jsx(ni,{className:"h-3.5 w-3.5"})})}),e.jsx(Wc,{children:"Copy update link"})]}),_e.email&&a&&e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>pe(_e),children:e.jsx(_r,{className:"h-3.5 w-3.5"})})}),e.jsx(Wc,{children:"Email update link"})]})]})})]},_e.id)})})]})})]})]}),v&&e.jsx(d1s,{contact:v,onClose:()=>_(null)}),e.jsx(EM,{open:w,onOpenChange:N,contact:C||void 0,bulkContacts:I.length>0?I:void 0,defaultSubject:R,defaultBody:q,gmailEmail:l})]})}function h1s(){const{user:t}=Gs(),{intakePage:s,isLoading:r,createPage:n,updatePage:a,submissions:o,loadingSubmissions:l}=bet(),[i,d]=S.useState(""),[u,p]=S.useState(""),[f,v]=S.useState(!1);S.useEffect(()=>{s&&p(s.welcome_message||"")},[s]),S.useEffect(()=>{if(t!=null&&t.email&&!s){const A=t.email.split("@")[0];d(A.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+$/,""))}},[t,s]);const _=s?`https://contacts.relevelup.com/${s.slug}`:"",b=()=>{navigator.clipboard.writeText(_),fe.success("Link copied!")};if(r)return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6 flex items-center justify-center",children:e.jsx(As,{className:"h-5 w-5 animate-spin text-muted-foreground"})})});if(!s)return e.jsxs(Ee,{children:[e.jsx(Lt,{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(Ho,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Connect Page"}),e.jsx(yr,{children:"Create a public link to capture contact info from new leads or update existing contacts"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Your Connect Page URL"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"contacts.relevelup.com/"}),e.jsx(Re,{value:i,onChange:A=>d(A.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"jane-smith",className:"max-w-[200px]"})]})]}),e.jsxs(K,{onClick:()=>n.mutate(i),disabled:!i.trim()||n.isPending,children:[n.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Connect Page"]})]})})]});const j=o.filter(A=>!A.is_processed),w=o.filter(A=>A.is_processed),N=j.length,C=(A,I)=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:[A.first_name," ",A.last_name||""]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[A.email&&e.jsx("span",{children:A.email}),A.phone&&e.jsx("span",{children:A.phone})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[A.real_estate_interest&&A.real_estate_interest!=="not_now"&&e.jsx(at,{variant:"outline",className:"text-xs",children:A.real_estate_interest==="buying"?"🏠 Buying":A.real_estate_interest==="selling"?"📋 Selling":A.real_estate_interest==="both"?"🔄 Both":A.real_estate_interest}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Tn,{className:"h-3 w-3"}),ws(new Date(A.created_at),"MMM d")]}),I&&e.jsx(da,{className:"h-4 w-4 text-emerald-500"})]})]},A.id);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{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(Ho,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Connect Page"}),e.jsx(yr,{children:"Share this link to capture contact info"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{htmlFor:"active-toggle",className:"text-sm text-muted-foreground",children:"Active"}),e.jsx(Br,{id:"active-toggle",checked:s.is_active,onCheckedChange:A=>a.mutate({is_active:A})})]})]})}),e.jsxs(Oe,{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:_}),e.jsxs(K,{size:"sm",variant:"outline",onClick:b,children:[e.jsx(ni,{className:"h-3.5 w-3.5 mr-1.5"})," Copy"]}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",children:e.jsx(sn,{className:"h-3.5 w-3.5"})})})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Welcome Message"}),f?e.jsxs("div",{className:"mt-1.5 space-y-2",children:[e.jsx("textarea",{value:u,onChange:A=>p(A.target.value),rows:3,className:"w-full px-3 py-2 text-sm border rounded-md bg-background"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",onClick:()=>{a.mutate({welcome_message:u}),v(!1)},children:"Save"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>v(!1),children:"Cancel"})]})]}):e.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground cursor-pointer hover:text-foreground transition-colors",onClick:()=>v(!0),children:s.welcome_message||"Click to set a welcome message..."})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(hr,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-base",children:"New Submissions"}),N>0&&e.jsxs(yr,{children:[N," awaiting sync"]})]})]}),N>0&&e.jsxs(K,{size:"sm",onClick:async()=>{try{const{data:A,error:I}=await G.functions.invoke("process-intake-submissions",{body:{action:"process_all"}});if(I)throw I;fe.success(`Synced ${A.processed} contacts to your CRM!`)}catch{fe.error("Failed to sync")}},className:"gap-1.5",children:["Sync ",N," to CRM"]})]})}),e.jsx(Oe,{children:l?e.jsx(As,{className:"h-5 w-5 animate-spin text-muted-foreground"}):j.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"All caught up! No new submissions to sync."}):e.jsx("div",{className:"space-y-3",children:j.map(A=>C(A,!1))})})]}),w.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(da,{className:"h-5 w-5 text-emerald-500"}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-base",children:"Synced to CRM"}),e.jsxs(yr,{children:[w.length," contacts already in your database"]})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[w.slice(0,10).map(A=>C(A,!0)),w.length>10&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-1",children:["+ ",w.length-10," more synced contacts"]})]})})]})]})}function m1s(){return e.jsx(Ms,{children:e.jsxs("div",{className:"max-w-3xl mx-auto py-8 px-4",children:[e.jsx("h1",{className:"text-2xl font-bold mb-6",children:"Connect Page"}),e.jsx(h1s,{})]})})}const p1s=S.lazy(()=>dy(()=>import("./PostcardManager-tVdA-szj.js"),__vite__mapDeps([0,1]))),f1s=S.lazy(()=>dy(()=>import("./HomeReelManager-C8mjQcbS.js"),[])),g1s=S.lazy(()=>dy(()=>import("./AdminCredits-DaHJ0aEB.js"),[])),x1s=S.lazy(()=>dy(()=>import("./DirectMail-D8tSLTRJ.js"),__vite__mapDeps([2,1]))),y1s=new Kdt,v1s=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},_1s=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},b1s=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},w1s=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},j1s=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},k1s=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},N1s=()=>{const t=window.location.hostname;return t==="booking.relevelup.com"||t.startsWith("booking.")},S1s=()=>{const t=window.location.hostname;return t==="contacts.relevelup.com"||t.startsWith("contacts.")},C1s=()=>{const t=window.location.hostname;return t==="pages.relevelup.com"||t.startsWith("pages.")},M1s=()=>e.jsx(Jdt,{client:y1s,children:e.jsx(PFe,{children:e.jsxs(QN,{children:[e.jsx(plt,{}),e.jsx(Wlt,{}),e.jsx(uht,{children:e.jsx(pft,{children:e.jsx(fft,{children:e.jsxs(xft,{children:[e.jsx(gft,{}),e.jsx(Zxt,{}),e.jsx(uyt,{}),k1s()?e.jsx(qvs,{}):_1s()?e.jsx(A0t,{}):v1s()?e.jsx(Qyt,{}):b1s()?e.jsx(I0t,{}):w1s()?e.jsx(sbt,{}):j1s()?e.jsx(vbt,{}):N1s()?e.jsx(Uvs,{}):S1s()?e.jsx(Vvs,{}):C1s()?e.jsx(Hvs,{}):e.jsxs(NFe,{children:[e.jsx(Vs,{path:"/",element:e.jsx(Mbt,{})}),e.jsx(Vs,{path:"/privacy-policy",element:e.jsx(Tbt,{})}),e.jsx(Vs,{path:"/terms-of-service",element:e.jsx(Abt,{})}),e.jsx(Vs,{path:"/data-deletion",element:e.jsx(Ebt,{})}),e.jsx(Vs,{path:"/public/listings",element:e.jsx(c9e,{})}),e.jsx(Vs,{path:"/public/listing/:slugOrId",element:e.jsx(Ajt,{})}),e.jsx(Vs,{path:"/card/:slug",element:e.jsx(Ejt,{})}),e.jsx(Vs,{path:"/join-brokerage/:slug",element:e.jsx(V0s,{})}),e.jsx(Vs,{path:"/recruit-video/:shareToken",element:e.jsx(W0s,{})}),e.jsx(Vs,{path:"/connect/:slug",element:e.jsx(KUe,{})}),e.jsx(Vs,{path:"/auth",element:e.jsx(Ibt,{})}),e.jsx(Vs,{path:"/subscription-success",element:e.jsx(Lbt,{})}),e.jsx(Vs,{path:"/subscription",element:e.jsx(ur,{children:e.jsx(z2t,{})})}),e.jsxs(Vs,{path:"/share/video",element:e.jsx(Sjt,{}),children:[e.jsx(Vs,{path:":shareToken",element:e.jsx(k3e,{})}),e.jsx(Vs,{path:":shareToken/r/:recipientToken",element:e.jsx(k3e,{})})]}),e.jsx(Vs,{path:"/p/:shareToken",element:e.jsx(dvs,{})}),e.jsx(Vs,{path:"/portal/:slug",element:e.jsx(xvs,{})}),e.jsx(Vs,{path:"/og/video/:token",element:e.jsx(Cjt,{})}),e.jsx(Vs,{path:"/setup-brokerage",element:e.jsx(ur,{children:e.jsx(B2t,{})})}),e.jsx(Vs,{path:"/claim-account",element:e.jsx(b3e,{})}),e.jsx(Vs,{path:"/claim",element:e.jsx(b3e,{})}),e.jsx(Vs,{path:"/join",element:e.jsx($2t,{})}),e.jsx(Vs,{path:"/trial",element:e.jsx(Q2t,{})}),e.jsx(Vs,{path:"/trial/success",element:e.jsx(J2t,{})}),e.jsx(Vs,{path:"/dashboard",element:e.jsx(ur,{children:e.jsx(X5t,{})})}),e.jsx(Vs,{path:"/profile",element:e.jsx(ur,{children:e.jsx(DLt,{})})}),e.jsx(Vs,{path:"/apps",element:e.jsx(ur,{children:e.jsx(ZLt,{})})}),e.jsx(Vs,{path:"/admin",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(L8t,{})})}),e.jsx(Vs,{path:"/admin/apps",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(R8t,{})})}),e.jsx(Vs,{path:"/admin/members",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(H8t,{})})}),e.jsx(Vs,{path:"/admin/invite-codes",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(W8t,{})})}),e.jsx(Vs,{path:"/admin/events",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Q8t,{})})}),e.jsx(Vs,{path:"/events",element:e.jsx(ur,{children:e.jsx(HLt,{})})}),e.jsx(Vs,{path:"/events/:eventId",element:e.jsx(ur,{children:e.jsx(GLt,{})})}),e.jsx(Vs,{path:"/templates",element:e.jsx(ur,{children:e.jsx(YLt,{})})}),e.jsx(Vs,{path:"/templates/:templateId",element:e.jsx(ur,{children:e.jsx(eDt,{})})}),e.jsx(Vs,{path:"/admin/templates",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(eRt,{})})}),e.jsx(Vs,{path:"/academy",element:e.jsx(ur,{children:e.jsx(tDt,{})})}),e.jsx(Vs,{path:"/academy/:videoId",element:e.jsx(ur,{children:e.jsx(rDt,{})})}),e.jsx(Vs,{path:"/admin/academy",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(sRt,{})})}),e.jsx(Vs,{path:"/toolbox",element:e.jsx(ur,{children:e.jsx(nDt,{})})}),e.jsx(Vs,{path:"/toolbox/:kitId",element:e.jsx(ur,{children:e.jsx(aDt,{})})}),e.jsx(Vs,{path:"/admin/toolbox",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(rRt,{})})}),e.jsx(Vs,{path:"/social-swag",element:e.jsx(ur,{children:e.jsx(iDt,{})})}),e.jsx(Vs,{path:"/social-swag-2",element:e.jsx(ur,{children:e.jsx(n8t,{})})}),e.jsx(Vs,{path:"/social-swag/:swagId",element:e.jsx(ur,{children:e.jsx(a8t,{})})}),e.jsx(Vs,{path:"/social-connections",element:e.jsx(ur,{children:e.jsx(G0s,{})})}),e.jsx(Vs,{path:"/social-connections/callback",element:e.jsx(ur,{children:e.jsx(K0s,{})})}),e.jsx(Vs,{path:"/social-connections/linkedin-callback",element:e.jsx(ur,{children:e.jsx(Y0s,{})})}),e.jsx(Vs,{path:"/social-connections/google-callback",element:e.jsx(ur,{children:e.jsx(Z0s,{})})}),e.jsx(Vs,{path:"/admin/social-swag",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(nRt,{})})}),e.jsx(Vs,{path:"/admin/social-swag-2",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx($Ft,{})})}),e.jsx(Vs,{path:"/community",element:e.jsx(ur,{children:e.jsx(k8t,{})})}),e.jsx(Vs,{path:"/support",element:e.jsx(ur,{children:e.jsx(N8t,{})})}),e.jsx(Vs,{path:"/admin/community",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(qFt,{})})}),e.jsx(Vs,{path:"/admin/support-tickets",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(QFt,{})})}),e.jsx(Vs,{path:"/admin/email-templates",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(tzt,{})})}),e.jsx(Vs,{path:"/admin/agent-email-templates",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(szt,{})})}),e.jsx(Vs,{path:"/admin/analytics",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(ZFt,{})})}),e.jsx(Vs,{path:"/admin/brokerage-resources",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(YFt,{})})}),e.jsx(Vs,{path:"/admin/dashboard-management",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(XFt,{})})}),e.jsx(Vs,{path:"/brokerage/dashboard",element:e.jsx(ur,{requireBrokerageManager:!0,children:e.jsx(pzt,{})})}),e.jsx(Vs,{path:"/brokerage/teams",element:e.jsx(ur,{requireBrokerageManager:!0,children:e.jsx(Gvs,{})})}),e.jsx(Vs,{path:"/my-team",element:e.jsx(ur,{children:e.jsx(Kvs,{})})}),e.jsx(Vs,{path:"/my-brokerage",element:e.jsx(ur,{children:e.jsx(_zt,{})})}),e.jsx(Vs,{path:"/brokerage-content",element:e.jsx(ur,{children:e.jsx(Szt,{})})}),e.jsx(Vs,{path:"/brokerage-content/:contentId",element:e.jsx(ur,{children:e.jsx(Ezt,{})})}),e.jsx(Vs,{path:"/brokerage-resources",element:e.jsx(ur,{requireBrokerageManager:!0,children:e.jsx(E8t,{})})}),e.jsx(Vs,{path:"/brokerage-resources/:resourceId",element:e.jsx(ur,{requireBrokerageManager:!0,children:e.jsx(P8t,{})})}),e.jsx(Vs,{path:"/newsletters",element:e.jsx(ur,{children:e.jsx(Pzt,{})})}),e.jsx(Vs,{path:"/newsletters/:id",element:e.jsx(ur,{children:e.jsx(Lzt,{})})}),e.jsx(Vs,{path:"/wishlist",element:e.jsx(ur,{children:e.jsx(Rzt,{})})}),e.jsx(Vs,{path:"/wishlist/:itemId",element:e.jsx(ur,{children:e.jsx(Fzt,{})})}),e.jsx(Vs,{path:"/admin/wishlist",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(zzt,{})})}),e.jsx(Vs,{path:"/admin/levelup-brief",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Bzt,{})})}),e.jsx(Vs,{path:"/admin/newsletters",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Ozt,{})})}),e.jsx(Vs,{path:"/admin/additional-services",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx($zt,{})})}),e.jsx(Vs,{path:"/admin/discounts",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(qzt,{})})}),e.jsx(Vs,{path:"/admin/subscriptions",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Uzt,{})})}),e.jsx(Vs,{path:"/admin/referrals",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Vzt,{})})}),e.jsx(Vs,{path:"/admin/prospector",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Qxs,{})})}),e.jsx(Vs,{path:"/admin/recruiting",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(_ys,{})})}),e.jsx(Vs,{path:"/admin/beta/social-post-generator",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(b0s,{})})}),e.jsx(Vs,{path:"/admin/credits",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(g1s,{})})})}),e.jsx(Vs,{path:"/admin/beta/postcard-manager",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(p1s,{})})})}),e.jsx(Vs,{path:"/admin/beta/homereel",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(f1s,{})})})}),e.jsx(Vs,{path:"/admin/lms",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(D0s,{})})}),e.jsx(Vs,{path:"/admin/lms/stats",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(B0s,{})})}),e.jsx(Vs,{path:"/admin/lms/:courseId",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(O0s,{})})}),e.jsx(Vs,{path:"/levelup-u",element:e.jsx(ur,{children:e.jsx($0s,{})})}),e.jsx(Vs,{path:"/levelup-u/:courseId",element:e.jsx(ur,{children:e.jsx(U0s,{})})}),e.jsx(Vs,{path:"/admin/brokerage-content-activity",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(bys,{})})}),e.jsx(Vs,{path:"/admin/onboarding-checklist",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Wzt,{})})}),e.jsx(Vs,{path:"/admin/marketplace",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Txs,{})})}),e.jsx(Vs,{path:"/admin/agent-points",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Jgs,{})})}),e.jsx(Vs,{path:"/admin/reward-store",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Vxs,{})})}),e.jsx(Vs,{path:"/admin/integrations",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Wxs,{})})}),e.jsx(Vs,{path:"/admin/integrations/callback",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Xxs,{})})}),e.jsx(Vs,{path:"/reward-store",element:e.jsx(ur,{children:e.jsx(nvs,{})})}),e.jsx(Vs,{path:"/additional-services",element:e.jsx(ur,{children:e.jsx(r7t,{})})}),e.jsx(Vs,{path:"/additional-services/:serviceId",element:e.jsx(ur,{children:e.jsx(n7t,{})})}),e.jsx(Vs,{path:"/ai-toolkit",element:e.jsx(ur,{children:e.jsx(a7t,{})})}),e.jsx(Vs,{path:"/mission-control",element:e.jsx(ur,{children:e.jsx(_7t,{})})}),e.jsx(Vs,{path:"/mission-control/contacts",element:e.jsx(ur,{children:e.jsx(eBt,{})})}),e.jsx(Vs,{path:"/mission-control/contacts/:contactId",element:e.jsx(ur,{children:e.jsx(kBt,{})})}),e.jsx(Vs,{path:"/mission-control/plans",element:e.jsx(ur,{children:e.jsx(NBt,{})})}),e.jsx(Vs,{path:"/mission-control/popbys",element:e.jsx(ur,{children:e.jsx(MBt,{})})}),e.jsx(Vs,{path:"/mission-control/popbys/map",element:e.jsx(ur,{children:e.jsx(TBt,{})})}),e.jsx(Vs,{path:"/admin/notification-settings",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Kxs,{})})}),e.jsx(Vs,{path:"/admin/agent-os",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Kzt,{})})}),e.jsx(Vs,{path:"/mission-control/listings",element:e.jsx(ur,{children:e.jsx(xps,{})})}),e.jsx(Vs,{path:"/mission-control/listings/new",element:e.jsx(ur,{children:e.jsx(jLe,{})})}),e.jsx(Vs,{path:"/mission-control/listings/:listingId",element:e.jsx(ur,{children:e.jsx(Pps,{})})}),e.jsx(Vs,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(ur,{children:e.jsx(jLe,{})})}),e.jsx(Vs,{path:"/admin/listing-exchange",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Ggs,{})})}),e.jsx(Vs,{path:"/mission-control/pipeline",element:e.jsx(ur,{children:e.jsx(tgs,{})})}),e.jsx(Vs,{path:"/mission-control/tasks",element:e.jsx(ur,{children:e.jsx(ugs,{})})}),e.jsx(Vs,{path:"/mission-control/my-card",element:e.jsx(ur,{children:e.jsx(Egs,{})})}),e.jsx(Vs,{path:"/mission-control/integrations",element:e.jsx(ur,{children:e.jsx(Bgs,{})})}),e.jsx(Vs,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(ur,{children:e.jsx($gs,{})})}),e.jsx(Vs,{path:"/mission-control/integrations/canva/callback",element:e.jsx(qgs,{})}),e.jsx(Vs,{path:"/mission-control/integrations/meta/callback",element:e.jsx(ur,{children:e.jsx(Ugs,{})})}),e.jsx(Vs,{path:"/mission-control/scorecard",element:e.jsx(ur,{children:e.jsx(ops,{})})}),e.jsx(Vs,{path:"/admin/scorecard",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Hgs,{})})}),e.jsx(Vs,{path:"/admin/scorecard/:userId",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(ILe,{})})}),e.jsx(Vs,{path:"/mission-control/scorecard/:userId",element:e.jsx(ur,{children:e.jsx(ILe,{})})}),e.jsx(Vs,{path:"/mission-control/relationship-scorecard",element:e.jsx(ur,{children:e.jsx(o1s,{})})}),e.jsx(Vs,{path:"/mission-control/sphere-gaps",element:e.jsx(ur,{children:e.jsx(u1s,{})})}),e.jsx(Vs,{path:"/mission-control/connect-page",element:e.jsx(ur,{children:e.jsx(m1s,{})})}),e.jsx(Vs,{path:"/admin/membership-reviews",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Kgs,{})})}),e.jsx(Vs,{path:"/admin/weekly-digest",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Xgs,{})})}),e.jsx(Vs,{path:"/mission-control/video/record",element:e.jsx(ur,{children:e.jsx(qps,{})})}),e.jsx(Vs,{path:"/mission-control/video-library",element:e.jsx(ur,{children:e.jsx(rfs,{})})}),e.jsx(Vs,{path:"/marketplace",element:e.jsx(ur,{children:e.jsx(X0s,{})})}),e.jsx(Vs,{path:"/marketplace/:productId",element:e.jsx(ur,{children:e.jsx(Q0s,{})})}),e.jsx(Vs,{path:"/marketplace/cart",element:e.jsx(ur,{children:e.jsx(J0s,{})})}),e.jsx(Vs,{path:"/marketplace/orders",element:e.jsx(ur,{children:e.jsx(evs,{})})}),e.jsx(Vs,{path:"/marketplace/orders/:orderId",element:e.jsx(ur,{children:e.jsx(svs,{})})}),e.jsx(Vs,{path:"/marketplace/success",element:e.jsx(ur,{children:e.jsx(rvs,{})})}),e.jsx(Vs,{path:"/admin/agent-cards",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(exs,{})})}),e.jsx(Vs,{path:"/admin/presentation-analytics",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Zxs,{})})}),e.jsx(Vs,{path:"/admin/guest-book-analytics",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Yxs,{})})}),e.jsx(Vs,{path:"/mission-control/smart-drips",element:e.jsx(ur,{children:e.jsx(Bvs,{})})}),e.jsx(Vs,{path:"/mission-control/direct-mail",element:e.jsx(ur,{children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(x1s,{})})})}),e.jsx(Vs,{path:"/mission-control/presentations",element:e.jsx(ur,{children:e.jsx(avs,{})})}),e.jsx(Vs,{path:"/mission-control/presentations/new",element:e.jsx(ur,{children:e.jsx(eDe,{})})}),e.jsx(Vs,{path:"/mission-control/presentations/:id",element:e.jsx(ur,{children:e.jsx(eDe,{})})}),e.jsx(Vs,{path:"/mission-control/guest-book",element:e.jsx(ur,{children:e.jsx(fvs,{})})}),e.jsx(Vs,{path:"/guestbook/:slug",element:e.jsx(U9e,{})}),e.jsx(Vs,{path:"/mission-control/card-studio",element:e.jsx(ur,{children:e.jsx(jvs,{})})}),e.jsx(Vs,{path:"/mission-control/scheduler",element:e.jsx(ur,{children:e.jsx(t1s,{})})}),e.jsx(Vs,{path:"/c/:shareToken",element:e.jsx(xet,{})}),e.jsx(Vs,{path:"/book/:slug",element:e.jsx(vet,{})}),e.jsx(Vs,{path:"/page/:slug",element:e.jsx(_et,{})}),e.jsx(Vs,{path:"/mission-control/landing-pages",element:e.jsx(ur,{children:e.jsx(s1s,{})})}),e.jsx(Vs,{path:"/mission-control/landing-pages/:pageId",element:e.jsx(ur,{children:e.jsx(a1s,{})})}),e.jsx(Vs,{path:"*",element:e.jsx(yet,{})})]}),")"]})})})})]})})}),fDe=window.location.hostname,T1s=fDe.includes("lovable.app")||fDe.includes("lovableproject.com");T1s&&"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))}));z8e(document.getElementById("root")).render(e.jsx(M1s,{}));export{ws as $,Ua as A,K as B,Ee as C,Ms as D,Mr as E,tr as F,Js as G,sr as H,Jo as I,er as J,At as K,As as L,_r as M,On as N,z1s as O,Zs as P,Ya as Q,Ra as R,Bu as S,Na as T,hr as U,An as V,En as W,js as X,jt as Y,Pn as Z,lt as _,va as a,u5 as a$,fe as a0,G as a1,Gs as a2,RZ as a3,ua as a4,Pt as a5,pp as a6,ul as a7,fse as a8,Pg as a9,C3 as aA,Fu as aB,nd as aC,ad as aD,k0 as aE,Wc as aF,EQ as aG,Xi as aH,Br as aI,Zn as aJ,So as aK,Co as aL,ko as aM,Bi as aN,Ec as aO,sP as aP,hn as aQ,da as aR,Qo as aS,ya as aT,EZ as aU,NZ as aV,QE as aW,_u as aX,E9 as aY,In as aZ,fn as a_,u0 as aa,Ur as ab,Ti as ac,xi as ad,m5 as ae,Po as af,lu as ag,kn as ah,O0 as ai,iN as aj,P0 as ak,I2t as al,gn as am,Ea as an,xn as ao,NKe as ap,iye as aq,wJ as ar,qKe as as,TKe as at,HKe as au,H1s as av,q9 as aw,gwe as ax,jle as ay,GKe as az,ks as b,zP as b0,uf as b1,Kr as b2,e2 as b3,zo as b4,an as b5,Ent as b6,_o as b7,mt as b8,Bte as c,Aa as d,Oe as e,at as f,br as g,ve as h,Re as i,e as j,ns as k,Ct as l,Ot as m,Lt as n,yr as o,zt as p,aN as q,S as r,ka as s,zs as t,Dr as u,vs as v,Ei as w,ys as x,Ss as y,Ns as z};